1 # - Check the username performing the build, as well as date and time
3 # GMX_DETECT_ACCELERATION(GMX_SUGGESTED_ACCELERATION)
5 # Try to detect CPU information and suggest an acceleration option
6 # (such as SSE/AVX) that fits the current CPU.
8 # GMX_SUGGESTED_ACCELERATION
11 # we rely on inline asm support for GNU!
12 include(gmxTestInlineASM)
14 macro(gmx_detect_acceleration GMX_SUGGESTED_ACCELERATION)
15 IF(NOT DEFINED ${GMX_SUGGESTED_ACCELERATION})
17 gmx_test_inline_asm_gcc_x86(GMX_X86_GCC_INLINE_ASM)
19 if(GMX_X86_GCC_INLINE_ASM)
20 set(GCC_INLINE_ASM_DEFINE "-DGMX_X86_GCC_INLINE_ASM")
21 else(GMX_X86_GCC_INLINE_ASM)
22 set(GCC_INLINE_ASM_DEFINE "")
23 endif(GMX_X86_GCC_INLINE_ASM)
25 message(STATUS "Detecting best acceleration for this CPU")
27 # Get CPU acceleration information
28 try_run(GMX_DETECTCPU_RUN_ACC GMX_DETECTCPU_COMPILED
30 ${CMAKE_SOURCE_DIR}/src/gmxlib/gmx_detectcpu.c
31 COMPILE_DEFINITIONS "@GCC_INLINE_ASM_DEFINE@ -I${CMAKE_SOURCE_DIR}/include -DGMX_DETECTCPU_STANDALONE"
32 RUN_OUTPUT_VARIABLE OUTPUT_TMP
33 COMPILE_OUTPUT_VARIABLE GMX_DETECTCPU_COMPILE_OUTPUT
36 if(NOT GMX_DETECTCPU_COMPILED)
37 message(WARNING "Cannot compile CPU detection code, which means no optimization.")
38 message(STATUS "Compile output: ${GMX_DETECTCPU_COMPILE_OUTPUT}")
39 set(OUTPUT_TMP "None")
40 endif(NOT GMX_DETECTCPU_COMPILED)
42 string(STRIP "@OUTPUT_TMP@" OUTPUT_ACC)
44 message(STATUS "Detecting best acceleration for this CPU - @OUTPUT_ACC@")
46 set(${GMX_SUGGESTED_ACCELERATION} "@OUTPUT_ACC@" CACHE INTERNAL "Gromacs CPU Acceleration")
48 ENDIF(NOT DEFINED ${GMX_SUGGESTED_ACCELERATION})
49 endmacro(gmx_detect_acceleration GMX_SUGGESTED_ACCELERATION)