Closed mgorny closed 4 months ago
Yes, shuffle.c is designed to statically include many SIMD instructions and then dynamically select the correct version at runtime. This worked pretty well for many years now.
I don't have an AMD Zen handy, but I have tried this out with an Intel i13900K and an assortment of different compilers (gcc-12, gcc-13, gcc-14, clang-16, clang-17 and clang-18), and only gcc-14 exhibits this issue. Could it be a bug introduced in gcc-14?
FWIW, removing "-march=znver2" in your example works for me.
It's not a bug. If you tell compiler to use AVX512, then it is permitted to use AVX512. That's what the flag does, by design. If anything, it just means that GCC 14 improved the optimizer that it finds new optimization possibilities.
Ok. Then I'm curious on why removing "-march=znver2" in your example works, as blosc is still telling the compiler to use AVX512.
It probably triggers a different optimization profile.
Indeed, see https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#index-mmmx (scroll down a bit);
These options enable GCC to use these extended instructions in generated code, even without -mfpmath=sse. Applications that perform run-time CPU detection must compile separate files for each supported architecture, using the appropriate flags. In particular, the file containing the CPU detection code should be compiled without these options.
Describe the bug When compiler supports SSE2/AVX2/AVX512 instructions, the respective
-m
flags are added to the flags forshuffle.c
. As a result, the compiler can compile arbitrary code with these instruction sets. For me, GCC 14 creates a library that uses AVX512 instructions on unsupported CPU and effectively crashes with SIGILL, e.g.:For example,
plugins/codecs/ndlz/test_ndlz
crashes inget_shuffle_implementation
:To Reproduce
Expected behavior Not crashing, i.e. not using SSE2/AVX2/AVX512 instructions outside specific files intended for them :-).
Logs CMake output: cmake.txt Ninja output (for build): build.txt
System information:
Additional context n/a