(git:374b731)
Loading...
Searching...
No Matches
machine_cpuid.c
Go to the documentation of this file.
1/*----------------------------------------------------------------------------*/
2/* CP2K: A general program to perform molecular dynamics simulations */
3/* Copyright 2000-2024 CP2K developers group <https://cp2k.org> */
4/* */
5/* SPDX-License-Identifier: GPL-2.0-or-later */
6/*----------------------------------------------------------------------------*/
7
8/* shared between C and Fortran */
9#include "machine_cpuid.h"
10
11#if defined(__cplusplus)
12extern "C" {
13#endif
14
15/*******************************************************************************
16 * \brief This routine determines the CPUID according to the given compiler
17 * flags (expected to be similar to Fortran). Similar to other Fortran
18 * compilers, "gfortran -E -dM -mavx - < /dev/null | grep AVX" defines a
19 * variety of predefined macros (also similar to C). However, with a
20 * Fortran translation unit only a subset of these definitions disappears
21 * ("gfortran -E -dM -mavx my.F | grep AVX")
22 * hence an implementation in C is used.
23 ******************************************************************************/
24int m_cpuid_static(void); /* avoid pedantic warning about missing prototype */
25int m_cpuid_static(void) {
26#if (__AVX512F__ && __AVX512CD__ && __AVX2__ && __FMA__ && __AVX__ && \
27 __SSE4_2__ && __SSE4_1__ && __SSE3__)
29#elif (__AVX2__ && __FMA__ && __AVX__ && __SSE4_2__ && __SSE4_1__ && __SSE3__)
31#elif (__AVX__ && __SSE4_2__ && __SSE4_1__ && __SSE3__)
32 return CP_MACHINE_X86_AVX;
33#elif (__SSE4_2__ && __SSE4_1__ && __SSE3__)
35#else
37#endif
38}
39
40#if defined(__cplusplus)
41}
42#endif
int m_cpuid_static(void)
This routine determines the CPUID according to the given compiler flags (expected to be similar to Fo...
#define CP_MACHINE_CPU_GENERIC
#define CP_MACHINE_X86_AVX
#define CP_MACHINE_X86_AVX2
#define CP_MACHINE_X86_AVX512
#define CP_MACHINE_X86_SSE4