diff mbox series

[2/3] x86: Add AMD Zen and AVX2/AVX platform support

Message ID 20200317044646.29707-3-PMallappa@amd.com
State New
Headers show
Series RFC: Platform Support for AMD Zen and AVX2/AVX | expand

Commit Message

Michael Kerrisk \(man-pages\) via Libc-alpha March 17, 2020, 4:46 a.m. UTC
From: Prem Mallappa <Premachandra.Mallappa@amd.com>

Priority as below
- AVX512
- Haswell/Zen as they are superset of AVX2/AVX
- AVX2
- AVX

Signed-off-by: Prem Mallappa <Premachandra.Mallappa@amd.com>
---
 sysdeps/x86/cpu-features.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index a36f385976..2097107968 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -328,20 +328,34 @@  set_platform (struct cpu_features *cpu_features)
 		GLRO(dl_hwcap) |= HWCAP_X86_AVX512_1;
 	    }
 	}
+    }
 
-      if (platform == NULL
-	  && CPU_FEATURES_ARCH_P (cpu_features, AVX2_Usable)
-	  && CPU_FEATURES_ARCH_P (cpu_features, FMA_Usable)
-	  && CPU_FEATURES_CPU_P (cpu_features, BMI1)
-	  && CPU_FEATURES_CPU_P (cpu_features, BMI2)
-	  && CPU_FEATURES_CPU_P (cpu_features, LZCNT)
-	  && CPU_FEATURES_CPU_P (cpu_features, MOVBE)
-	  && CPU_FEATURES_CPU_P (cpu_features, POPCNT))
+  if (platform == NULL
+      && CPU_FEATURES_ARCH_P (cpu_features, AVX2_Usable)
+      && CPU_FEATURES_ARCH_P (cpu_features, FMA_Usable)
+      && CPU_FEATURES_CPU_P (cpu_features, BMI1)
+      && CPU_FEATURES_CPU_P (cpu_features, BMI2)
+      && CPU_FEATURES_CPU_P (cpu_features, LZCNT)
+      && CPU_FEATURES_CPU_P (cpu_features, MOVBE)
+      && CPU_FEATURES_CPU_P (cpu_features, POPCNT))
+    {
+      if (cpu_features->basic.kind == arch_kind_intel)
 	platform = "haswell";
+      else if (cpu_features->basic.kind == arch_kind_amd)
+	platform = "zen";
     }
 
+  if (platform == NULL
+      && CPU_FEATURES_ARCH_P (cpu_features, AVX2_Usable))
+    platform = "generic-avx2";
+
+  if (platform == NULL
+      && CPU_FEATURES_ARCH_P (cpu_features, AVX_Usable))
+    platform = "generic-avx";
+
   if (platform != NULL)
     GLRO(dl_platform) = platform;
+
 #else
   GLRO(dl_hwcap) = 0;
   if (CPU_FEATURES_CPU_P (cpu_features, SSE2))