aboutsummaryrefslogtreecommitdiffstats
path: root/config/toolchain-simd.m4
blob: 29abbbb5b6a34cea7dec6656892b209407c6bb54 (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
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
dnl #
dnl # Checks if host toolchain supports SIMD instructions
dnl #
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_TOOLCHAIN_SIMD], [
	case "$host_cpu" in
		x86_64 | x86 | i686)
			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE
			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE2
			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE3
			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSSE3
			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE4_1
			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE4_2
			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX
			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX2
			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512F
			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512CD
			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512DQ
			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512BW
			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512IFMA
			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512VBMI
			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512PF
			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512ER
			ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512VL
			;;
	esac
])

dnl #
dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE
dnl #
AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE], [
	AC_MSG_CHECKING([whether host toolchain supports SSE])

	AC_LINK_IFELSE([AC_LANG_SOURCE([[
		void main()
		{
			__asm__ __volatile__("xorps %xmm0, %xmm1");
		}
	]])], [
		AC_DEFINE([HAVE_SSE], 1, [Define if host toolchain supports SSE])
		AC_MSG_RESULT([yes])
	], [
		AC_MSG_RESULT([no])
	])
])

dnl #
dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE2
dnl #
AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE2], [
	AC_MSG_CHECKING([whether host toolchain supports SSE2])

	AC_LINK_IFELSE([AC_LANG_SOURCE([[
		void main()
		{
			__asm__ __volatile__("pxor %xmm0, %xmm1");
		}
	]])], [
		AC_DEFINE([HAVE_SSE2], 1, [Define if host toolchain supports SSE2])
		AC_MSG_RESULT([yes])
	], [
		AC_MSG_RESULT([no])
	])
])

dnl #
dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE3
dnl #
AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE3], [
	AC_MSG_CHECKING([whether host toolchain supports SSE3])

	AC_LINK_IFELSE([AC_LANG_SOURCE([[
		void main()
		{
			char v[16];
			__asm__ __volatile__("lddqu %0,%%xmm0" :: "m"(v[0]));
		}
	]])], [
		AC_DEFINE([HAVE_SSE3], 1, [Define if host toolchain supports SSE3])
		AC_MSG_RESULT([yes])
	], [
		AC_MSG_RESULT([no])
	])
])

dnl #
dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSSE3
dnl #
AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSSE3], [
	AC_MSG_CHECKING([whether host toolchain supports SSSE3])

	AC_LINK_IFELSE([AC_LANG_SOURCE([[
		void main()
		{
			__asm__ __volatile__("pshufb %xmm0,%xmm1");
		}
	]])], [
		AC_DEFINE([HAVE_SSSE3], 1, [Define if host toolchain supports SSSE3])
		AC_MSG_RESULT([yes])
	], [
		AC_MSG_RESULT([no])
	])
])

dnl #
dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE4_1
dnl #
AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE4_1], [
	AC_MSG_CHECKING([whether host toolchain supports SSE4.1])

	AC_LINK_IFELSE([AC_LANG_SOURCE([[
		void main()
		{
			__asm__ __volatile__("pmaxsb %xmm0,%xmm1");
		}
	]])], [
		AC_DEFINE([HAVE_SSE4_1], 1, [Define if host toolchain supports SSE4.1])
		AC_MSG_RESULT([yes])
	], [
		AC_MSG_RESULT([no])
	])
])

dnl #
dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE4_2
dnl #
AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_SSE4_2], [
	AC_MSG_CHECKING([whether host toolchain supports SSE4.2])

	AC_LINK_IFELSE([AC_LANG_SOURCE([[
		void main()
		{
			__asm__ __volatile__("pcmpgtq %xmm0, %xmm1");
		}
	]])], [
		AC_DEFINE([HAVE_SSE4_2], 1, [Define if host toolchain supports SSE4.2])
		AC_MSG_RESULT([yes])
	], [
		AC_MSG_RESULT([no])
	])
])

dnl #
dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX
dnl #
AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX], [
	AC_MSG_CHECKING([whether host toolchain supports AVX])

	AC_LINK_IFELSE([AC_LANG_SOURCE([[
		void main()
		{
			char v[32];
			__asm__ __volatile__("vmovdqa %0,%%ymm0" :: "m"(v[0]));
		}
	]])], [
		AC_MSG_RESULT([yes])
		AC_DEFINE([HAVE_AVX], 1, [Define if host toolchain supports AVX])
	], [
		AC_MSG_RESULT([no])
	])
])

dnl #
dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX2
dnl #
AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX2], [
	AC_MSG_CHECKING([whether host toolchain supports AVX2])

	AC_LINK_IFELSE([AC_LANG_SOURCE([
	[
		void main()
		{
			__asm__ __volatile__("vpshufb %ymm0,%ymm1,%ymm2");
		}
	]])], [
		AC_MSG_RESULT([yes])
		AC_DEFINE([HAVE_AVX2], 1, [Define if host toolchain supports AVX2])
	], [
		AC_MSG_RESULT([no])
	])
])

