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 testInt8x32Binary(t *testing.T, f func(_, _ archsimd.Int8x32) archsimd.Int8x32, want func(_, _ []int8) []int8) {
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).Store(g)
26 w := want(x, y)
27 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
28 })
29 }
30
31
32 func testInt16x16Binary(t *testing.T, f func(_, _ archsimd.Int16x16) archsimd.Int16x16, want func(_, _ []int16) []int16) {
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).Store(g)
41 w := want(x, y)
42 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
43 })
44 }
45
46
47 func testInt32x8Binary(t *testing.T, f func(_, _ archsimd.Int32x8) archsimd.Int32x8, want func(_, _ []int32) []int32) {
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).Store(g)
56 w := want(x, y)
57 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
58 })
59 }
60
61
62 func testInt64x4Binary(t *testing.T, f func(_, _ archsimd.Int64x4) archsimd.Int64x4, 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).Store(g)
71 w := want(x, y)
72 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
73 })
74 }
75
76
77 func testUint8x32Binary(t *testing.T, f func(_, _ archsimd.Uint8x32) archsimd.Uint8x32, want func(_, _ []uint8) []uint8) {
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([]uint8, n)
85 f(a, b).Store(g)
86 w := want(x, y)
87 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
88 })
89 }
90
91
92 func testUint16x16Binary(t *testing.T, f func(_, _ archsimd.Uint16x16) archsimd.Uint16x16, want func(_, _ []uint16) []uint16) {
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([]uint16, n)
100 f(a, b).Store(g)
101 w := want(x, y)
102 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
103 })
104 }
105
106
107 func testUint32x8Binary(t *testing.T, f func(_, _ archsimd.Uint32x8) archsimd.Uint32x8, want func(_, _ []uint32) []uint32) {
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([]uint32, n)
115 f(a, b).Store(g)
116 w := want(x, y)
117 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
118 })
119 }
120
121
122 func testUint64x4Binary(t *testing.T, f func(_, _ archsimd.Uint64x4) archsimd.Uint64x4, want func(_, _ []uint64) []uint64) {
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([]uint64, n)
130 f(a, b).Store(g)
131 w := want(x, y)
132 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
133 })
134 }
135
136
137 func testFloat32x8Binary(t *testing.T, f func(_, _ archsimd.Float32x8) archsimd.Float32x8, want func(_, _ []float32) []float32) {
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([]float32, n)
145 f(a, b).Store(g)
146 w := want(x, y)
147 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
148 })
149 }
150
151
152 func testFloat64x4Binary(t *testing.T, f func(_, _ archsimd.Float64x4) archsimd.Float64x4, want func(_, _ []float64) []float64) {
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([]float64, n)
160 f(a, b).Store(g)
161 w := want(x, y)
162 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
163 })
164 }
165
166
167 func testInt8x64Binary(t *testing.T, f func(_, _ archsimd.Int8x64) archsimd.Int8x64, want func(_, _ []int8) []int8) {
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).Store(g)
176 w := want(x, y)
177 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
178 })
179 }
180
181
182 func testInt16x32Binary(t *testing.T, f func(_, _ archsimd.Int16x32) archsimd.Int16x32, want func(_, _ []int16) []int16) {
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).Store(g)
191 w := want(x, y)
192 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
193 })
194 }
195
196
197 func testInt32x16Binary(t *testing.T, f func(_, _ archsimd.Int32x16) archsimd.Int32x16, want func(_, _ []int32) []int32) {
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).Store(g)
206 w := want(x, y)
207 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
208 })
209 }
210
211
212 func testInt64x8Binary(t *testing.T, f func(_, _ archsimd.Int64x8) archsimd.Int64x8, 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).Store(g)
221 w := want(x, y)
222 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
223 })
224 }
225
226
227 func testUint8x64Binary(t *testing.T, f func(_, _ archsimd.Uint8x64) archsimd.Uint8x64, want func(_, _ []uint8) []uint8) {
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([]uint8, n)
235 f(a, b).Store(g)
236 w := want(x, y)
237 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
238 })
239 }
240
241
242 func testUint16x32Binary(t *testing.T, f func(_, _ archsimd.Uint16x32) archsimd.Uint16x32, want func(_, _ []uint16) []uint16) {
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([]uint16, n)
250 f(a, b).Store(g)
251 w := want(x, y)
252 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
253 })
254 }
255
256
257 func testUint32x16Binary(t *testing.T, f func(_, _ archsimd.Uint32x16) archsimd.Uint32x16, want func(_, _ []uint32) []uint32) {
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([]uint32, n)
265 f(a, b).Store(g)
266 w := want(x, y)
267 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
268 })
269 }
270
271
272 func testUint64x8Binary(t *testing.T, f func(_, _ archsimd.Uint64x8) archsimd.Uint64x8, want func(_, _ []uint64) []uint64) {
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([]uint64, n)
280 f(a, b).Store(g)
281 w := want(x, y)
282 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
283 })
284 }
285
286
287 func testFloat32x16Binary(t *testing.T, f func(_, _ archsimd.Float32x16) archsimd.Float32x16, want func(_, _ []float32) []float32) {
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([]float32, n)
295 f(a, b).Store(g)
296 w := want(x, y)
297 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
298 })
299 }
300
301
302 func testFloat64x8Binary(t *testing.T, f func(_, _ archsimd.Float64x8) archsimd.Float64x8, want func(_, _ []float64) []float64) {
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([]float64, n)
310 f(a, b).Store(g)
311 w := want(x, y)
312 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) })
313 })
314 }
315
View as plain text