# emulate AVX instructions with SSE4.1 otherwise.
foreach(_testflag ${ARGN} "")
# make valid variable names from the flag string: replace all non-alphanumerical chars
- string(REGEX REPLACE "[^a-zA-Z0-9]+" "_" FLAG_WORKS_VARIABLE "${LANGUAGE}_${_testflag}_FLAG_WORKS")
+ string(REGEX REPLACE "[^a-zA-Z0-9]+" "_" FLAG_ACCEPTED_VARIABLE "${LANGUAGE}_${_testflag}_FLAG_ACCEPTED")
string(REGEX REPLACE "[^a-zA-Z0-9]+" "_" COMPILE_WORKS_VARIABLE "${LANGUAGE}_${_testflag}_COMPILE_WORKS")
- # Check that the flag itself is fine, and that it does not generate warnings either
- gmx_check_compiler_flag("${${TOOLCHAIN_FLAGS_VARIABLE}} ${_testflag}" "${LANGUAGE}" ${FLAG_WORKS_VARIABLE})
+ # Check that the flag itself is fine, and that it does not generate warnings either, but don't
+ # confuse the user by saying an empty flag was "accepted"
+ if("${_testflag}" STREQUAL "")
+ set(${FLAG_ACCEPTED_VARIABLE} 1)
+ # Give the empty flag variable a better name since we cannot control the CMake status messages
+ set(COMPILE_WORKS_VARIABLE "${LANGUAGE}_COMPILE_WORKS_WITHOUT_SPECIAL_FLAGS")
+ else()
+ gmx_check_compiler_flag("${${TOOLCHAIN_FLAGS_VARIABLE}} ${_testflag}" "${LANGUAGE}" ${FLAG_ACCEPTED_VARIABLE})
+ endif()
- if(${FLAG_WORKS_VARIABLE})
+ if(${FLAG_ACCEPTED_VARIABLE})
IF(DEFINED ${COMPILE_WORKS_VARIABLE})
# This is a subsequent call to CMake, don't spam the status line
set(RUN_QUIETLY TRUE)
if(NOT ${COMPILE_WORKS_VARIABLE})
if (NOT RUN_QUIETLY)
- message(STATUS "Compiler flag was valid, but executable did not build - perhaps update the binutils package")
+ if("${_testflag}" STREQUAL "")
+ message(STATUS "Could not find any flag to build test source (this could be due to either the compiler or binutils)")
+ else()
+ message(STATUS "Flag was accepted, but it did not build test source (this could be due to either the compiler or binutils)")
+ set(SUGGEST_BINUTILS_UPDATE 1 PARENT_SCOPE)
+ endif()
endif()
- set(SUGGEST_BINUTILS_UPDATE 1 PARENT_SCOPE)
endif()
- if (${FLAG_WORKS_VARIABLE} AND ${COMPILE_WORKS_VARIABLE})
+ if (${FLAG_ACCEPTED_VARIABLE} AND ${COMPILE_WORKS_VARIABLE})
set(${RESULT_VARIABLE} 1 PARENT_SCOPE)
set(${NEW_FLAGS_VARIABLE} "${_testflag}" PARENT_SCOPE)
break()
# No flags needed. Not testing.
set(GMX_SIMD_X86_MIC 1)
- set(SIMD_STATUS_MESSAGE "Enabling MIC (Xeon Phi) SIMD instructions")
+ set(SIMD_STATUS_MESSAGE "Enabling MIC (Xeon Phi) SIMD instructions without special flags.")
elseif(GMX_SIMD_ACTIVE STREQUAL "AVX_512")
if (TEST_QPX)
set(GMX_SIMD_${GMX_SIMD_ACTIVE} 1)
- set(SIMD_STATUS_MESSAGE "Enabling IBM QPX SIMD instructions (no special flags)")
+ set(SIMD_STATUS_MESSAGE "Enabling IBM QPX SIMD instructions without special flags.")
else()
gmx_give_fatal_error_when_simd_support_not_found("IBM QPX" "or 'cmake .. -DCMAKE_TOOLCHAIN_FILE=Platform/BlueGeneQ-static-bgclang-CXX' to set up the tool chain" "${SUGGEST_BINUTILS_UPDATE}")
endif()
# Note that GMX_RELAXED_DOUBLE_PRECISION is enabled by default in the top-level CMakeLists.txt
set(GMX_SIMD_${GMX_SIMD_ACTIVE} 1)
- set(SIMD_STATUS_MESSAGE "Enabling Sparc64 HPC-ACE SIMD instructions")
+ set(SIMD_STATUS_MESSAGE "Enabling Sparc64 HPC-ACE SIMD instructions without special flags.")
elseif(GMX_SIMD_ACTIVE STREQUAL "REFERENCE")
endif()
set(GMX_SIMD_${GMX_SIMD_ACTIVE} 1)
- set(SIMD_STATUS_MESSAGE "Enabling reference (emulated) SIMD instructions.")
+ set(SIMD_STATUS_MESSAGE "Enabling reference (emulated) SIMD instructions without special flags.")
else()
gmx_invalid_option_value(GMX_SIMD_ACTIVE)
if(GMX_ENABLE_AVX512_TESTS AND
(GMX_SIMD_ACTIVE STREQUAL "AVX_256" OR GMX_SIMD_ACTIVE STREQUAL "AVX2_256" OR GMX_SIMD_ACTIVE STREQUAL "AVX2_128"))
+ if(NOT DEFINED SIMD_AVX_512_CXX_SUPPORTED)
+ message(STATUS "Detecting flags to enable runtime detection of AVX-512 units on newer CPUs")
+ set(SIMD_AVX_512_REPORT_STATUS 1)
+ endif()
gmx_find_simd_avx_512_flags(SIMD_AVX_512_C_SUPPORTED SIMD_AVX_512_CXX_SUPPORTED
SIMD_AVX_512_C_FLAGS SIMD_AVX_512_CXX_FLAGS)
+ if(SIMD_AVX_512_REPORT_STATUS)
+ if(SIMD_AVX_512_CXX_SUPPORTED)
+ message(STATUS "Detecting flags to enable runtime detection of AVX-512 units on newer CPUs - ${SIMD_AVX_512_CXX_FLAGS}")
+ else()
+ message(STATUS "Detecting flags to enable runtime detection of AVX-512 units on newer CPUs - not supported")
+ endif()
+ endif()
endif()
# By default, 32-bit windows cannot pass SIMD (SSE/AVX) arguments in registers,