Set GMX_SIMD to MIC for Xeon Phi
authorRoland Schulz <roland@rschulz.eu>
Fri, 10 Oct 2014 07:10:15 +0000 (03:10 -0400)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Sun, 23 Nov 2014 16:48:43 +0000 (17:48 +0100)
The reason GMX_SIMD wasn't set the same wasy as it is for other architectures,
was that we wanted it to also work for offload. But for offload it is easy to
overwrite it for a compilation unit being offloaded. Setting it normally for
native mode makes it more consistent and lets the user disable SIMD.

Change-Id: Id660a6560278039673ce0a4feaea3261647f40e8

CMakeLists.txt
cmake/gmxDetectSimd.cmake
cmake/gmxTestSimd.cmake
src/config.h.cmakein
src/gromacs/gmxlib/copyrite.cpp
src/gromacs/mdlib/nbnxn_kernels/nbnxn_kernel_simd_utils.h
src/gromacs/mdlib/nbnxn_simd.h
src/gromacs/simd/simd.h

index 9d11c547093862f7cb0825c59c6e225c45d3e032..df7f82a21f70f8fff67b5f8aa2fa2d2e51f8da49 100644 (file)
@@ -179,18 +179,14 @@ if(GMX_CPU_ACCELERATION)
     # TODO remove all references to GMX_CPU_ACCELERATION in master branch
 endif()
 
