Hello.
If you download the latest release of Blender 2.9 and activate debug menu (Preferences > Experimental > Cycles Debug), AVX2 is enabled (at least on my computer) and rendering works.
Now if I try to compile Blender and Cycles from sources using latest master, I get this error message:
[100%] Building CXX object intern/cycles/test/CMakeFiles/cycles_test.dir/util_avxf_avx2_test.cpp.o
[100%] Linking CXX executable ../../bin/Blender.app/Contents/MacOS/Blender
In file included from /Users/some_user/blender_repo/blender/intern/cycles/test/util_avxf_avx2_test.cpp:22:
In file included from /Users/some_user/blender_repo/blender/intern/cycles/test/./util_avxf_test.h:18:
In file included from /Users/some_user/blender_repo/blender/intern/cycles/test/../util/util_system.h:20:
In file included from /Users/some_user/blender_repo/blender/intern/cycles/test/../util/util_string.h:24:
In file included from /Users/some_user/blender_repo/blender/intern/cycles/test/../util/util_vector.h:24:
In file included from /Users/some_user/blender_repo/blender/intern/cycles/test/../util/util_aligned_malloc.h:20:
In file included from /Users/some_user/blender_repo/blender/intern/cycles/test/../util/util_types.h:160:
/Users/some_user/blender_repo/blender/intern/cycles/test/../util/util_avxf.h:354:10: error: always_inline function '_mm256_fmsub_ps' requires target
feature 'fma', but would be inlined into function 'msub' that is compiled without support for 'fma'
return _mm256_fmsub_ps(a, b, c);
^
/Users/some_user/blender_repo/blender/intern/cycles/test/../util/util_avxf.h:337:10: error: always_inline function '_mm256_fmadd_ps' requires target
feature 'fma', but would be inlined into function 'madd' that is compiled without support for 'fma'
return _mm256_fmadd_ps(a, b, c);
^
/Users/some_user/blender_repo/blender/intern/cycles/test/../util/util_avxf.h:346:10: error: always_inline function '_mm256_fnmadd_ps' requires target
feature 'fma', but would be inlined into function 'nmadd' that is compiled without support for 'fma'
return _mm256_fnmadd_ps(a, b, c);
^
/Users/some_user/blender_repo/blender/intern/cycles/test/../util/util_avxf.h:290:10: error: always_inline function '_mm256_permutevar8x32_ps' requires
target feature 'avx2', but would be inlined into function 'permute' that is compiled without support for 'avx2'
return _mm256_permutevar8x32_ps(a, _mm256_set_epi32(i7, i6, i5, i4, i3, i2, i1, i0));
^
4 errors generated.
make[2]: *** [intern/cycles/test/CMakeFiles/cycles_test.dir/util_avxf_avx2_test.cpp.o] Error 1
make[1]: *** [intern/cycles/test/CMakeFiles/cycles_test.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Apparently some people had a similar issue before but I have no idea how to handle this with Blender/Cycles. Somebody wrote this about FMA:
Due to a quirk in Clang, not all of AVX 2 is enabled, so to get FMA support, I had to go into Build Phases->Compile Sources and add the flag -mfma. Then I got fma instructions to compile. Note that it looks like this process has to be done for each source file.
I’m only using cmake, not xcode here. How to set such a flag?
I wanted to see if there’s a way to disable FMA for testing but I only found below about disabling AVX.
I used sysctl -a | grep machdep.cpu.features
to see if AVX is supported and it only lists AVX1.0. I can still use the latest release and render with Cycles and AVX2.
According to this thread, one can disable AVX with the command line by setting an environment variable such as CYCLES_CPU_NO_AVX2
but there’s nothing about FMA.