-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shuffle.c
is compiled with -mavx512*
which results in SIGILL
on lower CPUs
#621
Comments
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. |
Do not pass `-msse2`, `-mavx2`, etc. flags to the compiler when compiling `shuffle.c`. From what I can see, the file itself does not use any of these intrinsics, and they are only used by functions declared in `bitshuffle-*.c` and `shuffle-*.c` (where the respective flags are still passed). This prevents the compiler from incidentally optimizing the code called independenlty of the runtime CPU check to these instruction sets, effectively causing `SIGILL` on other CPUs. I have verified that this fixes the issue on `-march=znver2`, but also does not cause any issues on `-march=x86-64` and `-march=i686`. Fixes Blosc#621
Indeed, see https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#index-mmmx (scroll down a bit);
|
Do not pass `-msse2`, `-mavx2`, etc. flags to the compiler when compiling `shuffle.c`. From what I can see, the file itself does not use any of these intrinsics, and they are only used by functions declared in `bitshuffle-*.c` and `shuffle-*.c` (where the respective flags are still passed). This prevents the compiler from incidentally optimizing the code called independenlty of the runtime CPU check to these instruction sets, effectively causing `SIGILL` on other CPUs. I have verified that this fixes the issue on `-march=znver2`, but also does not cause any issues on `-march=x86-64` and `-march=i686`. Fixes Blosc#621
Do not pass `-msse2`, `-mavx2`, etc. flags to the compiler when compiling `shuffle.c`. From what I can see, the file itself does not use any of these intrinsics, and they are only used by functions declared in `bitshuffle-*.c` and `shuffle-*.c` (where the respective flags are still passed). This prevents the compiler from incidentally optimizing the code called independenlty of the runtime CPU check to these instruction sets, effectively causing `SIGILL` on other CPUs. I have verified that this fixes the issue on `-march=znver2`, but also does not cause any issues on `-march=x86-64` and `-march=i686`. Fixes Blosc#621
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
The text was updated successfully, but these errors were encountered: