summaryrefslogtreecommitdiff
blob: 18bd02ae9d57b4eb593a1b77138dfe9fe33a841a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
From 70acc386b6afb726d4576a3d4368b51114e92530 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Tue, 1 Sep 2020 12:54:19 +0100
Subject: [PATCH] stress-ng.h: build in target clone types if gcc supports the
 feature

Add in more build time optimization checks, try to build smarter with
various gcc compatibility support checks.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 stress-ng.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)

diff --git a/stress-ng.h b/stress-ng.h
index 3803bc71..6ce7d72e 100644
--- a/stress-ng.h
+++ b/stress-ng.h
@@ -1686,7 +1686,67 @@ extern void pr_dbg_lock(bool *locked, const char *fmt, ...)  FORMAT(printf, 2, 3
 
 /* GCC5.0+ target_clones attribute */
 #if defined(HAVE_TARGET_CLONES) && defined(STRESS_ARCH_X86)
-#define TARGET_CLONES	__attribute__((target_clones("mmx","sse","sse2","ssse3", "sse4.1", "sse4a", "avx", "avx2", "arch=skylake-avx512", "default")))
+#if defined(__MMX_WITH_SSE__)
+#define TARGET_CLONE_MMX	"mmx",
+#else
+#define TARGET_CLONE_MMX
+#endif
+
+#if defined(__AVX__)
+#define TARGET_CLONE_AVX	"avx",
+#else
+#define TARGET_CLONE_AVX
+#endif
+
+#if defined(__AVX2__)
+#define TARGET_CLONE_AVX2	"avx2",
+#else
+#define TARGET_CLONE_AVX2
+#endif
+
+#if defined(__SSE__)
+#define TARGET_CLONE_SSE	"sse",
+#else
+#define TARGET_CLONE_SSE
+#endif
+
+#if defined(__SSE2__)
+#define TARGET_CLONE_SSE2	"sse2",
+#else
+#define TARGET_CLONE_SSE2
+#endif
+
+#if defined(__SSE3__)
+#define TARGET_CLONE_SSE3	"sse3",
+#else
+#define TARGET_CLONE_SSE3
+#endif
+
+#if defined(__SSSE3__)
+#define TARGET_CLONE_SSSE3	"ssse3",
+#else
+#define TARGET_CLONE_SSSE3
+#endif
+
+#if defined(__SSE4_1__)
+#define TARGET_CLONE_SSE4_1	"sse4.1",
+#else
+#define TARGET_CLONE_SSE4_1
+#endif
+
+#if defined(__SSE4_2__)
+#define TARGET_CLONE_SSE4_2	"sse4.2",
+#else
+#define TARGET_CLONE_SSE4_2
+#endif
+
+#if defined(__AVX512F__)
+#define TARGET_CLONE_SKYLAKE_AVX512	"arch=skylake-avx512",
+#else
+#define TARGET_CLONE_SKYLAKE_AVX512
+#endif
+
+#define TARGET_CLONES	__attribute__((target_clones(TARGET_CLONE_AVX TARGET_CLONE_AVX2 TARGET_CLONE_MMX TARGET_CLONE_SSE TARGET_CLONE_SSE2 TARGET_CLONE_SSE3 TARGET_CLONE_SSSE3 TARGET_CLONE_SSE4_1 TARGET_CLONE_SSE4_2 TARGET_CLONE_SKYLAKE_AVX512 "default")))
 #elif defined(HAVE_TARGET_CLONES) && defined(STRESS_ARCH_PPC64)
 #define TARGET_CLONES	__attribute__((target_clones("cpu=power9,default")))
 #else