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

     1  // Code generated by 'tmplgen'; DO NOT EDIT.
     2  
     3  //go:build goexperiment.simd && (amd64 || wasm)
     4  
     5  // This file contains functions testing unary simd methods.
     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  // testInt8x16Unary tests the simd unary method f against the expected behavior generated by want
    17  func testInt8x16Unary(t *testing.T, f func(_ archsimd.Int8x16) archsimd.Int8x16, want func(_ []int8) []int8) {
    18  	n := 16
    19  	t.Helper()
    20  	forSlice(t, int8s, n, func(x []int8) bool {
    21  		t.Helper()
    22  		a := archsimd.LoadInt8x16(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  // testInt16x8Unary tests the simd unary method f against the expected behavior generated by want
    31  func testInt16x8Unary(t *testing.T, f func(_ archsimd.Int16x8) archsimd.Int16x8, want func(_ []int16) []int16) {
    32  	n := 8
    33  	t.Helper()
    34  	forSlice(t, int16s, n, func(x []int16) bool {
    35  		t.Helper()
    36  		a := archsimd.LoadInt16x8(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  // testInt32x4Unary tests the simd unary method f against the expected behavior generated by want
    45  func testInt32x4Unary(t *testing.T, f func(_ archsimd.Int32x4) archsimd.Int32x4, want func(_ []int32) []int32) {
    46  	n := 4
    47  	t.Helper()
    48  	forSlice(t, int32s, n, func(x []int32) bool {
    49  		t.Helper()
    50  		a := archsimd.LoadInt32x4(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  // testInt64x2Unary tests the simd unary method f against the expected behavior generated by want
    59  func testInt64x2Unary(t *testing.T, f func(_ archsimd.Int64x2) archsimd.Int64x2, want func(_ []int64) []int64) {
    60  	n := 2
    61  	t.Helper()
    62  	forSlice(t, int64s, n, func(x []int64) bool {
    63  		t.Helper()
    64  		a := archsimd.LoadInt64x2(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  // testUint8x16Unary tests the simd unary method f against the expected behavior generated by want
    73  func testUint8x16Unary(t *testing.T, f func(_ archsimd.Uint8x16) archsimd.Uint8x16, want func(_ []uint8) []uint8) {
    74  	n := 16
    75  	t.Helper()
    76  	forSlice(t, uint8s, n, func(x []uint8) bool {
    77  		t.Helper()
    78  		a := archsimd.LoadUint8x16(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  // testUint16x8Unary tests the simd unary method f against the expected behavior generated by want
    87  func testUint16x8Unary(t *testing.T, f func(_ archsimd.Uint16x8) archsimd.Uint16x8, want func(_ []uint16) []uint16) {
    88  	n := 8
    89  	t.Helper()
    90  	forSlice(t, uint16s, n, func(x []uint16) bool {
    91  		t.Helper()
    92  		a := archsimd.LoadUint16x8(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  // testUint32x4Unary tests the simd unary method f against the expected behavior generated by want
   101  func testUint32x4Unary(t *testing.T, f func(_ archsimd.Uint32x4) archsimd.Uint32x4, want func(_ []uint32) []uint32) {
   102  	n := 4
   103  	t.Helper()
   104  	forSlice(t, uint32s, n, func(x []uint32) bool {
   105  		t.Helper()
   106  		a := archsimd.LoadUint32x4(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  // testUint64x2Unary tests the simd unary method f against the expected behavior generated by want
   115  func testUint64x2Unary(t *testing.T, f func(_ archsimd.Uint64x2) archsimd.Uint64x2, want func(_ []uint64) []uint64) {
   116  	n := 2
   117  	t.Helper()
   118  	forSlice(t, uint64s, n, func(x []uint64) bool {
   119  		t.Helper()
   120  		a := archsimd.LoadUint64x2(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  // testFloat32x4Unary tests the simd unary method f against the expected behavior generated by want
   129  func testFloat32x4Unary(t *testing.T, f func(_ archsimd.Float32x4) archsimd.Float32x4, want func(_ []float32) []float32) {
   130  	n := 4
   131  	t.Helper()
   132  	forSlice(t, float32s, n, func(x []float32) bool {
   133  		t.Helper()
   134  		a := archsimd.LoadFloat32x4(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  // testFloat64x2Unary tests the simd unary method f against the expected behavior generated by want
   143  func testFloat64x2Unary(t *testing.T, f func(_ archsimd.Float64x2) archsimd.Float64x2, want func(_ []float64) []float64) {
   144  	n := 2
   145  	t.Helper()
   146  	forSlice(t, float64s, n, func(x []float64) bool {
   147  		t.Helper()
   148  		a := archsimd.LoadFloat64x2(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  

View as plain text