Add cmake option for Reference kernel
authorRoland Schulz <roland@utk.edu>
Fri, 10 Jan 2014 22:42:02 +0000 (17:42 -0500)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Thu, 30 Jan 2014 22:25:13 +0000 (23:25 +0100)
Change-Id: I6b6cb9c7eb575d8511dccd8e0bf410f44383259d

CMakeLists.txt
src/gromacs/legacyheaders/types/nb_verlet.h
src/gromacs/simd/macros.h

index 2ad3327ad10c94930b64c9d36e36a0dbe2dc0004..96559705fb8b64d4f3e94614bb4f994e4b75e504 100644 (file)
@@ -197,7 +197,7 @@ gmx_option_multichoice(
     GMX_CPU_ACCELERATION
     "Acceleration for CPU kernels and compiler optimization"
     "${GMX_SUGGESTED_CPU_ACCELERATION}"
-    None SSE2 SSE4.1 AVX_128_FMA AVX_256 IBM_QPX Sparc64_HPC_ACE)
+    None SSE2 SSE4.1 AVX_128_FMA AVX_256 IBM_QPX Sparc64_HPC_ACE Reference)
 
 gmx_option_multichoice(
     GMX_FFT_LIBRARY
@@ -223,6 +223,9 @@ gmx_option_multichoice(
     None
     none gaussian mopac gamess orca)
 
+gmx_dependent_cache_variable(GMX_NBNXN_REF_KERNEL_TYPE "Reference kernel type (4xn or 2xnn)" STRING "4xn" "GMX_CPU_ACCELERATION STREQUAL REFERENCE")
+gmx_dependent_cache_variable(GMX_NBNXN_REF_KERNEL_WIDTH "Reference kernel width" STRING "4" "GMX_CPU_ACCELERATION STREQUAL REFERENCE")
+
 option(GMX_BROKEN_CALLOC "Work around broken calloc()" OFF)
 mark_as_advanced(GMX_BROKEN_CALLOC)
 option(GMX_LOAD_PLUGINS "Compile with plugin support, needed to read VMD supported file formats" ON)
@@ -768,6 +771,23 @@ elseif(${GMX_CPU_ACCELERATION} STREQUAL "IBM_QPX")
     endif()
 elseif(${GMX_CPU_ACCELERATION} STREQUAL "SPARC64_HPC_ACE")
     set(GMX_CPU_ACCELERATION_SPARC64_HPC_ACE 1)
+elseif(${GMX_CPU_ACCELERATION} STREQUAL "REFERENCE")
+    add_definitions(-DGMX_SIMD_REFERENCE_PLAIN_C)
+    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")
+    endif()
 else()
     gmx_invalid_option_value(GMX_CPU_ACCELERATION)
 endif()
index acb5e2778e9e6e390ddf7cad86b2d6e46615bd58..7099912d66b309ddeacb85244c1eab144f79215d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
 extern "C" {
 #endif
 
-
-/* For testing the reference plain-C SIMD kernels, uncomment the next lines,
- * as well as the GMX_SIMD_REFERENCE_PLAIN_C define in gromacs/simd/macros.h
- * The actual SIMD width is set in gromacs/simd/macros.h
- * The 4xN reference kernels support 2-, 4- and 8-way SIMD.
- * The 2x(N+N) reference kernels support 8- and 16-way SIMD.
- */
-/* #define GMX_NBNXN_SIMD */
-/* #define GMX_NBNXN_SIMD_4XN */
-/* #define GMX_NBNXN_SIMD_2XNN */
-
+#ifdef GMX_SIMD_REFERENCE_PLAIN_C
+#define GMX_NBNXN_SIMD
+#endif
 
 #if (defined GMX_X86_SSE2) || (defined GMX_CPU_ACCELERATION_IBM_QPX)
 /* Use SIMD accelerated nbnxn search and kernels */
index d95b30923cf17a1c8791cb5089b4c9e8ee7404ba..4aad78beb3c6e9a4bc05f923cee3e4f3b8ae7a9d 100644 (file)
 
 /* NOTE: SSE2 acceleration does not include floor or blendv */
 
-
-/* Uncomment the next line, without other SIMD active, for testing plain-C */
-/* #define GMX_SIMD_REFERENCE_PLAIN_C */
 #ifdef GMX_SIMD_REFERENCE_PLAIN_C
 /* Plain C SIMD reference implementation, also serves as documentation */
 #define GMX_HAVE_SIMD_MACROS
 
-/* In general the reference SIMD supports any SIMD width, including 1.
- * But the nbnxn SIMD 4xN kernels only support 2, 4, 8 and 2xNN only 8, 16,
- * see types/nb_verlet.h for details
- */
-#define GMX_SIMD_REF_WIDTH  4
-
 /* Include plain-C reference implementation, also serves as documentation */
 #include "gromacs/simd/macros_ref.h"