[Mesa-dev] [PATCH 3/9] util: add fma3 or fma4 capable cpu detection

Maxence Le Doré maxence.ledore at gmail.com
Sat Jan 4 15:42:38 PST 2014


From: Maxence Le Doré <Maxence Le Doré>

---
 src/gallium/auxiliary/util/u_cpu_detect.c | 5 +++++
 src/gallium/auxiliary/util/u_cpu_detect.h | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_cpu_detect.c b/src/gallium/auxiliary/util/u_cpu_detect.c
index d2d1313..19ad4fa 100644
--- a/src/gallium/auxiliary/util/u_cpu_detect.c
+++ b/src/gallium/auxiliary/util/u_cpu_detect.c
@@ -371,6 +371,9 @@ util_cpu_detect(void)
                                     ((xgetbv() & 6) == 6);    // XMM & YMM
          util_cpu_caps.has_f16c   = (regs2[2] >> 29) & 1;
          util_cpu_caps.has_mmx2   = util_cpu_caps.has_sse; /* SSE cpus supports mmxext too */
+
+         util_cpu_caps.has_fma3   = (regs2[2] >> 12) & 1;
+         util_cpu_caps.has_fma4   = (regs2[2] >> 16) & 1;
 #if defined(PIPE_ARCH_X86_64)
          util_cpu_caps.has_daz = 1;
 #else
@@ -451,6 +454,8 @@ util_cpu_detect(void)
       debug_printf("util_cpu_caps.has_xop = %u\n", util_cpu_caps.has_xop);
       debug_printf("util_cpu_caps.has_altivec = %u\n", util_cpu_caps.has_altivec);
       debug_printf("util_cpu_caps.has_daz = %u\n", util_cpu_caps.has_daz);
+      debug_printf("util_cpu_caps.has_fma3 = %u\n", util_cpu_caps.has_fma3);
+      debug_printf("util_cpu_caps.has_fma4 = %u\n", util_cpu_caps.has_fma4);
    }
 #endif
 
diff --git a/src/gallium/auxiliary/util/u_cpu_detect.h b/src/gallium/auxiliary/util/u_cpu_detect.h
index 5ccfc93..6802e6a 100644
--- a/src/gallium/auxiliary/util/u_cpu_detect.h
+++ b/src/gallium/auxiliary/util/u_cpu_detect.h
@@ -71,6 +71,8 @@ struct util_cpu_caps {
    unsigned has_xop:1;
    unsigned has_altivec:1;
    unsigned has_daz:1;
+   unsigned has_fma3:1;
+   unsigned has_fma4:1;
 };
 
 extern struct util_cpu_caps
-- 
1.8.5.2



More information about the mesa-dev mailing list