RenderKit / ospray

An Open, Scalable, Portable, Ray Tracing Based Rendering Engine for High-Fidelity Visualization
http://ospray.org
Apache License 2.0
982 stars 178 forks source link

Build fails on ARM64 architecture #538

Closed goombado closed 1 year ago

goombado commented 1 year ago

I'm having an issue with building ospray on my computer (ARM supporting NEON). I have manually built all dependencies required for ospray, including an ARM build of ispc v1.18.0, oneTBB, rkcommon v1.10.0 and OpenVKL. However, after generating the CMake configuration files and running make, the following output is always given:

[  0%] Building CXX object ospray/CMakeFiles/ospray.dir/api/API.cpp.o                                  
[  0%] Building CXX object ospray/CMakeFiles/ospray.dir/api/Device.cpp.o                               
[  0%] Building CXX object ospray/CMakeFiles/ospray.dir/api/ospray_util_impl.cpp.o                     
[  0%] Building CXX object ospray/CMakeFiles/ospray.dir/api/ospray_cpp_defs.cpp.o                      
[  2%] Building CXX object ospray/CMakeFiles/ospray.dir/common/OSPCommon.cpp.o                         
[  2%] Linking CXX shared library ../libospray.so                                                      
[  2%] Built target ospray                                                                             
[  2%] Building ISPC object /home/andrei/repos/ospray/build/modules/cpu/local__volume/transferFunction/
LinearTransferFunction.dev.o                                                                           
Error: arch = aarch64 and target = sse2-i32x4 is not a valid combination.                              
make[2]: *** [modules/cpu/CMakeFiles/ospray_module_cpu.dir/build.make:1111: modules/cpu/local__volume/t
ransferFunction/LinearTransferFunction.dev.o] Error 1                                                  
make[1]: *** [CMakeFiles/Makefile2:477: modules/cpu/CMakeFiles/ospray_module_cpu.dir/all] Error 2      
make: *** [Makefile:156: all] Error 2 

I am not too experienced with CPU instructions etc., but, from my understanding, for some reason an SSE2 instruction is being used instead of a NEON. I have set the OSPRAY_BUILD_ISA option to NEON.

I have attempted to:

None of these have had any effect on the error message I keep receiving. Any help on the matter would be greatly appreciated, and if any additional information would help to narrow down the nature of the problem, please advise me as to what else I should upload.

Thanks!

johguenther commented 1 year ago

Hmm, indeed looks like the wrong ISA is used. Some suggestions to find out what goes wrong:

goombado commented 1 year ago

Thanks for the advice! I'm currently using a build of Asahi Linux, so I think the macOS builds are unfortunately not relevant to me (although, if I am incorrect in this assumption, and the only thing that matters is the ARM architecture, please do let me know). And, to answer your question, I did also build Embree from source. The superbuild, on my computer, attempts to download the Linux prebuilt binaries, which I don't believe are compiled for ARM, and so the build fails almost immediately. The only success I've had in compiling these tools is by doing so manually, as the superbuilds don't seem to work unfortunately.

As per your advice, I've enabled CMAKE_VERBOSE_MAKEFILE and the following commands are run that cause the error:

[  2%] Building ISPC object /home/andrei/repos/ospray/build/modules/cpu/local__volume/transferFunction/LinearTransferFunction.dev.o                                                                              
cd /home/andrei/repos/ospray/build/modules/cpu && /usr/bin/cmake -E make_directory /home/andrei/repos/ospray/build/modules/cpu/local__volume/transferFunction                                                    
cd /home/andrei/repos/ospray/build/modules/cpu && /usr/bin/cmake -E make_directory /home/andrei/repos/ospray/build/modules/cpu/volume/transferFunction/                                                          
cd /home/andrei/repos/ospray/build/modules/cpu && /home/andrei/ISPC/bin/ispc -I /home/andrei/repos/ospray/modules/cpu -I /home/andrei/repos/ospray/ospray/include -I /home/andrei/repos/ospray/ospray -I /home/an
drei/repos/ospray -I /home/andrei/repos/ospray/build -I /usr/local/include -I /usr/local/include -I /usr/local/include --arch=aarch64 --addressing=32 -O3 --target=neon-i32x4,sse2 --opt=fast-math --wno-perf --p
ic --opt=disable-assertions -h /home/andrei/repos/ospray/build/modules/cpu/volume/transferFunction/LinearTransferFunction_ispc.h -MMM /home/andrei/repos/ospray/build/modules/cpu/local__volume/transferFunction/
LinearTransferFunction.dev.idep -o /home/andrei/repos/ospray/build/modules/cpu/local__volume/transferFunction/LinearTransferFunction.dev.o /home/andrei/repos/ospray/modules/cpu/volume/transferFunction/LinearTr
ansferFunction.ispc                                                                                                                                                                                              
Error: arch = aarch64 and target = sse2-i32x4 is not a valid combination.                                                                                                                                        
make[2]: *** [modules/cpu/CMakeFiles/ospray_module_cpu.dir/build.make:1114: modules/cpu/local__volume/transferFunction/LinearTransferFunction.dev.o] Error 1                                                     
make[2]: Leaving directory '/home/andrei/repos/ospray/build'                                                                                                                                                     
make[1]: *** [CMakeFiles/Makefile2:480: modules/cpu/CMakeFiles/ospray_module_cpu.dir/all] Error 2                                                                                                                
make[1]: Leaving directory '/home/andrei/repos/ospray/build'                                                                                                                                                     
make: *** [Makefile:159: all] Error 2

It seems that in the generated build.make file, the target switch is always written as --target=neon-i32x4,sse2. I have gone into build.make and manually removed the ,sse2 component of the target switch, and this allows the command to succeed. It immediately fails on the next command, however, due to the same issue with a different instance of the command. Is there a way to specify that the target should explicitly be only neon-i32x4 without the ,sse2 at the end?

Again, thank you for your help!

goombado commented 1 year ago

Update: I looked into the trace of the initial CMake invocation, and saw a CMake option relating to embree called EMBREE_MAX_ISA. It seems that this is by default set to NONE, which, in turn, has the effect of enabling an SSE2 flag. Rebuilding Embree with EMBREE_MAX_ISA=NEON and then generating the OSPRay build files seemed to fix the issue. Thanks so much for the suggestion for looking into Embree!