util/u_cpu_detect: Detect clflushopt support
authorJordan Justen <jordan.l.justen@intel.com>
Thu, 30 Mar 2023 07:44:52 +0000 (00:44 -0700)
committerMarge Bot <emma+marge@anholt.net>
Wed, 6 Sep 2023 01:39:53 +0000 (01:39 +0000)
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22379>

src/util/u_cpu_detect.c
src/util/u_cpu_detect.h

index 395c93b..2394ab4 100644 (file)
@@ -878,22 +878,25 @@ _util_cpu_detect_once(void)
          if (cacheline > 0)
             util_cpu_caps.cacheline = cacheline;
       }
-      if (util_cpu_caps.has_avx && regs[0] >= 0x00000007) {
+      if (regs[0] >= 0x00000007) {
          uint32_t regs7[4];
          cpuid_count(0x00000007, 0x00000000, regs7);
-         util_cpu_caps.has_avx2 = (regs7[1] >> 5) & 1;
-
-         // check for avx512
-         if (xgetbv() & (0x7 << 5)) { // OPMASK: upper-256 enabled by OS
-            util_cpu_caps.has_avx512f    = (regs7[1] >> 16) & 1;
-            util_cpu_caps.has_avx512dq   = (regs7[1] >> 17) & 1;
-            util_cpu_caps.has_avx512ifma = (regs7[1] >> 21) & 1;
-            util_cpu_caps.has_avx512pf   = (regs7[1] >> 26) & 1;
-            util_cpu_caps.has_avx512er   = (regs7[1] >> 27) & 1;
-            util_cpu_caps.has_avx512cd   = (regs7[1] >> 28) & 1;
-            util_cpu_caps.has_avx512bw   = (regs7[1] >> 30) & 1;
-            util_cpu_caps.has_avx512vl   = (regs7[1] >> 31) & 1;
-            util_cpu_caps.has_avx512vbmi = (regs7[2] >>  1) & 1;
+         util_cpu_caps.has_clflushopt = (regs7[1] >> 23) & 1;
+         if (util_cpu_caps.has_avx) {
+            util_cpu_caps.has_avx2 = (regs7[1] >> 5) & 1;
+
+            // check for avx512
+            if (xgetbv() & (0x7 << 5)) { // OPMASK: upper-256 enabled by OS
+               util_cpu_caps.has_avx512f    = (regs7[1] >> 16) & 1;
+               util_cpu_caps.has_avx512dq   = (regs7[1] >> 17) & 1;
+               util_cpu_caps.has_avx512ifma = (regs7[1] >> 21) & 1;
+               util_cpu_caps.has_avx512pf   = (regs7[1] >> 26) & 1;
+               util_cpu_caps.has_avx512er   = (regs7[1] >> 27) & 1;
+               util_cpu_caps.has_avx512cd   = (regs7[1] >> 28) & 1;
+               util_cpu_caps.has_avx512bw   = (regs7[1] >> 30) & 1;
+               util_cpu_caps.has_avx512vl   = (regs7[1] >> 31) & 1;
+               util_cpu_caps.has_avx512vbmi = (regs7[2] >>  1) & 1;
+            }
          }
       }
 
@@ -986,6 +989,7 @@ _util_cpu_detect_once(void)
       printf("util_cpu_caps.has_avx512bw = %u\n", util_cpu_caps.has_avx512bw);
       printf("util_cpu_caps.has_avx512vl = %u\n", util_cpu_caps.has_avx512vl);
       printf("util_cpu_caps.has_avx512vbmi = %u\n", util_cpu_caps.has_avx512vbmi);
+      printf("util_cpu_caps.has_clflushopt = %u\n", util_cpu_caps.has_clflushopt);
       printf("util_cpu_caps.num_L3_caches = %u\n", util_cpu_caps.num_L3_caches);
       printf("util_cpu_caps.num_cpu_mask_bits = %u\n", util_cpu_caps.num_cpu_mask_bits);
    }
index 86ce912..6ae0c5d 100644 (file)
@@ -120,7 +120,7 @@ struct util_cpu_caps_t {
    unsigned has_avx512vl:1;
    unsigned has_avx512vbmi:1;
 
-   unsigned unused:1;
+   unsigned has_clflushopt:1;
 
    unsigned num_L3_caches;
    unsigned num_cpu_mask_bits;