diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2020-06-25 15:12:57 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2020-06-26 06:53:05 -0700 |
commit | 4fdd4d41a17dda26c854ed935658154a17d4b906 (patch) | |
tree | a5fbd905db96a1ef71ecef14140f19c59f96aac7 /sysdeps | |
parent | 6e540caa21616d5ec5511fafb22819204525138e (diff) | |
download | glibc-4fdd4d41a17dda26c854ed935658154a17d4b906.tar.gz glibc-4fdd4d41a17dda26c854ed935658154a17d4b906.tar.xz glibc-4fdd4d41a17dda26c854ed935658154a17d4b906.zip |
x86: Detect Intel Advanced Matrix Extensions
Intel Advanced Matrix Extensions (Intel AMX) is a new programming paradigm consisting of two components: a set of 2-dimensional registers (tiles) representing sub-arrays from a larger 2-dimensional memory image, and accelerators able to operate on tiles. Intel AMX is an extensible architecture. New accelerators can be added and the existing accelerator may be enhanced to provide higher performance. The initial features are AMX-BF16, AMX-TILE and AMX-INT8, which are usable only if the operating system supports both XTILECFG state and XTILEDATA state. Add AMX-BF16, AMX-TILE and AMX-INT8 support to HAS_CPU_FEATURE and CPU_FEATURE_USABLE.
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/x86/cpu-features.c | 18 | ||||
-rw-r--r-- | sysdeps/x86/cpu-features.h | 20 | ||||
-rw-r--r-- | sysdeps/x86/tst-get-cpu-features.c | 6 |
3 files changed, 44 insertions, 0 deletions
diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c index 79bc0d7216..c351bdd54a 100644 --- a/sysdeps/x86/cpu-features.c +++ b/sysdeps/x86/cpu-features.c @@ -239,6 +239,24 @@ get_common_indices (struct cpu_features *cpu_features, } } + /* Are XTILECFG and XTILEDATA states usable? */ + if ((xcrlow & (bit_XTILECFG_state | bit_XTILEDATA_state)) + == (bit_XTILECFG_state | bit_XTILEDATA_state)) + { + /* Determine if AMX_BF16 is usable. */ + if (CPU_FEATURES_CPU_P (cpu_features, AMX_BF16)) + cpu_features->usable[index_arch_AMX_BF16_Usable] + |= bit_arch_AMX_BF16_Usable; + /* Determine if AMX_TILE is usable. */ + if (CPU_FEATURES_CPU_P (cpu_features, AMX_TILE)) + cpu_features->usable[index_arch_AMX_TILE_Usable] + |= bit_arch_AMX_TILE_Usable; + /* Determine if AMX_INT8 is usable. */ + if (CPU_FEATURES_CPU_P (cpu_features, AMX_INT8)) + cpu_features->usable[index_arch_AMX_INT8_Usable] + |= bit_arch_AMX_INT8_Usable; + } + /* For _dl_runtime_resolve, set xsave_state_size to xsave area size + integer register save size and align it to 64 bytes. */ if (cpu_features->basic.max_cpuid >= 0xd) diff --git a/sysdeps/x86/cpu-features.h b/sysdeps/x86/cpu-features.h index 574f055e0c..d66dc206f7 100644 --- a/sysdeps/x86/cpu-features.h +++ b/sysdeps/x86/cpu-features.h @@ -156,6 +156,9 @@ extern const struct cpu_features *__get_cpu_features (void) #define bit_arch_AVX512_VP2INTERSECT_Usable (1u << 24) #define bit_arch_AVX512_BF16_Usable (1u << 25) #define bit_arch_PKU_Usable (1u << 26) +#define bit_arch_AMX_BF16_Usable (1u << 27) +#define bit_arch_AMX_TILE_Usable (1u << 28) +#define bit_arch_AMX_INT8_Usable (1u << 29) #define index_arch_AVX_Usable USABLE_FEATURE_INDEX_1 #define index_arch_AVX2_Usable USABLE_FEATURE_INDEX_1 @@ -184,6 +187,9 @@ extern const struct cpu_features *__get_cpu_features (void) #define index_arch_AVX512_VP2INTERSECT_Usable USABLE_FEATURE_INDEX_1 #define index_arch_AVX512_BF16_Usable USABLE_FEATURE_INDEX_1 #define index_arch_PKU_Usable USABLE_FEATURE_INDEX_1 +#define index_arch_AMX_BF16_Usable USABLE_FEATURE_INDEX_1 +#define index_arch_AMX_TILE_Usable USABLE_FEATURE_INDEX_1 +#define index_arch_AMX_INT8_Usable USABLE_FEATURE_INDEX_1 #define feature_AVX_Usable usable #define feature_AVX2_Usable usable @@ -212,6 +218,9 @@ extern const struct cpu_features *__get_cpu_features (void) #define feature_AVX512_VP2INTERSECT_Usable usable #define feature_AVX512_BF16_Usable usable #define feature_PKU_Usable usable +#define feature_AMX_BF16_Usable usable +#define feature_AMX_TILE_Usable usable +#define feature_AMX_INT8_Usable usable /* CPU features. */ @@ -347,6 +356,9 @@ extern const struct cpu_features *__get_cpu_features (void) #define bit_cpu_TSXLDTRK (1u << 16) #define bit_cpu_PCONFIG (1u << 18) #define bit_cpu_IBT (1u << 20) +#define bit_cpu_AMX_BF16 (1u << 22) +#define bit_cpu_AMX_TILE (1u << 24) +#define bit_cpu_AMX_INT8 (1u << 25) #define bit_cpu_IBRS_IBPB (1u << 26) #define bit_cpu_STIBP (1u << 27) #define bit_cpu_L1D_FLUSH (1u << 28) @@ -529,6 +541,9 @@ extern const struct cpu_features *__get_cpu_features (void) #define index_cpu_TSXLDTRK COMMON_CPUID_INDEX_7 #define index_cpu_PCONFIG COMMON_CPUID_INDEX_7 #define index_cpu_IBT COMMON_CPUID_INDEX_7 +#define index_cpu_AMX_BF16 COMMON_CPUID_INDEX_7 +#define index_cpu_AMX_TILE COMMON_CPUID_INDEX_7 +#define index_cpu_AMX_INT8 COMMON_CPUID_INDEX_7 #define index_cpu_IBRS_IBPB COMMON_CPUID_INDEX_7 #define index_cpu_STIBP COMMON_CPUID_INDEX_7 #define index_cpu_L1D_FLUSH COMMON_CPUID_INDEX_7 @@ -711,6 +726,9 @@ extern const struct cpu_features *__get_cpu_features (void) #define reg_TSXLDTRK edx #define reg_PCONFIG edx #define reg_IBT edx +#define reg_AMX_BF16 edx +#define reg_AMX_TILE edx +#define reg_AMX_INT8 edx #define reg_IBRS_IBPB edx #define reg_STIBP edx #define reg_L1D_FLUSH edx @@ -819,6 +837,8 @@ extern const struct cpu_features *__get_cpu_features (void) #define bit_Opmask_state (1u << 5) #define bit_ZMM0_15_state (1u << 6) #define bit_ZMM16_31_state (1u << 7) +#define bit_XTILECFG_state (1u << 17) +#define bit_XTILEDATA_state (1u << 18) # if defined (_LIBC) && !IS_IN (nonlib) /* Unused for x86. */ diff --git a/sysdeps/x86/tst-get-cpu-features.c b/sysdeps/x86/tst-get-cpu-features.c index c60918cf00..dafd66434c 100644 --- a/sysdeps/x86/tst-get-cpu-features.c +++ b/sysdeps/x86/tst-get-cpu-features.c @@ -187,6 +187,9 @@ do_test (void) CHECK_CPU_FEATURE (TSXLDTRK); CHECK_CPU_FEATURE (PCONFIG); CHECK_CPU_FEATURE (IBT); + CHECK_CPU_FEATURE (AMX_BF16); + CHECK_CPU_FEATURE (AMX_TILE); + CHECK_CPU_FEATURE (AMX_INT8); CHECK_CPU_FEATURE (IBRS_IBPB); CHECK_CPU_FEATURE (STIBP); CHECK_CPU_FEATURE (L1D_FLUSH); @@ -239,6 +242,9 @@ do_test (void) CHECK_CPU_FEATURE_USABLE (AVX512_4VNNIW); CHECK_CPU_FEATURE_USABLE (AVX512_4FMAPS); CHECK_CPU_FEATURE_USABLE (AVX512_VP2INTERSECT); + CHECK_CPU_FEATURE_USABLE (AMX_BF16); + CHECK_CPU_FEATURE_USABLE (AMX_TILE); + CHECK_CPU_FEATURE_USABLE (AMX_INT8); CHECK_CPU_FEATURE_USABLE (XOP); CHECK_CPU_FEATURE_USABLE (FMA4); CHECK_CPU_FEATURE_USABLE (XSAVEC); |