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

     1  // Code generated by 'tmplgen'; DO NOT EDIT.
     2  
     3  //go:build goexperiment.simd && (amd64 || wasm || arm64)
     4  
     5  // This file contains functions testing shift 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  // testInt8x16ShiftAll tests a shift-all method (unary + scalar uint64).
    17  func testInt8x16ShiftAll(t *testing.T, f func(_ archsimd.Int8x16, _ uint64) archsimd.Int8x16, want func(_ []int8, _ uint64) []int8) {
    18  	n := 16
    19  	t.Helper()
    20  	forSlice(t, int8s, n, func(x []int8) bool {
    21  		t.Helper()
    22  		for _, amt := range testShiftAllAmts {
    23  			a := archsimd.LoadInt8x16(x)
    24  			g := make([]int8, n)
    25  			f(a, amt).Store(g)
    26  			w := want(x, amt)
    27  			if !checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v, amt=%d", x, amt) }) {
    28  				return false
    29  			}
    30  		}
    31  		return true
    32  	})
    33  }
    34  
    35  // testInt16x8ShiftAll tests a shift-all method (unary + scalar uint64).
    36  func testInt16x8ShiftAll(t *testing.T, f func(_ archsimd.Int16x8, _ uint64) archsimd.Int16x8, want func(_ []int16, _ uint64) []int16) {
    37  	n := 8
    38  	t.Helper()
    39  	forSlice(t, int16s, n, func(x []int16) bool {
    40  		t.Helper()
    41  		for _, amt := range testShiftAllAmts {
    42  			a := archsimd.LoadInt16x8(x)
    43  			g := make([]int16, n)
    44  			f(a, amt).Store(g)
    45  			w := want(x, amt)
    46  			if !checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v, amt=%d", x, amt) }) {
    47  				return false
    48  			}
    49  		}
    50  		return true
    51  	})
    52  }
    53  
    54  // testInt32x4ShiftAll tests a shift-all method (unary + scalar uint64).
    55  func testInt32x4ShiftAll(t *testing.T, f func(_ archsimd.Int32x4, _ uint64) archsimd.Int32x4, want func(_ []int32, _ uint64) []int32) {
    56  	n := 4
    57  	t.Helper()
    58  	forSlice(t, int32s, n, func(x []int32) bool {
    59  		t.Helper()
    60  		for _, amt := range testShiftAllAmts {
    61  			a := archsimd.LoadInt32x4(x)
    62  			g := make([]int32, n)
    63  			f(a, amt).Store(g)
    64  			w := want(x, amt)
    65  			if !checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v, amt=%d", x, amt) }) {
    66  				return false
    67  			}
    68  		}
    69  		return true
    70  	})
    71  }
    72  
    73  // testInt64x2ShiftAll tests a shift-all method (unary + scalar uint64).
    74  func testInt64x2ShiftAll(t *testing.T, f func(_ archsimd.Int64x2, _ uint64) archsimd.Int64x2, want func(_ []int64, _ uint64) []int64) {
    75  	n := 2
    76  	t.Helper()
    77  	forSlice(t, int64s, n, func(x []int64) bool {
    78  		t.Helper()
    79  		for _, amt := range testShiftAllAmts {
    80  			a := archsimd.LoadInt64x2(x)
    81  			g := make([]int64, n)
    82  			f(a, amt).Store(g)
    83  			w := want(x, amt)
    84  			if !checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v, amt=%d", x, amt) }) {
    85  				return false
    86  			}
    87  		}
    88  		return true
    89  	})
    90  }
    91  
    92  // testUint8x16ShiftAll tests a shift-all method (unary + scalar uint64).
    93  func testUint8x16ShiftAll(t *testing.T, f func(_ archsimd.Uint8x16, _ uint64) archsimd.Uint8x16, want func(_ []uint8, _ uint64) []uint8) {
    94  	n := 16
    95  	t.Helper()
    96  	forSlice(t, uint8s, n, func(x []uint8) bool {
    97  		t.Helper()
    98  		for _, amt := range testShiftAllAmts {
    99  			a := archsimd.LoadUint8x16(x)
   100  			g := make([]uint8, n)
   101  			f(a, amt).Store(g)
   102  			w := want(x, amt)
   103  			if !checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v, amt=%d", x, amt) }) {
   104  				return false
   105  			}
   106  		}
   107  		return true
   108  	})
   109  }
   110  
   111  // testUint16x8ShiftAll tests a shift-all method (unary + scalar uint64).
   112  func testUint16x8ShiftAll(t *testing.T, f func(_ archsimd.Uint16x8, _ uint64) archsimd.Uint16x8, want func(_ []uint16, _ uint64) []uint16) {
   113  	n := 8
   114  	t.Helper()
   115  	forSlice(t, uint16s, n, func(x []uint16) bool {
   116  		t.Helper()
   117  		for _, amt := range testShiftAllAmts {
   118  			a := archsimd.LoadUint16x8(x)
   119  			g := make([]uint16, n)
   120  			f(a, amt).Store(g)
   121  			w := want(x, amt)
   122  			if !checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v, amt=%d", x, amt) }) {
   123  				return false
   124  			}
   125  		}
   126  		return true
   127  	})
   128  }
   129  
   130  // testUint32x4ShiftAll tests a shift-all method (unary + scalar uint64).
   131  func testUint32x4ShiftAll(t *testing.T, f func(_ archsimd.Uint32x4, _ uint64) archsimd.Uint32x4, want func(_ []uint32, _ uint64) []uint32) {
   132  	n := 4
   133  	t.Helper()
   134  	forSlice(t, uint32s, n, func(x []uint32) bool {
   135  		t.Helper()
   136  		for _, amt := range testShiftAllAmts {
   137  			a := archsimd.LoadUint32x4(x)
   138  			g := make([]uint32, n)
   139  			f(a, amt).Store(g)
   140  			w := want(x, amt)
   141  			if !checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v, amt=%d", x, amt) }) {
   142  				return false
   143  			}
   144  		}
   145  		return true
   146  	})
   147  }
   148  
   149  // testUint64x2ShiftAll tests a shift-all method (unary + scalar uint64).
   150  func testUint64x2ShiftAll(t *testing.T, f func(_ archsimd.Uint64x2, _ uint64) archsimd.Uint64x2, want func(_ []uint64, _ uint64) []uint64) {
   151  	n := 2
   152  	t.Helper()
   153  	forSlice(t, uint64s, n, func(x []uint64) bool {
   154  		t.Helper()
   155  		for _, amt := range testShiftAllAmts {
   156  			a := archsimd.LoadUint64x2(x)
   157  			g := make([]uint64, n)
   158  			f(a, amt).Store(g)
   159  			w := want(x, amt)
   160  			if !checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v, amt=%d", x, amt) }) {
   161  				return false
   162  			}
   163  		}
   164  		return true
   165  	})
   166  }
   167  

View as plain text