1
2
3
4
5
6
7 package simd_test
8
9 import (
10 "simd/archsimd"
11 "testing"
12 )
13
14 func TestLookupOrZero(t *testing.T) {
15
16 x := []uint8{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
17 indices := []uint8{7, 6, 5, 4, 3, 2, 1, 0, 0xff, 8, 16, 9, 128, 10, 20, 11}
18 want := []uint8{8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 0, 10, 0, 11, 0, 12}
19 got := make([]uint8, len(x))
20 archsimd.LoadUint8x16(x).LookupOrZero(archsimd.LoadUint8x16(indices)).Store(got)
21 checkSlices(t, got, want)
22 }
23
24 func TestClMul(t *testing.T) {
25 var x = archsimd.LoadUint64x2([]uint64{1, 5})
26 var y = archsimd.LoadUint64x2([]uint64{3, 9})
27
28 foo := func(v archsimd.Uint64x2, s []uint64) {
29 r := make([]uint64, 2, 2)
30 v.Store(r)
31 checkSlices[uint64](t, r, s)
32 }
33
34 foo(x.CarrylessMultiplyEven(y), []uint64{3, 0})
35 foo(x.CarrylessMultiplyEvenOdd(y), []uint64{9, 0})
36 foo(x.CarrylessMultiplyOddEven(y), []uint64{15, 0})
37 foo(x.CarrylessMultiplyOdd(y), []uint64{45, 0})
38 foo(y.CarrylessMultiplyEven(y), []uint64{5, 0})
39 }
40
View as plain text