1 /******************************************************************************
2 * Copyright (c) Intel Corporation - All rights reserved.                      *
3 * This file is part of the LIBXSMM library.                                   *
4 *                                                                             *
5 * For information on the license, see the LICENSE file.                       *
6 * Further information: https://github.com/hfp/libxsmm/                        *
7 * SPDX-License-Identifier: BSD-3-Clause                                       *
8 ******************************************************************************/
9 /* Hans Pabst (Intel Corp.)
10 ******************************************************************************/
11 #ifndef LIBXSMM_CPUID_H
12 #define LIBXSMM_CPUID_H
13 
14 #include "libxsmm_macros.h"
15 
16 /**
17  * Enumerates the available target architectures and instruction
18  * set extensions as returned by libxsmm_get_target_archid().
19  */
20 #define LIBXSMM_TARGET_ARCH_UNKNOWN 0
21 #define LIBXSMM_TARGET_ARCH_GENERIC 1
22 #define LIBXSMM_X86_GENERIC      1002
23 #define LIBXSMM_X86_SSE3         1003
24 #define LIBXSMM_X86_SSE4         1004
25 #define LIBXSMM_X86_AVX          1005
26 #define LIBXSMM_X86_AVX2         1006
27 #define LIBXSMM_X86_AVX512       1007
28 #define LIBXSMM_X86_AVX512_MIC   1010 /* KNL */
29 #define LIBXSMM_X86_AVX512_KNM   1011
30 #define LIBXSMM_X86_AVX512_CORE  1020 /* SKX */
31 #define LIBXSMM_X86_AVX512_CLX   1021
32 #define LIBXSMM_X86_AVX512_CPX   1022
33 #define LIBXSMM_X86_ALLFEAT      1999 /* all features supported which are used anywhere in LIBXSMM, this value should never be used to set arch, only for compares */
34 
35 /** A zero-initialized structure assumes conservative properties. */
36 LIBXSMM_EXTERN_C typedef struct LIBXSMM_RETARGETABLE libxsmm_cpuid_x86_info {
37   int constant_tsc; /** Timer stamp counter is monotonic. */
38   int has_context;  /** Context switches are permitted. */
39 } libxsmm_cpuid_x86_info;
40 
41 /** Returns the target architecture and instruction set extensions. */
42 #if defined(__cplusplus) /* note: stay compatible with TF */
43 LIBXSMM_API int libxsmm_cpuid_x86(libxsmm_cpuid_x86_info* info = NULL);
44 #else
45 LIBXSMM_API int libxsmm_cpuid_x86(libxsmm_cpuid_x86_info* info);
46 #endif
47 
48 /**
49  * Similar to libxsmm_cpuid_x86, but conceptually not x86-specific.
50  * The actual code path (as used by LIBXSMM) is determined by
51  * libxsmm_[get|set]_target_archid/libxsmm_[get|set]_target_arch.
52  */
53 LIBXSMM_API int libxsmm_cpuid(void);
54 
55 /** Names the CPU architecture given by CPUID. */
56 LIBXSMM_API const char* libxsmm_cpuid_name(int id);
57 
58 /** SIMD vector length (VLEN) in 32-bit elements. */
59 LIBXSMM_API int libxsmm_cpuid_vlen32(int id);
60 
61 #endif /*LIBXSMM_CPUID_H*/
62 
63