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 testInt8x32Unary(t *testing.T, f func(_ archsimd.Int8x32) archsimd.Int8x32, want func(_ []int8) []int8) {
18 n := 32
19 t.Helper()
20 forSlice(t, int8s, n, func(x []int8) bool {
21 t.Helper()
22 a := archsimd.LoadInt8x32(x)
23 g := make([]int8, n)
24 f(a).Store(g)
25 w := want(x)
26 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
27 })
28 }
29
30
31 func testInt16x16Unary(t *testing.T, f func(_ archsimd.Int16x16) archsimd.Int16x16, want func(_ []int16) []int16) {
32 n := 16
33 t.Helper()
34 forSlice(t, int16s, n, func(x []int16) bool {
35 t.Helper()
36 a := archsimd.LoadInt16x16(x)
37 g := make([]int16, n)
38 f(a).Store(g)
39 w := want(x)
40 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
41 })
42 }
43
44
45 func testInt32x8Unary(t *testing.T, f func(_ archsimd.Int32x8) archsimd.Int32x8, want func(_ []int32) []int32) {
46 n := 8
47 t.Helper()
48 forSlice(t, int32s, n, func(x []int32) bool {
49 t.Helper()
50 a := archsimd.LoadInt32x8(x)
51 g := make([]int32, n)
52 f(a).Store(g)
53 w := want(x)
54 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
55 })
56 }
57
58
59 func testInt64x4Unary(t *testing.T, f func(_ archsimd.Int64x4) archsimd.Int64x4, want func(_ []int64) []int64) {
60 n := 4
61 t.Helper()
62 forSlice(t, int64s, n, func(x []int64) bool {
63 t.Helper()
64 a := archsimd.LoadInt64x4(x)
65 g := make([]int64, n)
66 f(a).Store(g)
67 w := want(x)
68 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
69 })
70 }
71
72
73 func testUint8x32Unary(t *testing.T, f func(_ archsimd.Uint8x32) archsimd.Uint8x32, want func(_ []uint8) []uint8) {
74 n := 32
75 t.Helper()
76 forSlice(t, uint8s, n, func(x []uint8) bool {
77 t.Helper()
78 a := archsimd.LoadUint8x32(x)
79 g := make([]uint8, n)
80 f(a).Store(g)
81 w := want(x)
82 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
83 })
84 }
85
86
87 func testUint16x16Unary(t *testing.T, f func(_ archsimd.Uint16x16) archsimd.Uint16x16, want func(_ []uint16) []uint16) {
88 n := 16
89 t.Helper()
90 forSlice(t, uint16s, n, func(x []uint16) bool {
91 t.Helper()
92 a := archsimd.LoadUint16x16(x)
93 g := make([]uint16, n)
94 f(a).Store(g)
95 w := want(x)
96 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
97 })
98 }
99
100
101 func testUint32x8Unary(t *testing.T, f func(_ archsimd.Uint32x8) archsimd.Uint32x8, want func(_ []uint32) []uint32) {
102 n := 8
103 t.Helper()
104 forSlice(t, uint32s, n, func(x []uint32) bool {
105 t.Helper()
106 a := archsimd.LoadUint32x8(x)
107 g := make([]uint32, n)
108 f(a).Store(g)
109 w := want(x)
110 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
111 })
112 }
113
114
115 func testUint64x4Unary(t *testing.T, f func(_ archsimd.Uint64x4) archsimd.Uint64x4, want func(_ []uint64) []uint64) {
116 n := 4
117 t.Helper()
118 forSlice(t, uint64s, n, func(x []uint64) bool {
119 t.Helper()
120 a := archsimd.LoadUint64x4(x)
121 g := make([]uint64, n)
122 f(a).Store(g)
123 w := want(x)
124 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
125 })
126 }
127
128
129 func testFloat32x8Unary(t *testing.T, f func(_ archsimd.Float32x8) archsimd.Float32x8, want func(_ []float32) []float32) {
130 n := 8
131 t.Helper()
132 forSlice(t, float32s, n, func(x []float32) bool {
133 t.Helper()
134 a := archsimd.LoadFloat32x8(x)
135 g := make([]float32, n)
136 f(a).Store(g)
137 w := want(x)
138 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
139 })
140 }
141
142
143 func testFloat64x4Unary(t *testing.T, f func(_ archsimd.Float64x4) archsimd.Float64x4, want func(_ []float64) []float64) {
144 n := 4
145 t.Helper()
146 forSlice(t, float64s, n, func(x []float64) bool {
147 t.Helper()
148 a := archsimd.LoadFloat64x4(x)
149 g := make([]float64, n)
150 f(a).Store(g)
151 w := want(x)
152 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
153 })
154 }
155
156
157 func testInt8x64Unary(t *testing.T, f func(_ archsimd.Int8x64) archsimd.Int8x64, want func(_ []int8) []int8) {
158 n := 64
159 t.Helper()
160 forSlice(t, int8s, n, func(x []int8) bool {
161 t.Helper()
162 a := archsimd.LoadInt8x64(x)
163 g := make([]int8, n)
164 f(a).Store(g)
165 w := want(x)
166 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
167 })
168 }
169
170
171 func testInt16x32Unary(t *testing.T, f func(_ archsimd.Int16x32) archsimd.Int16x32, want func(_ []int16) []int16) {
172 n := 32
173 t.Helper()
174 forSlice(t, int16s, n, func(x []int16) bool {
175 t.Helper()
176 a := archsimd.LoadInt16x32(x)
177 g := make([]int16, n)
178 f(a).Store(g)
179 w := want(x)
180 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
181 })
182 }
183
184
185 func testInt32x16Unary(t *testing.T, f func(_ archsimd.Int32x16) archsimd.Int32x16, want func(_ []int32) []int32) {
186 n := 16
187 t.Helper()
188 forSlice(t, int32s, n, func(x []int32) bool {
189 t.Helper()
190 a := archsimd.LoadInt32x16(x)
191 g := make([]int32, n)
192 f(a).Store(g)
193 w := want(x)
194 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
195 })
196 }
197
198
199 func testInt64x8Unary(t *testing.T, f func(_ archsimd.Int64x8) archsimd.Int64x8, want func(_ []int64) []int64) {
200 n := 8
201 t.Helper()
202 forSlice(t, int64s, n, func(x []int64) bool {
203 t.Helper()
204 a := archsimd.LoadInt64x8(x)
205 g := make([]int64, n)
206 f(a).Store(g)
207 w := want(x)
208 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
209 })
210 }
211
212
213 func testUint8x64Unary(t *testing.T, f func(_ archsimd.Uint8x64) archsimd.Uint8x64, want func(_ []uint8) []uint8) {
214 n := 64
215 t.Helper()
216 forSlice(t, uint8s, n, func(x []uint8) bool {
217 t.Helper()
218 a := archsimd.LoadUint8x64(x)
219 g := make([]uint8, n)
220 f(a).Store(g)
221 w := want(x)
222 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
223 })
224 }
225
226
227 func testUint16x32Unary(t *testing.T, f func(_ archsimd.Uint16x32) archsimd.Uint16x32, want func(_ []uint16) []uint16) {
228 n := 32
229 t.Helper()
230 forSlice(t, uint16s, n, func(x []uint16) bool {
231 t.Helper()
232 a := archsimd.LoadUint16x32(x)
233 g := make([]uint16, n)
234 f(a).Store(g)
235 w := want(x)
236 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
237 })
238 }
239
240
241 func testUint32x16Unary(t *testing.T, f func(_ archsimd.Uint32x16) archsimd.Uint32x16, want func(_ []uint32) []uint32) {
242 n := 16
243 t.Helper()
244 forSlice(t, uint32s, n, func(x []uint32) bool {
245 t.Helper()
246 a := archsimd.LoadUint32x16(x)
247 g := make([]uint32, n)
248 f(a).Store(g)
249 w := want(x)
250 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
251 })
252 }
253
254
255 func testUint64x8Unary(t *testing.T, f func(_ archsimd.Uint64x8) archsimd.Uint64x8, want func(_ []uint64) []uint64) {
256 n := 8
257 t.Helper()
258 forSlice(t, uint64s, n, func(x []uint64) bool {
259 t.Helper()
260 a := archsimd.LoadUint64x8(x)
261 g := make([]uint64, n)
262 f(a).Store(g)
263 w := want(x)
264 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
265 })
266 }
267
268
269 func testFloat32x16Unary(t *testing.T, f func(_ archsimd.Float32x16) archsimd.Float32x16, want func(_ []float32) []float32) {
270 n := 16
271 t.Helper()
272 forSlice(t, float32s, n, func(x []float32) bool {
273 t.Helper()
274 a := archsimd.LoadFloat32x16(x)
275 g := make([]float32, n)
276 f(a).Store(g)
277 w := want(x)
278 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
279 })
280 }
281
282
283 func testFloat64x8Unary(t *testing.T, f func(_ archsimd.Float64x8) archsimd.Float64x8, want func(_ []float64) []float64) {
284 n := 8
285 t.Helper()
286 forSlice(t, float64s, n, func(x []float64) bool {
287 t.Helper()
288 a := archsimd.LoadFloat64x8(x)
289 g := make([]float64, n)
290 f(a).Store(g)
291 w := want(x)
292 return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) })
293 })
294 }
295
View as plain text