Conversation
Configure AVX2 and AVX-512 code using the compiler target macros instead of probing the build machine. Remove the now-unused host-derived SIMD and CPU extension flags from the Makefiles so CFLAGS controls the selected implementation. Signed-off-by: Dima Pasechnik <dima@pasechnik.info> Co-authored-by: Codex <codex@openai.com>
|
@mohabsafey - This should make life much easier for distributions. The normally don't want arch-dependent flags of the build host to leak into binaries they build - something that potentially leads to annoying runtime errors. You can still build using the host arch, by passing |
|
You may wonder why one CI run on this PR is failing - this is reproducible with the random seed of that very run, namely: fails both ways, with and without this PR branch. |
|
@orlitzky - this came from an attempt to make a Gentoo ebuild for msolve. |
|
This is an improvement as-is (we don't want machine Gentoo has USE flags for these ( The best solution from that perspective would be,
|
Let packagers override the compiler-target defaults with --disable-avx2 and --disable-avx512f without changing CFLAGS. Check that enabled code can compile with the selected target, including the AVX-512BW intrinsics used by the AVX-512 implementation. Include the intrinsic headers when AVX-512 is enabled independently of AVX2. Co-authored-by: Codex <codex@openai.com> Signed-off-by: Dima Pasechnik <dima@pasechnik.info>
|
@orlitzky - like this? |
Summary
AX_EXTprobes the build machine's CPU and adds SIMD flags based on that machine. Distribution and cross builds need the selected code path to follow the compiler target without appending machine-derived flags toCFLAGS.Select AVX2 and AVX-512 code from the compiler target by default. Add
--enable-avx2and--enable-avx512f, so packagers can explicitly enable or disable either code path. An explicit enable checks that the compiler target supports the required intrinsics and fails at configure time with a clear message if it does not. The AVX-512 implementation requires both AVX-512F and AVX-512BW. The two options can be disabled independently, including AVX2 while retaining AVX-512.This is compile-time selection; it does not add runtime CPU dispatch.
Validation
CFLAGS='-O2 -pipe -march=x86-64': build and all 68 tests passed; neither SIMD implementation enabled.CFLAGS='-O2 -pipe -mavx2': build and all 68 tests passed with AVX2 enabled.CFLAGS='-O2 -pipe -mavx2' --disable-avx2: build and all 68 tests passed with both SIMD implementations disabled.CFLAGS='-O2 -pipe -mavx512f -mavx512bw' --disable-avx2 --enable-avx512f: build passed with AVX-512 enabled and AVX2 disabled. The binary was not run because this host lacks AVX-512.CFLAGS='-O2 -pipe -mavx512f'fails during configure with an AVX-512BW requirement message;--disable-avx512fallows that target.--enable-avx2with a baseline x86-64 compiler target fails during configure with an AVX2 requirement message.make distcheckpassed before the option follow-up.Signed-off-by: Dima Pasechnik dima@pasechnik.info
AI assistance: Codex helped prepare and validate this change.