cmake: Set SIMD flags on appropriate source files only#322
Merged
matteo-frigo merged 1 commit intoFFTW:masterfrom Apr 7, 2023
Merged
cmake: Set SIMD flags on appropriate source files only#322matteo-frigo merged 1 commit intoFFTW:masterfrom
matteo-frigo merged 1 commit intoFFTW:masterfrom
Conversation
Doing this matches the behavior of the configure script and makefiles. Previously, enabling a set of SIMD instructions with the CMake build would build the whole library with that flag enabled, allowing the compiler to optimize by using that set of instructions anywhere. That would then require that any SIMD instructions enabled at build time would have to be present at run time. This change enables the intended behavior of using SIMD instructions only when they are detected at run time.
Merged
4 tasks
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This addresses a shortcoming observed with the Windows FFTW package on conda-forge, which uses CMake to build with MSVC. Those packages are built with SSE2 and AVX instructions enabled, and contrary to the desired behavior, users with processors that don't have AVX support have been reporting that the library fails to load. I finally tracked this down to the fact that when using CMake the entire library is built with the enabled SIMD flags, rather than just the specific SIMD files as with configure/make. Thus the compiler was inserting SIMD instructions elsewhere in the library, not gated by the check for whether the runtime CPU supported them.
This PR modifies the CMake build so that it applies the SIMD flags only on the appropriate source files as with configure/make. Patching this fix into the conda-forge package allowed me to use the library on a machine without AVX support while the package still had it enabled.