Source file src/simd/archsimd/internal/simd_test/arm64_compare_helpers_test.go

     1  // Code generated by 'tmplgen'; DO NOT EDIT.
     2  
     3  //go:build goexperiment.simd && arm64
     4  
     5  // This file contains functions testing simd methods that compare two operands.
     6  // Each function in this file is specialized for a
     7  // particular simd type <BaseType><Width>x<Count>.
     8  
     9  package simd_test
    10  
    11  import (
    12  	"simd/archsimd"
    13  	"testing"
    14  )
    15  
    16  // testInt8x16Compare tests the simd comparison method f against the expected behavior generated by want
    17  func testInt8x16Compare(t *testing.T, f func(_, _ archsimd.Int8x16) archsimd.Mask8x16, want func(_, _ []int8) []int64) {
    18  	n := 16
    19  	t.Helper()
    20  	forSlicePair(t, int8s, n, func(x, y []int8) bool {
    21  		t.Helper()
    22  		a := archsimd.LoadInt8x16(x)
    23  		b := archsimd.LoadInt8x16(y)
    24  		g := make([]int8, n)
    25  		f(a, b).ToInt8x16().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  // testInt16x8Compare tests the simd comparison method f against the expected behavior generated by want
    32  func testInt16x8Compare(t *testing.T, f func(_, _ archsimd.Int16x8) archsimd.Mask16x8, want func(_, _ []int16) []int64) {
    33  	n := 8
    34  	t.Helper()
    35  	forSlicePair(t, int16s, n, func(x, y []int16) bool {
    36  		t.Helper()
    37  		a := archsimd.LoadInt16x8(x)
    38  		b := archsimd.LoadInt16x8(y)
    39  		g := make([]int16, n)
    40  		f(a, b).ToInt16x8().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  // testInt32x4Compare tests the simd comparison method f against the expected behavior generated by want
    47  func testInt32x4Compare(t *testing.T, f func(_, _ archsimd.Int32x4) archsimd.Mask32x4, want func(_, _ []int32) []int64) {
    48  	n := 4
    49  	t.Helper()
    50  	forSlicePair(t, int32s, n, func(x, y []int32) bool {
    51  		t.Helper()
    52  		a := archsimd.LoadInt32x4(x)
    53  		b := archsimd.LoadInt32x4(y)
    54  		g := make([]int32, n)
    55  		f(a, b).ToInt32x4().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  // testInt64x2Compare tests the simd comparison method f against the expected behavior generated by want
    62  func testInt64x2Compare(t *testing.T, f func(_, _ archsimd.Int64x2) archsimd.Mask64x2, want func(_, _ []int64) []int64) {
    63  	n := 2
    64  	t.Helper()
    65  	forSlicePair(t, int64s, n, func(x, y []int64) bool {
    66  		t.Helper()
    67  		a := archsimd.LoadInt64x2(x)
    68  		b := archsimd.LoadInt64x2(y)
    69  		g := make([]int64, n)
    70  		f(a, b).ToInt64x2().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  // testUint8x16Compare tests the simd comparison method f against the expected behavior generated by want
    77  func testUint8x16Compare(t *testing.T, f func(_, _ archsimd.Uint8x16) archsimd.Mask8x16, want func(_, _ []uint8) []int64) {
    78  	n := 16
    79  	t.Helper()
    80  	forSlicePair(t, uint8s, n, func(x, y []uint8) bool {
    81  		t.Helper()
    82  		a := archsimd.LoadUint8x16(x)
    83  		b := archsimd.LoadUint8x16(y)
    84  		g := make([]int8, n)
    85  		f(a, b).ToInt8x16().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  // testUint16x8Compare tests the simd comparison method f against the expected behavior generated by want
    92  func testUint16x8Compare(t *testing.T, f func(_, _ archsimd.Uint16x8) archsimd.Mask16x8, want func(_, _ []uint16) []int64) {
    93  	n := 8
    94  	t.Helper()
    95  	forSlicePair(t, uint16s, n, func(x, y []uint16) bool {
    96  		t.Helper()
    97  		a := archsimd.LoadUint16x8(x)
    98  		b := archsimd.LoadUint16x8(y)
    99  		g := make([]int16, n)
   100  		f(a, b).ToInt16x8().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  // testUint32x4Compare tests the simd comparison method f against the expected behavior generated by want
   107  func testUint32x4Compare(t *testing.T, f func(_, _ archsimd.Uint32x4) archsimd.Mask32x4, want func(_, _ []uint32) []int64) {
   108  	n := 4
   109  	t.Helper()
   110  	forSlicePair(t, uint32s, n, func(x, y []uint32) bool {
   111  		t.Helper()
   112  		a := archsimd.LoadUint32x4(x)
   113  		b := archsimd.LoadUint32x4(y)
   114  		g := make([]int32, n)
   115  		f(a, b).ToInt32x4().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  // testUint64x2Compare tests the simd comparison method f against the expected behavior generated by want
   122  func testUint64x2Compare(t *testing.T, f func(_, _ archsimd.Uint64x2) archsimd.Mask64x2, want func(_, _ []uint64) []int64) {
   123  	n := 2
   124  	t.Helper()
   125  	forSlicePair(t, uint64s, n, func(x, y []uint64) bool {
   126  		t.Helper()
   127  		a := archsimd.LoadUint64x2(x)
   128  		b := archsimd.LoadUint64x2(y)
   129  		g := make([]int64, n)
   130  		f(a, b).ToInt64x2().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  // testFloat32x4Compare tests the simd comparison method f against the expected behavior generated by want
   137  func testFloat32x4Compare(t *testing.T, f func(_, _ archsimd.Float32x4) archsimd.Mask32x4, want func(_, _ []float32) []int64) {
   138  	n := 4
   139  	t.Helper()
   140  	forSlicePair(t, float32s, n, func(x, y []float32) bool {
   141  		t.Helper()
   142  		a := archsimd.LoadFloat32x4(x)
   143  		b := archsimd.LoadFloat32x4(y)
   144  		g := make([]int32, n)
   145  		f(a, b).ToInt32x4().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  // testFloat64x2Compare tests the simd comparison method f against the expected behavior generated by want
   152  func testFloat64x2Compare(t *testing.T, f func(_, _ archsimd.Float64x2) archsimd.Mask64x2, want func(_, _ []float64) []int64) {
   153  	n := 2
   154  	t.Helper()
   155  	forSlicePair(t, float64s, n, func(x, y []float64) bool {
   156  		t.Helper()
   157  		a := archsimd.LoadFloat64x2(x)
   158  		b := archsimd.LoadFloat64x2(y)
   159  		g := make([]int64, n)
   160  		f(a, b).ToInt64x2().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  

View as plain text