Add Power8 VSX SIMD support
[alexxy/gromacs.git] / src / gromacs / legacyheaders / gmx_cpuid.h
index 4aefc72a57f102877447e2ebb06cd2338f09c33a..eba7ba33523d4194afaad8856adc3b48220224d5 100644 (file)
@@ -1,22 +1,36 @@
-/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
+/*
+ * This file is part of the GROMACS molecular simulation package.
  *
+ * 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.
  *
- * This file is part of GROMACS.
- * Copyright (c) 2012-
- *
- * Written by the Gromacs development team under coordination of
- * David van der Spoel, Berk Hess, and Erik Lindahl.
- *
- * This library is free software; you can redistribute it and/or
+ * GROMACS is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2
+ * as published by the Free Software Foundation; either version 2.1
  * of the License, or (at your option) any later version.
  *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the research papers on the package. Check out http://www.gromacs.org
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- * And Hey:
- * Gnomes, ROck Monsters And Chili Sauce
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
  */
 #ifndef GMX_CPUID_H_
 #define GMX_CPUID_H_
@@ -41,6 +55,7 @@ enum gmx_cpuid_vendor
     GMX_CPUID_VENDOR_AMD,
     GMX_CPUID_VENDOR_FUJITSU,
     GMX_CPUID_VENDOR_IBM,
+    GMX_CPUID_VENDOR_ARM,
     GMX_CPUID_NVENDORS
 };
 
@@ -97,26 +112,37 @@ enum gmx_cpuid_feature
     GMX_CPUID_FEATURE_X86_TDT,           /* TSC deadline timer                           */
     GMX_CPUID_FEATURE_X86_X2APIC,        /* Extended xAPIC Support                       */
     GMX_CPUID_FEATURE_X86_XOP,           /* AMD extended instructions, only AMD for now  */
+    GMX_CPUID_FEATURE_ARM_NEON,          /* 32-bit ARM NEON                              */
+    GMX_CPUID_FEATURE_ARM_NEON_ASIMD,    /* 64-bit ARM AArch64 Advanced SIMD             */
+    GMX_CPUID_FEATURE_IBM_QPX,           /* IBM QPX SIMD (BlueGene/Q and later)          */
+    GMX_CPUID_FEATURE_IBM_VMX,           /* IBM VMX SIMD (Altivec on Power6 and later)   */
+    GMX_CPUID_FEATURE_IBM_VSX,           /* IBM VSX SIMD (Power7 and later)              */
     GMX_CPUID_NFEATURES
 };
 
 
-/* Currently supported acceleration instruction sets, intrinsics or other similar combinations
+/* Currently supported SIMD instruction sets, intrinsics or other similar combinations
  * in Gromacs. There is not always a 1-to-1 correspondence with feature flags; on some AMD
  * hardware we prefer to use 128bit AVX instructions (although 256-bit ones could be executed),
  * and we still haven't written the AVX2 kernels.
  */
-enum gmx_cpuid_acceleration
+enum gmx_cpuid_simd
 {
-    GMX_CPUID_ACCELERATION_CANNOTDETECT,    /* Should only be used if something fails */
-    GMX_CPUID_ACCELERATION_NONE,
-    GMX_CPUID_ACCELERATION_X86_SSE2,
-    GMX_CPUID_ACCELERATION_X86_SSE4_1,
-    GMX_CPUID_ACCELERATION_X86_AVX_128_FMA,
-    GMX_CPUID_ACCELERATION_X86_AVX_256,
-    GMX_CPUID_ACCELERATION_SPARC64_HPC_ACE,
-    GMX_CPUID_ACCELERATION_IBM_QPX,
-    GMX_CPUID_NACCELERATIONS
+    GMX_CPUID_SIMD_CANNOTDETECT,    /* Should only be used if something fails */
+    GMX_CPUID_SIMD_NONE,
+    GMX_CPUID_SIMD_REFERENCE,
+    GMX_CPUID_SIMD_X86_SSE2,
+    GMX_CPUID_SIMD_X86_SSE4_1,
+    GMX_CPUID_SIMD_X86_AVX_128_FMA,
+    GMX_CPUID_SIMD_X86_AVX_256,
+    GMX_CPUID_SIMD_X86_AVX2_256,
+    GMX_CPUID_SIMD_SPARC64_HPC_ACE,
+    GMX_CPUID_SIMD_IBM_QPX,
+    GMX_CPUID_SIMD_IBM_VMX,
+    GMX_CPUID_SIMD_IBM_VSX,
+    GMX_CPUID_SIMD_ARM_NEON,
+    GMX_CPUID_SIMD_ARM_NEON_ASIMD,
+    GMX_CPUID_NSIMD
 };
 
 /* Text strings corresponding to CPU vendors */
@@ -127,9 +153,9 @@ gmx_cpuid_vendor_string[GMX_CPUID_NVENDORS];
 extern const char *
 gmx_cpuid_feature_string[GMX_CPUID_NFEATURES];
 
-/* Text strings for Gromacs acceleration/instruction sets */
+/* Text strings for Gromacs SIMD instruction sets */
 extern const char *
-gmx_cpuid_acceleration_string[GMX_CPUID_NACCELERATIONS];
+gmx_cpuid_simd_string[GMX_CPUID_NSIMD];
 
 
 /* Abstract data type with CPU detection information. Set by gmx_cpuid_init(). */
@@ -266,20 +292,22 @@ gmx_cpuid_formatstring      (gmx_cpuid_t                cpuid,
                              int                        n);
 
 
-/* Suggests a suitable gromacs acceleration based on the support in the
+/* Suggests a suitable gromacs SIMD based on the support in the
  * hardware.
  */
-enum gmx_cpuid_acceleration
-gmx_cpuid_acceleration_suggest  (gmx_cpuid_t                    cpuid);
+enum gmx_cpuid_simd
+gmx_cpuid_simd_suggest  (gmx_cpuid_t                    cpuid);
 
 
-/* Check if this binary was compiled with the same acceleration as we
+/* Check if this binary was compiled with the same SIMD instructions as we
  * would suggest for the current hardware. Always print stats to the log file
- * if it is non-NULL, and print a warning in stdout if we don't have a match.
+ * if it is non-NULL, and if we don't have a match, print a warning in log
+ * (if non-NULL) and if print_to_stderr!=0 also to stderr.
  */
 int
-gmx_cpuid_acceleration_check    (gmx_cpuid_t                cpuid,
-                                 FILE *                     log);
+gmx_cpuid_simd_check    (gmx_cpuid_t                cpuid,
+                         FILE *                     log,
+                         int                        print_to_stderr);
 
 
 /* Release resources used by data structure. Note that the pointer to the