mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.simd] simd: add test wrappers
This CL adds test wrappers for unit tests, and change the existing Add/Sub test to be using wrappers. This CL is generated by CL 683455. Change-Id: Ibd388d82632ce56aad7a1ab5fff62db232819bb5 Reviewed-on: https://go-review.googlesource.com/c/go/+/683015 Auto-Submit: Junyang Shao <shaojunyang@google.com> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
e32488003d
commit
61c1183342
3 changed files with 6756 additions and 77 deletions
|
|
@ -96,22 +96,6 @@ func TestReflectMethod(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestAdd(t *testing.T) {
|
||||
xv := [4]int32{1, 2, 3, 4}
|
||||
yv := [4]int32{5, 6, 7, 8}
|
||||
want := []int32{6, 8, 10, 12}
|
||||
x := simd.LoadInt32x4(&xv)
|
||||
y := simd.LoadInt32x4(&yv)
|
||||
x = x.Add(y)
|
||||
got := [4]int32{}
|
||||
x.Store(&got)
|
||||
for i := range 4 {
|
||||
if want[i] != got[i] {
|
||||
t.Errorf("Result at %d incorrect: want %d, got %d", i, want[i], got[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestVectorConversion(t *testing.T) {
|
||||
if !simd.HasAVX512() {
|
||||
t.Skip("Test requires HasAVX512, not available on this hardware")
|
||||
|
|
@ -151,64 +135,20 @@ func TestMaskConversion(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestAdd(t *testing.T) {
|
||||
testInt32x4Binary(t, []int32{1, 2, 3, 4}, []int32{5, 6, 7, 8}, []int32{6, 8, 10, 12}, "Add")
|
||||
}
|
||||
|
||||
func TestSub(t *testing.T) {
|
||||
testInt32x4Binary(t, []int32{5, 5, 5, 3}, []int32{3, 3, 3, 3}, []int32{2, 2, 2, 0}, "Sub")
|
||||
}
|
||||
|
||||
func TestMaskedAdd(t *testing.T) {
|
||||
if !simd.HasAVX512() {
|
||||
t.Skip("Test requires HasAVX512, not available on this hardware")
|
||||
return
|
||||
}
|
||||
xv := [4]int32{1, 2, 3, 4}
|
||||
yv := [4]int32{5, 6, 7, 8}
|
||||
// masking elements 1 and 2.
|
||||
maskv := [4]int32{-1, -1, 0, 0}
|
||||
want := []int32{6, 8, 0, 0}
|
||||
x := simd.LoadInt32x4(&xv)
|
||||
y := simd.LoadInt32x4(&yv)
|
||||
mask := simd.LoadInt32x4(&maskv).AsMask32x4()
|
||||
x = x.MaskedAdd(y, mask)
|
||||
got := [4]int32{}
|
||||
x.Store(&got)
|
||||
for i := range 4 {
|
||||
if want[i] != got[i] {
|
||||
t.Errorf("Result at %d incorrect: want %d, got %d", i, want[i], got[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompare(t *testing.T) {
|
||||
xv := [4]int32{5, 1, 5, 3}
|
||||
yv := [4]int32{3, 3, 3, 3}
|
||||
want := []int32{8, 0, 8, 0}
|
||||
x := simd.LoadInt32x4(&xv)
|
||||
y := simd.LoadInt32x4(&yv)
|
||||
if !simd.HasAVX512() {
|
||||
t.Skip("Test requires HasAVX512, not available on this hardware")
|
||||
return
|
||||
}
|
||||
mask := x.Greater(y)
|
||||
x = x.MaskedAdd(y, mask)
|
||||
got := [4]int32{}
|
||||
x.Store(&got)
|
||||
for i := range 4 {
|
||||
if want[i] != got[i] {
|
||||
t.Errorf("Result at %d incorrect: want %d, got %d", i, want[i], got[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSub(t *testing.T) {
|
||||
xv := [4]int32{5, 5, 5, 3}
|
||||
yv := [4]int32{3, 3, 3, 3}
|
||||
want := []int32{2, 2, 2, 0}
|
||||
x := simd.LoadInt32x4(&xv)
|
||||
y := simd.LoadInt32x4(&yv)
|
||||
x = x.Sub(y)
|
||||
got := [4]int32{}
|
||||
x.Store(&got)
|
||||
for i := range 4 {
|
||||
if want[i] != got[i] {
|
||||
t.Errorf("Result at %d incorrect: want %d, got %d", i, want[i], got[i])
|
||||
}
|
||||
}
|
||||
testInt32x4BinaryMasked(t, []int32{1, 2, 3, 4}, []int32{5, 6, 7, 8}, []int32{-1, -1, 0, 0}, []int32{6, 8, 0, 0}, "MaskedAdd")
|
||||
}
|
||||
|
||||
// checkInt8Slices ensures that b and a are equal, to the end of b.
|
||||
|
|
|
|||
6739
src/simd/simd_wrapped_test.go
Normal file
6739
src/simd/simd_wrapped_test.go
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -7244,42 +7244,42 @@ func (x Uint32x16) SaturatedUnsignedSignedQuadDotProdAccumulate(y Uint8x64, z In
|
|||
|
||||
/* SetElem */
|
||||
|
||||
// SetElem sets a single constant-indexed element's value
|
||||
// SetElem sets a single constant-indexed element's value.
|
||||
//
|
||||
// Asm: VPINSRB, CPU Feature: AVX
|
||||
func (x Int8x16) SetElem(imm uint8, y int8) Int8x16
|
||||
|
||||
// SetElem sets a single constant-indexed element's value
|
||||
// SetElem sets a single constant-indexed element's value.
|
||||
//
|
||||
// Asm: VPINSRW, CPU Feature: AVX
|
||||
func (x Int16x8) SetElem(imm uint8, y int16) Int16x8
|
||||
|
||||
// SetElem sets a single constant-indexed element's value
|
||||
// SetElem sets a single constant-indexed element's value.
|
||||
//
|
||||
// Asm: VPINSRD, CPU Feature: AVX
|
||||
func (x Int32x4) SetElem(imm uint8, y int8) Int32x4
|
||||
|
||||
// SetElem sets a single constant-indexed element's value
|
||||
// SetElem sets a single constant-indexed element's value.
|
||||
//
|
||||
// Asm: VPINSRQ, CPU Feature: AVX
|
||||
func (x Int64x2) SetElem(imm uint8, y int64) Int64x2
|
||||
|
||||
// SetElem sets a single constant-indexed element's value
|
||||
// SetElem sets a single constant-indexed element's value.
|
||||
//
|
||||
// Asm: VPINSRB, CPU Feature: AVX
|
||||
func (x Uint8x16) SetElem(imm uint8, y uint8) Uint8x16
|
||||
|
||||
// SetElem sets a single constant-indexed element's value
|
||||
// SetElem sets a single constant-indexed element's value.
|
||||
//
|
||||
// Asm: VPINSRW, CPU Feature: AVX
|
||||
func (x Uint16x8) SetElem(imm uint8, y uint16) Uint16x8
|
||||
|
||||
// SetElem sets a single constant-indexed element's value
|
||||
// SetElem sets a single constant-indexed element's value.
|
||||
//
|
||||
// Asm: VPINSRD, CPU Feature: AVX
|
||||
func (x Uint32x4) SetElem(imm uint8, y uint8) Uint32x4
|
||||
|
||||
// SetElem sets a single constant-indexed element's value
|
||||
// SetElem sets a single constant-indexed element's value.
|
||||
//
|
||||
// Asm: VPINSRQ, CPU Feature: AVX
|
||||
func (x Uint64x2) SetElem(imm uint8, y uint64) Uint64x2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue