[PATCH 19/30] x86_64: Add glibc-hwcaps support
Florian Weimer
fweimer@redhat.com
Mon Jun 22 15:14:37 GMT 2020
Details of the supported CPU flags and the names are still subject to
changes.
---
sysdeps/x86_64/dl-hwcaps-subdirs.c | 73 ++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+)
create mode 100644 sysdeps/x86_64/dl-hwcaps-subdirs.c
diff --git a/sysdeps/x86_64/dl-hwcaps-subdirs.c b/sysdeps/x86_64/dl-hwcaps-subdirs.c
new file mode 100644
index 0000000000..4a8fae976e
--- /dev/null
+++ b/sysdeps/x86_64/dl-hwcaps-subdirs.c
@@ -0,0 +1,73 @@
+/* Architecture-specific glibc-hwcaps subdirectories. x86 version.
+ Copyright (C) 2020 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <dl-hwcaps.h>
+#include <cpu-features.h>
+
+const char _dl_hwcaps_subdirs[] = "x86-103:x86-102:x86-101:x86-100";
+
+int32_t
+_dl_hwcaps_subdirs_active (void)
+{
+ const struct cpu_features *cpu_features = __get_cpu_features ();
+ int32_t result = 0;
+ int32_t bit = 1 << 3;
+
+ /* Test in reverse preference order. */
+
+ /* x86-100. */
+ if (!(CPU_FEATURES_ARCH_P (cpu_features, CMPXCHG16B_Usable)
+ && CPU_FEATURES_ARCH_P (cpu_features, POPCNT_Usable)
+ && CPU_FEATURES_ARCH_P (cpu_features, SSE3_Usable)
+ && CPU_FEATURES_ARCH_P (cpu_features, SSE4_1_Usable)
+ && CPU_FEATURES_ARCH_P (cpu_features, SSE4_2_Usable)
+ && CPU_FEATURES_ARCH_P (cpu_features, SSSE3_Usable)))
+ return result;
+ result |= bit;
+ bit >>= 1;
+
+ /* x86-101. */
+ if (!(CPU_FEATURES_ARCH_P (cpu_features, AVX_Usable)))
+ return result;
+ result |= bit;
+ bit >>= 1;
+
+ /* x86-102. */
+ if (!(CPU_FEATURES_ARCH_P (cpu_features, AVX2_Usable)
+ && CPU_FEATURES_ARCH_P (cpu_features, BMI1_Usable)
+ && CPU_FEATURES_ARCH_P (cpu_features, BMI2_Usable)
+ && CPU_FEATURES_ARCH_P (cpu_features, F16C_Usable)
+ && CPU_FEATURES_ARCH_P (cpu_features, FMA_Usable)
+ && CPU_FEATURES_ARCH_P (cpu_features, LZCNT_Usable)
+ && CPU_FEATURES_ARCH_P (cpu_features, MOVBE_Usable)))
+ return result;
+ result |= bit;
+ bit >>= 1;
+
+ /* x86-103. */
+ if (!(CPU_FEATURES_ARCH_P (cpu_features, AVX512F_Usable)
+ && CPU_FEATURES_CPU_P (cpu_features, AVX512BW)
+ && CPU_FEATURES_CPU_P (cpu_features, AVX512CD)
+ && CPU_FEATURES_CPU_P (cpu_features, AVX512DQ)
+ && CPU_FEATURES_CPU_P (cpu_features, AVX512VL)))
+ return result;
+ result |= bit;
+ bit >>= 1;
+
+ return result;
+}
--
2.25.4
More information about the Libc-alpha
mailing list