Source file src/simd/archsimd/internal/simd_test/ternary_arm64_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 ternary 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  // testInt8x16Ternary tests the simd ternary method f against the expected behavior generated by want
    17  func testInt8x16Ternary(t *testing.T, f func(_, _, _ archsimd.Int8x16) archsimd.Int8x16, want func(_, _, _ []int8) []int8) {
    18  	n := 16
    19  	t.Helper()
    20  	forSliceTriple(t, int8s, n, func(x, y, z []int8) bool {
    21  		t.Helper()
    22  		a := archsimd.LoadInt8x16(x)
    23  		b := archsimd.LoadInt8x16(y)
    24  		c := archsimd.LoadInt8x16(z)
    25  		g := make([]int8, n)
    26  		f(a, b, c).Store(g)
    27  		w := want(x, y, z)
    28  		return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
    29  	})
    30  }
    31  
    32  // testInt16x8Ternary tests the simd ternary method f against the expected behavior generated by want
    33  func testInt16x8Ternary(t *testing.T, f func(_, _, _ archsimd.Int16x8) archsimd.Int16x8, want func(_, _, _ []int16) []int16) {
    34  	n := 8
    35  	t.Helper()
    36  	forSliceTriple(t, int16s, n, func(x, y, z []int16) bool {
    37  		t.Helper()
    38  		a := archsimd.LoadInt16x8(x)
    39  		b := archsimd.LoadInt16x8(y)
    40  		c := archsimd.LoadInt16x8(z)
    41  		g := make([]int16, n)
    42  		f(a, b, c).Store(g)
    43  		w := want(x, y, z)
    44  		return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
    45  	})
    46  }
    47  
    48  // testInt32x4Ternary tests the simd ternary method f against the expected behavior generated by want
    49  func testInt32x4Ternary(t *testing.T, f func(_, _, _ archsimd.Int32x4) archsimd.Int32x4, want func(_, _, _ []int32) []int32) {
    50  	n := 4
    51  	t.Helper()
    52  	forSliceTriple(t, int32s, n, func(x, y, z []int32) bool {
    53  		t.Helper()
    54  		a := archsimd.LoadInt32x4(x)
    55  		b := archsimd.LoadInt32x4(y)
    56  		c := archsimd.LoadInt32x4(z)
    57  		g := make([]int32, n)
    58  		f(a, b, c).Store(g)
    59  		w := want(x, y, z)
    60  		return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
    61  	})
    62  }
    63  
    64  // testInt64x2Ternary tests the simd ternary method f against the expected behavior generated by want
    65  func testInt64x2Ternary(t *testing.T, f func(_, _, _ archsimd.Int64x2) archsimd.Int64x2, want func(_, _, _ []int64) []int64) {
    66  	n := 2
    67  	t.Helper()
    68  	forSliceTriple(t, int64s, n, func(x, y, z []int64) bool {
    69  		t.Helper()
    70  		a := archsimd.LoadInt64x2(x)
    71  		b := archsimd.LoadInt64x2(y)
    72  		c := archsimd.LoadInt64x2(z)
    73  		g := make([]int64, n)
    74  		f(a, b, c).Store(g)
    75  		w := want(x, y, z)
    76  		return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
    77  	})
    78  }
    79  
    80  // testUint8x16Ternary tests the simd ternary method f against the expected behavior generated by want
    81  func testUint8x16Ternary(t *testing.T, f func(_, _, _ archsimd.Uint8x16) archsimd.Uint8x16, want func(_, _, _ []uint8) []uint8) {
    82  	n := 16
    83  	t.Helper()
    84  	forSliceTriple(t, uint8s, n, func(x, y, z []uint8) bool {
    85  		t.Helper()
    86  		a := archsimd.LoadUint8x16(x)
    87  		b := archsimd.LoadUint8x16(y)
    88  		c := archsimd.LoadUint8x16(z)
    89  		g := make([]uint8, n)
    90  		f(a, b, c).Store(g)
    91  		w := want(x, y, z)
    92  		return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
    93  	})
    94  }
    95  
    96  // testUint16x8Ternary tests the simd ternary method f against the expected behavior generated by want
    97  func testUint16x8Ternary(t *testing.T, f func(_, _, _ archsimd.Uint16x8) archsimd.Uint16x8, want func(_, _, _ []uint16) []uint16) {
    98  	n := 8
    99  	t.Helper()
   100  	forSliceTriple(t, uint16s, n, func(x, y, z []uint16) bool {
   101  		t.Helper()
   102  		a := archsimd.LoadUint16x8(x)
   103  		b := archsimd.LoadUint16x8(y)
   104  		c := archsimd.LoadUint16x8(z)
   105  		g := make([]uint16, n)
   106  		f(a, b, c).Store(g)
   107  		w := want(x, y, z)
   108  		return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
   109  	})
   110  }
   111  
   112  // testUint32x4Ternary tests the simd ternary method f against the expected behavior generated by want
   113  func testUint32x4Ternary(t *testing.T, f func(_, _, _ archsimd.Uint32x4) archsimd.Uint32x4, want func(_, _, _ []uint32) []uint32) {
   114  	n := 4
   115  	t.Helper()
   116  	forSliceTriple(t, uint32s, n, func(x, y, z []uint32) bool {
   117  		t.Helper()
   118  		a := archsimd.LoadUint32x4(x)
   119  		b := archsimd.LoadUint32x4(y)
   120  		c := archsimd.LoadUint32x4(z)
   121  		g := make([]uint32, n)
   122  		f(a, b, c).Store(g)
   123  		w := want(x, y, z)
   124  		return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
   125  	})
   126  }
   127  
   128  // testUint64x2Ternary tests the simd ternary method f against the expected behavior generated by want
   129  func testUint64x2Ternary(t *testing.T, f func(_, _, _ archsimd.Uint64x2) archsimd.Uint64x2, want func(_, _, _ []uint64) []uint64) {
   130  	n := 2
   131  	t.Helper()
   132  	forSliceTriple(t, uint64s, n, func(x, y, z []uint64) bool {
   133  		t.Helper()
   134  		a := archsimd.LoadUint64x2(x)
   135  		b := archsimd.LoadUint64x2(y)
   136  		c := archsimd.LoadUint64x2(z)
   137  		g := make([]uint64, n)
   138  		f(a, b, c).Store(g)
   139  		w := want(x, y, z)
   140  		return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
   141  	})
   142  }
   143  
   144  // testFloat32x4Ternary tests the simd ternary method f against the expected behavior generated by want
   145  func testFloat32x4Ternary(t *testing.T, f func(_, _, _ archsimd.Float32x4) archsimd.Float32x4, want func(_, _, _ []float32) []float32) {
   146  	n := 4
   147  	t.Helper()
   148  	forSliceTriple(t, float32s, n, func(x, y, z []float32) bool {
   149  		t.Helper()
   150  		a := archsimd.LoadFloat32x4(x)
   151  		b := archsimd.LoadFloat32x4(y)
   152  		c := archsimd.LoadFloat32x4(z)
   153  		g := make([]float32, n)
   154  		f(a, b, c).Store(g)
   155  		w := want(x, y, z)
   156  		return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
   157  	})
   158  }
   159  
   160  // testFloat64x2Ternary tests the simd ternary method f against the expected behavior generated by want
   161  func testFloat64x2Ternary(t *testing.T, f func(_, _, _ archsimd.Float64x2) archsimd.Float64x2, want func(_, _, _ []float64) []float64) {
   162  	n := 2
   163  	t.Helper()
   164  	forSliceTriple(t, float64s, n, func(x, y, z []float64) bool {
   165  		t.Helper()
   166  		a := archsimd.LoadFloat64x2(x)
   167  		b := archsimd.LoadFloat64x2(y)
   168  		c := archsimd.LoadFloat64x2(z)
   169  		g := make([]float64, n)
   170  		f(a, b, c).Store(g)
   171  		w := want(x, y, z)
   172  		return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
   173  	})
   174  }
   175  
   176  // testInt8x16TernaryFlaky tests the simd ternary method f against the expected behavior generated by want,
   177  // but using a flakiness parameter because we haven't exactly figured out how simd floating point works
   178  func testInt8x16TernaryFlaky(t *testing.T, f func(x, y, z archsimd.Int8x16) archsimd.Int8x16, want func(x, y, z []int8) []int8, flakiness float64) {
   179  	n := 16
   180  	t.Helper()
   181  	forSliceTriple(t, int8s, n, func(x, y, z []int8) bool {
   182  		t.Helper()
   183  		a := archsimd.LoadInt8x16(x)
   184  		b := archsimd.LoadInt8x16(y)
   185  		c := archsimd.LoadInt8x16(z)
   186  		g := make([]int8, n)
   187  		f(a, b, c).Store(g)
   188  		w := want(x, y, z)
   189  		return checkSlicesLogInput(t, g, w, flakiness, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
   190  	})
   191  }
   192  
   193  // testInt16x8TernaryFlaky tests the simd ternary method f against the expected behavior generated by want,
   194  // but using a flakiness parameter because we haven't exactly figured out how simd floating point works
   195  func testInt16x8TernaryFlaky(t *testing.T, f func(x, y, z archsimd.Int16x8) archsimd.Int16x8, want func(x, y, z []int16) []int16, flakiness float64) {
   196  	n := 8
   197  	t.Helper()
   198  	forSliceTriple(t, int16s, n, func(x, y, z []int16) bool {
   199  		t.Helper()
   200  		a := archsimd.LoadInt16x8(x)
   201  		b := archsimd.LoadInt16x8(y)
   202  		c := archsimd.LoadInt16x8(z)
   203  		g := make([]int16, n)
   204  		f(a, b, c).Store(g)
   205  		w := want(x, y, z)
   206  		return checkSlicesLogInput(t, g, w, flakiness, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
   207  	})
   208  }
   209  
   210  // testInt32x4TernaryFlaky tests the simd ternary method f against the expected behavior generated by want,
   211  // but using a flakiness parameter because we haven't exactly figured out how simd floating point works
   212  func testInt32x4TernaryFlaky(t *testing.T, f func(x, y, z archsimd.Int32x4) archsimd.Int32x4, want func(x, y, z []int32) []int32, flakiness float64) {
   213  	n := 4
   214  	t.Helper()
   215  	forSliceTriple(t, int32s, n, func(x, y, z []int32) bool {
   216  		t.Helper()
   217  		a := archsimd.LoadInt32x4(x)
   218  		b := archsimd.LoadInt32x4(y)
   219  		c := archsimd.LoadInt32x4(z)
   220  		g := make([]int32, n)
   221  		f(a, b, c).Store(g)
   222  		w := want(x, y, z)
   223  		return checkSlicesLogInput(t, g, w, flakiness, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
   224  	})
   225  }
   226  
   227  // testInt64x2TernaryFlaky tests the simd ternary method f against the expected behavior generated by want,
   228  // but using a flakiness parameter because we haven't exactly figured out how simd floating point works
   229  func testInt64x2TernaryFlaky(t *testing.T, f func(x, y, z archsimd.Int64x2) archsimd.Int64x2, want func(x, y, z []int64) []int64, flakiness float64) {
   230  	n := 2
   231  	t.Helper()
   232  	forSliceTriple(t, int64s, n, func(x, y, z []int64) bool {
   233  		t.Helper()
   234  		a := archsimd.LoadInt64x2(x)
   235  		b := archsimd.LoadInt64x2(y)
   236  		c := archsimd.LoadInt64x2(z)
   237  		g := make([]int64, n)
   238  		f(a, b, c).Store(g)
   239  		w := want(x, y, z)
   240  		return checkSlicesLogInput(t, g, w, flakiness, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
   241  	})
   242  }
   243  
   244  // testUint8x16TernaryFlaky tests the simd ternary method f against the expected behavior generated by want,
   245  // but using a flakiness parameter because we haven't exactly figured out how simd floating point works
   246  func testUint8x16TernaryFlaky(t *testing.T, f func(x, y, z archsimd.Uint8x16) archsimd.Uint8x16, want func(x, y, z []uint8) []uint8, flakiness float64) {
   247  	n := 16
   248  	t.Helper()
   249  	forSliceTriple(t, uint8s, n, func(x, y, z []uint8) bool {
   250  		t.Helper()
   251  		a := archsimd.LoadUint8x16(x)
   252  		b := archsimd.LoadUint8x16(y)
   253  		c := archsimd.LoadUint8x16(z)
   254  		g := make([]uint8, n)
   255  		f(a, b, c).Store(g)
   256  		w := want(x, y, z)
   257  		return checkSlicesLogInput(t, g, w, flakiness, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
   258  	})
   259  }
   260  
   261  // testUint16x8TernaryFlaky tests the simd ternary method f against the expected behavior generated by want,
   262  // but using a flakiness parameter because we haven't exactly figured out how simd floating point works
   263  func testUint16x8TernaryFlaky(t *testing.T, f func(x, y, z archsimd.Uint16x8) archsimd.Uint16x8, want func(x, y, z []uint16) []uint16, flakiness float64) {
   264  	n := 8
   265  	t.Helper()
   266  	forSliceTriple(t, uint16s, n, func(x, y, z []uint16) bool {
   267  		t.Helper()
   268  		a := archsimd.LoadUint16x8(x)
   269  		b := archsimd.LoadUint16x8(y)
   270  		c := archsimd.LoadUint16x8(z)
   271  		g := make([]uint16, n)
   272  		f(a, b, c).Store(g)
   273  		w := want(x, y, z)
   274  		return checkSlicesLogInput(t, g, w, flakiness, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
   275  	})
   276  }
   277  
   278  // testUint32x4TernaryFlaky tests the simd ternary method f against the expected behavior generated by want,
   279  // but using a flakiness parameter because we haven't exactly figured out how simd floating point works
   280  func testUint32x4TernaryFlaky(t *testing.T, f func(x, y, z archsimd.Uint32x4) archsimd.Uint32x4, want func(x, y, z []uint32) []uint32, flakiness float64) {
   281  	n := 4
   282  	t.Helper()
   283  	forSliceTriple(t, uint32s, n, func(x, y, z []uint32) bool {
   284  		t.Helper()
   285  		a := archsimd.LoadUint32x4(x)
   286  		b := archsimd.LoadUint32x4(y)
   287  		c := archsimd.LoadUint32x4(z)
   288  		g := make([]uint32, n)
   289  		f(a, b, c).Store(g)
   290  		w := want(x, y, z)
   291  		return checkSlicesLogInput(t, g, w, flakiness, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
   292  	})
   293  }
   294  
   295  // testUint64x2TernaryFlaky tests the simd ternary method f against the expected behavior generated by want,
   296  // but using a flakiness parameter because we haven't exactly figured out how simd floating point works
   297  func testUint64x2TernaryFlaky(t *testing.T, f func(x, y, z archsimd.Uint64x2) archsimd.Uint64x2, want func(x, y, z []uint64) []uint64, flakiness float64) {
   298  	n := 2
   299  	t.Helper()
   300  	forSliceTriple(t, uint64s, n, func(x, y, z []uint64) bool {
   301  		t.Helper()
   302  		a := archsimd.LoadUint64x2(x)
   303  		b := archsimd.LoadUint64x2(y)
   304  		c := archsimd.LoadUint64x2(z)
   305  		g := make([]uint64, n)
   306  		f(a, b, c).Store(g)
   307  		w := want(x, y, z)
   308  		return checkSlicesLogInput(t, g, w, flakiness, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
   309  	})
   310  }
   311  
   312  // testFloat32x4TernaryFlaky tests the simd ternary method f against the expected behavior generated by want,
   313  // but using a flakiness parameter because we haven't exactly figured out how simd floating point works
   314  func testFloat32x4TernaryFlaky(t *testing.T, f func(x, y, z archsimd.Float32x4) archsimd.Float32x4, want func(x, y, z []float32) []float32, flakiness float64) {
   315  	n := 4
   316  	t.Helper()
   317  	forSliceTriple(t, float32s, n, func(x, y, z []float32) bool {
   318  		t.Helper()
   319  		a := archsimd.LoadFloat32x4(x)
   320  		b := archsimd.LoadFloat32x4(y)
   321  		c := archsimd.LoadFloat32x4(z)
   322  		g := make([]float32, n)
   323  		f(a, b, c).Store(g)
   324  		w := want(x, y, z)
   325  		return checkSlicesLogInput(t, g, w, flakiness, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
   326  	})
   327  }
   328  
   329  // testFloat64x2TernaryFlaky tests the simd ternary method f against the expected behavior generated by want,
   330  // but using a flakiness parameter because we haven't exactly figured out how simd floating point works
   331  func testFloat64x2TernaryFlaky(t *testing.T, f func(x, y, z archsimd.Float64x2) archsimd.Float64x2, want func(x, y, z []float64) []float64, flakiness float64) {
   332  	n := 2
   333  	t.Helper()
   334  	forSliceTriple(t, float64s, n, func(x, y, z []float64) bool {
   335  		t.Helper()
   336  		a := archsimd.LoadFloat64x2(x)
   337  		b := archsimd.LoadFloat64x2(y)
   338  		c := archsimd.LoadFloat64x2(z)
   339  		g := make([]float64, n)
   340  		f(a, b, c).Store(g)
   341  		w := want(x, y, z)
   342  		return checkSlicesLogInput(t, g, w, flakiness, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) })
   343  	})
   344  }
   345  

View as plain text