Repository navigation
Conversation
|
@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,
|
|
@orlitzky - like this? |
Yeah, thanks. It looks like avx512bw was also being included under the umbrella of avx512f? I don't have a new enough processor to confirm, but if so, we have a separate USE flag for avx512bw. It would also be nice to have an |
|
The intel docs say that
In the future, someone could improve the granularity by adding fallback C multiplication for the few avx512bw instructions, allowing people with avx512f but not avx512bw to reap most of the benefits. |
|
(And I think I see that there's an issue (#71) and draft PR (#376) for runtime detection. I don't think this necessarily conflicts, we would just limit runtime detection to the "auto" case. Being able to disable the intrinsics is independently useful, and in the easy case (building for your own machine) it would remain much simpler to just enable them. |
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>
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>
b07c350 to
a8e000a
Compare
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.