1
2
3
4
5
6
7
8
9 package simd_test
10
11 import (
12 "simd/archsimd"
13 "testing"
14 )
15
16
17 func testInt8x32Compare(t *testing.T, f func(_, _ archsimd.Int8x32) archsimd.Mask8x32, want func(_, _ []int8) []int64) {
18 n := 32
19 t.Helper()
20 forSlicePair(t, int8s, n, func(x, y []int8) bool {
21 t.Helper()
22 a := archsimd.LoadInt8x32(x)
23 b := archsimd.LoadInt8x32(y)
24 g := make([]int8, n)
25 f(a, b).ToInt8x32().Store(g)
26 w := want(x, y)
27 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
28 })
29 }
30
31
32 func testInt16x16Compare(t *testing.T, f func(_, _ archsimd.Int16x16) archsimd.Mask16x16, want func(_, _ []int16) []int64) {
33 n := 16
34 t.Helper()
35 forSlicePair(t, int16s, n, func(x, y []int16) bool {
36 t.Helper()
37 a := archsimd.LoadInt16x16(x)
38 b := archsimd.LoadInt16x16(y)
39 g := make([]int16, n)
40 f(a, b).ToInt16x16().Store(g)
41 w := want(x, y)
42 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
43 })
44 }
45
46
47 func testInt32x8Compare(t *testing.T, f func(_, _ archsimd.Int32x8) archsimd.Mask32x8, want func(_, _ []int32) []int64) {
48 n := 8
49 t.Helper()
50 forSlicePair(t, int32s, n, func(x, y []int32) bool {
51 t.Helper()
52 a := archsimd.LoadInt32x8(x)
53 b := archsimd.LoadInt32x8(y)
54 g := make([]int32, n)
55 f(a, b).ToInt32x8().Store(g)
56 w := want(x, y)
57 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
58 })
59 }
60
61
62 func testInt64x4Compare(t *testing.T, f func(_, _ archsimd.Int64x4) archsimd.Mask64x4, want func(_, _ []int64) []int64) {
63 n := 4
64 t.Helper()
65 forSlicePair(t, int64s, n, func(x, y []int64) bool {
66 t.Helper()
67 a := archsimd.LoadInt64x4(x)
68 b := archsimd.LoadInt64x4(y)
69 g := make([]int64, n)
70 f(a, b).ToInt64x4().Store(g)
71 w := want(x, y)
72 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
73 })
74 }
75
76
77 func testUint8x32Compare(t *testing.T, f func(_, _ archsimd.Uint8x32) archsimd.Mask8x32, want func(_, _ []uint8) []int64) {
78 n := 32
79 t.Helper()
80 forSlicePair(t, uint8s, n, func(x, y []uint8) bool {
81 t.Helper()
82 a := archsimd.LoadUint8x32(x)
83 b := archsimd.LoadUint8x32(y)
84 g := make([]int8, n)
85 f(a, b).ToInt8x32().Store(g)
86 w := want(x, y)
87 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
88 })
89 }
90
91
92 func testUint16x16Compare(t *testing.T, f func(_, _ archsimd.Uint16x16) archsimd.Mask16x16, want func(_, _ []uint16) []int64) {
93 n := 16
94 t.Helper()
95 forSlicePair(t, uint16s, n, func(x, y []uint16) bool {
96 t.Helper()
97 a := archsimd.LoadUint16x16(x)
98 b := archsimd.LoadUint16x16(y)
99 g := make([]int16, n)
100 f(a, b).ToInt16x16().Store(g)
101 w := want(x, y)
102 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
103 })
104 }
105
106
107 func testUint32x8Compare(t *testing.T, f func(_, _ archsimd.Uint32x8) archsimd.Mask32x8, want func(_, _ []uint32) []int64) {
108 n := 8
109 t.Helper()
110 forSlicePair(t, uint32s, n, func(x, y []uint32) bool {
111 t.Helper()
112 a := archsimd.LoadUint32x8(x)
113 b := archsimd.LoadUint32x8(y)
114 g := make([]int32, n)
115 f(a, b).ToInt32x8().Store(g)
116 w := want(x, y)
117 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
118 })
119 }
120
121
122 func testUint64x4Compare(t *testing.T, f func(_, _ archsimd.Uint64x4) archsimd.Mask64x4, want func(_, _ []uint64) []int64) {
123 n := 4
124 t.Helper()
125 forSlicePair(t, uint64s, n, func(x, y []uint64) bool {
126 t.Helper()
127 a := archsimd.LoadUint64x4(x)
128 b := archsimd.LoadUint64x4(y)
129 g := make([]int64, n)
130 f(a, b).ToInt64x4().Store(g)
131 w := want(x, y)
132 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
133 })
134 }
135
136
137 func testFloat32x8Compare(t *testing.T, f func(_, _ archsimd.Float32x8) archsimd.Mask32x8, want func(_, _ []float32) []int64) {
138 n := 8
139 t.Helper()
140 forSlicePair(t, float32s, n, func(x, y []float32) bool {
141 t.Helper()
142 a := archsimd.LoadFloat32x8(x)
143 b := archsimd.LoadFloat32x8(y)
144 g := make([]int32, n)
145 f(a, b).ToInt32x8().Store(g)
146 w := want(x, y)
147 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
148 })
149 }
150
151
152 func testFloat64x4Compare(t *testing.T, f func(_, _ archsimd.Float64x4) archsimd.Mask64x4, want func(_, _ []float64) []int64) {
153 n := 4
154 t.Helper()
155 forSlicePair(t, float64s, n, func(x, y []float64) bool {
156 t.Helper()
157 a := archsimd.LoadFloat64x4(x)
158 b := archsimd.LoadFloat64x4(y)
159 g := make([]int64, n)
160 f(a, b).ToInt64x4().Store(g)
161 w := want(x, y)
162 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
163 })
164 }
165
166
167 func testInt8x64Compare(t *testing.T, f func(_, _ archsimd.Int8x64) archsimd.Mask8x64, want func(_, _ []int8) []int64) {
168 n := 64
169 t.Helper()
170 forSlicePair(t, int8s, n, func(x, y []int8) bool {
171 t.Helper()
172 a := archsimd.LoadInt8x64(x)
173 b := archsimd.LoadInt8x64(y)
174 g := make([]int8, n)
175 f(a, b).ToInt8x64().Store(g)
176 w := want(x, y)
177 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
178 })
179 }
180
181
182 func testInt16x32Compare(t *testing.T, f func(_, _ archsimd.Int16x32) archsimd.Mask16x32, want func(_, _ []int16) []int64) {
183 n := 32
184 t.Helper()
185 forSlicePair(t, int16s, n, func(x, y []int16) bool {
186 t.Helper()
187 a := archsimd.LoadInt16x32(x)
188 b := archsimd.LoadInt16x32(y)
189 g := make([]int16, n)
190 f(a, b).ToInt16x32().Store(g)
191 w := want(x, y)
192 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
193 })
194 }
195
196
197 func testInt32x16Compare(t *testing.T, f func(_, _ archsimd.Int32x16) archsimd.Mask32x16, want func(_, _ []int32) []int64) {
198 n := 16
199 t.Helper()
200 forSlicePair(t, int32s, n, func(x, y []int32) bool {
201 t.Helper()
202 a := archsimd.LoadInt32x16(x)
203 b := archsimd.LoadInt32x16(y)
204 g := make([]int32, n)
205 f(a, b).ToInt32x16().Store(g)
206 w := want(x, y)
207 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
208 })
209 }
210
211
212 func testInt64x8Compare(t *testing.T, f func(_, _ archsimd.Int64x8) archsimd.Mask64x8, want func(_, _ []int64) []int64) {
213 n := 8
214 t.Helper()
215 forSlicePair(t, int64s, n, func(x, y []int64) bool {
216 t.Helper()
217 a := archsimd.LoadInt64x8(x)
218 b := archsimd.LoadInt64x8(y)
219 g := make([]int64, n)
220 f(a, b).ToInt64x8().Store(g)
221 w := want(x, y)
222 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
223 })
224 }
225
226
227 func testUint8x64Compare(t *testing.T, f func(_, _ archsimd.Uint8x64) archsimd.Mask8x64, want func(_, _ []uint8) []int64) {
228 n := 64
229 t.Helper()
230 forSlicePair(t, uint8s, n, func(x, y []uint8) bool {
231 t.Helper()
232 a := archsimd.LoadUint8x64(x)
233 b := archsimd.LoadUint8x64(y)
234 g := make([]int8, n)
235 f(a, b).ToInt8x64().Store(g)
236 w := want(x, y)
237 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
238 })
239 }
240
241
242 func testUint16x32Compare(t *testing.T, f func(_, _ archsimd.Uint16x32) archsimd.Mask16x32, want func(_, _ []uint16) []int64) {
243 n := 32
244 t.Helper()
245 forSlicePair(t, uint16s, n, func(x, y []uint16) bool {
246 t.Helper()
247 a := archsimd.LoadUint16x32(x)
248 b := archsimd.LoadUint16x32(y)
249 g := make([]int16, n)
250 f(a, b).ToInt16x32().Store(g)
251 w := want(x, y)
252 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
253 })
254 }
255
256
257 func testUint32x16Compare(t *testing.T, f func(_, _ archsimd.Uint32x16) archsimd.Mask32x16, want func(_, _ []uint32) []int64) {
258 n := 16
259 t.Helper()
260 forSlicePair(t, uint32s, n, func(x, y []uint32) bool {
261 t.Helper()
262 a := archsimd.LoadUint32x16(x)
263 b := archsimd.LoadUint32x16(y)
264 g := make([]int32, n)
265 f(a, b).ToInt32x16().Store(g)
266 w := want(x, y)
267 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
268 })
269 }
270
271
272 func testUint64x8Compare(t *testing.T, f func(_, _ archsimd.Uint64x8) archsimd.Mask64x8, want func(_, _ []uint64) []int64) {
273 n := 8
274 t.Helper()
275 forSlicePair(t, uint64s, n, func(x, y []uint64) bool {
276 t.Helper()
277 a := archsimd.LoadUint64x8(x)
278 b := archsimd.LoadUint64x8(y)
279 g := make([]int64, n)
280 f(a, b).ToInt64x8().Store(g)
281 w := want(x, y)
282 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
283 })
284 }
285
286
287 func testFloat32x16Compare(t *testing.T, f func(_, _ archsimd.Float32x16) archsimd.Mask32x16, want func(_, _ []float32) []int64) {
288 n := 16
289 t.Helper()
290 forSlicePair(t, float32s, n, func(x, y []float32) bool {
291 t.Helper()
292 a := archsimd.LoadFloat32x16(x)
293 b := archsimd.LoadFloat32x16(y)
294 g := make([]int32, n)
295 f(a, b).ToInt32x16().Store(g)
296 w := want(x, y)
297 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
298 })
299 }
300
301
302 func testFloat64x8Compare(t *testing.T, f func(_, _ archsimd.Float64x8) archsimd.Mask64x8, want func(_, _ []float64) []int64) {
303 n := 8
304 t.Helper()
305 forSlicePair(t, float64s, n, func(x, y []float64) bool {
306 t.Helper()
307 a := archsimd.LoadFloat64x8(x)
308 b := archsimd.LoadFloat64x8(y)
309 g := make([]int64, n)
310 f(a, b).ToInt64x8().Store(g)
311 w := want(x, y)
312 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
313 })
314 }
315
316
317 func testFloat32x8UnaryCompare(t *testing.T, f func(x archsimd.Float32x8) archsimd.Mask32x8, want func(x []float32) []int64) {
318 n := 8
319 t.Helper()
320 forSlice(t, float32s, n, func(x []float32) bool {
321 t.Helper()
322 a := archsimd.LoadFloat32x8(x)
323 g := make([]int32, n)
324 f(a).ToInt32x8().Store(g)
325 w := want(x)
326 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
327 })
328 }
329
330
331 func testFloat64x4UnaryCompare(t *testing.T, f func(x archsimd.Float64x4) archsimd.Mask64x4, want func(x []float64) []int64) {
332 n := 4
333 t.Helper()
334 forSlice(t, float64s, n, func(x []float64) bool {
335 t.Helper()
336 a := archsimd.LoadFloat64x4(x)
337 g := make([]int64, n)
338 f(a).ToInt64x4().Store(g)
339 w := want(x)
340 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
341 })
342 }
343
344
345 func testFloat32x16UnaryCompare(t *testing.T, f func(x archsimd.Float32x16) archsimd.Mask32x16, want func(x []float32) []int64) {
346 n := 16
347 t.Helper()
348 forSlice(t, float32s, n, func(x []float32) bool {
349 t.Helper()
350 a := archsimd.LoadFloat32x16(x)
351 g := make([]int32, n)
352 f(a).ToInt32x16().Store(g)
353 w := want(x)
354 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
355 })
356 }
357
358
359 func testFloat64x8UnaryCompare(t *testing.T, f func(x archsimd.Float64x8) archsimd.Mask64x8, want func(x []float64) []int64) {
360 n := 8
361 t.Helper()
362 forSlice(t, float64s, n, func(x []float64) bool {
363 t.Helper()
364 a := archsimd.LoadFloat64x8(x)
365 g := make([]int64, n)
366 f(a).ToInt64x8().Store(g)
367 w := want(x)
368 return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
369 })
370 }
371
View as plain text