-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimd.prf
199 lines (175 loc) · 7.17 KB
/
simd.prf
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#
# W A R N I N G
# -------------
#
# This file is not part of the Qt API. It exists purely as an
# implementation detail. It may change from version to version
# without notice, or even be removed.
#
# We mean it.
#
# Get the SIMD flags
load(qt_build_config)
# Set QT_CPU_FEATURES for convenience
QT_CPU_FEATURES = $$eval(QT_CPU_FEATURES.$$QT_ARCH)
#
# Set up compilers for SIMD (SSE/AVX, NEON etc)
#
defineTest(addSimdCompiler) {
name = $$1
upname = $$upper($$name)
headers_var = $${upname}_HEADERS
sources_var = $${upname}_SOURCES
csources_var = $${upname}_C_SOURCES
asm_var = $${upname}_ASM
CONFIG($$1) {
cflags = $$eval(QMAKE_CFLAGS_$${upname})
ltcg: cflags += $$QMAKE_CFLAGS_DISABLE_LTCG
contains(QT_CPU_FEATURES, $$name) {
# Default compiler settings include this feature, so just add to SOURCES
SOURCES += $$eval($$sources_var)
export(SOURCES)
} else {
# We need special compiler flags
# Split C and C++ sources
$$csources_var = $$find($$sources_var, ".*\\.c$")
$$sources_var -= $$eval($$csources_var)
export($$csources_var)
export($$sources_var)
# Add C++ compiler
$${name}_compiler.commands = $$QMAKE_CXX -c $(CXXFLAGS) $$cflags $(INCPATH) ${QMAKE_FILE_IN}
msvc: $${name}_compiler.commands += -Fo${QMAKE_FILE_OUT}
else: $${name}_compiler.commands += -o ${QMAKE_FILE_OUT}
$${name}_compiler.dependency_type = TYPE_C
$${name}_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
$${name}_compiler.input = $$sources_var
$${name}_compiler.variable_out = OBJECTS
$${name}_compiler.name = compiling[$${name}] ${QMAKE_FILE_IN}
silent: $${name}_compiler.commands = @echo compiling[$${name}] ${QMAKE_FILE_IN} && $$eval($${name}_compiler.commands)
QMAKE_EXTRA_COMPILERS += $${name}_compiler
export($${name}_compiler.commands)
export($${name}_compiler.dependency_type)
export($${name}_compiler.output)
export($${name}_compiler.input)
export($${name}_compiler.variable_out)
export($${name}_compiler.name)
# Add a C compiler
$${name}_c_compiler.commands = $$QMAKE_CC -c $(CFLAGS) $$cflags $(INCPATH) ${QMAKE_FILE_IN}
msvc: $${name}_c_compiler.commands += -Fo${QMAKE_FILE_OUT}
else: $${name}_c_compiler.commands += -o ${QMAKE_FILE_OUT}
$${name}_c_compiler.dependency_type = TYPE_C
$${name}_c_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
$${name}_c_compiler.input = $$csources_var
$${name}_c_compiler.variable_out = OBJECTS
$${name}_c_compiler.name = compiling[$${name}] ${QMAKE_FILE_IN}
silent: $${name}_c_compiler.commands = @echo compiling[$${name}] ${QMAKE_FILE_IN} && $$eval($${name}_c_compiler.commands)
QMAKE_EXTRA_COMPILERS += $${name}_c_compiler
export($${name}_c_compiler.commands)
export($${name}_c_compiler.dependency_type)
export($${name}_c_compiler.output)
export($${name}_c_compiler.input)
export($${name}_c_compiler.variable_out)
export($${name}_c_compiler.name)
}
# We always need an assembler (need to run the C compiler and without precompiled headers)
msvc {
# Don't know how to run MSVC's assembler...
!isEmpty($$asm_var): error("Sorry, not implemented: assembling $$upname for MSVC.")
} else: false {
# This is just for the IDE
SOURCES += $$eval($$asm_var)
export(SOURCES)
} else {
$${name}_assembler.commands = $$QMAKE_CC -c $(CFLAGS)
!contains(QT_CPU_FEATURES, $${name}): $${name}_assembler.commands += $$cflags
clang:no_clang_integrated_as: $${name}_assembler.commands += -fno-integrated-as
$${name}_assembler.commands += $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
$${name}_assembler.dependency_type = TYPE_C
$${name}_assembler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
$${name}_assembler.input = $$asm_var
$${name}_assembler.variable_out = OBJECTS
$${name}_assembler.name = assembling[$${name}] ${QMAKE_FILE_IN}
silent: $${name}_assembler.commands = @echo assembling[$${name}] ${QMAKE_FILE_IN} && $$eval($${name}_assembler.commands)
QMAKE_EXTRA_COMPILERS += $${name}_assembler
export($${name}_assembler.commands)
export($${name}_assembler.dependency_type)
export($${name}_assembler.output)
export($${name}_assembler.input)
export($${name}_assembler.variable_out)
export($${name}_assembler.name)
}
HEADERS += $$eval($$headers_var)
export(HEADERS)
export(QMAKE_EXTRA_COMPILERS)
}
}
addSimdCompiler(sse2)
addSimdCompiler(sse3)
addSimdCompiler(ssse3)
addSimdCompiler(sse4_1)
addSimdCompiler(sse4_2)
addSimdCompiler(aesni)
addSimdCompiler(shani)
addSimdCompiler(vaes)
addSimdCompiler(avx)
addSimdCompiler(avx2)
addSimdCompiler(avx512f)
addSimdCompiler(avx512cd)
addSimdCompiler(avx512er)
addSimdCompiler(avx512pf)
addSimdCompiler(avx512dq)
addSimdCompiler(avx512bw)
addSimdCompiler(avx512vl)
addSimdCompiler(avx512vnni)
addSimdCompiler(avx512ifma)
addSimdCompiler(avx512vbmi)
addSimdCompiler(avx512vbmi2)
addSimdCompiler(avx512bitalg)
addSimdCompiler(avx512vpopcntd)
addSimdCompiler(f16c)
addSimdCompiler(rdrnd)
addSimdCompiler(rdseed)
addSimdCompiler(neon)
addSimdCompiler(mips_dsp)
addSimdCompiler(mips_dspr2)
# Haswell sub-architecture
defineTest(addSimdArch) {
name = arch_$$1
dependencies = $$2
upname = $$upper($$name)
cpu_features_missing =
for(part, dependencies) {
!contains(QT_CPU_FEATURES, $$part): cpu_features_missing = 1
}
CONFIG += $$name
isEmpty(cpu_features_missing): QT_CPU_FEATURES += $$name
export(QT_CPU_FEATURES)
export(CONFIG)
addSimdCompiler($$name)
}
isEmpty(QMAKE_CFLAGS_ARCH_HASWELL): QMAKE_CFLAGS_ARCH_HASWELL = $$QMAKE_CFLAGS_AVX2
avx2: addSimdArch(haswell, avx2 bmi bmi2 f16c fma lzcnt popcnt)
# Follow the Intel compiler's lead and define profiles of AVX512 instructions
defineTest(addAvx512Profile) {
name = $$1
dependencies = $$2
upname = $$upper($$name)
varname = QMAKE_CFLAGS_$$upname
cpu_features_missing =
cflags = $$QMAKE_CFLAGS_ARCH_HASWELL $$QMAKE_CFLAGS_AVX512F
for(part, dependencies) {
!CONFIG($$part): return() # Profile isn't supported by the compiler
uppart = $$upper($$part)
cflags *= $$eval(QMAKE_CFLAGS_$${uppart})
!contains(QT_CPU_FEATURES, $$uppart): cpu_features_missing += $$uppart
}
CONFIG += $$name
isEmpty(cpu_features_missing): QT_CPU_FEATURES += $$name
$$varname = $$cflags
export(QT_CPU_FEATURES)
export(CONFIG)
export($$varname)
addSimdCompiler($$name)
}
addAvx512Profile(avx512common, avx512cd)
addAvx512Profile(avx512core, avx512cd avx512bw avx512dq avx512vl)