dnl #
dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512F
dnl #
AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512F], [
	AC_MSG_CHECKING([whether host toolchain supports AVX512F])

	AC_LINK_IFELSE([AC_LANG_SOURCE([
	[
		void main()
		{
			__asm__ __volatile__("vpandd %zmm0,%zmm1,%zmm2");
		}
	]])], [
		AC_MSG_RESULT([yes])
		AC_DEFINE([HAVE_AVX512F], 1, [Define if host toolchain supports AVX512F])
	], [
		AC_MSG_RESULT([no])
	])
])

dnl #
dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512CD
dnl #
AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512CD], [
	AC_MSG_CHECKING([whether host toolchain supports AVX512CD])

	AC_LINK_IFELSE([AC_LANG_SOURCE([
	[
		void main()
		{
			__asm__ __volatile__("vplzcntd %zmm0,%zmm1");
		}
	]])], [
		AC_MSG_RESULT([yes])
		AC_DEFINE([HAVE_AVX512CD], 1, [Define if host toolchain supports AVX512CD])
	], [
		AC_MSG_RESULT([no])
	])
])

dnl #
dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512DQ
dnl #
AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512DQ], [
	AC_MSG_CHECKING([whether host toolchain supports AVX512DQ])

	AC_LINK_IFELSE([AC_LANG_SOURCE([
	[
		void main()
		{
			__asm__ __volatile__("vandpd %zmm0,%zmm1,%zmm2");
		}
	]])], [
		AC_MSG_RESULT([yes])
		AC_DEFINE([HAVE_AVX512DQ], 1, [Define if host toolchain supports AVX512DQ])
	], [
		AC_MSG_RESULT([no])
	])
])

dnl #
dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512BW
dnl #
AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512BW], [
	AC_MSG_CHECKING([whether host toolchain supports AVX512BW])

	AC_LINK_IFELSE([AC_LANG_SOURCE([
	[
		void main()
		{
			__asm__ __volatile__("vpshufb %zmm0,%zmm1,%zmm2");
		}
	]])], [
		AC_MSG_RESULT([yes])
		AC_DEFINE([HAVE_AVX512BW], 1, [Define if host toolchain supports AVX512BW])
	], [
		AC_MSG_RESULT([no])
	])
])

dnl #
dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512IFMA
dnl #
AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512IFMA], [
	AC_MSG_CHECKING([whether host toolchain supports AVX512IFMA])

	AC_LINK_IFELSE([AC_LANG_SOURCE([
	[
		void main()
		{
			__asm__ __volatile__("vpmadd52luq %zmm0,%zmm1,%zmm2");
		}
	]])], [
		AC_MSG_RESULT([yes])
		AC_DEFINE([HAVE_AVX512IFMA], 1, [Define if host toolchain supports AVX512IFMA])
	], [
		AC_MSG_RESULT([no])
	])
])

dnl #
dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512VBMI
dnl #
AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512VBMI], [
	AC_MSG_CHECKING([whether host toolchain supports AVX512VBMI])

	AC_LINK_IFELSE([AC_LANG_SOURCE([
	[
		void main()
		{
			__asm__ __volatile__("vpermb %zmm0,%zmm1,%zmm2");
		}
	]])], [
		AC_MSG_RESULT([yes])
		AC_DEFINE([HAVE_AVX512VBMI], 1, [Define if host toolchain supports AVX512VBMI])
	], [
		AC_MSG_RESULT([no])
	])
])

dnl #
dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512PF
dnl #
AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512PF], [
	AC_MSG_CHECKING([whether host toolchain supports AVX512PF])

	AC_LINK_IFELSE([AC_LANG_SOURCE([
	[
		void main()
		{
			__asm__ __volatile__("vgatherpf0dps (%rsi,%zmm0,4){%k1}");
		}
	]])], [
		AC_MSG_RESULT([yes])
		AC_DEFINE([HAVE_AVX512PF], 1, [Define if host toolchain supports AVX512PF])
	], [
		AC_MSG_RESULT([no])
	])
])

dnl #
dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512ER
dnl #
AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512ER], [
	AC_MSG_CHECKING([whether host toolchain supports AVX512ER])

	AC_LINK_IFELSE([AC_LANG_SOURCE([
	[
		void main()
		{
			__asm__ __volatile__("vexp2pd %zmm0,%zmm1");
		}
	]])], [
		AC_MSG_RESULT([yes])
		AC_DEFINE([HAVE_AVX512ER], 1, [Define if host toolchain supports AVX512ER])
	], [
		AC_MSG_RESULT([no])
	])
])

dnl #
dnl # ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512VL
dnl #
AC_DEFUN([ZFS_AC_CONFIG_TOOLCHAIN_CAN_BUILD_AVX512VL], [
	AC_MSG_CHECKING([whether host toolchain supports AVX512VL])

	AC_LINK_IFELSE([AC_LANG_SOURCE([
	[
		void main()
		{
			__asm__ __volatile__("vpabsq %zmm0,%zmm1");
		}
	]])], [
		AC_MSG_RESULT([yes])
		AC_DEFINE([HAVE_AVX512VL], 1, [Define if host toolchain supports AVX512VL])
	], [
		AC_MSG_RESULT([no])
	])
])