Source file src/simd/internal/simd_test/comparemasked_helpers_test.go

     1  // Code generated by 'go run genfiles.go'; DO NOT EDIT.
     2  
     3  //go:build goexperiment.simd
     4  
     5  // This file contains functions testing simd methods that compare two operands under a mask.
     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"
    13  	"testing"
    14  )
    15  
    16  // testInt8x16CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
    17  // The mask is applied to the output of want; anything not in the mask, is zeroed.
    18  func testInt8x16CompareMasked(t *testing.T,
    19  	f func(_, _ simd.Int8x16, m simd.Mask8x16) simd.Mask8x16,
    20  	want func(_, _ []int8) []int64) {
    21  	n := 16
    22  	t.Helper()
    23  	forSlicePairMasked(t, int8s, n, func(x, y []int8, m []bool) bool {
    24  		t.Helper()
    25  		a := simd.LoadInt8x16Slice(x)
    26  		b := simd.LoadInt8x16Slice(y)
    27  		k := simd.LoadInt8x16Slice(toVect[int8](m)).ToMask()
    28  		g := make([]int8, n)
    29  		f(a, b, k).AsInt8x16().StoreSlice(g)
    30  		w := want(x, y)
    31  		for i := range m {
    32  			if !m[i] {
    33  				w[i] = 0
    34  			}
    35  		}
    36  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
    37  	})
    38  }
    39  
    40  // testInt16x8CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
    41  // The mask is applied to the output of want; anything not in the mask, is zeroed.
    42  func testInt16x8CompareMasked(t *testing.T,
    43  	f func(_, _ simd.Int16x8, m simd.Mask16x8) simd.Mask16x8,
    44  	want func(_, _ []int16) []int64) {
    45  	n := 8
    46  	t.Helper()
    47  	forSlicePairMasked(t, int16s, n, func(x, y []int16, m []bool) bool {
    48  		t.Helper()
    49  		a := simd.LoadInt16x8Slice(x)
    50  		b := simd.LoadInt16x8Slice(y)
    51  		k := simd.LoadInt16x8Slice(toVect[int16](m)).ToMask()
    52  		g := make([]int16, n)
    53  		f(a, b, k).AsInt16x8().StoreSlice(g)
    54  		w := want(x, y)
    55  		for i := range m {
    56  			if !m[i] {
    57  				w[i] = 0
    58  			}
    59  		}
    60  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
    61  	})
    62  }
    63  
    64  // testInt32x4CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
    65  // The mask is applied to the output of want; anything not in the mask, is zeroed.
    66  func testInt32x4CompareMasked(t *testing.T,
    67  	f func(_, _ simd.Int32x4, m simd.Mask32x4) simd.Mask32x4,
    68  	want func(_, _ []int32) []int64) {
    69  	n := 4
    70  	t.Helper()
    71  	forSlicePairMasked(t, int32s, n, func(x, y []int32, m []bool) bool {
    72  		t.Helper()
    73  		a := simd.LoadInt32x4Slice(x)
    74  		b := simd.LoadInt32x4Slice(y)
    75  		k := simd.LoadInt32x4Slice(toVect[int32](m)).ToMask()
    76  		g := make([]int32, n)
    77  		f(a, b, k).AsInt32x4().StoreSlice(g)
    78  		w := want(x, y)
    79  		for i := range m {
    80  			if !m[i] {
    81  				w[i] = 0
    82  			}
    83  		}
    84  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
    85  	})
    86  }
    87  
    88  // testInt64x2CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
    89  // The mask is applied to the output of want; anything not in the mask, is zeroed.
    90  func testInt64x2CompareMasked(t *testing.T,
    91  	f func(_, _ simd.Int64x2, m simd.Mask64x2) simd.Mask64x2,
    92  	want func(_, _ []int64) []int64) {
    93  	n := 2
    94  	t.Helper()
    95  	forSlicePairMasked(t, int64s, n, func(x, y []int64, m []bool) bool {
    96  		t.Helper()
    97  		a := simd.LoadInt64x2Slice(x)
    98  		b := simd.LoadInt64x2Slice(y)
    99  		k := simd.LoadInt64x2Slice(toVect[int64](m)).ToMask()
   100  		g := make([]int64, n)
   101  		f(a, b, k).AsInt64x2().StoreSlice(g)
   102  		w := want(x, y)
   103  		for i := range m {
   104  			if !m[i] {
   105  				w[i] = 0
   106  			}
   107  		}
   108  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   109  	})
   110  }
   111  
   112  // testUint8x16CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   113  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   114  func testUint8x16CompareMasked(t *testing.T,
   115  	f func(_, _ simd.Uint8x16, m simd.Mask8x16) simd.Mask8x16,
   116  	want func(_, _ []uint8) []int64) {
   117  	n := 16
   118  	t.Helper()
   119  	forSlicePairMasked(t, uint8s, n, func(x, y []uint8, m []bool) bool {
   120  		t.Helper()
   121  		a := simd.LoadUint8x16Slice(x)
   122  		b := simd.LoadUint8x16Slice(y)
   123  		k := simd.LoadInt8x16Slice(toVect[int8](m)).ToMask()
   124  		g := make([]int8, n)
   125  		f(a, b, k).AsInt8x16().StoreSlice(g)
   126  		w := want(x, y)
   127  		for i := range m {
   128  			if !m[i] {
   129  				w[i] = 0
   130  			}
   131  		}
   132  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   133  	})
   134  }
   135  
   136  // testUint16x8CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   137  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   138  func testUint16x8CompareMasked(t *testing.T,
   139  	f func(_, _ simd.Uint16x8, m simd.Mask16x8) simd.Mask16x8,
   140  	want func(_, _ []uint16) []int64) {
   141  	n := 8
   142  	t.Helper()
   143  	forSlicePairMasked(t, uint16s, n, func(x, y []uint16, m []bool) bool {
   144  		t.Helper()
   145  		a := simd.LoadUint16x8Slice(x)
   146  		b := simd.LoadUint16x8Slice(y)
   147  		k := simd.LoadInt16x8Slice(toVect[int16](m)).ToMask()
   148  		g := make([]int16, n)
   149  		f(a, b, k).AsInt16x8().StoreSlice(g)
   150  		w := want(x, y)
   151  		for i := range m {
   152  			if !m[i] {
   153  				w[i] = 0
   154  			}
   155  		}
   156  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   157  	})
   158  }
   159  
   160  // testUint32x4CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   161  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   162  func testUint32x4CompareMasked(t *testing.T,
   163  	f func(_, _ simd.Uint32x4, m simd.Mask32x4) simd.Mask32x4,
   164  	want func(_, _ []uint32) []int64) {
   165  	n := 4
   166  	t.Helper()
   167  	forSlicePairMasked(t, uint32s, n, func(x, y []uint32, m []bool) bool {
   168  		t.Helper()
   169  		a := simd.LoadUint32x4Slice(x)
   170  		b := simd.LoadUint32x4Slice(y)
   171  		k := simd.LoadInt32x4Slice(toVect[int32](m)).ToMask()
   172  		g := make([]int32, n)
   173  		f(a, b, k).AsInt32x4().StoreSlice(g)
   174  		w := want(x, y)
   175  		for i := range m {
   176  			if !m[i] {
   177  				w[i] = 0
   178  			}
   179  		}
   180  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   181  	})
   182  }
   183  
   184  // testUint64x2CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   185  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   186  func testUint64x2CompareMasked(t *testing.T,
   187  	f func(_, _ simd.Uint64x2, m simd.Mask64x2) simd.Mask64x2,
   188  	want func(_, _ []uint64) []int64) {
   189  	n := 2
   190  	t.Helper()
   191  	forSlicePairMasked(t, uint64s, n, func(x, y []uint64, m []bool) bool {
   192  		t.Helper()
   193  		a := simd.LoadUint64x2Slice(x)
   194  		b := simd.LoadUint64x2Slice(y)
   195  		k := simd.LoadInt64x2Slice(toVect[int64](m)).ToMask()
   196  		g := make([]int64, n)
   197  		f(a, b, k).AsInt64x2().StoreSlice(g)
   198  		w := want(x, y)
   199  		for i := range m {
   200  			if !m[i] {
   201  				w[i] = 0
   202  			}
   203  		}
   204  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   205  	})
   206  }
   207  
   208  // testFloat32x4CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   209  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   210  func testFloat32x4CompareMasked(t *testing.T,
   211  	f func(_, _ simd.Float32x4, m simd.Mask32x4) simd.Mask32x4,
   212  	want func(_, _ []float32) []int64) {
   213  	n := 4
   214  	t.Helper()
   215  	forSlicePairMasked(t, float32s, n, func(x, y []float32, m []bool) bool {
   216  		t.Helper()
   217  		a := simd.LoadFloat32x4Slice(x)
   218  		b := simd.LoadFloat32x4Slice(y)
   219  		k := simd.LoadInt32x4Slice(toVect[int32](m)).ToMask()
   220  		g := make([]int32, n)
   221  		f(a, b, k).AsInt32x4().StoreSlice(g)
   222  		w := want(x, y)
   223  		for i := range m {
   224  			if !m[i] {
   225  				w[i] = 0
   226  			}
   227  		}
   228  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   229  	})
   230  }
   231  
   232  // testFloat64x2CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   233  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   234  func testFloat64x2CompareMasked(t *testing.T,
   235  	f func(_, _ simd.Float64x2, m simd.Mask64x2) simd.Mask64x2,
   236  	want func(_, _ []float64) []int64) {
   237  	n := 2
   238  	t.Helper()
   239  	forSlicePairMasked(t, float64s, n, func(x, y []float64, m []bool) bool {
   240  		t.Helper()
   241  		a := simd.LoadFloat64x2Slice(x)
   242  		b := simd.LoadFloat64x2Slice(y)
   243  		k := simd.LoadInt64x2Slice(toVect[int64](m)).ToMask()
   244  		g := make([]int64, n)
   245  		f(a, b, k).AsInt64x2().StoreSlice(g)
   246  		w := want(x, y)
   247  		for i := range m {
   248  			if !m[i] {
   249  				w[i] = 0
   250  			}
   251  		}
   252  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   253  	})
   254  }
   255  
   256  // testInt8x32CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   257  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   258  func testInt8x32CompareMasked(t *testing.T,
   259  	f func(_, _ simd.Int8x32, m simd.Mask8x32) simd.Mask8x32,
   260  	want func(_, _ []int8) []int64) {
   261  	n := 32
   262  	t.Helper()
   263  	forSlicePairMasked(t, int8s, n, func(x, y []int8, m []bool) bool {
   264  		t.Helper()
   265  		a := simd.LoadInt8x32Slice(x)
   266  		b := simd.LoadInt8x32Slice(y)
   267  		k := simd.LoadInt8x32Slice(toVect[int8](m)).ToMask()
   268  		g := make([]int8, n)
   269  		f(a, b, k).AsInt8x32().StoreSlice(g)
   270  		w := want(x, y)
   271  		for i := range m {
   272  			if !m[i] {
   273  				w[i] = 0
   274  			}
   275  		}
   276  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   277  	})
   278  }
   279  
   280  // testInt16x16CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   281  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   282  func testInt16x16CompareMasked(t *testing.T,
   283  	f func(_, _ simd.Int16x16, m simd.Mask16x16) simd.Mask16x16,
   284  	want func(_, _ []int16) []int64) {
   285  	n := 16
   286  	t.Helper()
   287  	forSlicePairMasked(t, int16s, n, func(x, y []int16, m []bool) bool {
   288  		t.Helper()
   289  		a := simd.LoadInt16x16Slice(x)
   290  		b := simd.LoadInt16x16Slice(y)
   291  		k := simd.LoadInt16x16Slice(toVect[int16](m)).ToMask()
   292  		g := make([]int16, n)
   293  		f(a, b, k).AsInt16x16().StoreSlice(g)
   294  		w := want(x, y)
   295  		for i := range m {
   296  			if !m[i] {
   297  				w[i] = 0
   298  			}
   299  		}
   300  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   301  	})
   302  }
   303  
   304  // testInt32x8CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   305  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   306  func testInt32x8CompareMasked(t *testing.T,
   307  	f func(_, _ simd.Int32x8, m simd.Mask32x8) simd.Mask32x8,
   308  	want func(_, _ []int32) []int64) {
   309  	n := 8
   310  	t.Helper()
   311  	forSlicePairMasked(t, int32s, n, func(x, y []int32, m []bool) bool {
   312  		t.Helper()
   313  		a := simd.LoadInt32x8Slice(x)
   314  		b := simd.LoadInt32x8Slice(y)
   315  		k := simd.LoadInt32x8Slice(toVect[int32](m)).ToMask()
   316  		g := make([]int32, n)
   317  		f(a, b, k).AsInt32x8().StoreSlice(g)
   318  		w := want(x, y)
   319  		for i := range m {
   320  			if !m[i] {
   321  				w[i] = 0
   322  			}
   323  		}
   324  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   325  	})
   326  }
   327  
   328  // testInt64x4CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   329  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   330  func testInt64x4CompareMasked(t *testing.T,
   331  	f func(_, _ simd.Int64x4, m simd.Mask64x4) simd.Mask64x4,
   332  	want func(_, _ []int64) []int64) {
   333  	n := 4
   334  	t.Helper()
   335  	forSlicePairMasked(t, int64s, n, func(x, y []int64, m []bool) bool {
   336  		t.Helper()
   337  		a := simd.LoadInt64x4Slice(x)
   338  		b := simd.LoadInt64x4Slice(y)
   339  		k := simd.LoadInt64x4Slice(toVect[int64](m)).ToMask()
   340  		g := make([]int64, n)
   341  		f(a, b, k).AsInt64x4().StoreSlice(g)
   342  		w := want(x, y)
   343  		for i := range m {
   344  			if !m[i] {
   345  				w[i] = 0
   346  			}
   347  		}
   348  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   349  	})
   350  }
   351  
   352  // testUint8x32CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   353  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   354  func testUint8x32CompareMasked(t *testing.T,
   355  	f func(_, _ simd.Uint8x32, m simd.Mask8x32) simd.Mask8x32,
   356  	want func(_, _ []uint8) []int64) {
   357  	n := 32
   358  	t.Helper()
   359  	forSlicePairMasked(t, uint8s, n, func(x, y []uint8, m []bool) bool {
   360  		t.Helper()
   361  		a := simd.LoadUint8x32Slice(x)
   362  		b := simd.LoadUint8x32Slice(y)
   363  		k := simd.LoadInt8x32Slice(toVect[int8](m)).ToMask()
   364  		g := make([]int8, n)
   365  		f(a, b, k).AsInt8x32().StoreSlice(g)
   366  		w := want(x, y)
   367  		for i := range m {
   368  			if !m[i] {
   369  				w[i] = 0
   370  			}
   371  		}
   372  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   373  	})
   374  }
   375  
   376  // testUint16x16CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   377  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   378  func testUint16x16CompareMasked(t *testing.T,
   379  	f func(_, _ simd.Uint16x16, m simd.Mask16x16) simd.Mask16x16,
   380  	want func(_, _ []uint16) []int64) {
   381  	n := 16
   382  	t.Helper()
   383  	forSlicePairMasked(t, uint16s, n, func(x, y []uint16, m []bool) bool {
   384  		t.Helper()
   385  		a := simd.LoadUint16x16Slice(x)
   386  		b := simd.LoadUint16x16Slice(y)
   387  		k := simd.LoadInt16x16Slice(toVect[int16](m)).ToMask()
   388  		g := make([]int16, n)
   389  		f(a, b, k).AsInt16x16().StoreSlice(g)
   390  		w := want(x, y)
   391  		for i := range m {
   392  			if !m[i] {
   393  				w[i] = 0
   394  			}
   395  		}
   396  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   397  	})
   398  }
   399  
   400  // testUint32x8CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   401  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   402  func testUint32x8CompareMasked(t *testing.T,
   403  	f func(_, _ simd.Uint32x8, m simd.Mask32x8) simd.Mask32x8,
   404  	want func(_, _ []uint32) []int64) {
   405  	n := 8
   406  	t.Helper()
   407  	forSlicePairMasked(t, uint32s, n, func(x, y []uint32, m []bool) bool {
   408  		t.Helper()
   409  		a := simd.LoadUint32x8Slice(x)
   410  		b := simd.LoadUint32x8Slice(y)
   411  		k := simd.LoadInt32x8Slice(toVect[int32](m)).ToMask()
   412  		g := make([]int32, n)
   413  		f(a, b, k).AsInt32x8().StoreSlice(g)
   414  		w := want(x, y)
   415  		for i := range m {
   416  			if !m[i] {
   417  				w[i] = 0
   418  			}
   419  		}
   420  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   421  	})
   422  }
   423  
   424  // testUint64x4CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   425  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   426  func testUint64x4CompareMasked(t *testing.T,
   427  	f func(_, _ simd.Uint64x4, m simd.Mask64x4) simd.Mask64x4,
   428  	want func(_, _ []uint64) []int64) {
   429  	n := 4
   430  	t.Helper()
   431  	forSlicePairMasked(t, uint64s, n, func(x, y []uint64, m []bool) bool {
   432  		t.Helper()
   433  		a := simd.LoadUint64x4Slice(x)
   434  		b := simd.LoadUint64x4Slice(y)
   435  		k := simd.LoadInt64x4Slice(toVect[int64](m)).ToMask()
   436  		g := make([]int64, n)
   437  		f(a, b, k).AsInt64x4().StoreSlice(g)
   438  		w := want(x, y)
   439  		for i := range m {
   440  			if !m[i] {
   441  				w[i] = 0
   442  			}
   443  		}
   444  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   445  	})
   446  }
   447  
   448  // testFloat32x8CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   449  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   450  func testFloat32x8CompareMasked(t *testing.T,
   451  	f func(_, _ simd.Float32x8, m simd.Mask32x8) simd.Mask32x8,
   452  	want func(_, _ []float32) []int64) {
   453  	n := 8
   454  	t.Helper()
   455  	forSlicePairMasked(t, float32s, n, func(x, y []float32, m []bool) bool {
   456  		t.Helper()
   457  		a := simd.LoadFloat32x8Slice(x)
   458  		b := simd.LoadFloat32x8Slice(y)
   459  		k := simd.LoadInt32x8Slice(toVect[int32](m)).ToMask()
   460  		g := make([]int32, n)
   461  		f(a, b, k).AsInt32x8().StoreSlice(g)
   462  		w := want(x, y)
   463  		for i := range m {
   464  			if !m[i] {
   465  				w[i] = 0
   466  			}
   467  		}
   468  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   469  	})
   470  }
   471  
   472  // testFloat64x4CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   473  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   474  func testFloat64x4CompareMasked(t *testing.T,
   475  	f func(_, _ simd.Float64x4, m simd.Mask64x4) simd.Mask64x4,
   476  	want func(_, _ []float64) []int64) {
   477  	n := 4
   478  	t.Helper()
   479  	forSlicePairMasked(t, float64s, n, func(x, y []float64, m []bool) bool {
   480  		t.Helper()
   481  		a := simd.LoadFloat64x4Slice(x)
   482  		b := simd.LoadFloat64x4Slice(y)
   483  		k := simd.LoadInt64x4Slice(toVect[int64](m)).ToMask()
   484  		g := make([]int64, n)
   485  		f(a, b, k).AsInt64x4().StoreSlice(g)
   486  		w := want(x, y)
   487  		for i := range m {
   488  			if !m[i] {
   489  				w[i] = 0
   490  			}
   491  		}
   492  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   493  	})
   494  }
   495  
   496  // testInt8x64CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   497  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   498  func testInt8x64CompareMasked(t *testing.T,
   499  	f func(_, _ simd.Int8x64, m simd.Mask8x64) simd.Mask8x64,
   500  	want func(_, _ []int8) []int64) {
   501  	n := 64
   502  	t.Helper()
   503  	forSlicePairMasked(t, int8s, n, func(x, y []int8, m []bool) bool {
   504  		t.Helper()
   505  		a := simd.LoadInt8x64Slice(x)
   506  		b := simd.LoadInt8x64Slice(y)
   507  		k := simd.LoadInt8x64Slice(toVect[int8](m)).ToMask()
   508  		g := make([]int8, n)
   509  		f(a, b, k).AsInt8x64().StoreSlice(g)
   510  		w := want(x, y)
   511  		for i := range m {
   512  			if !m[i] {
   513  				w[i] = 0
   514  			}
   515  		}
   516  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   517  	})
   518  }
   519  
   520  // testInt16x32CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   521  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   522  func testInt16x32CompareMasked(t *testing.T,
   523  	f func(_, _ simd.Int16x32, m simd.Mask16x32) simd.Mask16x32,
   524  	want func(_, _ []int16) []int64) {
   525  	n := 32
   526  	t.Helper()
   527  	forSlicePairMasked(t, int16s, n, func(x, y []int16, m []bool) bool {
   528  		t.Helper()
   529  		a := simd.LoadInt16x32Slice(x)
   530  		b := simd.LoadInt16x32Slice(y)
   531  		k := simd.LoadInt16x32Slice(toVect[int16](m)).ToMask()
   532  		g := make([]int16, n)
   533  		f(a, b, k).AsInt16x32().StoreSlice(g)
   534  		w := want(x, y)
   535  		for i := range m {
   536  			if !m[i] {
   537  				w[i] = 0
   538  			}
   539  		}
   540  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   541  	})
   542  }
   543  
   544  // testInt32x16CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   545  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   546  func testInt32x16CompareMasked(t *testing.T,
   547  	f func(_, _ simd.Int32x16, m simd.Mask32x16) simd.Mask32x16,
   548  	want func(_, _ []int32) []int64) {
   549  	n := 16
   550  	t.Helper()
   551  	forSlicePairMasked(t, int32s, n, func(x, y []int32, m []bool) bool {
   552  		t.Helper()
   553  		a := simd.LoadInt32x16Slice(x)
   554  		b := simd.LoadInt32x16Slice(y)
   555  		k := simd.LoadInt32x16Slice(toVect[int32](m)).ToMask()
   556  		g := make([]int32, n)
   557  		f(a, b, k).AsInt32x16().StoreSlice(g)
   558  		w := want(x, y)
   559  		for i := range m {
   560  			if !m[i] {
   561  				w[i] = 0
   562  			}
   563  		}
   564  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   565  	})
   566  }
   567  
   568  // testInt64x8CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   569  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   570  func testInt64x8CompareMasked(t *testing.T,
   571  	f func(_, _ simd.Int64x8, m simd.Mask64x8) simd.Mask64x8,
   572  	want func(_, _ []int64) []int64) {
   573  	n := 8
   574  	t.Helper()
   575  	forSlicePairMasked(t, int64s, n, func(x, y []int64, m []bool) bool {
   576  		t.Helper()
   577  		a := simd.LoadInt64x8Slice(x)
   578  		b := simd.LoadInt64x8Slice(y)
   579  		k := simd.LoadInt64x8Slice(toVect[int64](m)).ToMask()
   580  		g := make([]int64, n)
   581  		f(a, b, k).AsInt64x8().StoreSlice(g)
   582  		w := want(x, y)
   583  		for i := range m {
   584  			if !m[i] {
   585  				w[i] = 0
   586  			}
   587  		}
   588  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   589  	})
   590  }
   591  
   592  // testUint8x64CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   593  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   594  func testUint8x64CompareMasked(t *testing.T,
   595  	f func(_, _ simd.Uint8x64, m simd.Mask8x64) simd.Mask8x64,
   596  	want func(_, _ []uint8) []int64) {
   597  	n := 64
   598  	t.Helper()
   599  	forSlicePairMasked(t, uint8s, n, func(x, y []uint8, m []bool) bool {
   600  		t.Helper()
   601  		a := simd.LoadUint8x64Slice(x)
   602  		b := simd.LoadUint8x64Slice(y)
   603  		k := simd.LoadInt8x64Slice(toVect[int8](m)).ToMask()
   604  		g := make([]int8, n)
   605  		f(a, b, k).AsInt8x64().StoreSlice(g)
   606  		w := want(x, y)
   607  		for i := range m {
   608  			if !m[i] {
   609  				w[i] = 0
   610  			}
   611  		}
   612  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   613  	})
   614  }
   615  
   616  // testUint16x32CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   617  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   618  func testUint16x32CompareMasked(t *testing.T,
   619  	f func(_, _ simd.Uint16x32, m simd.Mask16x32) simd.Mask16x32,
   620  	want func(_, _ []uint16) []int64) {
   621  	n := 32
   622  	t.Helper()
   623  	forSlicePairMasked(t, uint16s, n, func(x, y []uint16, m []bool) bool {
   624  		t.Helper()
   625  		a := simd.LoadUint16x32Slice(x)
   626  		b := simd.LoadUint16x32Slice(y)
   627  		k := simd.LoadInt16x32Slice(toVect[int16](m)).ToMask()
   628  		g := make([]int16, n)
   629  		f(a, b, k).AsInt16x32().StoreSlice(g)
   630  		w := want(x, y)
   631  		for i := range m {
   632  			if !m[i] {
   633  				w[i] = 0
   634  			}
   635  		}
   636  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   637  	})
   638  }
   639  
   640  // testUint32x16CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   641  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   642  func testUint32x16CompareMasked(t *testing.T,
   643  	f func(_, _ simd.Uint32x16, m simd.Mask32x16) simd.Mask32x16,
   644  	want func(_, _ []uint32) []int64) {
   645  	n := 16
   646  	t.Helper()
   647  	forSlicePairMasked(t, uint32s, n, func(x, y []uint32, m []bool) bool {
   648  		t.Helper()
   649  		a := simd.LoadUint32x16Slice(x)
   650  		b := simd.LoadUint32x16Slice(y)
   651  		k := simd.LoadInt32x16Slice(toVect[int32](m)).ToMask()
   652  		g := make([]int32, n)
   653  		f(a, b, k).AsInt32x16().StoreSlice(g)
   654  		w := want(x, y)
   655  		for i := range m {
   656  			if !m[i] {
   657  				w[i] = 0
   658  			}
   659  		}
   660  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   661  	})
   662  }
   663  
   664  // testUint64x8CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   665  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   666  func testUint64x8CompareMasked(t *testing.T,
   667  	f func(_, _ simd.Uint64x8, m simd.Mask64x8) simd.Mask64x8,
   668  	want func(_, _ []uint64) []int64) {
   669  	n := 8
   670  	t.Helper()
   671  	forSlicePairMasked(t, uint64s, n, func(x, y []uint64, m []bool) bool {
   672  		t.Helper()
   673  		a := simd.LoadUint64x8Slice(x)
   674  		b := simd.LoadUint64x8Slice(y)
   675  		k := simd.LoadInt64x8Slice(toVect[int64](m)).ToMask()
   676  		g := make([]int64, n)
   677  		f(a, b, k).AsInt64x8().StoreSlice(g)
   678  		w := want(x, y)
   679  		for i := range m {
   680  			if !m[i] {
   681  				w[i] = 0
   682  			}
   683  		}
   684  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   685  	})
   686  }
   687  
   688  // testFloat32x16CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   689  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   690  func testFloat32x16CompareMasked(t *testing.T,
   691  	f func(_, _ simd.Float32x16, m simd.Mask32x16) simd.Mask32x16,
   692  	want func(_, _ []float32) []int64) {
   693  	n := 16
   694  	t.Helper()
   695  	forSlicePairMasked(t, float32s, n, func(x, y []float32, m []bool) bool {
   696  		t.Helper()
   697  		a := simd.LoadFloat32x16Slice(x)
   698  		b := simd.LoadFloat32x16Slice(y)
   699  		k := simd.LoadInt32x16Slice(toVect[int32](m)).ToMask()
   700  		g := make([]int32, n)
   701  		f(a, b, k).AsInt32x16().StoreSlice(g)
   702  		w := want(x, y)
   703  		for i := range m {
   704  			if !m[i] {
   705  				w[i] = 0
   706  			}
   707  		}
   708  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   709  	})
   710  }
   711  
   712  // testFloat64x8CompareMasked tests the simd masked comparison method f against the expected behavior generated by want
   713  // The mask is applied to the output of want; anything not in the mask, is zeroed.
   714  func testFloat64x8CompareMasked(t *testing.T,
   715  	f func(_, _ simd.Float64x8, m simd.Mask64x8) simd.Mask64x8,
   716  	want func(_, _ []float64) []int64) {
   717  	n := 8
   718  	t.Helper()
   719  	forSlicePairMasked(t, float64s, n, func(x, y []float64, m []bool) bool {
   720  		t.Helper()
   721  		a := simd.LoadFloat64x8Slice(x)
   722  		b := simd.LoadFloat64x8Slice(y)
   723  		k := simd.LoadInt64x8Slice(toVect[int64](m)).ToMask()
   724  		g := make([]int64, n)
   725  		f(a, b, k).AsInt64x8().StoreSlice(g)
   726  		w := want(x, y)
   727  		for i := range m {
   728  			if !m[i] {
   729  				w[i] = 0
   730  			}
   731  		}
   732  		return checkSlicesLogInput(t, s64(g), w, 0.0, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("m=%v", m) })
   733  	})
   734  }
   735  

View as plain text