Redesigned SIMD module and unit tests.
[alexxy/gromacs.git] / cmake / gmxTestSimd.cmake
index 9d910073dc099e5f4757deb67c3e448e0b5c5f97..bdf4e708e7509e7412b26b12f768fb32a6a91aa6 100644 (file)
@@ -80,8 +80,6 @@ elseif(${GMX_SIMD} STREQUAL "SSE2")
     endif()
 
     set(GMX_SIMD_X86_SSE2 1)
-    set(GMX_SIMD_X86_SSE2_OR_HIGHER 1)
-
     set(SIMD_STATUS_MESSAGE "Enabling SSE2 SIMD instructions")
 
 elseif(${GMX_SIMD} STREQUAL "SSE4.1")
@@ -108,8 +106,6 @@ elseif(${GMX_SIMD} STREQUAL "SSE4.1")
     endif()
 
     set(GMX_SIMD_X86_SSE4_1 1)
-    set(GMX_SIMD_X86_SSE4_1_OR_HIGHER 1)
-    set(GMX_SIMD_X86_SSE2_OR_HIGHER   1)
     set(SIMD_STATUS_MESSAGE "Enabling SSE4.1 SIMD instructions")
 
 elseif(${GMX_SIMD} STREQUAL "AVX_128_FMA")
@@ -203,10 +199,6 @@ int main(){__m128 x=_mm_set1_ps(0.5);x=_mm_frcz_ps(x);return 0;}"
     gmx_test_avx_gcc_maskload_bug(GMX_SIMD_X86_AVX_GCC_MASKLOAD_BUG "${SIMD_C_FLAGS}")
 
     set(GMX_SIMD_X86_AVX_128_FMA 1)
-    set(GMX_SIMD_X86_AVX_128_FMA_OR_HIGHER 1)
-    set(GMX_SIMD_X86_SSE4_1_OR_HIGHER      1)
-    set(GMX_SIMD_X86_SSE2_OR_HIGHER        1)
-
     set(SIMD_STATUS_MESSAGE "Enabling 128-bit AVX SIMD Gromacs SIMD (with fused-multiply add)")
 
 elseif(${GMX_SIMD} STREQUAL "AVX_256")
@@ -231,17 +223,10 @@ elseif(${GMX_SIMD} STREQUAL "AVX_256")
     gmx_test_avx_gcc_maskload_bug(GMX_SIMD_X86_AVX_GCC_MASKLOAD_BUG "${SIMD_C_FLAGS}")
 
     set(GMX_SIMD_X86_AVX_256 1)
-    set(GMX_SIMD_X86_AVX_256_OR_HIGHER  1)
-    set(GMX_SIMD_X86_SSE4_1_OR_HIGHER   1)
-    set(GMX_SIMD_X86_SSE2_OR_HIGHER     1)
-
     set(SIMD_STATUS_MESSAGE "Enabling 256-bit AVX SIMD instructions")
 
 elseif(${GMX_SIMD} STREQUAL "AVX2_256")
 
-    # Comment out this line for AVX2 development
-    message(FATAL_ERROR "AVX2_256 is disabled until the implementation has been commited.")
-
     gmx_use_clang_as_with_gnu_compilers_on_osx()
 
     gmx_find_cflag_for_source(CFLAGS_AVX2 "C compiler AVX2 flag"
@@ -262,11 +247,6 @@ elseif(${GMX_SIMD} STREQUAL "AVX2_256")
     # No need to test for Maskload bug - it was fixed before gcc added AVX2 support
 
     set(GMX_SIMD_X86_AVX2_256 1)
-    set(GMX_SIMD_X86_AVX2_256_OR_HIGHER 1)
-    set(GMX_SIMD_X86_AVX_256_OR_HIGHER  1)
-    set(GMX_SIMD_X86_SSE4_1_OR_HIGHER   1)
-    set(GMX_SIMD_X86_SSE2_OR_HIGHER     1)
-
     set(SIMD_STATUS_MESSAGE "Enabling 256-bit AVX2 SIMD instructions")
 
 elseif(${GMX_SIMD} STREQUAL "IBM_QPX")
@@ -290,22 +270,18 @@ elseif(${GMX_SIMD} STREQUAL "SPARC64_HPC_ACE")
 
 elseif(${GMX_SIMD} STREQUAL "REFERENCE")
 
-    add_definitions(-DGMX_SIMD_REFERENCE)
-    if(${GMX_NBNXN_REF_KERNEL_TYPE} STREQUAL "4xn")
-        if(${GMX_NBNXN_REF_KERNEL_WIDTH} STREQUAL "2" OR ${GMX_NBNXN_REF_KERNEL_WIDTH} STREQUAL "4" OR ${GMX_NBNXN_REF_KERNEL_WIDTH} STREQUAL "8")
-            add_definitions(-DGMX_NBNXN_SIMD_4XN -DGMX_SIMD_REF_WIDTH=${GMX_NBNXN_REF_KERNEL_WIDTH})
-        else()
-            message(FATAL_ERROR "Unsupported width for 4xn reference kernels")
-        endif()
-    elseif(${GMX_NBNXN_REF_KERNEL_TYPE} STREQUAL "2xnn")
-        if(${GMX_NBNXN_REF_KERNEL_WIDTH} STREQUAL "8" OR ${GMX_NBNXN_REF_KERNEL_WIDTH} STREQUAL "16")
-            add_definitions(-DGMX_NBNXN_SIMD_2XNN -DGMX_SIMD_REF_WIDTH=${GMX_NBNXN_REF_KERNEL_WIDTH})
-        else()
-            message(FATAL_ERROR "Unsupported width for 2xn reference kernels")
-        endif()
-    else()
-        message(FATAL_ERROR "Unsupported kernel type")
+    # NB: This file handles settings for the SIMD module, so in the interest 
+    # of proper modularization, please do NOT put any verlet kernel settings in this file.
+
+    if(GMX_SIMD_REF_FLOAT_WIDTH)
+        add_definitions(-DGMX_SIMD_REF_FLOAT_WIDTH=${GMX_SIMD_REF_FLOAT_WIDTH})
     endif()
+    if(GMX_SIMD_REF_DOUBLE_WIDTH)
+       add_definitions(-DGMX_SIMD_REF_DOUBLE_WIDTH=${GMX_SIMD_REF_DOUBLE_WIDTH})
+    endif()
+
+    set(GMX_SIMD_REFERENCE 1)
+    set(SIMD_STATUS_MESSAGE "Enabling reference (emulated) SIMD instructions.")
 
 else()
     gmx_invalid_option_value(GMX_SIMD)