Also, please use the syntax :issue:`number` to reference issues on redmine, without the
a space between the colon and number!
+Avoid configuring the own-FFTW with AVX512 enabled when GROMACS does not use AVX512
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+Previously if GROMACS was configured to use any AVX flavor, the internally built FFTW
+would be configured to also contain AVX512 kernels. This could cause performance loss
+if the (often noisy) FFTW auto-tuner picks an AVX512 kernel in a run that otherwise
+only uses AVX/AVX2 which could run at higher CPU clocks without AVX512 clock speed limitation.
+Now AVX512 is only used for the internal FFTW if GROMACS is also configured with
+the same SIMD flavor.
set(_fftw_simd_support_level "--enable-sse2")
elseif(${GMX_SIMD_ACTIVE} MATCHES "^(SSE)")
set(_fftw_simd_support_level "--enable-sse2")
-elseif(${GMX_SIMD_ACTIVE} MATCHES "^(AVX)")
+elseif(${GMX_SIMD_ACTIVE} MATCHES "^(AVX)" AND NOT ${GMX_SIMD_ACTIVE} MATCHES "^(AVX_512)")
# Testing shows FFTW configured with --enable-sse2 --enable-avx is
# slightly faster on most architectures than --enable-sse2 alone.
# Support for --enable-avx2 was only added in 3.3.5, but
# configuring with it is at worst a warning, even on an earlier
# version.
+ # On platforms capable of AVX512 where we are building with AVX2,
+ # enabling AVX512 risks clock-throttling the entire mdrun if
+ # fftw happens to pick up an AVX512 kernel (which is not unlikely
+ # as fftw tuning is known to produce highly varying results).
+ set(_fftw_simd_support_level --enable-sse2;--enable-avx;--enable-avx2)
+elseif(${GMX_SIMD_ACTIVE} MATCHES "^(AVX_512)")
# MSVC, GCC < 4.9, Clang < 3.9 do not support AVX-512, so
# we should not enable it.
-if(MSVC OR (CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9.0) OR
- (CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 3.9.0))
- set(_fftw_simd_support_level --enable-sse2;--enable-avx;--enable-avx2)
-else()
- set(_fftw_simd_support_level --enable-sse2;--enable-avx;--enable-avx2;--enable-avx512)
-endif()
+ if(MSVC OR (CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9.0) OR
+ (CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 3.9.0))
+ set(_fftw_simd_support_level --enable-sse2;--enable-avx;--enable-avx2)
+ else()
+ set(_fftw_simd_support_level --enable-sse2;--enable-avx;--enable-avx2;--enable-avx512)
+ endif()
elseif(${GMX_SIMD_ACTIVE} MATCHES "^(VSX)")
set(_fftw_simd_support_level --enable-vsx)
endif()