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. |
b07c350 to
a8e000a
Compare
a8e000a to
ec7007e
Compare
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>
ec7007e to
195d192
Compare
|
Thank you @dimpase Will try to have a look asap (but not before the end of the coming week) |
Compile the vector operations used by Hensel lifting before enabling its fft_small path. FLINT_HAVE_FFT_SMALL describes the installed library, but its headers can require AVX2 and FMA that are absent from msolve's target flags. Use the existing polynomial-multiplication fallback when the probe fails, without adding target flags or running a configure test program. Keep explicit HENSEL_NTT overrides available. Validated against FLINT 3.6.0: all 97 tests pass on ARM macOS with the detected fast path and with the configure result forced to the fallback. The probe rejects baseline x86-64 and AVX2 without FMA, and accepts AVX2 with FMA, when cross-compiling at -O0, -O2 and -O3. Co-authored-by: Codex <codex@openai.com> Signed-off-by: Dima Pasechnik <dima@pasechnik.info>
|
5f0679a is meant to fix building failures detected by Windows CI (installed Flint AVX capabilities don't mean they are available on the testing host, too) |
|
@dimpase thank you for this. I think the INSTALL and README files should (strongly) suggest CFLAGS="-O2 -march=native" as an option to ./configure. Also, I agree with the suggestion of @orlitzky (many thanks). One problem I find is that it seems that even with -march=native, the IFMA, AVX-512 BW/DQ, FMA3 and SSE2/SSSE3 paths stay out of compilation (according to claude). Reason is that their HAVE_* macros are no longer defined. Since we recently improved the efficiency in several ways including using these, I would like to make sure that the user who wants the best for his computer after compilation just gets it. |
Restore SSE2, SSSE3, FMA3 and the AVX-512 BW, DQ and IFMA guards without adding flags for the build host. Keep the AVX2 and AVX-512 opt-outs and document native builds as a local opt-in. Co-authored-by: OpenAI Codex <codex@openai.com>
Resolve the overlap with algebraic-solving#410 by retaining the configure-time FLINT fft_small compile check, so the Hensel code still falls back when the target cannot compile those headers. Co-authored-by: OpenAI Dot <support@openai.com>
|
@mohabsafey please have a look at the update - does it fix everything you asked for? |
|
Many thanks. It seems that a target with AVX-512F but no BW (for example -mavx2 -mfma -mavx512f) makes configure stop with an error, although nobody asked for AVX-512. Could be fixed by checking AVX512BW as @orlitzky suggested? I also think that configure should displays something about the SIMD kernels it selects. Also, shouldn't the CI be adapted? Many thanks again @dimpase |
A target such as -mavx2 -mfma -mavx512f can compile the foundation kernels. Probe byte and word support separately and use the AVX2 or scalar implementations where those 512-bit operations are unavailable. Allow packagers to override BW selection with --enable/--disable-avx512bw. Print the selected kernels at the end of configure. Exercise the F-only target, optional extensions and explicit disables in CI. Check the configuration and build each combination, run its tests when the CPU supports it, and test the native target in the Linux fixed-seed build. Co-authored-by: Codex <codex@openai.com> Signed-off-by: Dima Pasechnik <dima@pasechnik.info>
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.Configure selects AVX2, AVX-512F and the AVX-512 extensions supported by the compiler target, and lists the selected SIMD kernels. The
--enable-avx2and--enable-avx512foptions and their--disableforms control the two groups independently. AVX-512F kernels also work on targets that lack AVX-512BW. The--enable-avx512bwand--disable-avx512bwoptions control the byte and word kernels within the AVX-512F group. Explicitly requesting an unavailable feature gives a configure error.For Hensel lifting, configure also checks whether the installed FLINT
fft_smallvector operations compile with the selected flags. If they do not, msolve uses its polynomial multiplication fallback.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 AVX2 nor AVX-512 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 AVX2 and AVX-512 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 -mavx2 -mfma -mavx512f'. Configure selected AVX-512F, and the 8-bit and 16-bit sparse-row kernels used their AVX2 implementations.--enable-avx512bwon this target produced the expected error.--enable-avx2with a baseline x86-64 compiler target fails during configure with an AVX2 requirement message.make distcheckpassed before the option follow-up.-march=native.Signed-off-by: Dima Pasechnik dima@pasechnik.info
AI assistance: Codex helped prepare and validate this change.