-/* -*- 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.
*
- *
- * This file is part of GROMACS.
- * Copyright (c) 2012-
+ * 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.
*
- * 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.
+ *
+ * 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.
*
- * And Hey:
- * Gnomes, ROck Monsters And Chili Sauce
+ * 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_
#include <stdio.h>
+
#ifdef __cplusplus
extern "C" {
#endif
GMX_CPUID_VENDOR_UNKNOWN,
GMX_CPUID_VENDOR_INTEL,
GMX_CPUID_VENDOR_AMD,
+ GMX_CPUID_VENDOR_FUJITSU,
+ GMX_CPUID_VENDOR_IBM,
+ GMX_CPUID_VENDOR_ARM,
GMX_CPUID_NVENDORS
};
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_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_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_ARM_NEON,
+ GMX_CPUID_NSIMD
};
/* Text strings corresponding to CPU vendors */
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(). */
typedef struct gmx_cpuid *
-gmx_cpuid_t;
+ gmx_cpuid_t;
/* Fill the data structure by using CPU detection instructions.
enum gmx_cpuid_feature feature);
+/* Return pointers to cpu topology information.
+ *
+ * Important: CPU topology requires more OS support than most other
+ * functions in this file, including support for thread pinning to hardware.
+ * This means it will not work on some platforms, including e.g. Mac OS X.
+ * Thus, it is IMPERATIVE that you check the return value from this routine
+ * before doing anything with the information. It is only if the return
+ * value is zero that the data is valid.
+ *
+ * For the returned values we have:
+ * - nprocessors Total number of logical processors reported by OS
+ * - npackages Usually number of CPU sockets
+ * - ncores_per_package Number of cores in each package
+ * - nhwthreads_per_core Number of hardware threads per core; 2 for hyperthreading.
+ * - package_id Array with the package index for each logical cpu
+ * - core_id Array with local core index for each logical cpu
+ * - hwthread_id Array with local hwthread index for each logical cpu
+ * - locality_order Array with logical cpu numbers, sorted in order
+ * of physical and logical locality in the system.
+ *
+ * All arrays are of length nprocessors.
+ */
+int
+gmx_cpuid_topology(gmx_cpuid_t cpuid,
+ int * nprocessors,
+ int * npackages,
+ int * ncores_per_package,
+ int * nhwthreads_per_core,
+ const int ** package_id,
+ const int ** core_id,
+ const int ** hwthread_id,
+ const int ** locality_order);
+
/* Enumerated values for x86 SMT enabled-status. Note that this does not refer
* to Hyper-Threading support (that is the flag GMX_CPUID_FEATURE_X86_HTT), but
* whether Hyper-Threading is _enabled_ and _used_ in bios right now.
* in order not to give the impression we can detect any SMT. We haven't
* even tested the performance on other SMT implementations, so it is not
* obvious we shouldn't use SMT there.
+ *
+ * Note that you can get more complete topology information from
+ * gmx_cpuid_topology(), although that requires slightly more OS support.
*/
enum gmx_cpuid_x86_smt
gmx_cpuid_x86_smt(gmx_cpuid_t cpuid);
-
/* Formats a text string (up to n characters) from the data structure.
* The output will have max 80 chars between newline characters.
*/
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