RenderKit / embree

Embree ray tracing kernels repository.
Apache License 2.0
2.37k stars 389 forks source link

Fix generic Linux aarch64 support on GCC with lax vector conversions #408

Closed Mluckydwyer closed 1 year ago

Mluckydwyer commented 1 year ago

These changes are in response to #391 and fix the compilation issue on generic ARM64 systems. It does this by adding support for properly detecting generic ARM64 compatible Linux systems using the CMake value stored in CMAKE_SYSTEM_PROCESSOR and properly setting the EMBREE_ARM CMake flag. It also adds the -flax-vector-conversions compile flag when utilizing GCC to ignore the SIMD vector conversion errors described below.

Without this change, when compiling using GCC on ARM64 devices that are not Apple Silicon, you will need to manually specify the -DEMBREE_ARM CMake flag to invoke the ARM SIMD flags and complete configuration. When attempting to compile, you will then see the following error message:

/simd/arm/sse2neon.h:6749:55: error: cannot convert ‘int64x2_t {aka __vector(2) long int}’ to ‘__m128i {aka __vector(4) int}’ in return

Please see issue #391 for further details.

These changes have been tested and shown working on a Nvidia Jetson AGX Xavier Developer Kit (16GB version). Below is the CMake output and first few lines of compilation as evidence for compilation success. I have also linked against the compiled libraries in my own research applications without issue (when comparing output of my application to my Intel x86 system).

.../embree-test/build$ cmake -DCMAKE_CONFIGURATION_TYPE="Release" -DEMBREE_ISPC_SUPPORT=OFF -DEMBREE_TBB_ROOT=/home/mluck/git/RTAO-Research/rtao-benchmark/external/oneTBB/build/install -DTBB_DIR=/home/mluck/git/RTAO-Research/rtao-benchmark/external/oneTBB/build/install ..
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /usr/bin/git (found version "2.25.1") 
-- Building for ARM64
-- GNU detected
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Could NOT find TBB (missing: TBB_DIR)
-- Looking for TBB components tbb; ()
-- Found TBB version 2021.8 at /home/mluck/git/RTAO-Research/rtao-benchmark/external/oneTBB/build/install
-- OpenImageIO not found in your environment. You can 1) install
                              via your OS package manager, or 2) install it
                              somewhere on your machine and point OPENIMAGEIO_ROOT to it. (missing: OPENIMAGEIO_INCLUDE_DIR OPENIMAGEIO_LIBRARY) 
-- Found JPEG: /usr/lib/aarch64-linux-gnu/libjpeg.so (found version "80") 
-- Found PNG: /usr/include  
-- Found OpenGL: /usr/lib/aarch64-linux-gnu/libOpenGL.so   
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_CONFIGURATION_TYPE

-- Build files have been written to: /home/mluck/git/RTAO-Research/rtao-benchmark/external/embree-test/build
.../embree-test/build$ make
Scanning dependencies of target sys
[  1%] Building CXX object common/sys/CMakeFiles/sys.dir/sysinfo.cpp.o
[  1%] Building CXX object common/sys/CMakeFiles/sys.dir/alloc.cpp.o
[  2%] Building CXX object common/sys/CMakeFiles/sys.dir/filename.cpp.o
[  2%] Building CXX object common/sys/CMakeFiles/sys.dir/library.cpp.o
[  3%] Building CXX object common/sys/CMakeFiles/sys.dir/thread.cpp.o
[  3%] Building CXX object common/sys/CMakeFiles/sys.dir/string.cpp.o
[  4%] Building CXX object common/sys/CMakeFiles/sys.dir/regression.cpp.o
[  4%] Building CXX object common/sys/CMakeFiles/sys.dir/mutex.cpp.o
[  4%] Building CXX object common/sys/CMakeFiles/sys.dir/condition.cpp.o
...
 [99%] Linking CXX executable ../../multiscene_geometry
[ 99%] Built target multiscene_geometry
[ 99%] Linking CXX executable ../../next_hit
[ 99%] Built target next_hit
[ 99%] Linking CXX executable ../../viewer_stream
[ 99%] Built target viewer_stream
[ 99%] Linking CXX executable ../../quaternion_motion_blur
[ 99%] Built target quaternion_motion_blur
[100%] Linking CXX executable ../../viewer_anim
[100%] Built target viewer_anim