-if(NOT GMX_TARGET_MIC)
-    include(gmxDetectSimd)
-    gmx_detect_simd(GMX_SUGGESTED_SIMD)
-else()
-    set(GMX_SUGGESTED_SIMD "None")
-endif()
+include(gmxDetectSimd)
+gmx_detect_simd(GMX_SUGGESTED_SIMD)
 
 gmx_option_multichoice(
     GMX_SIMD
     "SIMD instruction set for CPU kernels and compiler optimization"
     "${GMX_SUGGESTED_SIMD}"
-    None SSE2 SSE4.1 AVX_128_FMA AVX_256 AVX2_256 ARM_NEON ARM_NEON_ASIMD IBM_QPX IBM_VMX IBM_VSX Sparc64_HPC_ACE Reference)
+    None SSE2 SSE4.1 AVX_128_FMA AVX_256 AVX2_256 MIC ARM_NEON ARM_NEON_ASIMD IBM_QPX IBM_VMX IBM_VSX Sparc64_HPC_ACE Reference)
 
 gmx_option_multichoice(
     GMX_FFT_LIBRARY
index 49fa77a1fcced9b6d45b15bc022d0999578222a2..881086d63a5f2c9acf7affab0f2d4a2a7e541cdf 100644 (file)
@@ -98,6 +98,8 @@ function(gmx_detect_simd _suggested_simd)
             # HPC-ACE is always present. In the future we
             # should add detection for HPC-ACE2 here.
             set(${_suggested_simd} "Sparc64_HPC_ACE")
+        elseif(GMX_TARGET_MIC)
+            set(${_suggested_simd} "MIC")
         elseif(GMX_TARGET_X86)
             gmx_suggest_x86_simd(${_suggested_simd})
         else()
index 090ba65cf8adc18eda20afec5d3c49ca443d9822..0c215cb9df98d9f543ca8ef379bb7b0d3c2c064f 100644 (file)
@@ -249,6 +249,12 @@ elseif(${GMX_SIMD} STREQUAL "AVX2_256")
     set(GMX_SIMD_X86_AVX2_256 1)
     set(SIMD_STATUS_MESSAGE "Enabling 256-bit AVX2 SIMD instructions")
 
+elseif(${GMX_SIMD} STREQUAL "MIC")
+
+    # No flags needed. Not testing.
+    set(GMX_SIMD_X86_MIC 1)
+    set(SIMD_STATUS_MESSAGE "Enabling MIC (Xeon Phi) SIMD instructions")
+
 elseif(${GMX_SIMD} STREQUAL "ARM_NEON")
 
     gmx_find_cflag_for_source(CFLAGS_ARM_NEON "C compiler 32-bit ARM NEON flag"
index 2000bbb8ef70f1341915e60b998d5edbec90dbea..c5afb7e2b8d833b200c67fbb2089c8a6152bbdcc 100644 (file)
 /* AVX2 256-bit SIMD instruction set level was selected */
 #cmakedefine GMX_SIMD_X86_AVX2_256
 
+/* MIC (Xeon Phi) SIMD instruction set level was selected */
+#cmakedefine GMX_SIMD_X86_MIC
+
 /* 32-bit ARM NEON SIMD instruction set level was selected */
 #cmakedefine GMX_SIMD_ARM_NEON
 
index be67e2ec4891e952c98d39f3d9e39d2d6fd3bc26..ba36dfef24c90e6f6d8b57e1160173cbd4b4d1e6 100644 (file)
@@ -680,12 +680,7 @@ static void gmx_print_version_info(FILE *fp)
 #define gmx_stringify2(x) #x
 #define gmx_stringify(x) gmx_stringify2(x)
     fprintf(fp, "invsqrt routine:    %s\n", gmx_stringify(gmx_invsqrt(x)));
-#ifndef __MIC__
     fprintf(fp, "SIMD instructions:  %s\n", GMX_SIMD_STRING);
-#else
-    fprintf(fp, "SIMD instructions:  %s\n", "Intel MIC");
-#endif
-
     fprintf(fp, "FFT library:        %s\n", gmx_fft_get_version_info());
 #ifdef HAVE_RDTSCP
     fprintf(fp, "RDTSCP usage:       enabled\n");
index b5167b1fa85c0891ce1d677dab2000229447a628..5e1e01114160693eef9e1cdc5af59730a1fc6178 100644 (file)
@@ -69,7 +69,7 @@ prepare_table_load_buffer(const int gmx_unused *array)
 
 #else /* GMX_SIMD_REFERENCE */
 
-#if defined  GMX_TARGET_X86 && !defined __MIC__
+#if defined  GMX_TARGET_X86 && !defined GMX_SIMD_X86_MIC
 /* Include x86 SSE2 compatible SIMD functions */
 
 /* Set the stride for the lookup of the two LJ parameters from their
@@ -110,7 +110,7 @@ prepare_table_load_buffer(int gmx_unused *array)
 #endif
 #endif /* GMX_DOUBLE */
 
-#else  /* GMX_TARGET_X86 && !__MIC__ */
+#else  /* GMX_TARGET_X86 && !GMX_SIMD_X86_MIC */
 
 #if GMX_SIMD_REAL_WIDTH > 4
 /* For width>4 we use unaligned loads. And thus we can use the minimal stride */
@@ -128,11 +128,11 @@ static const int nbfp_stride = GMX_SIMD_REAL_WIDTH;
 #include "gromacs/mdlib/nbnxn_kernels/nbnxn_kernel_simd_utils_ibm_qpx.h"
 #endif /* GMX_SIMD_IBM_QPX */
 
-#ifdef __MIC__
+#ifdef GMX_SIMD_X86_MIC
 #include "gromacs/mdlib/nbnxn_kernels/nbnxn_kernel_simd_utils_x86_mic.h"
 #endif
 
-#endif /* GMX_TARGET_X86 && !__MIC__ */
+#endif /* GMX_TARGET_X86 && !GMX_SIMD_X86_MIC */
 
 #endif /* GMX_SIMD_REFERENCE */
 
index 8ac29639b148faa80e900243ef68ccc509b705c4..eae76faa151b221efdb4c8bbd70fb6670c1d997f 100644 (file)
@@ -61,7 +61,7 @@
 
 /* MIC for double is implemented in the SIMD module but so far missing in
    mdlib/nbnxn_kernels/nbnxn_kernel_simd_utils_x86_mic.h */
-#if defined __MIC__ && !defined GMX_DOUBLE
+#if defined GMX_SIMD_X86_MIC && !defined GMX_DOUBLE
 #define GMX_NBNXN_SIMD
 #endif
 
index 485025c18b1444e4c0912fe482e68ae5ef634b6f..33036bfe2847d98079ee2b00902c530967db1afd 100644 (file)
@@ -111,7 +111,7 @@ static gmx_inline double * gmx_simd4_align_d(double *p);
  * this SIMD module are static, so it will work perfectly fine to include this
  * file with different SIMD definitions for different files.
  */
-#if defined __MIC__
+#if defined GMX_SIMD_X86_MIC
 #    include "impl_intel_mic/impl_intel_mic.h"
 #elif defined GMX_SIMD_X86_AVX2_256
 #    include "impl_x86_avx2_256/impl_x86_avx2_256.h"