aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarat Dukhan <marat@fb.com>2017-10-13 07:10:25 -0700
committerMarat Dukhan <marat@fb.com>2017-10-13 07:10:25 -0700
commit861d21a1cedc0ee7c7263aca1ead7ee356d55a22 (patch)
treee940a1a30abae7f9cedc938ffee99250a1ebc1e2
parentca67e696a5164ea6fe77c7510c55665197e64915 (diff)
downloadcpuinfo-861d21a1cedc0ee7c7263aca1ead7ee356d55a22.tar.gz
Detect new x86 ISA extensions: VAES, VPCLMULQDQ, GFNI, AVX512VBMI2, AVX512BITALG, AVX512VNNI
-rw-r--r--include/cpuinfo.h54
-rw-r--r--src/x86/isa.c38
-rw-r--r--tools/isa-info.c6
3 files changed, 97 insertions, 1 deletions
diff --git a/include/cpuinfo.h b/include/cpuinfo.h
index 2b1c60a..10470cd 100644
--- a/include/cpuinfo.h
+++ b/include/cpuinfo.h
@@ -546,7 +546,10 @@ void CPUINFO_ABI cpuinfo_deinitialize(void);
bool avx512vl;
bool avx512ifma;
bool avx512vbmi;
+ bool avx512vbmi2;
+ bool avx512bitalg;
bool avx512vpopcntdq;
+ bool avx512vnni;
bool avx512_4vnniw;
bool avx512_4fmaps;
bool hle;
@@ -571,7 +574,10 @@ void CPUINFO_ABI cpuinfo_deinitialize(void);
bool bmi2;
bool adx;
bool aes;
+ bool vaes;
bool pclmulqdq;
+ bool vpclmulqdq;
+ bool gfni;
bool rdrand;
bool rdseed;
bool sha;
@@ -982,6 +988,22 @@ static inline bool cpuinfo_has_x86_avx512vbmi(void) {
#endif
}
+static inline bool cpuinfo_has_x86_avx512vbmi2(void) {
+ #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
+ return cpuinfo_isa.avx512vbmi2;
+ #else
+ return false;
+ #endif
+}
+
+static inline bool cpuinfo_has_x86_avx512bitalg(void) {
+ #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
+ return cpuinfo_isa.avx512bitalg;
+ #else
+ return false;
+ #endif
+}
+
static inline bool cpuinfo_has_x86_avx512vpopcntdq(void) {
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
return cpuinfo_isa.avx512vpopcntdq;
@@ -990,6 +1012,14 @@ static inline bool cpuinfo_has_x86_avx512vpopcntdq(void) {
#endif
}
+static inline bool cpuinfo_has_x86_avx512vnni(void) {
+ #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_X86_64
+ return cpuinfo_isa.avx512vnni;
+ #else
+ return false;
+ #endif
+}
+
static inline bool cpuinfo_has_x86_avx512_4vnniw(void) {
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
return cpuinfo_isa.avx512_4vnniw;
@@ -1154,6 +1184,14 @@ static inline bool cpuinfo_has_x86_aes(void) {
#endif
}
+static inline bool cpuinfo_has_x86_vaes(void) {
+ #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
+ return cpuinfo_isa.vaes;
+ #else
+ return false;
+ #endif
+}
+
static inline bool cpuinfo_has_x86_pclmulqdq(void) {
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
return cpuinfo_isa.pclmulqdq;
@@ -1162,6 +1200,22 @@ static inline bool cpuinfo_has_x86_pclmulqdq(void) {
#endif
}
+static inline bool cpuinfo_has_x86_vpclmulqdq(void) {
+ #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
+ return cpuinfo_isa.vpclmulqdq;
+ #else
+ return false;
+ #endif
+}
+
+static inline bool cpuinfo_has_x86_gfni(void) {
+ #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
+ return cpuinfo_isa.gfni;
+ #else
+ return false;
+ #endif
+}
+
static inline bool cpuinfo_has_x86_rdrand(void) {
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
return cpuinfo_isa.rdrand;
diff --git a/src/x86/isa.c b/src/x86/isa.c
index 70fc7d1..3c1df0f 100644
--- a/src/x86/isa.c
+++ b/src/x86/isa.c
@@ -431,12 +431,30 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa(
isa.avx512vbmi = avx512_regs && !!(structured_feature_info.ecx & UINT32_C(0x00000002));
/*
- * AVX512_VPOPCNTDQ instructions:
+ * AVX512VBMI2 instructions:
+ * - Intel: ecx[bit 6] in structured feature info.
+ */
+ isa.avx512vbmi2 = avx512_regs && !!(structured_feature_info.ecx & UINT32_C(0x00000040));
+
+ /*
+ * AVX512BITALG instructions:
+ * - Intel: ecx[bit 12] in structured feature info.
+ */
+ isa.avx512bitalg = avx512_regs && !!(structured_feature_info.ecx & UINT32_C(0x00001000));
+
+ /*
+ * AVX512VPOPCNTDQ instructions:
* - Intel: ecx[bit 14] in structured feature info.
*/
isa.avx512vpopcntdq = avx512_regs && !!(structured_feature_info.ecx & UINT32_C(0x00004000));
/*
+ * AVX512VNNI instructions:
+ * - Intel: ecx[bit 11] in structured feature info.
+ */
+ isa.avx512vnni = avx512_regs && !!(structured_feature_info.ecx & UINT32_C(0x00000800));
+
+ /*
* AVX512_4VNNIW instructions:
* - Intel: edx[bit 2] in structured feature info.
*/
@@ -564,12 +582,30 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa(
isa.aes = !!(basic_info.ecx & UINT32_C(0x02000000));
/*
+ * VAES instructions:
+ * - Intel: ecx[bit 9] in structured feature info.
+ */
+ isa.vaes = !!(structured_feature_info.ecx & UINT32_C(0x00000200));
+
+ /*
* PCLMULQDQ instruction:
* - Intel: ecx[bit 1] in basic info (reserved bit on AMD CPUs).
*/
isa.pclmulqdq = !!(basic_info.ecx & UINT32_C(0x00000002));
/*
+ * VPCLMULQDQ instruction:
+ * - Intel: ecx[bit 10] in structured feature info.
+ */
+ isa.vpclmulqdq = !!(structured_feature_info.ecx & UINT32_C(0x00000400));
+
+ /*
+ * GFNI instructions:
+ * - Intel: ecx[bit 8] in structured feature info.
+ */
+ isa.gfni = !!(structured_feature_info.ecx & UINT32_C(0x00000100));
+
+ /*
* RDRAND instruction:
* - Intel: ecx[bit 30] in basic info (reserved bit on AMD CPUs).
*/
diff --git a/tools/isa-info.c b/tools/isa-info.c
index 97d1e6d..ceeb0d3 100644
--- a/tools/isa-info.c
+++ b/tools/isa-info.c
@@ -59,7 +59,10 @@ int main(int argc, char** argv) {
printf("\tAVX512VL: %s\n", cpuinfo_has_x86_avx512vl() ? "yes" : "no");
printf("\tAVX512IFMA: %s\n", cpuinfo_has_x86_avx512ifma() ? "yes" : "no");
printf("\tAVX512VBMI: %s\n", cpuinfo_has_x86_avx512vbmi() ? "yes" : "no");
+ printf("\tAVX512VBMI2: %s\n", cpuinfo_has_x86_avx512vbmi2() ? "yes" : "no");
+ printf("\tAVX512BITALG: %s\n", cpuinfo_has_x86_avx512bitalg() ? "yes" : "no");
printf("\tAVX512VPOPCNTDQ: %s\n", cpuinfo_has_x86_avx512vpopcntdq() ? "yes" : "no");
+ printf("\tAVX512VNNI: %s\n", cpuinfo_has_x86_avx512vnni() ? "yes" : "no");
printf("\tAVX512_4VNNIW: %s\n", cpuinfo_has_x86_avx512_4vnniw() ? "yes" : "no");
printf("\tAVX512_4FMAPS: %s\n", cpuinfo_has_x86_avx512_4fmaps() ? "yes" : "no");
@@ -79,7 +82,10 @@ int main(int argc, char** argv) {
printf("Cryptography extensions:\n");
printf("\tAES: %s\n", cpuinfo_has_x86_aes() ? "yes" : "no");
+ printf("\tVAES: %s\n", cpuinfo_has_x86_vaes() ? "yes" : "no");
printf("\tPCLMULQDQ: %s\n", cpuinfo_has_x86_pclmulqdq() ? "yes" : "no");
+ printf("\tVPCLMULQDQ: %s\n", cpuinfo_has_x86_vpclmulqdq() ? "yes" : "no");
+ printf("\tGFNI: %s\n", cpuinfo_has_x86_gfni() ? "yes" : "no");
printf("\tRDRAND: %s\n", cpuinfo_has_x86_rdrand() ? "yes" : "no");
printf("\tRDSEED: %s\n", cpuinfo_has_x86_rdseed() ? "yes" : "no");
printf("\tSHA: %s\n", cpuinfo_has_x86_sha() ? "yes" : "no");