1 import jdk.incubator.vector.*; 2 import jdk.internal.vm.annotation.ForceInline; 3 import org.testng.Assert; 4 import org.testng.annotations.Test; 5 import org.testng.annotations.DataProvider; 6 7 import java.util.Arrays; 8 import java.util.List; 9 import java.util.function.IntFunction; 10 11 /** 12 * @test 13 * @modules jdk.incubator.vector 14 * @modules java.base/jdk.internal.vm.annotation 15 * @run testng VectorReshapeTests 16 */ 17 18 @Test 19 public class VectorReshapeTests { 20 static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); 21 static final int NUM_ITER = 200 * INVOC_COUNT; 22 23 static final IntVector.IntSpecies<Shapes.S64Bit> ispec64 = IntVector.speciesInstance(Shapes.S_64_BIT); 24 static final FloatVector.FloatSpecies<Shapes.S64Bit> fspec64 = FloatVector.speciesInstance(Shapes.S_64_BIT); 25 static final LongVector.LongSpecies<Shapes.S64Bit> lspec64 = LongVector.speciesInstance(Shapes.S_64_BIT); 26 static final DoubleVector.DoubleSpecies<Shapes.S64Bit> dspec64 = DoubleVector.speciesInstance(Shapes.S_64_BIT); 27 static final ByteVector.ByteSpecies<Shapes.S64Bit> bspec64 = ByteVector.speciesInstance(Shapes.S_64_BIT); 28 static final ShortVector.ShortSpecies<Shapes.S64Bit> sspec64 = ShortVector.speciesInstance(Shapes.S_64_BIT); 29 30 static final IntVector.IntSpecies<Shapes.S128Bit> ispec128 = IntVector.speciesInstance(Shapes.S_128_BIT); 31 static final FloatVector.FloatSpecies<Shapes.S128Bit> fspec128 = FloatVector.speciesInstance(Shapes.S_128_BIT); 32 static final LongVector.LongSpecies<Shapes.S128Bit> lspec128 = LongVector.speciesInstance(Shapes.S_128_BIT); 33 static final DoubleVector.DoubleSpecies<Shapes.S128Bit> dspec128 = DoubleVector.speciesInstance(Shapes.S_128_BIT); 34 static final ByteVector.ByteSpecies<Shapes.S128Bit> bspec128 = ByteVector.speciesInstance(Shapes.S_128_BIT); 35 static final ShortVector.ShortSpecies<Shapes.S128Bit> sspec128 = ShortVector.speciesInstance(Shapes.S_128_BIT); 36 37 static final IntVector.IntSpecies<Shapes.S256Bit> ispec256 = IntVector.speciesInstance(Shapes.S_256_BIT); 38 static final FloatVector.FloatSpecies<Shapes.S256Bit> fspec256 = FloatVector.speciesInstance(Shapes.S_256_BIT); 39 static final LongVector.LongSpecies<Shapes.S256Bit> lspec256 = LongVector.speciesInstance(Shapes.S_256_BIT); 40 static final DoubleVector.DoubleSpecies<Shapes.S256Bit> dspec256 = DoubleVector.speciesInstance(Shapes.S_256_BIT); 41 static final ByteVector.ByteSpecies<Shapes.S256Bit> bspec256 = ByteVector.speciesInstance(Shapes.S_256_BIT); 42 static final ShortVector.ShortSpecies<Shapes.S256Bit> sspec256 = ShortVector.speciesInstance(Shapes.S_256_BIT); 43 44 static final IntVector.IntSpecies<Shapes.S512Bit> ispec512 = IntVector.speciesInstance(Shapes.S_512_BIT); 45 static final FloatVector.FloatSpecies<Shapes.S512Bit> fspec512 = FloatVector.speciesInstance(Shapes.S_512_BIT); 46 static final LongVector.LongSpecies<Shapes.S512Bit> lspec512 = LongVector.speciesInstance(Shapes.S_512_BIT); 47 static final DoubleVector.DoubleSpecies<Shapes.S512Bit> dspec512 = DoubleVector.speciesInstance(Shapes.S_512_BIT); 48 static final ByteVector.ByteSpecies<Shapes.S512Bit> bspec512 = ByteVector.speciesInstance(Shapes.S_512_BIT); 49 static final ShortVector.ShortSpecies<Shapes.S512Bit> sspec512 = ShortVector.speciesInstance(Shapes.S_512_BIT); 50 51 static <T> IntFunction<T> withToString(String s, IntFunction<T> f) { 52 return new IntFunction<T>() { 53 @Override 54 public T apply(int v) { 55 return f.apply(v); 56 } 57 58 @Override 59 public String toString() { 60 return s; 61 } 62 }; 63 } 64 65 interface ToByteF { 66 byte apply(int i); 67 } 68 69 static byte[] fill_byte(int s , ToByteF f) { 70 return fill_byte(new byte[s], f); 71 } 72 73 static byte[] fill_byte(byte[] a, ToByteF f) { 74 for (int i = 0; i < a.length; i++) { 75 a[i] = f.apply(i); 76 } 77 return a; 78 } 79 80 interface ToBoolF { 81 boolean apply(int i); 82 } 83 84 static boolean[] fill_bool(int s , ToBoolF f) { 85 return fill_bool(new boolean[s], f); 86 } 87 88 static boolean[] fill_bool(boolean[] a, ToBoolF f) { 89 for (int i = 0; i < a.length; i++) { 90 a[i] = f.apply(i); 91 } 92 return a; 93 } 94 95 interface ToShortF { 96 short apply(int i); 97 } 98 99 static short[] fill_short(int s , ToShortF f) { 100 return fill_short(new short[s], f); 101 } 102 103 static short[] fill_short(short[] a, ToShortF f) { 104 for (int i = 0; i < a.length; i++) { 105 a[i] = f.apply(i); 106 } 107 return a; 108 } 109 110 interface ToIntF { 111 int apply(int i); 112 } 113 114 static int[] fill_int(int s , ToIntF f) { 115 return fill_int(new int[s], f); 116 } 117 118 static int[] fill_int(int[] a, ToIntF f) { 119 for (int i = 0; i < a.length; i++) { 120 a[i] = f.apply(i); 121 } 122 return a; 123 } 124 125 interface ToLongF { 126 long apply(int i); 127 } 128 129 static long[] fill_long(int s , ToLongF f) { 130 return fill_long(new long[s], f); 131 } 132 133 static long[] fill_long(long[] a, ToLongF f) { 134 for (int i = 0; i < a.length; i++) { 135 a[i] = f.apply(i); 136 } 137 return a; 138 } 139 140 interface ToFloatF { 141 float apply(int i); 142 } 143 144 static float[] fill_float(int s , ToFloatF f) { 145 return fill_float(new float[s], f); 146 } 147 148 static float[] fill_float(float[] a, ToFloatF f) { 149 for (int i = 0; i < a.length; i++) { 150 a[i] = f.apply(i); 151 } 152 return a; 153 } 154 155 interface ToDoubleF { 156 double apply(int i); 157 } 158 159 static double[] fill_double(int s , ToDoubleF f) { 160 return fill_double(new double[s], f); 161 } 162 163 static double[] fill_double(double[] a, ToDoubleF f) { 164 for (int i = 0; i < a.length; i++) { 165 a[i] = f.apply(i); 166 } 167 return a; 168 } 169 170 static final List<IntFunction<byte[]>> BYTE_GENERATORS = List.of( 171 withToString("byte(i)", (int s) -> { 172 return fill_byte(s, i -> (byte)i); 173 }) 174 ); 175 176 @DataProvider 177 public Object[][] byteUnaryOpProvider() { 178 return BYTE_GENERATORS.stream(). 179 map(f -> new Object[]{f}). 180 toArray(Object[][]::new); 181 } 182 183 static final List<IntFunction<boolean[]>> BOOL_GENERATORS = List.of( 184 withToString("boolean(i%3)", (int s) -> { 185 return fill_bool(s, i -> i % 3 == 0); 186 }) 187 ); 188 189 @DataProvider 190 public Object[][] booleanUnaryOpProvider() { 191 return BOOL_GENERATORS.stream(). 192 map(f -> new Object[]{f}). 193 toArray(Object[][]::new); 194 } 195 196 static final List<IntFunction<short[]>> SHORT_GENERATORS = List.of( 197 withToString("short(i)", (int s) -> { 198 return fill_short(s, i -> (short)i); 199 }) 200 ); 201 202 @DataProvider 203 public Object[][] shortUnaryOpProvider() { 204 return SHORT_GENERATORS.stream(). 205 map(f -> new Object[]{f}). 206 toArray(Object[][]::new); 207 } 208 209 static final List<IntFunction<int[]>> INT_GENERATORS = List.of( 210 withToString("int(i)", (int s) -> { 211 return fill_int(s, i -> (int)i); 212 }) 213 ); 214 215 @DataProvider 216 public Object[][] intUnaryOpProvider() { 217 return INT_GENERATORS.stream(). 218 map(f -> new Object[]{f}). 219 toArray(Object[][]::new); 220 } 221 222 static final List<IntFunction<long[]>> LONG_GENERATORS = List.of( 223 withToString("long(i)", (int s) -> { 224 return fill_long(s, i -> (long)i); 225 }) 226 ); 227 228 @DataProvider 229 public Object[][] longUnaryOpProvider() { 230 return LONG_GENERATORS.stream(). 231 map(f -> new Object[]{f}). 232 toArray(Object[][]::new); 233 } 234 235 static final List<IntFunction<float[]>> FLOAT_GENERATORS = List.of( 236 withToString("float(i)", (int s) -> { 237 return fill_float(s, i -> (float)i); 238 }) 239 ); 240 241 @DataProvider 242 public Object[][] floatUnaryOpProvider() { 243 return FLOAT_GENERATORS.stream(). 244 map(f -> new Object[]{f}). 245 toArray(Object[][]::new); 246 } 247 248 static final List<IntFunction<double[]>> DOUBLE_GENERATORS = List.of( 249 withToString("double(i)", (int s) -> { 250 return fill_double(s, i -> (double)i); 251 }) 252 ); 253 254 @DataProvider 255 public Object[][] doubleUnaryOpProvider() { 256 return DOUBLE_GENERATORS.stream(). 257 map(f -> new Object[]{f}). 258 toArray(Object[][]::new); 259 } 260 261 @ForceInline 262 static <E,S extends Vector.Shape,T extends Vector.Shape> 263 void testVectorResize(Vector.Species<E,S> a, Vector.Species<E,T> b, byte[] input, byte[] output) { 264 Vector<E, S> av = a.fromByteArray(input, 0); 265 Vector<E, T> bv = b.resize(av); 266 bv.intoByteArray(output, 0); 267 268 byte[] expected = Arrays.copyOf(input, output.length); 269 270 271 Assert.assertEquals(expected, output); 272 } 273 274 @Test(dataProvider = "byteUnaryOpProvider") 275 static void testResizeByte(IntFunction<byte[]> fa) { 276 byte[] bin64 = fa.apply(64/Byte.SIZE); 277 byte[] bin128 = fa.apply(128/Byte.SIZE); 278 byte[] bin256 = fa.apply(256/Byte.SIZE); 279 byte[] bin512 = fa.apply(512/Byte.SIZE); 280 byte[] bout64 = new byte[bin64.length]; 281 byte[] bout128 = new byte[bin128.length]; 282 byte[] bout256 = new byte[bin256.length]; 283 byte[] bout512 = new byte[bin512.length]; 284 285 for (int i = 0; i < NUM_ITER; i++) { 286 testVectorResize(bspec64, bspec64, bin64, bout64); 287 testVectorResize(bspec64, bspec128, bin64, bout128); 288 testVectorResize(bspec64, bspec256, bin64, bout256); 289 testVectorResize(bspec64, bspec512, bin64, bout512); 290 291 testVectorResize(bspec128, bspec64, bin128, bout64); 292 testVectorResize(bspec128, bspec128, bin128, bout128); 293 testVectorResize(bspec128, bspec256, bin128, bout256); 294 testVectorResize(bspec128, bspec512, bin128, bout512); 295 296 testVectorResize(bspec256, bspec64, bin256, bout64); 297 testVectorResize(bspec256, bspec128, bin256, bout128); 298 testVectorResize(bspec256, bspec256, bin256, bout256); 299 testVectorResize(bspec256, bspec512, bin256, bout512); 300 301 testVectorResize(bspec512, bspec64, bin512, bout64); 302 testVectorResize(bspec512, bspec128, bin512, bout128); 303 testVectorResize(bspec512, bspec256, bin512, bout256); 304 testVectorResize(bspec512, bspec512, bin512, bout512); 305 } 306 } 307 308 @Test(dataProvider = "byteUnaryOpProvider") 309 static void testResizeShort(IntFunction<byte[]> fa) { 310 byte[] bin64 = fa.apply(64/Byte.SIZE); 311 byte[] bin128 = fa.apply(128/Byte.SIZE); 312 byte[] bin256 = fa.apply(256/Byte.SIZE); 313 byte[] bin512 = fa.apply(512/Byte.SIZE); 314 byte[] bout64 = new byte[bin64.length]; 315 byte[] bout128 = new byte[bin128.length]; 316 byte[] bout256 = new byte[bin256.length]; 317 byte[] bout512 = new byte[bin512.length]; 318 319 for (int i = 0; i < NUM_ITER; i++) { 320 testVectorResize(sspec64, sspec64, bin64, bout64); 321 testVectorResize(sspec64, sspec128, bin64, bout128); 322 testVectorResize(sspec64, sspec256, bin64, bout256); 323 testVectorResize(sspec64, sspec512, bin64, bout512); 324 325 testVectorResize(sspec128, sspec64, bin128, bout64); 326 testVectorResize(sspec128, sspec128, bin128, bout128); 327 testVectorResize(sspec128, sspec256, bin128, bout256); 328 testVectorResize(sspec128, sspec512, bin128, bout512); 329 330 testVectorResize(sspec256, sspec64, bin256, bout64); 331 testVectorResize(sspec256, sspec128, bin256, bout128); 332 testVectorResize(sspec256, sspec256, bin256, bout256); 333 testVectorResize(sspec256, sspec512, bin256, bout512); 334 335 testVectorResize(sspec512, sspec64, bin512, bout64); 336 testVectorResize(sspec512, sspec128, bin512, bout128); 337 testVectorResize(sspec512, sspec256, bin512, bout256); 338 testVectorResize(sspec512, sspec512, bin512, bout512); 339 } 340 } 341 342 @Test(dataProvider = "byteUnaryOpProvider") 343 static void testResizeInt(IntFunction<byte[]> fa) { 344 byte[] bin64 = fa.apply(64/Byte.SIZE); 345 byte[] bin128 = fa.apply(128/Byte.SIZE); 346 byte[] bin256 = fa.apply(256/Byte.SIZE); 347 byte[] bin512 = fa.apply(512/Byte.SIZE); 348 byte[] bout64 = new byte[bin64.length]; 349 byte[] bout128 = new byte[bin128.length]; 350 byte[] bout256 = new byte[bin256.length]; 351 byte[] bout512 = new byte[bin512.length]; 352 353 for (int i = 0; i < NUM_ITER; i++) { 354 testVectorResize(ispec64, ispec64, bin64, bout64); 355 testVectorResize(ispec64, ispec128, bin64, bout128); 356 testVectorResize(ispec64, ispec256, bin64, bout256); 357 testVectorResize(ispec64, ispec512, bin64, bout512); 358 359 testVectorResize(ispec128, ispec64, bin128, bout64); 360 testVectorResize(ispec128, ispec128, bin128, bout128); 361 testVectorResize(ispec128, ispec256, bin128, bout256); 362 testVectorResize(ispec128, ispec512, bin128, bout512); 363 364 testVectorResize(ispec256, ispec64, bin256, bout64); 365 testVectorResize(ispec256, ispec128, bin256, bout128); 366 testVectorResize(ispec256, ispec256, bin256, bout256); 367 testVectorResize(ispec256, ispec512, bin256, bout512); 368 369 testVectorResize(ispec512, ispec64, bin512, bout64); 370 testVectorResize(ispec512, ispec128, bin512, bout128); 371 testVectorResize(ispec512, ispec256, bin512, bout256); 372 testVectorResize(ispec512, ispec512, bin512, bout512); 373 } 374 } 375 376 @Test(dataProvider = "byteUnaryOpProvider") 377 static void testResizeLong(IntFunction<byte[]> fa) { 378 byte[] bin64 = fa.apply(64/Byte.SIZE); 379 byte[] bin128 = fa.apply(128/Byte.SIZE); 380 byte[] bin256 = fa.apply(256/Byte.SIZE); 381 byte[] bin512 = fa.apply(512/Byte.SIZE); 382 byte[] bout64 = new byte[bin64.length]; 383 byte[] bout128 = new byte[bin128.length]; 384 byte[] bout256 = new byte[bin256.length]; 385 byte[] bout512 = new byte[bin512.length]; 386 387 for (int i = 0; i < NUM_ITER; i++) { 388 testVectorResize(lspec64, lspec64, bin64, bout64); 389 testVectorResize(lspec64, lspec128, bin64, bout128); 390 testVectorResize(lspec64, lspec256, bin64, bout256); 391 testVectorResize(lspec64, lspec512, bin64, bout512); 392 393 testVectorResize(lspec128, lspec64, bin128, bout64); 394 testVectorResize(lspec128, lspec128, bin128, bout128); 395 testVectorResize(lspec128, lspec256, bin128, bout256); 396 testVectorResize(lspec128, lspec512, bin128, bout512); 397 398 testVectorResize(lspec256, lspec64, bin256, bout64); 399 testVectorResize(lspec256, lspec128, bin256, bout128); 400 testVectorResize(lspec256, lspec256, bin256, bout256); 401 testVectorResize(lspec256, lspec512, bin256, bout512); 402 403 testVectorResize(lspec512, lspec64, bin512, bout64); 404 testVectorResize(lspec512, lspec128, bin512, bout128); 405 testVectorResize(lspec512, lspec256, bin512, bout256); 406 testVectorResize(lspec512, lspec512, bin512, bout512); 407 } 408 } 409 410 @Test(dataProvider = "byteUnaryOpProvider") 411 static void testResizeFloat(IntFunction<byte[]> fa) { 412 byte[] bin64 = fa.apply(64/Byte.SIZE); 413 byte[] bin128 = fa.apply(128/Byte.SIZE); 414 byte[] bin256 = fa.apply(256/Byte.SIZE); 415 byte[] bin512 = fa.apply(512/Byte.SIZE); 416 byte[] bout64 = new byte[bin64.length]; 417 byte[] bout128 = new byte[bin128.length]; 418 byte[] bout256 = new byte[bin256.length]; 419 byte[] bout512 = new byte[bin512.length]; 420 421 for (int i = 0; i < NUM_ITER; i++) { 422 testVectorResize(fspec64, fspec64, bin64, bout64); 423 testVectorResize(fspec64, fspec128, bin64, bout128); 424 testVectorResize(fspec64, fspec256, bin64, bout256); 425 testVectorResize(fspec64, fspec512, bin64, bout512); 426 427 testVectorResize(fspec128, fspec64, bin128, bout64); 428 testVectorResize(fspec128, fspec128, bin128, bout128); 429 testVectorResize(fspec128, fspec256, bin128, bout256); 430 testVectorResize(fspec128, fspec512, bin128, bout512); 431 432 testVectorResize(fspec256, fspec64, bin256, bout64); 433 testVectorResize(fspec256, fspec128, bin256, bout128); 434 testVectorResize(fspec256, fspec256, bin256, bout256); 435 testVectorResize(fspec256, fspec512, bin256, bout512); 436 437 testVectorResize(fspec512, fspec64, bin512, bout64); 438 testVectorResize(fspec512, fspec128, bin512, bout128); 439 testVectorResize(fspec512, fspec256, bin512, bout256); 440 testVectorResize(fspec512, fspec512, bin512, bout512); 441 } 442 } 443 444 @Test(dataProvider = "byteUnaryOpProvider") 445 static void testResizeDouble(IntFunction<byte[]> fa) { 446 byte[] bin64 = fa.apply(64/Byte.SIZE); 447 byte[] bin128 = fa.apply(128/Byte.SIZE); 448 byte[] bin256 = fa.apply(256/Byte.SIZE); 449 byte[] bin512 = fa.apply(512/Byte.SIZE); 450 byte[] bout64 = new byte[bin64.length]; 451 byte[] bout128 = new byte[bin128.length]; 452 byte[] bout256 = new byte[bin256.length]; 453 byte[] bout512 = new byte[bin512.length]; 454 455 for (int i = 0; i < NUM_ITER; i++) { 456 testVectorResize(dspec64, dspec64, bin64, bout64); 457 testVectorResize(dspec64, dspec128, bin64, bout128); 458 testVectorResize(dspec64, dspec256, bin64, bout256); 459 testVectorResize(dspec64, dspec512, bin64, bout512); 460 461 testVectorResize(dspec128, dspec64, bin128, bout64); 462 testVectorResize(dspec128, dspec128, bin128, bout128); 463 testVectorResize(dspec128, dspec256, bin128, bout256); 464 testVectorResize(dspec128, dspec512, bin128, bout512); 465 466 testVectorResize(dspec256, dspec64, bin256, bout64); 467 testVectorResize(dspec256, dspec128, bin256, bout128); 468 testVectorResize(dspec256, dspec256, bin256, bout256); 469 testVectorResize(dspec256, dspec512, bin256, bout512); 470 471 testVectorResize(dspec512, dspec64, bin512, bout64); 472 testVectorResize(dspec512, dspec128, bin512, bout128); 473 testVectorResize(dspec512, dspec256, bin512, bout256); 474 testVectorResize(dspec512, dspec512, bin512, bout512); 475 } 476 } 477 478 @ForceInline 479 static <E,F,S extends Vector.Shape> 480 void testVectorRebracket(Vector.Species<E,S> a, Vector.Species<F,S> b, byte[] input, byte[] output) { 481 assert(input.length == output.length); 482 483 Vector<E, S> av = a.fromByteArray(input, 0); 484 Vector<F, S> bv = b.rebracket(av); 485 bv.intoByteArray(output, 0); 486 487 Assert.assertEquals(input, output); 488 } 489 490 @Test(dataProvider = "byteUnaryOpProvider") 491 static void testRebracket64(IntFunction<byte[]> fa) { 492 byte[] barr = fa.apply(64/Byte.SIZE); 493 byte[] bout = new byte[barr.length]; 494 for (int i = 0; i < NUM_ITER; i++) { 495 testVectorRebracket(bspec64, bspec64, barr, bout); 496 testVectorRebracket(bspec64, sspec64, barr, bout); 497 testVectorRebracket(bspec64, ispec64, barr, bout); 498 testVectorRebracket(bspec64, lspec64, barr, bout); 499 testVectorRebracket(bspec64, fspec64, barr, bout); 500 testVectorRebracket(bspec64, dspec64, barr, bout); 501 502 testVectorRebracket(sspec64, bspec64, barr, bout); 503 testVectorRebracket(sspec64, sspec64, barr, bout); 504 testVectorRebracket(sspec64, ispec64, barr, bout); 505 testVectorRebracket(sspec64, lspec64, barr, bout); 506 testVectorRebracket(sspec64, fspec64, barr, bout); 507 testVectorRebracket(sspec64, dspec64, barr, bout); 508 509 testVectorRebracket(ispec64, bspec64, barr, bout); 510 testVectorRebracket(ispec64, sspec64, barr, bout); 511 testVectorRebracket(ispec64, ispec64, barr, bout); 512 testVectorRebracket(ispec64, lspec64, barr, bout); 513 testVectorRebracket(ispec64, fspec64, barr, bout); 514 testVectorRebracket(ispec64, dspec64, barr, bout); 515 516 testVectorRebracket(lspec64, bspec64, barr, bout); 517 testVectorRebracket(lspec64, sspec64, barr, bout); 518 testVectorRebracket(lspec64, ispec64, barr, bout); 519 testVectorRebracket(lspec64, lspec64, barr, bout); 520 testVectorRebracket(lspec64, fspec64, barr, bout); 521 testVectorRebracket(lspec64, dspec64, barr, bout); 522 523 testVectorRebracket(fspec64, bspec64, barr, bout); 524 testVectorRebracket(fspec64, sspec64, barr, bout); 525 testVectorRebracket(fspec64, ispec64, barr, bout); 526 testVectorRebracket(fspec64, lspec64, barr, bout); 527 testVectorRebracket(fspec64, fspec64, barr, bout); 528 testVectorRebracket(fspec64, dspec64, barr, bout); 529 530 testVectorRebracket(dspec64, bspec64, barr, bout); 531 testVectorRebracket(dspec64, sspec64, barr, bout); 532 testVectorRebracket(dspec64, ispec64, barr, bout); 533 testVectorRebracket(dspec64, lspec64, barr, bout); 534 testVectorRebracket(dspec64, fspec64, barr, bout); 535 testVectorRebracket(dspec64, dspec64, barr, bout); 536 } 537 } 538 539 @Test(dataProvider = "byteUnaryOpProvider") 540 static void testRebracket128(IntFunction<byte[]> fa) { 541 byte[] barr = fa.apply(128/Byte.SIZE); 542 byte[] bout = new byte[barr.length]; 543 for (int i = 0; i < NUM_ITER; i++) { 544 testVectorRebracket(bspec128, bspec128, barr, bout); 545 testVectorRebracket(bspec128, sspec128, barr, bout); 546 testVectorRebracket(bspec128, ispec128, barr, bout); 547 testVectorRebracket(bspec128, lspec128, barr, bout); 548 testVectorRebracket(bspec128, fspec128, barr, bout); 549 testVectorRebracket(bspec128, dspec128, barr, bout); 550 551 testVectorRebracket(sspec128, bspec128, barr, bout); 552 testVectorRebracket(sspec128, sspec128, barr, bout); 553 testVectorRebracket(sspec128, ispec128, barr, bout); 554 testVectorRebracket(sspec128, lspec128, barr, bout); 555 testVectorRebracket(sspec128, fspec128, barr, bout); 556 testVectorRebracket(sspec128, dspec128, barr, bout); 557 558 testVectorRebracket(ispec128, bspec128, barr, bout); 559 testVectorRebracket(ispec128, sspec128, barr, bout); 560 testVectorRebracket(ispec128, ispec128, barr, bout); 561 testVectorRebracket(ispec128, lspec128, barr, bout); 562 testVectorRebracket(ispec128, fspec128, barr, bout); 563 testVectorRebracket(ispec128, dspec128, barr, bout); 564 565 testVectorRebracket(lspec128, bspec128, barr, bout); 566 testVectorRebracket(lspec128, sspec128, barr, bout); 567 testVectorRebracket(lspec128, ispec128, barr, bout); 568 testVectorRebracket(lspec128, lspec128, barr, bout); 569 testVectorRebracket(lspec128, fspec128, barr, bout); 570 testVectorRebracket(lspec128, dspec128, barr, bout); 571 572 testVectorRebracket(fspec128, bspec128, barr, bout); 573 testVectorRebracket(fspec128, sspec128, barr, bout); 574 testVectorRebracket(fspec128, ispec128, barr, bout); 575 testVectorRebracket(fspec128, lspec128, barr, bout); 576 testVectorRebracket(fspec128, fspec128, barr, bout); 577 testVectorRebracket(fspec128, dspec128, barr, bout); 578 579 testVectorRebracket(dspec128, bspec128, barr, bout); 580 testVectorRebracket(dspec128, sspec128, barr, bout); 581 testVectorRebracket(dspec128, ispec128, barr, bout); 582 testVectorRebracket(dspec128, lspec128, barr, bout); 583 testVectorRebracket(dspec128, fspec128, barr, bout); 584 testVectorRebracket(dspec128, dspec128, barr, bout); 585 } 586 } 587 588 @Test(dataProvider = "byteUnaryOpProvider") 589 static void testRebracket256(IntFunction<byte[]> fa) { 590 byte[] barr = fa.apply(256/Byte.SIZE); 591 byte[] bout = new byte[barr.length]; 592 for (int i = 0; i < NUM_ITER; i++) { 593 testVectorRebracket(bspec256, bspec256, barr, bout); 594 testVectorRebracket(bspec256, sspec256, barr, bout); 595 testVectorRebracket(bspec256, ispec256, barr, bout); 596 testVectorRebracket(bspec256, lspec256, barr, bout); 597 testVectorRebracket(bspec256, fspec256, barr, bout); 598 testVectorRebracket(bspec256, dspec256, barr, bout); 599 600 testVectorRebracket(sspec256, bspec256, barr, bout); 601 testVectorRebracket(sspec256, sspec256, barr, bout); 602 testVectorRebracket(sspec256, ispec256, barr, bout); 603 testVectorRebracket(sspec256, lspec256, barr, bout); 604 testVectorRebracket(sspec256, fspec256, barr, bout); 605 testVectorRebracket(sspec256, dspec256, barr, bout); 606 607 testVectorRebracket(ispec256, bspec256, barr, bout); 608 testVectorRebracket(ispec256, sspec256, barr, bout); 609 testVectorRebracket(ispec256, ispec256, barr, bout); 610 testVectorRebracket(ispec256, lspec256, barr, bout); 611 testVectorRebracket(ispec256, fspec256, barr, bout); 612 testVectorRebracket(ispec256, dspec256, barr, bout); 613 614 testVectorRebracket(lspec256, bspec256, barr, bout); 615 testVectorRebracket(lspec256, sspec256, barr, bout); 616 testVectorRebracket(lspec256, ispec256, barr, bout); 617 testVectorRebracket(lspec256, lspec256, barr, bout); 618 testVectorRebracket(lspec256, fspec256, barr, bout); 619 testVectorRebracket(lspec256, dspec256, barr, bout); 620 621 testVectorRebracket(fspec256, bspec256, barr, bout); 622 testVectorRebracket(fspec256, sspec256, barr, bout); 623 testVectorRebracket(fspec256, ispec256, barr, bout); 624 testVectorRebracket(fspec256, lspec256, barr, bout); 625 testVectorRebracket(fspec256, fspec256, barr, bout); 626 testVectorRebracket(fspec256, dspec256, barr, bout); 627 628 testVectorRebracket(dspec256, bspec256, barr, bout); 629 testVectorRebracket(dspec256, sspec256, barr, bout); 630 testVectorRebracket(dspec256, ispec256, barr, bout); 631 testVectorRebracket(dspec256, lspec256, barr, bout); 632 testVectorRebracket(dspec256, fspec256, barr, bout); 633 testVectorRebracket(dspec256, dspec256, barr, bout); 634 } 635 } 636 637 @Test(dataProvider = "byteUnaryOpProvider") 638 static void testRebracket512(IntFunction<byte[]> fa) { 639 byte[] barr = fa.apply(512/Byte.SIZE); 640 byte[] bout = new byte[barr.length]; 641 for (int i = 0; i < NUM_ITER; i++) { 642 testVectorRebracket(bspec512, bspec512, barr, bout); 643 testVectorRebracket(bspec512, sspec512, barr, bout); 644 testVectorRebracket(bspec512, ispec512, barr, bout); 645 testVectorRebracket(bspec512, lspec512, barr, bout); 646 testVectorRebracket(bspec512, fspec512, barr, bout); 647 testVectorRebracket(bspec512, dspec512, barr, bout); 648 649 testVectorRebracket(sspec512, bspec512, barr, bout); 650 testVectorRebracket(sspec512, sspec512, barr, bout); 651 testVectorRebracket(sspec512, ispec512, barr, bout); 652 testVectorRebracket(sspec512, lspec512, barr, bout); 653 testVectorRebracket(sspec512, fspec512, barr, bout); 654 testVectorRebracket(sspec512, dspec512, barr, bout); 655 656 testVectorRebracket(ispec512, bspec512, barr, bout); 657 testVectorRebracket(ispec512, sspec512, barr, bout); 658 testVectorRebracket(ispec512, ispec512, barr, bout); 659 testVectorRebracket(ispec512, lspec512, barr, bout); 660 testVectorRebracket(ispec512, fspec512, barr, bout); 661 testVectorRebracket(ispec512, dspec512, barr, bout); 662 663 testVectorRebracket(lspec512, bspec512, barr, bout); 664 testVectorRebracket(lspec512, sspec512, barr, bout); 665 testVectorRebracket(lspec512, ispec512, barr, bout); 666 testVectorRebracket(lspec512, lspec512, barr, bout); 667 testVectorRebracket(lspec512, fspec512, barr, bout); 668 testVectorRebracket(lspec512, dspec512, barr, bout); 669 670 testVectorRebracket(fspec512, bspec512, barr, bout); 671 testVectorRebracket(fspec512, sspec512, barr, bout); 672 testVectorRebracket(fspec512, ispec512, barr, bout); 673 testVectorRebracket(fspec512, lspec512, barr, bout); 674 testVectorRebracket(fspec512, fspec512, barr, bout); 675 testVectorRebracket(fspec512, dspec512, barr, bout); 676 677 testVectorRebracket(dspec512, bspec512, barr, bout); 678 testVectorRebracket(dspec512, sspec512, barr, bout); 679 testVectorRebracket(dspec512, ispec512, barr, bout); 680 testVectorRebracket(dspec512, lspec512, barr, bout); 681 testVectorRebracket(dspec512, fspec512, barr, bout); 682 testVectorRebracket(dspec512, dspec512, barr, bout); 683 } 684 } 685 686 @ForceInline 687 static <S extends Vector.Shape, T extends Vector.Shape> 688 void testVectorCastByteToFloat(ByteVector.ByteSpecies<S> a, FloatVector.FloatSpecies<T> b, byte[] input, float[] output) { 689 assert(input.length == a.length()); 690 assert(output.length == b.length()); 691 692 ByteVector<S> av = a.fromArray(input, 0); 693 FloatVector<T> bv = b.cast(av); 694 bv.intoArray(output, 0); 695 696 for (int i = 0; i < Math.min(input.length, output.length); i++) { 697 Assert.assertEquals(output[i], (float)input[i]); 698 } 699 for(int i = input.length; i < output.length; i++) { 700 Assert.assertEquals(output[i], (float)0); 701 } 702 } 703 704 @ForceInline 705 static <S extends Vector.Shape, T extends Vector.Shape> 706 void testVectorCastShortToFloat(ShortVector.ShortSpecies<S> a, FloatVector.FloatSpecies<T> b, short[] input, float[] output) { 707 assert(input.length == a.length()); 708 assert(output.length == b.length()); 709 710 ShortVector<S> av = a.fromArray(input, 0); 711 FloatVector<T> bv = b.cast(av); 712 bv.intoArray(output, 0); 713 714 for (int i = 0; i < Math.min(input.length, output.length); i++) { 715 Assert.assertEquals(output[i], (float)input[i]); 716 } 717 for(int i = input.length; i < output.length; i++) { 718 Assert.assertEquals(output[i], (float)0); 719 } 720 } 721 722 @ForceInline 723 static <S extends Vector.Shape, T extends Vector.Shape> 724 void testVectorCastIntToFloat(IntVector.IntSpecies<S> a, FloatVector.FloatSpecies<T> b, int[] input, float[] output) { 725 assert(input.length == a.length()); 726 assert(output.length == b.length()); 727 728 IntVector<S> av = a.fromArray(input, 0); 729 FloatVector<T> bv = b.cast(av); 730 bv.intoArray(output, 0); 731 732 for (int i = 0; i < Math.min(input.length, output.length); i++) { 733 Assert.assertEquals(output[i], (float)input[i]); 734 } 735 for(int i = input.length; i < output.length; i++) { 736 Assert.assertEquals(output[i], (float)0); 737 } 738 } 739 740 @ForceInline 741 static <S extends Vector.Shape, T extends Vector.Shape> 742 void testVectorCastLongToFloat(LongVector.LongSpecies<S> a, FloatVector.FloatSpecies<T> b, long[] input, float[] output) { 743 assert(input.length == a.length()); 744 assert(output.length == b.length()); 745 746 LongVector<S> av = a.fromArray(input, 0); 747 FloatVector<T> bv = b.cast(av); 748 bv.intoArray(output, 0); 749 750 for (int i = 0; i < Math.min(input.length, output.length); i++) { 751 Assert.assertEquals(output[i], (float)input[i]); 752 } 753 for(int i = input.length; i < output.length; i++) { 754 Assert.assertEquals(output[i], (float)0); 755 } 756 } 757 758 @ForceInline 759 static <S extends Vector.Shape, T extends Vector.Shape> 760 void testVectorCastFloatToFloat(FloatVector.FloatSpecies<S> a, FloatVector.FloatSpecies<T> b, float[] input, float[] output) { 761 assert(input.length == a.length()); 762 assert(output.length == b.length()); 763 764 FloatVector<S> av = a.fromArray(input, 0); 765 FloatVector<T> bv = b.cast(av); 766 bv.intoArray(output, 0); 767 768 for (int i = 0; i < Math.min(input.length, output.length); i++) { 769 Assert.assertEquals(output[i], (float)input[i]); 770 } 771 for(int i = input.length; i < output.length; i++) { 772 Assert.assertEquals(output[i], (float)0); 773 } 774 } 775 776 @ForceInline 777 static <S extends Vector.Shape, T extends Vector.Shape> 778 void testVectorCastDoubleToFloat(DoubleVector.DoubleSpecies<S> a, FloatVector.FloatSpecies<T> b, double[] input, float[] output) { 779 assert(input.length == a.length()); 780 assert(output.length == b.length()); 781 782 DoubleVector<S> av = a.fromArray(input, 0); 783 FloatVector<T> bv = b.cast(av); 784 bv.intoArray(output, 0); 785 786 for (int i = 0; i < Math.min(input.length, output.length); i++) { 787 Assert.assertEquals(output[i], (float)input[i]); 788 } 789 for(int i = input.length; i < output.length; i++) { 790 Assert.assertEquals(output[i], (float)0); 791 } 792 } 793 794 @ForceInline 795 static <S extends Vector.Shape, T extends Vector.Shape> 796 void testVectorCastByteToByte(ByteVector.ByteSpecies<S> a, ByteVector.ByteSpecies<T> b, byte[] input, byte[] output) { 797 assert(input.length == a.length()); 798 assert(output.length == b.length()); 799 800 ByteVector<S> av = a.fromArray(input, 0); 801 ByteVector<T> bv = b.cast(av); 802 bv.intoArray(output, 0); 803 804 for (int i = 0; i < Math.min(input.length, output.length); i++) { 805 Assert.assertEquals(output[i], (byte)input[i]); 806 } 807 for(int i = input.length; i < output.length; i++) { 808 Assert.assertEquals(output[i], (byte)0); 809 } 810 } 811 812 @ForceInline 813 static <S extends Vector.Shape, T extends Vector.Shape> 814 void testVectorCastShortToByte(ShortVector.ShortSpecies<S> a, ByteVector.ByteSpecies<T> b, short[] input, byte[] output) { 815 assert(input.length == a.length()); 816 assert(output.length == b.length()); 817 818 ShortVector<S> av = a.fromArray(input, 0); 819 ByteVector<T> bv = b.cast(av); 820 bv.intoArray(output, 0); 821 822 for (int i = 0; i < Math.min(input.length, output.length); i++) { 823 Assert.assertEquals(output[i], (byte)input[i]); 824 } 825 for(int i = input.length; i < output.length; i++) { 826 Assert.assertEquals(output[i], (byte)0); 827 } 828 } 829 830 @ForceInline 831 static <S extends Vector.Shape, T extends Vector.Shape> 832 void testVectorCastIntToByte(IntVector.IntSpecies<S> a, ByteVector.ByteSpecies<T> b, int[] input, byte[] output) { 833 assert(input.length == a.length()); 834 assert(output.length == b.length()); 835 836 IntVector<S> av = a.fromArray(input, 0); 837 ByteVector<T> bv = b.cast(av); 838 bv.intoArray(output, 0); 839 840 for (int i = 0; i < Math.min(input.length, output.length); i++) { 841 Assert.assertEquals(output[i], (byte)input[i]); 842 } 843 for(int i = input.length; i < output.length; i++) { 844 Assert.assertEquals(output[i], (byte)0); 845 } 846 } 847 848 @ForceInline 849 static <S extends Vector.Shape, T extends Vector.Shape> 850 void testVectorCastLongToByte(LongVector.LongSpecies<S> a, ByteVector.ByteSpecies<T> b, long[] input, byte[] output) { 851 assert(input.length == a.length()); 852 assert(output.length == b.length()); 853 854 LongVector<S> av = a.fromArray(input, 0); 855 ByteVector<T> bv = b.cast(av); 856 bv.intoArray(output, 0); 857 858 for (int i = 0; i < Math.min(input.length, output.length); i++) { 859 Assert.assertEquals(output[i], (byte)input[i]); 860 } 861 for(int i = input.length; i < output.length; i++) { 862 Assert.assertEquals(output[i], (byte)0); 863 } 864 } 865 866 @ForceInline 867 static <S extends Vector.Shape, T extends Vector.Shape> 868 void testVectorCastFloatToByte(FloatVector.FloatSpecies<S> a, ByteVector.ByteSpecies<T> b, float[] input, byte[] output) { 869 assert(input.length == a.length()); 870 assert(output.length == b.length()); 871 872 FloatVector<S> av = a.fromArray(input, 0); 873 ByteVector<T> bv = b.cast(av); 874 bv.intoArray(output, 0); 875 876 for (int i = 0; i < Math.min(input.length, output.length); i++) { 877 Assert.assertEquals(output[i], (byte)input[i]); 878 } 879 for(int i = input.length; i < output.length; i++) { 880 Assert.assertEquals(output[i], (byte)0); 881 } 882 } 883 884 @ForceInline 885 static <S extends Vector.Shape, T extends Vector.Shape> 886 void testVectorCastDoubleToByte(DoubleVector.DoubleSpecies<S> a, ByteVector.ByteSpecies<T> b, double[] input, byte[] output) { 887 assert(input.length == a.length()); 888 assert(output.length == b.length()); 889 890 DoubleVector<S> av = a.fromArray(input, 0); 891 ByteVector<T> bv = b.cast(av); 892 bv.intoArray(output, 0); 893 894 for (int i = 0; i < Math.min(input.length, output.length); i++) { 895 Assert.assertEquals(output[i], (byte)input[i]); 896 } 897 for(int i = input.length; i < output.length; i++) { 898 Assert.assertEquals(output[i], (byte)0); 899 } 900 } 901 902 @ForceInline 903 static <S extends Vector.Shape, T extends Vector.Shape> 904 void testVectorCastByteToShort(ByteVector.ByteSpecies<S> a, ShortVector.ShortSpecies<T> b, byte[] input, short[] output) { 905 assert(input.length == a.length()); 906 assert(output.length == b.length()); 907 908 ByteVector<S> av = a.fromArray(input, 0); 909 ShortVector<T> bv = b.cast(av); 910 bv.intoArray(output, 0); 911 912 for (int i = 0; i < Math.min(input.length, output.length); i++) { 913 Assert.assertEquals(output[i], (short)input[i]); 914 } 915 for(int i = input.length; i < output.length; i++) { 916 Assert.assertEquals(output[i], (short)0); 917 } 918 } 919 920 @ForceInline 921 static <S extends Vector.Shape, T extends Vector.Shape> 922 void testVectorCastShortToShort(ShortVector.ShortSpecies<S> a, ShortVector.ShortSpecies<T> b, short[] input, short[] output) { 923 assert(input.length == a.length()); 924 assert(output.length == b.length()); 925 926 ShortVector<S> av = a.fromArray(input, 0); 927 ShortVector<T> bv = b.cast(av); 928 bv.intoArray(output, 0); 929 930 for (int i = 0; i < Math.min(input.length, output.length); i++) { 931 Assert.assertEquals(output[i], (short)input[i]); 932 } 933 for(int i = input.length; i < output.length; i++) { 934 Assert.assertEquals(output[i], (short)0); 935 } 936 } 937 938 @ForceInline 939 static <S extends Vector.Shape, T extends Vector.Shape> 940 void testVectorCastIntToShort(IntVector.IntSpecies<S> a, ShortVector.ShortSpecies<T> b, int[] input, short[] output) { 941 assert(input.length == a.length()); 942 assert(output.length == b.length()); 943 944 IntVector<S> av = a.fromArray(input, 0); 945 ShortVector<T> bv = b.cast(av); 946 bv.intoArray(output, 0); 947 948 for (int i = 0; i < Math.min(input.length, output.length); i++) { 949 Assert.assertEquals(output[i], (short)input[i]); 950 } 951 for(int i = input.length; i < output.length; i++) { 952 Assert.assertEquals(output[i], (short)0); 953 } 954 } 955 956 @ForceInline 957 static <S extends Vector.Shape, T extends Vector.Shape> 958 void testVectorCastLongToShort(LongVector.LongSpecies<S> a, ShortVector.ShortSpecies<T> b, long[] input, short[] output) { 959 assert(input.length == a.length()); 960 assert(output.length == b.length()); 961 962 LongVector<S> av = a.fromArray(input, 0); 963 ShortVector<T> bv = b.cast(av); 964 bv.intoArray(output, 0); 965 966 for (int i = 0; i < Math.min(input.length, output.length); i++) { 967 Assert.assertEquals(output[i], (short)input[i]); 968 } 969 for(int i = input.length; i < output.length; i++) { 970 Assert.assertEquals(output[i], (short)0); 971 } 972 } 973 974 @ForceInline 975 static <S extends Vector.Shape, T extends Vector.Shape> 976 void testVectorCastFloatToShort(FloatVector.FloatSpecies<S> a, ShortVector.ShortSpecies<T> b, float[] input, short[] output) { 977 assert(input.length == a.length()); 978 assert(output.length == b.length()); 979 980 FloatVector<S> av = a.fromArray(input, 0); 981 ShortVector<T> bv = b.cast(av); 982 bv.intoArray(output, 0); 983 984 for (int i = 0; i < Math.min(input.length, output.length); i++) { 985 Assert.assertEquals(output[i], (short)input[i]); 986 } 987 for(int i = input.length; i < output.length; i++) { 988 Assert.assertEquals(output[i], (short)0); 989 } 990 } 991 992 @ForceInline 993 static <S extends Vector.Shape, T extends Vector.Shape> 994 void testVectorCastDoubleToShort(DoubleVector.DoubleSpecies<S> a, ShortVector.ShortSpecies<T> b, double[] input, short[] output) { 995 assert(input.length == a.length()); 996 assert(output.length == b.length()); 997 998 DoubleVector<S> av = a.fromArray(input, 0); 999 ShortVector<T> bv = b.cast(av); 1000 bv.intoArray(output, 0); 1001 1002 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1003 Assert.assertEquals(output[i], (short)input[i]); 1004 } 1005 for(int i = input.length; i < output.length; i++) { 1006 Assert.assertEquals(output[i], (short)0); 1007 } 1008 } 1009 1010 @ForceInline 1011 static <S extends Vector.Shape, T extends Vector.Shape> 1012 void testVectorCastByteToInt(ByteVector.ByteSpecies<S> a, IntVector.IntSpecies<T> b, byte[] input, int[] output) { 1013 assert(input.length == a.length()); 1014 assert(output.length == b.length()); 1015 1016 ByteVector<S> av = a.fromArray(input, 0); 1017 IntVector<T> bv = b.cast(av); 1018 bv.intoArray(output, 0); 1019 1020 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1021 Assert.assertEquals(output[i], (int)input[i]); 1022 } 1023 for(int i = input.length; i < output.length; i++) { 1024 Assert.assertEquals(output[i], (int)0); 1025 } 1026 } 1027 1028 @ForceInline 1029 static <S extends Vector.Shape, T extends Vector.Shape> 1030 void testVectorCastShortToInt(ShortVector.ShortSpecies<S> a, IntVector.IntSpecies<T> b, short[] input, int[] output) { 1031 assert(input.length == a.length()); 1032 assert(output.length == b.length()); 1033 1034 ShortVector<S> av = a.fromArray(input, 0); 1035 IntVector<T> bv = b.cast(av); 1036 bv.intoArray(output, 0); 1037 1038 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1039 Assert.assertEquals(output[i], (int)input[i]); 1040 } 1041 for(int i = input.length; i < output.length; i++) { 1042 Assert.assertEquals(output[i], (int)0); 1043 } 1044 } 1045 1046 @ForceInline 1047 static <S extends Vector.Shape, T extends Vector.Shape> 1048 void testVectorCastIntToInt(IntVector.IntSpecies<S> a, IntVector.IntSpecies<T> b, int[] input, int[] output) { 1049 assert(input.length == a.length()); 1050 assert(output.length == b.length()); 1051 1052 IntVector<S> av = a.fromArray(input, 0); 1053 IntVector<T> bv = b.cast(av); 1054 bv.intoArray(output, 0); 1055 1056 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1057 Assert.assertEquals(output[i], (int)input[i]); 1058 } 1059 for(int i = input.length; i < output.length; i++) { 1060 Assert.assertEquals(output[i], (int)0); 1061 } 1062 } 1063 1064 @ForceInline 1065 static <S extends Vector.Shape, T extends Vector.Shape> 1066 void testVectorCastLongToInt(LongVector.LongSpecies<S> a, IntVector.IntSpecies<T> b, long[] input, int[] output) { 1067 assert(input.length == a.length()); 1068 assert(output.length == b.length()); 1069 1070 LongVector<S> av = a.fromArray(input, 0); 1071 IntVector<T> bv = b.cast(av); 1072 bv.intoArray(output, 0); 1073 1074 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1075 Assert.assertEquals(output[i], (int)input[i]); 1076 } 1077 for(int i = input.length; i < output.length; i++) { 1078 Assert.assertEquals(output[i], (int)0); 1079 } 1080 } 1081 1082 @ForceInline 1083 static <S extends Vector.Shape, T extends Vector.Shape> 1084 void testVectorCastFloatToInt(FloatVector.FloatSpecies<S> a, IntVector.IntSpecies<T> b, float[] input, int[] output) { 1085 assert(input.length == a.length()); 1086 assert(output.length == b.length()); 1087 1088 FloatVector<S> av = a.fromArray(input, 0); 1089 IntVector<T> bv = b.cast(av); 1090 bv.intoArray(output, 0); 1091 1092 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1093 Assert.assertEquals(output[i], (int)input[i]); 1094 } 1095 for(int i = input.length; i < output.length; i++) { 1096 Assert.assertEquals(output[i], (int)0); 1097 } 1098 } 1099 1100 @ForceInline 1101 static <S extends Vector.Shape, T extends Vector.Shape> 1102 void testVectorCastDoubleToInt(DoubleVector.DoubleSpecies<S> a, IntVector.IntSpecies<T> b, double[] input, int[] output) { 1103 assert(input.length == a.length()); 1104 assert(output.length == b.length()); 1105 1106 DoubleVector<S> av = a.fromArray(input, 0); 1107 IntVector<T> bv = b.cast(av); 1108 bv.intoArray(output, 0); 1109 1110 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1111 Assert.assertEquals(output[i], (int)input[i]); 1112 } 1113 for(int i = input.length; i < output.length; i++) { 1114 Assert.assertEquals(output[i], (int)0); 1115 } 1116 } 1117 1118 @ForceInline 1119 static <S extends Vector.Shape, T extends Vector.Shape> 1120 void testVectorCastByteToLong(ByteVector.ByteSpecies<S> a, LongVector.LongSpecies<T> b, byte[] input, long[] output) { 1121 assert(input.length == a.length()); 1122 assert(output.length == b.length()); 1123 1124 ByteVector<S> av = a.fromArray(input, 0); 1125 LongVector<T> bv = b.cast(av); 1126 bv.intoArray(output, 0); 1127 1128 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1129 Assert.assertEquals(output[i], (long)input[i]); 1130 } 1131 for(int i = input.length; i < output.length; i++) { 1132 Assert.assertEquals(output[i], (long)0); 1133 } 1134 } 1135 1136 @ForceInline 1137 static <S extends Vector.Shape, T extends Vector.Shape> 1138 void testVectorCastShortToLong(ShortVector.ShortSpecies<S> a, LongVector.LongSpecies<T> b, short[] input, long[] output) { 1139 assert(input.length == a.length()); 1140 assert(output.length == b.length()); 1141 1142 ShortVector<S> av = a.fromArray(input, 0); 1143 LongVector<T> bv = b.cast(av); 1144 bv.intoArray(output, 0); 1145 1146 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1147 Assert.assertEquals(output[i], (long)input[i]); 1148 } 1149 for(int i = input.length; i < output.length; i++) { 1150 Assert.assertEquals(output[i], (long)0); 1151 } 1152 } 1153 1154 @ForceInline 1155 static <S extends Vector.Shape, T extends Vector.Shape> 1156 void testVectorCastIntToLong(IntVector.IntSpecies<S> a, LongVector.LongSpecies<T> b, int[] input, long[] output) { 1157 assert(input.length == a.length()); 1158 assert(output.length == b.length()); 1159 1160 IntVector<S> av = a.fromArray(input, 0); 1161 LongVector<T> bv = b.cast(av); 1162 bv.intoArray(output, 0); 1163 1164 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1165 Assert.assertEquals(output[i], (long)input[i]); 1166 } 1167 for(int i = input.length; i < output.length; i++) { 1168 Assert.assertEquals(output[i], (long)0); 1169 } 1170 } 1171 1172 @ForceInline 1173 static <S extends Vector.Shape, T extends Vector.Shape> 1174 void testVectorCastLongToLong(LongVector.LongSpecies<S> a, LongVector.LongSpecies<T> b, long[] input, long[] output) { 1175 assert(input.length == a.length()); 1176 assert(output.length == b.length()); 1177 1178 LongVector<S> av = a.fromArray(input, 0); 1179 LongVector<T> bv = b.cast(av); 1180 bv.intoArray(output, 0); 1181 1182 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1183 Assert.assertEquals(output[i], (long)input[i]); 1184 } 1185 for(int i = input.length; i < output.length; i++) { 1186 Assert.assertEquals(output[i], (long)0); 1187 } 1188 } 1189 1190 @ForceInline 1191 static <S extends Vector.Shape, T extends Vector.Shape> 1192 void testVectorCastFloatToLong(FloatVector.FloatSpecies<S> a, LongVector.LongSpecies<T> b, float[] input, long[] output) { 1193 assert(input.length == a.length()); 1194 assert(output.length == b.length()); 1195 1196 FloatVector<S> av = a.fromArray(input, 0); 1197 LongVector<T> bv = b.cast(av); 1198 bv.intoArray(output, 0); 1199 1200 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1201 Assert.assertEquals(output[i], (long)input[i]); 1202 } 1203 for(int i = input.length; i < output.length; i++) { 1204 Assert.assertEquals(output[i], (long)0); 1205 } 1206 } 1207 1208 @ForceInline 1209 static <S extends Vector.Shape, T extends Vector.Shape> 1210 void testVectorCastDoubleToLong(DoubleVector.DoubleSpecies<S> a, LongVector.LongSpecies<T> b, double[] input, long[] output) { 1211 assert(input.length == a.length()); 1212 assert(output.length == b.length()); 1213 1214 DoubleVector<S> av = a.fromArray(input, 0); 1215 LongVector<T> bv = b.cast(av); 1216 bv.intoArray(output, 0); 1217 1218 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1219 Assert.assertEquals(output[i], (long)input[i]); 1220 } 1221 for(int i = input.length; i < output.length; i++) { 1222 Assert.assertEquals(output[i], (long)0); 1223 } 1224 } 1225 1226 @ForceInline 1227 static <S extends Vector.Shape, T extends Vector.Shape> 1228 void testVectorCastByteToDouble(ByteVector.ByteSpecies<S> a, DoubleVector.DoubleSpecies<T> b, byte[] input, double[] output) { 1229 assert(input.length == a.length()); 1230 assert(output.length == b.length()); 1231 1232 ByteVector<S> av = a.fromArray(input, 0); 1233 DoubleVector<T> bv = b.cast(av); 1234 bv.intoArray(output, 0); 1235 1236 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1237 Assert.assertEquals(output[i], (double)input[i]); 1238 } 1239 for(int i = input.length; i < output.length; i++) { 1240 Assert.assertEquals(output[i], (double)0); 1241 } 1242 } 1243 1244 @ForceInline 1245 static <S extends Vector.Shape, T extends Vector.Shape> 1246 void testVectorCastShortToDouble(ShortVector.ShortSpecies<S> a, DoubleVector.DoubleSpecies<T> b, short[] input, double[] output) { 1247 assert(input.length == a.length()); 1248 assert(output.length == b.length()); 1249 1250 ShortVector<S> av = a.fromArray(input, 0); 1251 DoubleVector<T> bv = b.cast(av); 1252 bv.intoArray(output, 0); 1253 1254 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1255 Assert.assertEquals(output[i], (double)input[i]); 1256 } 1257 for(int i = input.length; i < output.length; i++) { 1258 Assert.assertEquals(output[i], (double)0); 1259 } 1260 } 1261 1262 @ForceInline 1263 static <S extends Vector.Shape, T extends Vector.Shape> 1264 void testVectorCastIntToDouble(IntVector.IntSpecies<S> a, DoubleVector.DoubleSpecies<T> b, int[] input, double[] output) { 1265 assert(input.length == a.length()); 1266 assert(output.length == b.length()); 1267 1268 IntVector<S> av = a.fromArray(input, 0); 1269 DoubleVector<T> bv = b.cast(av); 1270 bv.intoArray(output, 0); 1271 1272 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1273 Assert.assertEquals(output[i], (double)input[i]); 1274 } 1275 for(int i = input.length; i < output.length; i++) { 1276 Assert.assertEquals(output[i], (double)0); 1277 } 1278 } 1279 1280 @ForceInline 1281 static <S extends Vector.Shape, T extends Vector.Shape> 1282 void testVectorCastLongToDouble(LongVector.LongSpecies<S> a, DoubleVector.DoubleSpecies<T> b, long[] input, double[] output) { 1283 assert(input.length == a.length()); 1284 assert(output.length == b.length()); 1285 1286 LongVector<S> av = a.fromArray(input, 0); 1287 DoubleVector<T> bv = b.cast(av); 1288 bv.intoArray(output, 0); 1289 1290 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1291 Assert.assertEquals(output[i], (double)input[i]); 1292 } 1293 for(int i = input.length; i < output.length; i++) { 1294 Assert.assertEquals(output[i], (double)0); 1295 } 1296 } 1297 1298 @ForceInline 1299 static <S extends Vector.Shape, T extends Vector.Shape> 1300 void testVectorCastFloatToDouble(FloatVector.FloatSpecies<S> a, DoubleVector.DoubleSpecies<T> b, float[] input, double[] output) { 1301 assert(input.length == a.length()); 1302 assert(output.length == b.length()); 1303 1304 FloatVector<S> av = a.fromArray(input, 0); 1305 DoubleVector<T> bv = b.cast(av); 1306 bv.intoArray(output, 0); 1307 1308 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1309 Assert.assertEquals(output[i], (double)input[i]); 1310 } 1311 for(int i = input.length; i < output.length; i++) { 1312 Assert.assertEquals(output[i], (double)0); 1313 } 1314 } 1315 1316 @ForceInline 1317 static <S extends Vector.Shape, T extends Vector.Shape> 1318 void testVectorCastDoubleToDouble(DoubleVector.DoubleSpecies<S> a, DoubleVector.DoubleSpecies<T> b, double[] input, double[] output) { 1319 assert(input.length == a.length()); 1320 assert(output.length == b.length()); 1321 1322 DoubleVector<S> av = a.fromArray(input, 0); 1323 DoubleVector<T> bv = b.cast(av); 1324 bv.intoArray(output, 0); 1325 1326 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1327 Assert.assertEquals(output[i], (double)input[i]); 1328 } 1329 for(int i = input.length; i < output.length; i++) { 1330 Assert.assertEquals(output[i], (double)0); 1331 } 1332 } 1333 1334 @Test(dataProvider = "byteUnaryOpProvider") 1335 static void testCastFromByte(IntFunction<byte[]> fa) { 1336 byte[] bin64 = fa.apply(bspec64.length()); 1337 byte[] bin128 = fa.apply(bspec128.length()); 1338 byte[] bin256 = fa.apply(bspec256.length()); 1339 byte[] bin512 = fa.apply(bspec512.length()); 1340 1341 byte[] bout64 = new byte[bspec64.length()]; 1342 byte[] bout128 = new byte[bspec128.length()]; 1343 byte[] bout256 = new byte[bspec256.length()]; 1344 byte[] bout512 = new byte[bspec512.length()]; 1345 1346 short[] sout64 = new short[sspec64.length()]; 1347 short[] sout128 = new short[sspec128.length()]; 1348 short[] sout256 = new short[sspec256.length()]; 1349 short[] sout512 = new short[sspec512.length()]; 1350 1351 int[] iout64 = new int[ispec64.length()]; 1352 int[] iout128 = new int[ispec128.length()]; 1353 int[] iout256 = new int[ispec256.length()]; 1354 int[] iout512 = new int[ispec512.length()]; 1355 1356 long[] lout64 = new long[lspec64.length()]; 1357 long[] lout128 = new long[lspec128.length()]; 1358 long[] lout256 = new long[lspec256.length()]; 1359 long[] lout512 = new long[lspec512.length()]; 1360 1361 float[] fout64 = new float[fspec64.length()]; 1362 float[] fout128 = new float[fspec128.length()]; 1363 float[] fout256 = new float[fspec256.length()]; 1364 float[] fout512 = new float[fspec512.length()]; 1365 1366 double[] dout64 = new double[dspec64.length()]; 1367 double[] dout128 = new double[dspec128.length()]; 1368 double[] dout256 = new double[dspec256.length()]; 1369 double[] dout512 = new double[dspec512.length()]; 1370 1371 for (int i = 0; i < NUM_ITER; i++) { 1372 testVectorCastByteToByte(bspec64, bspec64, bin64, bout64); 1373 testVectorCastByteToByte(bspec64, bspec128, bin64, bout128); 1374 testVectorCastByteToByte(bspec64, bspec256, bin64, bout256); 1375 testVectorCastByteToByte(bspec64, bspec512, bin64, bout512); 1376 1377 testVectorCastByteToByte(bspec128, bspec64, bin128, bout64); 1378 testVectorCastByteToByte(bspec128, bspec128, bin128, bout128); 1379 testVectorCastByteToByte(bspec128, bspec256, bin128, bout256); 1380 testVectorCastByteToByte(bspec128, bspec512, bin128, bout512); 1381 1382 testVectorCastByteToByte(bspec256, bspec64, bin256, bout64); 1383 testVectorCastByteToByte(bspec256, bspec128, bin256, bout128); 1384 testVectorCastByteToByte(bspec256, bspec256, bin256, bout256); 1385 testVectorCastByteToByte(bspec256, bspec512, bin256, bout512); 1386 1387 testVectorCastByteToByte(bspec512, bspec64, bin512, bout64); 1388 testVectorCastByteToByte(bspec512, bspec128, bin512, bout128); 1389 testVectorCastByteToByte(bspec512, bspec256, bin512, bout256); 1390 testVectorCastByteToByte(bspec512, bspec512, bin512, bout512); 1391 1392 testVectorCastByteToShort(bspec64, sspec64, bin64, sout64); 1393 testVectorCastByteToShort(bspec64, sspec128, bin64, sout128); 1394 testVectorCastByteToShort(bspec64, sspec256, bin64, sout256); 1395 testVectorCastByteToShort(bspec64, sspec512, bin64, sout512); 1396 1397 testVectorCastByteToShort(bspec128, sspec64, bin128, sout64); 1398 testVectorCastByteToShort(bspec128, sspec128, bin128, sout128); 1399 testVectorCastByteToShort(bspec128, sspec256, bin128, sout256); 1400 testVectorCastByteToShort(bspec128, sspec512, bin128, sout512); 1401 1402 testVectorCastByteToShort(bspec256, sspec64, bin256, sout64); 1403 testVectorCastByteToShort(bspec256, sspec128, bin256, sout128); 1404 testVectorCastByteToShort(bspec256, sspec256, bin256, sout256); 1405 testVectorCastByteToShort(bspec256, sspec512, bin256, sout512); 1406 1407 testVectorCastByteToShort(bspec512, sspec64, bin512, sout64); 1408 testVectorCastByteToShort(bspec512, sspec128, bin512, sout128); 1409 testVectorCastByteToShort(bspec512, sspec256, bin512, sout256); 1410 testVectorCastByteToShort(bspec512, sspec512, bin512, sout512); 1411 1412 testVectorCastByteToInt(bspec64, ispec64, bin64, iout64); 1413 testVectorCastByteToInt(bspec64, ispec128, bin64, iout128); 1414 testVectorCastByteToInt(bspec64, ispec256, bin64, iout256); 1415 testVectorCastByteToInt(bspec64, ispec512, bin64, iout512); 1416 1417 testVectorCastByteToInt(bspec128, ispec64, bin128, iout64); 1418 testVectorCastByteToInt(bspec128, ispec128, bin128, iout128); 1419 testVectorCastByteToInt(bspec128, ispec256, bin128, iout256); 1420 testVectorCastByteToInt(bspec128, ispec512, bin128, iout512); 1421 1422 testVectorCastByteToInt(bspec256, ispec64, bin256, iout64); 1423 testVectorCastByteToInt(bspec256, ispec128, bin256, iout128); 1424 testVectorCastByteToInt(bspec256, ispec256, bin256, iout256); 1425 testVectorCastByteToInt(bspec256, ispec512, bin256, iout512); 1426 1427 testVectorCastByteToInt(bspec512, ispec64, bin512, iout64); 1428 testVectorCastByteToInt(bspec512, ispec128, bin512, iout128); 1429 testVectorCastByteToInt(bspec512, ispec256, bin512, iout256); 1430 testVectorCastByteToInt(bspec512, ispec512, bin512, iout512); 1431 1432 testVectorCastByteToLong(bspec64, lspec64, bin64, lout64); 1433 testVectorCastByteToLong(bspec64, lspec128, bin64, lout128); 1434 testVectorCastByteToLong(bspec64, lspec256, bin64, lout256); 1435 testVectorCastByteToLong(bspec64, lspec512, bin64, lout512); 1436 1437 testVectorCastByteToLong(bspec128, lspec64, bin128, lout64); 1438 testVectorCastByteToLong(bspec128, lspec128, bin128, lout128); 1439 testVectorCastByteToLong(bspec128, lspec256, bin128, lout256); 1440 testVectorCastByteToLong(bspec128, lspec512, bin128, lout512); 1441 1442 testVectorCastByteToLong(bspec256, lspec64, bin256, lout64); 1443 testVectorCastByteToLong(bspec256, lspec128, bin256, lout128); 1444 testVectorCastByteToLong(bspec256, lspec256, bin256, lout256); 1445 testVectorCastByteToLong(bspec256, lspec512, bin256, lout512); 1446 1447 testVectorCastByteToLong(bspec512, lspec64, bin512, lout64); 1448 testVectorCastByteToLong(bspec512, lspec128, bin512, lout128); 1449 testVectorCastByteToLong(bspec512, lspec256, bin512, lout256); 1450 testVectorCastByteToLong(bspec512, lspec512, bin512, lout512); 1451 1452 testVectorCastByteToFloat(bspec64, fspec64, bin64, fout64); 1453 testVectorCastByteToFloat(bspec64, fspec128, bin64, fout128); 1454 testVectorCastByteToFloat(bspec64, fspec256, bin64, fout256); 1455 testVectorCastByteToFloat(bspec64, fspec512, bin64, fout512); 1456 1457 testVectorCastByteToFloat(bspec128, fspec64, bin128, fout64); 1458 testVectorCastByteToFloat(bspec128, fspec128, bin128, fout128); 1459 testVectorCastByteToFloat(bspec128, fspec256, bin128, fout256); 1460 testVectorCastByteToFloat(bspec128, fspec512, bin128, fout512); 1461 1462 testVectorCastByteToFloat(bspec256, fspec64, bin256, fout64); 1463 testVectorCastByteToFloat(bspec256, fspec128, bin256, fout128); 1464 testVectorCastByteToFloat(bspec256, fspec256, bin256, fout256); 1465 testVectorCastByteToFloat(bspec256, fspec512, bin256, fout512); 1466 1467 testVectorCastByteToFloat(bspec512, fspec64, bin512, fout64); 1468 testVectorCastByteToFloat(bspec512, fspec128, bin512, fout128); 1469 testVectorCastByteToFloat(bspec512, fspec256, bin512, fout256); 1470 testVectorCastByteToFloat(bspec512, fspec512, bin512, fout512); 1471 1472 testVectorCastByteToDouble(bspec64, dspec64, bin64, dout64); 1473 testVectorCastByteToDouble(bspec64, dspec128, bin64, dout128); 1474 testVectorCastByteToDouble(bspec64, dspec256, bin64, dout256); 1475 testVectorCastByteToDouble(bspec64, dspec512, bin64, dout512); 1476 1477 testVectorCastByteToDouble(bspec128, dspec64, bin128, dout64); 1478 testVectorCastByteToDouble(bspec128, dspec128, bin128, dout128); 1479 testVectorCastByteToDouble(bspec128, dspec256, bin128, dout256); 1480 testVectorCastByteToDouble(bspec128, dspec512, bin128, dout512); 1481 1482 testVectorCastByteToDouble(bspec256, dspec64, bin256, dout64); 1483 testVectorCastByteToDouble(bspec256, dspec128, bin256, dout128); 1484 testVectorCastByteToDouble(bspec256, dspec256, bin256, dout256); 1485 testVectorCastByteToDouble(bspec256, dspec512, bin256, dout512); 1486 1487 testVectorCastByteToDouble(bspec512, dspec64, bin512, dout64); 1488 testVectorCastByteToDouble(bspec512, dspec128, bin512, dout128); 1489 testVectorCastByteToDouble(bspec512, dspec256, bin512, dout256); 1490 testVectorCastByteToDouble(bspec512, dspec512, bin512, dout512); 1491 } 1492 } 1493 1494 @Test(dataProvider = "shortUnaryOpProvider") 1495 static void testCastFromShort(IntFunction<short[]> fa) { 1496 short[] sin64 = fa.apply(sspec64.length()); 1497 short[] sin128 = fa.apply(sspec128.length()); 1498 short[] sin256 = fa.apply(sspec256.length()); 1499 short[] sin512 = fa.apply(sspec512.length()); 1500 1501 byte[] bout64 = new byte[bspec64.length()]; 1502 byte[] bout128 = new byte[bspec128.length()]; 1503 byte[] bout256 = new byte[bspec256.length()]; 1504 byte[] bout512 = new byte[bspec512.length()]; 1505 1506 short[] sout64 = new short[sspec64.length()]; 1507 short[] sout128 = new short[sspec128.length()]; 1508 short[] sout256 = new short[sspec256.length()]; 1509 short[] sout512 = new short[sspec512.length()]; 1510 1511 int[] iout64 = new int[ispec64.length()]; 1512 int[] iout128 = new int[ispec128.length()]; 1513 int[] iout256 = new int[ispec256.length()]; 1514 int[] iout512 = new int[ispec512.length()]; 1515 1516 long[] lout64 = new long[lspec64.length()]; 1517 long[] lout128 = new long[lspec128.length()]; 1518 long[] lout256 = new long[lspec256.length()]; 1519 long[] lout512 = new long[lspec512.length()]; 1520 1521 float[] fout64 = new float[fspec64.length()]; 1522 float[] fout128 = new float[fspec128.length()]; 1523 float[] fout256 = new float[fspec256.length()]; 1524 float[] fout512 = new float[fspec512.length()]; 1525 1526 double[] dout64 = new double[dspec64.length()]; 1527 double[] dout128 = new double[dspec128.length()]; 1528 double[] dout256 = new double[dspec256.length()]; 1529 double[] dout512 = new double[dspec512.length()]; 1530 1531 for (int i = 0; i < NUM_ITER; i++) { 1532 testVectorCastShortToByte(sspec64, bspec64, sin64, bout64); 1533 testVectorCastShortToByte(sspec64, bspec128, sin64, bout128); 1534 testVectorCastShortToByte(sspec64, bspec256, sin64, bout256); 1535 testVectorCastShortToByte(sspec64, bspec512, sin64, bout512); 1536 1537 testVectorCastShortToByte(sspec128, bspec64, sin128, bout64); 1538 testVectorCastShortToByte(sspec128, bspec128, sin128, bout128); 1539 testVectorCastShortToByte(sspec128, bspec256, sin128, bout256); 1540 testVectorCastShortToByte(sspec128, bspec512, sin128, bout512); 1541 1542 testVectorCastShortToByte(sspec256, bspec64, sin256, bout64); 1543 testVectorCastShortToByte(sspec256, bspec128, sin256, bout128); 1544 testVectorCastShortToByte(sspec256, bspec256, sin256, bout256); 1545 testVectorCastShortToByte(sspec256, bspec512, sin256, bout512); 1546 1547 testVectorCastShortToByte(sspec512, bspec64, sin512, bout64); 1548 testVectorCastShortToByte(sspec512, bspec128, sin512, bout128); 1549 testVectorCastShortToByte(sspec512, bspec256, sin512, bout256); 1550 testVectorCastShortToByte(sspec512, bspec512, sin512, bout512); 1551 1552 testVectorCastShortToShort(sspec64, sspec64, sin64, sout64); 1553 testVectorCastShortToShort(sspec64, sspec128, sin64, sout128); 1554 testVectorCastShortToShort(sspec64, sspec256, sin64, sout256); 1555 testVectorCastShortToShort(sspec64, sspec512, sin64, sout512); 1556 1557 testVectorCastShortToShort(sspec128, sspec64, sin128, sout64); 1558 testVectorCastShortToShort(sspec128, sspec128, sin128, sout128); 1559 testVectorCastShortToShort(sspec128, sspec256, sin128, sout256); 1560 testVectorCastShortToShort(sspec128, sspec512, sin128, sout512); 1561 1562 testVectorCastShortToShort(sspec256, sspec64, sin256, sout64); 1563 testVectorCastShortToShort(sspec256, sspec128, sin256, sout128); 1564 testVectorCastShortToShort(sspec256, sspec256, sin256, sout256); 1565 testVectorCastShortToShort(sspec256, sspec512, sin256, sout512); 1566 1567 testVectorCastShortToShort(sspec512, sspec64, sin512, sout64); 1568 testVectorCastShortToShort(sspec512, sspec128, sin512, sout128); 1569 testVectorCastShortToShort(sspec512, sspec256, sin512, sout256); 1570 testVectorCastShortToShort(sspec512, sspec512, sin512, sout512); 1571 1572 testVectorCastShortToInt(sspec64, ispec64, sin64, iout64); 1573 testVectorCastShortToInt(sspec64, ispec128, sin64, iout128); 1574 testVectorCastShortToInt(sspec64, ispec256, sin64, iout256); 1575 testVectorCastShortToInt(sspec64, ispec512, sin64, iout512); 1576 1577 testVectorCastShortToInt(sspec128, ispec64, sin128, iout64); 1578 testVectorCastShortToInt(sspec128, ispec128, sin128, iout128); 1579 testVectorCastShortToInt(sspec128, ispec256, sin128, iout256); 1580 testVectorCastShortToInt(sspec128, ispec512, sin128, iout512); 1581 1582 testVectorCastShortToInt(sspec256, ispec64, sin256, iout64); 1583 testVectorCastShortToInt(sspec256, ispec128, sin256, iout128); 1584 testVectorCastShortToInt(sspec256, ispec256, sin256, iout256); 1585 testVectorCastShortToInt(sspec256, ispec512, sin256, iout512); 1586 1587 testVectorCastShortToInt(sspec512, ispec64, sin512, iout64); 1588 testVectorCastShortToInt(sspec512, ispec128, sin512, iout128); 1589 testVectorCastShortToInt(sspec512, ispec256, sin512, iout256); 1590 testVectorCastShortToInt(sspec512, ispec512, sin512, iout512); 1591 1592 testVectorCastShortToLong(sspec64, lspec64, sin64, lout64); 1593 testVectorCastShortToLong(sspec64, lspec128, sin64, lout128); 1594 testVectorCastShortToLong(sspec64, lspec256, sin64, lout256); 1595 testVectorCastShortToLong(sspec64, lspec512, sin64, lout512); 1596 1597 testVectorCastShortToLong(sspec128, lspec64, sin128, lout64); 1598 testVectorCastShortToLong(sspec128, lspec128, sin128, lout128); 1599 testVectorCastShortToLong(sspec128, lspec256, sin128, lout256); 1600 testVectorCastShortToLong(sspec128, lspec512, sin128, lout512); 1601 1602 testVectorCastShortToLong(sspec256, lspec64, sin256, lout64); 1603 testVectorCastShortToLong(sspec256, lspec128, sin256, lout128); 1604 testVectorCastShortToLong(sspec256, lspec256, sin256, lout256); 1605 testVectorCastShortToLong(sspec256, lspec512, sin256, lout512); 1606 1607 testVectorCastShortToLong(sspec512, lspec64, sin512, lout64); 1608 testVectorCastShortToLong(sspec512, lspec128, sin512, lout128); 1609 testVectorCastShortToLong(sspec512, lspec256, sin512, lout256); 1610 testVectorCastShortToLong(sspec512, lspec512, sin512, lout512); 1611 1612 testVectorCastShortToFloat(sspec64, fspec64, sin64, fout64); 1613 testVectorCastShortToFloat(sspec64, fspec128, sin64, fout128); 1614 testVectorCastShortToFloat(sspec64, fspec256, sin64, fout256); 1615 testVectorCastShortToFloat(sspec64, fspec512, sin64, fout512); 1616 1617 testVectorCastShortToFloat(sspec128, fspec64, sin128, fout64); 1618 testVectorCastShortToFloat(sspec128, fspec128, sin128, fout128); 1619 testVectorCastShortToFloat(sspec128, fspec256, sin128, fout256); 1620 testVectorCastShortToFloat(sspec128, fspec512, sin128, fout512); 1621 1622 testVectorCastShortToFloat(sspec256, fspec64, sin256, fout64); 1623 testVectorCastShortToFloat(sspec256, fspec128, sin256, fout128); 1624 testVectorCastShortToFloat(sspec256, fspec256, sin256, fout256); 1625 testVectorCastShortToFloat(sspec256, fspec512, sin256, fout512); 1626 1627 testVectorCastShortToFloat(sspec512, fspec64, sin512, fout64); 1628 testVectorCastShortToFloat(sspec512, fspec128, sin512, fout128); 1629 testVectorCastShortToFloat(sspec512, fspec256, sin512, fout256); 1630 testVectorCastShortToFloat(sspec512, fspec512, sin512, fout512); 1631 1632 testVectorCastShortToDouble(sspec64, dspec64, sin64, dout64); 1633 testVectorCastShortToDouble(sspec64, dspec128, sin64, dout128); 1634 testVectorCastShortToDouble(sspec64, dspec256, sin64, dout256); 1635 testVectorCastShortToDouble(sspec64, dspec512, sin64, dout512); 1636 1637 testVectorCastShortToDouble(sspec128, dspec64, sin128, dout64); 1638 testVectorCastShortToDouble(sspec128, dspec128, sin128, dout128); 1639 testVectorCastShortToDouble(sspec128, dspec256, sin128, dout256); 1640 testVectorCastShortToDouble(sspec128, dspec512, sin128, dout512); 1641 1642 testVectorCastShortToDouble(sspec256, dspec64, sin256, dout64); 1643 testVectorCastShortToDouble(sspec256, dspec128, sin256, dout128); 1644 testVectorCastShortToDouble(sspec256, dspec256, sin256, dout256); 1645 testVectorCastShortToDouble(sspec256, dspec512, sin256, dout512); 1646 1647 testVectorCastShortToDouble(sspec512, dspec64, sin512, dout64); 1648 testVectorCastShortToDouble(sspec512, dspec128, sin512, dout128); 1649 testVectorCastShortToDouble(sspec512, dspec256, sin512, dout256); 1650 testVectorCastShortToDouble(sspec512, dspec512, sin512, dout512); 1651 } 1652 } 1653 1654 @Test(dataProvider = "intUnaryOpProvider") 1655 static void testCastFromInt(IntFunction<int[]> fa) { 1656 int[] iin64 = fa.apply(ispec64.length()); 1657 int[] iin128 = fa.apply(ispec128.length()); 1658 int[] iin256 = fa.apply(ispec256.length()); 1659 int[] iin512 = fa.apply(ispec512.length()); 1660 1661 byte[] bout64 = new byte[bspec64.length()]; 1662 byte[] bout128 = new byte[bspec128.length()]; 1663 byte[] bout256 = new byte[bspec256.length()]; 1664 byte[] bout512 = new byte[bspec512.length()]; 1665 1666 short[] sout64 = new short[sspec64.length()]; 1667 short[] sout128 = new short[sspec128.length()]; 1668 short[] sout256 = new short[sspec256.length()]; 1669 short[] sout512 = new short[sspec512.length()]; 1670 1671 int[] iout64 = new int[ispec64.length()]; 1672 int[] iout128 = new int[ispec128.length()]; 1673 int[] iout256 = new int[ispec256.length()]; 1674 int[] iout512 = new int[ispec512.length()]; 1675 1676 long[] lout64 = new long[lspec64.length()]; 1677 long[] lout128 = new long[lspec128.length()]; 1678 long[] lout256 = new long[lspec256.length()]; 1679 long[] lout512 = new long[lspec512.length()]; 1680 1681 float[] fout64 = new float[fspec64.length()]; 1682 float[] fout128 = new float[fspec128.length()]; 1683 float[] fout256 = new float[fspec256.length()]; 1684 float[] fout512 = new float[fspec512.length()]; 1685 1686 double[] dout64 = new double[dspec64.length()]; 1687 double[] dout128 = new double[dspec128.length()]; 1688 double[] dout256 = new double[dspec256.length()]; 1689 double[] dout512 = new double[dspec512.length()]; 1690 1691 for (int i = 0; i < NUM_ITER; i++) { 1692 testVectorCastIntToByte(ispec64, bspec64, iin64, bout64); 1693 testVectorCastIntToByte(ispec64, bspec128, iin64, bout128); 1694 testVectorCastIntToByte(ispec64, bspec256, iin64, bout256); 1695 testVectorCastIntToByte(ispec64, bspec512, iin64, bout512); 1696 1697 testVectorCastIntToByte(ispec128, bspec64, iin128, bout64); 1698 testVectorCastIntToByte(ispec128, bspec128, iin128, bout128); 1699 testVectorCastIntToByte(ispec128, bspec256, iin128, bout256); 1700 testVectorCastIntToByte(ispec128, bspec512, iin128, bout512); 1701 1702 testVectorCastIntToByte(ispec256, bspec64, iin256, bout64); 1703 testVectorCastIntToByte(ispec256, bspec128, iin256, bout128); 1704 testVectorCastIntToByte(ispec256, bspec256, iin256, bout256); 1705 testVectorCastIntToByte(ispec256, bspec512, iin256, bout512); 1706 1707 testVectorCastIntToByte(ispec512, bspec64, iin512, bout64); 1708 testVectorCastIntToByte(ispec512, bspec128, iin512, bout128); 1709 testVectorCastIntToByte(ispec512, bspec256, iin512, bout256); 1710 testVectorCastIntToByte(ispec512, bspec512, iin512, bout512); 1711 1712 testVectorCastIntToShort(ispec64, sspec64, iin64, sout64); 1713 testVectorCastIntToShort(ispec64, sspec128, iin64, sout128); 1714 testVectorCastIntToShort(ispec64, sspec256, iin64, sout256); 1715 testVectorCastIntToShort(ispec64, sspec512, iin64, sout512); 1716 1717 testVectorCastIntToShort(ispec128, sspec64, iin128, sout64); 1718 testVectorCastIntToShort(ispec128, sspec128, iin128, sout128); 1719 testVectorCastIntToShort(ispec128, sspec256, iin128, sout256); 1720 testVectorCastIntToShort(ispec128, sspec512, iin128, sout512); 1721 1722 testVectorCastIntToShort(ispec256, sspec64, iin256, sout64); 1723 testVectorCastIntToShort(ispec256, sspec128, iin256, sout128); 1724 testVectorCastIntToShort(ispec256, sspec256, iin256, sout256); 1725 testVectorCastIntToShort(ispec256, sspec512, iin256, sout512); 1726 1727 testVectorCastIntToShort(ispec512, sspec64, iin512, sout64); 1728 testVectorCastIntToShort(ispec512, sspec128, iin512, sout128); 1729 testVectorCastIntToShort(ispec512, sspec256, iin512, sout256); 1730 testVectorCastIntToShort(ispec512, sspec512, iin512, sout512); 1731 1732 testVectorCastIntToInt(ispec64, ispec64, iin64, iout64); 1733 testVectorCastIntToInt(ispec64, ispec128, iin64, iout128); 1734 testVectorCastIntToInt(ispec64, ispec256, iin64, iout256); 1735 testVectorCastIntToInt(ispec64, ispec512, iin64, iout512); 1736 1737 testVectorCastIntToInt(ispec128, ispec64, iin128, iout64); 1738 testVectorCastIntToInt(ispec128, ispec128, iin128, iout128); 1739 testVectorCastIntToInt(ispec128, ispec256, iin128, iout256); 1740 testVectorCastIntToInt(ispec128, ispec512, iin128, iout512); 1741 1742 testVectorCastIntToInt(ispec256, ispec64, iin256, iout64); 1743 testVectorCastIntToInt(ispec256, ispec128, iin256, iout128); 1744 testVectorCastIntToInt(ispec256, ispec256, iin256, iout256); 1745 testVectorCastIntToInt(ispec256, ispec512, iin256, iout512); 1746 1747 testVectorCastIntToInt(ispec512, ispec64, iin512, iout64); 1748 testVectorCastIntToInt(ispec512, ispec128, iin512, iout128); 1749 testVectorCastIntToInt(ispec512, ispec256, iin512, iout256); 1750 testVectorCastIntToInt(ispec512, ispec512, iin512, iout512); 1751 1752 testVectorCastIntToLong(ispec64, lspec64, iin64, lout64); 1753 testVectorCastIntToLong(ispec64, lspec128, iin64, lout128); 1754 testVectorCastIntToLong(ispec64, lspec256, iin64, lout256); 1755 testVectorCastIntToLong(ispec64, lspec512, iin64, lout512); 1756 1757 testVectorCastIntToLong(ispec128, lspec64, iin128, lout64); 1758 testVectorCastIntToLong(ispec128, lspec128, iin128, lout128); 1759 testVectorCastIntToLong(ispec128, lspec256, iin128, lout256); 1760 testVectorCastIntToLong(ispec128, lspec512, iin128, lout512); 1761 1762 testVectorCastIntToLong(ispec256, lspec64, iin256, lout64); 1763 testVectorCastIntToLong(ispec256, lspec128, iin256, lout128); 1764 testVectorCastIntToLong(ispec256, lspec256, iin256, lout256); 1765 testVectorCastIntToLong(ispec256, lspec512, iin256, lout512); 1766 1767 testVectorCastIntToLong(ispec512, lspec64, iin512, lout64); 1768 testVectorCastIntToLong(ispec512, lspec128, iin512, lout128); 1769 testVectorCastIntToLong(ispec512, lspec256, iin512, lout256); 1770 testVectorCastIntToLong(ispec512, lspec512, iin512, lout512); 1771 1772 testVectorCastIntToFloat(ispec64, fspec64, iin64, fout64); 1773 testVectorCastIntToFloat(ispec64, fspec128, iin64, fout128); 1774 testVectorCastIntToFloat(ispec64, fspec256, iin64, fout256); 1775 testVectorCastIntToFloat(ispec64, fspec512, iin64, fout512); 1776 1777 testVectorCastIntToFloat(ispec128, fspec64, iin128, fout64); 1778 testVectorCastIntToFloat(ispec128, fspec128, iin128, fout128); 1779 testVectorCastIntToFloat(ispec128, fspec256, iin128, fout256); 1780 testVectorCastIntToFloat(ispec128, fspec512, iin128, fout512); 1781 1782 testVectorCastIntToFloat(ispec256, fspec64, iin256, fout64); 1783 testVectorCastIntToFloat(ispec256, fspec128, iin256, fout128); 1784 testVectorCastIntToFloat(ispec256, fspec256, iin256, fout256); 1785 testVectorCastIntToFloat(ispec256, fspec512, iin256, fout512); 1786 1787 testVectorCastIntToFloat(ispec512, fspec64, iin512, fout64); 1788 testVectorCastIntToFloat(ispec512, fspec128, iin512, fout128); 1789 testVectorCastIntToFloat(ispec512, fspec256, iin512, fout256); 1790 testVectorCastIntToFloat(ispec512, fspec512, iin512, fout512); 1791 1792 testVectorCastIntToDouble(ispec64, dspec64, iin64, dout64); 1793 testVectorCastIntToDouble(ispec64, dspec128, iin64, dout128); 1794 testVectorCastIntToDouble(ispec64, dspec256, iin64, dout256); 1795 testVectorCastIntToDouble(ispec64, dspec512, iin64, dout512); 1796 1797 testVectorCastIntToDouble(ispec128, dspec64, iin128, dout64); 1798 testVectorCastIntToDouble(ispec128, dspec128, iin128, dout128); 1799 testVectorCastIntToDouble(ispec128, dspec256, iin128, dout256); 1800 testVectorCastIntToDouble(ispec128, dspec512, iin128, dout512); 1801 1802 testVectorCastIntToDouble(ispec256, dspec64, iin256, dout64); 1803 testVectorCastIntToDouble(ispec256, dspec128, iin256, dout128); 1804 testVectorCastIntToDouble(ispec256, dspec256, iin256, dout256); 1805 testVectorCastIntToDouble(ispec256, dspec512, iin256, dout512); 1806 1807 testVectorCastIntToDouble(ispec512, dspec64, iin512, dout64); 1808 testVectorCastIntToDouble(ispec512, dspec128, iin512, dout128); 1809 testVectorCastIntToDouble(ispec512, dspec256, iin512, dout256); 1810 testVectorCastIntToDouble(ispec512, dspec512, iin512, dout512); 1811 } 1812 } 1813 1814 @Test(dataProvider = "longUnaryOpProvider") 1815 static void testCastFromLong(IntFunction<long[]> fa) { 1816 long[] lin64 = fa.apply(lspec64.length()); 1817 long[] lin128 = fa.apply(lspec128.length()); 1818 long[] lin256 = fa.apply(lspec256.length()); 1819 long[] lin512 = fa.apply(lspec512.length()); 1820 1821 byte[] bout64 = new byte[bspec64.length()]; 1822 byte[] bout128 = new byte[bspec128.length()]; 1823 byte[] bout256 = new byte[bspec256.length()]; 1824 byte[] bout512 = new byte[bspec512.length()]; 1825 1826 short[] sout64 = new short[sspec64.length()]; 1827 short[] sout128 = new short[sspec128.length()]; 1828 short[] sout256 = new short[sspec256.length()]; 1829 short[] sout512 = new short[sspec512.length()]; 1830 1831 int[] iout64 = new int[ispec64.length()]; 1832 int[] iout128 = new int[ispec128.length()]; 1833 int[] iout256 = new int[ispec256.length()]; 1834 int[] iout512 = new int[ispec512.length()]; 1835 1836 long[] lout64 = new long[lspec64.length()]; 1837 long[] lout128 = new long[lspec128.length()]; 1838 long[] lout256 = new long[lspec256.length()]; 1839 long[] lout512 = new long[lspec512.length()]; 1840 1841 float[] fout64 = new float[fspec64.length()]; 1842 float[] fout128 = new float[fspec128.length()]; 1843 float[] fout256 = new float[fspec256.length()]; 1844 float[] fout512 = new float[fspec512.length()]; 1845 1846 double[] dout64 = new double[dspec64.length()]; 1847 double[] dout128 = new double[dspec128.length()]; 1848 double[] dout256 = new double[dspec256.length()]; 1849 double[] dout512 = new double[dspec512.length()]; 1850 1851 for (int i = 0; i < NUM_ITER; i++) { 1852 testVectorCastLongToByte(lspec64, bspec64, lin64, bout64); 1853 testVectorCastLongToByte(lspec64, bspec128, lin64, bout128); 1854 testVectorCastLongToByte(lspec64, bspec256, lin64, bout256); 1855 testVectorCastLongToByte(lspec64, bspec512, lin64, bout512); 1856 1857 testVectorCastLongToByte(lspec128, bspec64, lin128, bout64); 1858 testVectorCastLongToByte(lspec128, bspec128, lin128, bout128); 1859 testVectorCastLongToByte(lspec128, bspec256, lin128, bout256); 1860 testVectorCastLongToByte(lspec128, bspec512, lin128, bout512); 1861 1862 testVectorCastLongToByte(lspec256, bspec64, lin256, bout64); 1863 testVectorCastLongToByte(lspec256, bspec128, lin256, bout128); 1864 testVectorCastLongToByte(lspec256, bspec256, lin256, bout256); 1865 testVectorCastLongToByte(lspec256, bspec512, lin256, bout512); 1866 1867 testVectorCastLongToByte(lspec512, bspec64, lin512, bout64); 1868 testVectorCastLongToByte(lspec512, bspec128, lin512, bout128); 1869 testVectorCastLongToByte(lspec512, bspec256, lin512, bout256); 1870 testVectorCastLongToByte(lspec512, bspec512, lin512, bout512); 1871 1872 testVectorCastLongToShort(lspec64, sspec64, lin64, sout64); 1873 testVectorCastLongToShort(lspec64, sspec128, lin64, sout128); 1874 testVectorCastLongToShort(lspec64, sspec256, lin64, sout256); 1875 testVectorCastLongToShort(lspec64, sspec512, lin64, sout512); 1876 1877 testVectorCastLongToShort(lspec128, sspec64, lin128, sout64); 1878 testVectorCastLongToShort(lspec128, sspec128, lin128, sout128); 1879 testVectorCastLongToShort(lspec128, sspec256, lin128, sout256); 1880 testVectorCastLongToShort(lspec128, sspec512, lin128, sout512); 1881 1882 testVectorCastLongToShort(lspec256, sspec64, lin256, sout64); 1883 testVectorCastLongToShort(lspec256, sspec128, lin256, sout128); 1884 testVectorCastLongToShort(lspec256, sspec256, lin256, sout256); 1885 testVectorCastLongToShort(lspec256, sspec512, lin256, sout512); 1886 1887 testVectorCastLongToShort(lspec512, sspec64, lin512, sout64); 1888 testVectorCastLongToShort(lspec512, sspec128, lin512, sout128); 1889 testVectorCastLongToShort(lspec512, sspec256, lin512, sout256); 1890 testVectorCastLongToShort(lspec512, sspec512, lin512, sout512); 1891 1892 testVectorCastLongToInt(lspec64, ispec64, lin64, iout64); 1893 testVectorCastLongToInt(lspec64, ispec128, lin64, iout128); 1894 testVectorCastLongToInt(lspec64, ispec256, lin64, iout256); 1895 testVectorCastLongToInt(lspec64, ispec512, lin64, iout512); 1896 1897 testVectorCastLongToInt(lspec128, ispec64, lin128, iout64); 1898 testVectorCastLongToInt(lspec128, ispec128, lin128, iout128); 1899 testVectorCastLongToInt(lspec128, ispec256, lin128, iout256); 1900 testVectorCastLongToInt(lspec128, ispec512, lin128, iout512); 1901 1902 testVectorCastLongToInt(lspec256, ispec64, lin256, iout64); 1903 testVectorCastLongToInt(lspec256, ispec128, lin256, iout128); 1904 testVectorCastLongToInt(lspec256, ispec256, lin256, iout256); 1905 testVectorCastLongToInt(lspec256, ispec512, lin256, iout512); 1906 1907 testVectorCastLongToInt(lspec512, ispec64, lin512, iout64); 1908 testVectorCastLongToInt(lspec512, ispec128, lin512, iout128); 1909 testVectorCastLongToInt(lspec512, ispec256, lin512, iout256); 1910 testVectorCastLongToInt(lspec512, ispec512, lin512, iout512); 1911 1912 testVectorCastLongToLong(lspec64, lspec64, lin64, lout64); 1913 testVectorCastLongToLong(lspec64, lspec128, lin64, lout128); 1914 testVectorCastLongToLong(lspec64, lspec256, lin64, lout256); 1915 testVectorCastLongToLong(lspec64, lspec512, lin64, lout512); 1916 1917 testVectorCastLongToLong(lspec128, lspec64, lin128, lout64); 1918 testVectorCastLongToLong(lspec128, lspec128, lin128, lout128); 1919 testVectorCastLongToLong(lspec128, lspec256, lin128, lout256); 1920 testVectorCastLongToLong(lspec128, lspec512, lin128, lout512); 1921 1922 testVectorCastLongToLong(lspec256, lspec64, lin256, lout64); 1923 testVectorCastLongToLong(lspec256, lspec128, lin256, lout128); 1924 testVectorCastLongToLong(lspec256, lspec256, lin256, lout256); 1925 testVectorCastLongToLong(lspec256, lspec512, lin256, lout512); 1926 1927 testVectorCastLongToLong(lspec512, lspec64, lin512, lout64); 1928 testVectorCastLongToLong(lspec512, lspec128, lin512, lout128); 1929 testVectorCastLongToLong(lspec512, lspec256, lin512, lout256); 1930 testVectorCastLongToLong(lspec512, lspec512, lin512, lout512); 1931 1932 testVectorCastLongToFloat(lspec64, fspec64, lin64, fout64); 1933 testVectorCastLongToFloat(lspec64, fspec128, lin64, fout128); 1934 testVectorCastLongToFloat(lspec64, fspec256, lin64, fout256); 1935 testVectorCastLongToFloat(lspec64, fspec512, lin64, fout512); 1936 1937 testVectorCastLongToFloat(lspec128, fspec64, lin128, fout64); 1938 testVectorCastLongToFloat(lspec128, fspec128, lin128, fout128); 1939 testVectorCastLongToFloat(lspec128, fspec256, lin128, fout256); 1940 testVectorCastLongToFloat(lspec128, fspec512, lin128, fout512); 1941 1942 testVectorCastLongToFloat(lspec256, fspec64, lin256, fout64); 1943 testVectorCastLongToFloat(lspec256, fspec128, lin256, fout128); 1944 testVectorCastLongToFloat(lspec256, fspec256, lin256, fout256); 1945 testVectorCastLongToFloat(lspec256, fspec512, lin256, fout512); 1946 1947 testVectorCastLongToFloat(lspec512, fspec64, lin512, fout64); 1948 testVectorCastLongToFloat(lspec512, fspec128, lin512, fout128); 1949 testVectorCastLongToFloat(lspec512, fspec256, lin512, fout256); 1950 testVectorCastLongToFloat(lspec512, fspec512, lin512, fout512); 1951 1952 testVectorCastLongToDouble(lspec64, dspec64, lin64, dout64); 1953 testVectorCastLongToDouble(lspec64, dspec128, lin64, dout128); 1954 testVectorCastLongToDouble(lspec64, dspec256, lin64, dout256); 1955 testVectorCastLongToDouble(lspec64, dspec512, lin64, dout512); 1956 1957 testVectorCastLongToDouble(lspec128, dspec64, lin128, dout64); 1958 testVectorCastLongToDouble(lspec128, dspec128, lin128, dout128); 1959 testVectorCastLongToDouble(lspec128, dspec256, lin128, dout256); 1960 testVectorCastLongToDouble(lspec128, dspec512, lin128, dout512); 1961 1962 testVectorCastLongToDouble(lspec256, dspec64, lin256, dout64); 1963 testVectorCastLongToDouble(lspec256, dspec128, lin256, dout128); 1964 testVectorCastLongToDouble(lspec256, dspec256, lin256, dout256); 1965 testVectorCastLongToDouble(lspec256, dspec512, lin256, dout512); 1966 1967 testVectorCastLongToDouble(lspec512, dspec64, lin512, dout64); 1968 testVectorCastLongToDouble(lspec512, dspec128, lin512, dout128); 1969 testVectorCastLongToDouble(lspec512, dspec256, lin512, dout256); 1970 testVectorCastLongToDouble(lspec512, dspec512, lin512, dout512); 1971 } 1972 } 1973 1974 @Test(dataProvider = "floatUnaryOpProvider") 1975 static void testCastFromFloat(IntFunction<float[]> fa) { 1976 float[] fin64 = fa.apply(fspec64.length()); 1977 float[] fin128 = fa.apply(fspec128.length()); 1978 float[] fin256 = fa.apply(fspec256.length()); 1979 float[] fin512 = fa.apply(fspec512.length()); 1980 1981 byte[] bout64 = new byte[bspec64.length()]; 1982 byte[] bout128 = new byte[bspec128.length()]; 1983 byte[] bout256 = new byte[bspec256.length()]; 1984 byte[] bout512 = new byte[bspec512.length()]; 1985 1986 short[] sout64 = new short[sspec64.length()]; 1987 short[] sout128 = new short[sspec128.length()]; 1988 short[] sout256 = new short[sspec256.length()]; 1989 short[] sout512 = new short[sspec512.length()]; 1990 1991 int[] iout64 = new int[ispec64.length()]; 1992 int[] iout128 = new int[ispec128.length()]; 1993 int[] iout256 = new int[ispec256.length()]; 1994 int[] iout512 = new int[ispec512.length()]; 1995 1996 long[] lout64 = new long[lspec64.length()]; 1997 long[] lout128 = new long[lspec128.length()]; 1998 long[] lout256 = new long[lspec256.length()]; 1999 long[] lout512 = new long[lspec512.length()]; 2000 2001 float[] fout64 = new float[fspec64.length()]; 2002 float[] fout128 = new float[fspec128.length()]; 2003 float[] fout256 = new float[fspec256.length()]; 2004 float[] fout512 = new float[fspec512.length()]; 2005 2006 double[] dout64 = new double[dspec64.length()]; 2007 double[] dout128 = new double[dspec128.length()]; 2008 double[] dout256 = new double[dspec256.length()]; 2009 double[] dout512 = new double[dspec512.length()]; 2010 2011 for (int i = 0; i < NUM_ITER; i++) { 2012 testVectorCastFloatToByte(fspec64, bspec64, fin64, bout64); 2013 testVectorCastFloatToByte(fspec64, bspec128, fin64, bout128); 2014 testVectorCastFloatToByte(fspec64, bspec256, fin64, bout256); 2015 testVectorCastFloatToByte(fspec64, bspec512, fin64, bout512); 2016 2017 testVectorCastFloatToByte(fspec128, bspec64, fin128, bout64); 2018 testVectorCastFloatToByte(fspec128, bspec128, fin128, bout128); 2019 testVectorCastFloatToByte(fspec128, bspec256, fin128, bout256); 2020 testVectorCastFloatToByte(fspec128, bspec512, fin128, bout512); 2021 2022 testVectorCastFloatToByte(fspec256, bspec64, fin256, bout64); 2023 testVectorCastFloatToByte(fspec256, bspec128, fin256, bout128); 2024 testVectorCastFloatToByte(fspec256, bspec256, fin256, bout256); 2025 testVectorCastFloatToByte(fspec256, bspec512, fin256, bout512); 2026 2027 testVectorCastFloatToByte(fspec512, bspec64, fin512, bout64); 2028 testVectorCastFloatToByte(fspec512, bspec128, fin512, bout128); 2029 testVectorCastFloatToByte(fspec512, bspec256, fin512, bout256); 2030 testVectorCastFloatToByte(fspec512, bspec512, fin512, bout512); 2031 2032 testVectorCastFloatToShort(fspec64, sspec64, fin64, sout64); 2033 testVectorCastFloatToShort(fspec64, sspec128, fin64, sout128); 2034 testVectorCastFloatToShort(fspec64, sspec256, fin64, sout256); 2035 testVectorCastFloatToShort(fspec64, sspec512, fin64, sout512); 2036 2037 testVectorCastFloatToShort(fspec128, sspec64, fin128, sout64); 2038 testVectorCastFloatToShort(fspec128, sspec128, fin128, sout128); 2039 testVectorCastFloatToShort(fspec128, sspec256, fin128, sout256); 2040 testVectorCastFloatToShort(fspec128, sspec512, fin128, sout512); 2041 2042 testVectorCastFloatToShort(fspec256, sspec64, fin256, sout64); 2043 testVectorCastFloatToShort(fspec256, sspec128, fin256, sout128); 2044 testVectorCastFloatToShort(fspec256, sspec256, fin256, sout256); 2045 testVectorCastFloatToShort(fspec256, sspec512, fin256, sout512); 2046 2047 testVectorCastFloatToShort(fspec512, sspec64, fin512, sout64); 2048 testVectorCastFloatToShort(fspec512, sspec128, fin512, sout128); 2049 testVectorCastFloatToShort(fspec512, sspec256, fin512, sout256); 2050 testVectorCastFloatToShort(fspec512, sspec512, fin512, sout512); 2051 2052 testVectorCastFloatToInt(fspec64, ispec64, fin64, iout64); 2053 testVectorCastFloatToInt(fspec64, ispec128, fin64, iout128); 2054 testVectorCastFloatToInt(fspec64, ispec256, fin64, iout256); 2055 testVectorCastFloatToInt(fspec64, ispec512, fin64, iout512); 2056 2057 testVectorCastFloatToInt(fspec128, ispec64, fin128, iout64); 2058 testVectorCastFloatToInt(fspec128, ispec128, fin128, iout128); 2059 testVectorCastFloatToInt(fspec128, ispec256, fin128, iout256); 2060 testVectorCastFloatToInt(fspec128, ispec512, fin128, iout512); 2061 2062 testVectorCastFloatToInt(fspec256, ispec64, fin256, iout64); 2063 testVectorCastFloatToInt(fspec256, ispec128, fin256, iout128); 2064 testVectorCastFloatToInt(fspec256, ispec256, fin256, iout256); 2065 testVectorCastFloatToInt(fspec256, ispec512, fin256, iout512); 2066 2067 testVectorCastFloatToInt(fspec512, ispec64, fin512, iout64); 2068 testVectorCastFloatToInt(fspec512, ispec128, fin512, iout128); 2069 testVectorCastFloatToInt(fspec512, ispec256, fin512, iout256); 2070 testVectorCastFloatToInt(fspec512, ispec512, fin512, iout512); 2071 2072 testVectorCastFloatToLong(fspec64, lspec64, fin64, lout64); 2073 testVectorCastFloatToLong(fspec64, lspec128, fin64, lout128); 2074 testVectorCastFloatToLong(fspec64, lspec256, fin64, lout256); 2075 testVectorCastFloatToLong(fspec64, lspec512, fin64, lout512); 2076 2077 testVectorCastFloatToLong(fspec128, lspec64, fin128, lout64); 2078 testVectorCastFloatToLong(fspec128, lspec128, fin128, lout128); 2079 testVectorCastFloatToLong(fspec128, lspec256, fin128, lout256); 2080 testVectorCastFloatToLong(fspec128, lspec512, fin128, lout512); 2081 2082 testVectorCastFloatToLong(fspec256, lspec64, fin256, lout64); 2083 testVectorCastFloatToLong(fspec256, lspec128, fin256, lout128); 2084 testVectorCastFloatToLong(fspec256, lspec256, fin256, lout256); 2085 testVectorCastFloatToLong(fspec256, lspec512, fin256, lout512); 2086 2087 testVectorCastFloatToLong(fspec512, lspec64, fin512, lout64); 2088 testVectorCastFloatToLong(fspec512, lspec128, fin512, lout128); 2089 testVectorCastFloatToLong(fspec512, lspec256, fin512, lout256); 2090 testVectorCastFloatToLong(fspec512, lspec512, fin512, lout512); 2091 2092 testVectorCastFloatToFloat(fspec64, fspec64, fin64, fout64); 2093 testVectorCastFloatToFloat(fspec64, fspec128, fin64, fout128); 2094 testVectorCastFloatToFloat(fspec64, fspec256, fin64, fout256); 2095 testVectorCastFloatToFloat(fspec64, fspec512, fin64, fout512); 2096 2097 testVectorCastFloatToFloat(fspec128, fspec64, fin128, fout64); 2098 testVectorCastFloatToFloat(fspec128, fspec128, fin128, fout128); 2099 testVectorCastFloatToFloat(fspec128, fspec256, fin128, fout256); 2100 testVectorCastFloatToFloat(fspec128, fspec512, fin128, fout512); 2101 2102 testVectorCastFloatToFloat(fspec256, fspec64, fin256, fout64); 2103 testVectorCastFloatToFloat(fspec256, fspec128, fin256, fout128); 2104 testVectorCastFloatToFloat(fspec256, fspec256, fin256, fout256); 2105 testVectorCastFloatToFloat(fspec256, fspec512, fin256, fout512); 2106 2107 testVectorCastFloatToFloat(fspec512, fspec64, fin512, fout64); 2108 testVectorCastFloatToFloat(fspec512, fspec128, fin512, fout128); 2109 testVectorCastFloatToFloat(fspec512, fspec256, fin512, fout256); 2110 testVectorCastFloatToFloat(fspec512, fspec512, fin512, fout512); 2111 2112 testVectorCastFloatToDouble(fspec64, dspec64, fin64, dout64); 2113 testVectorCastFloatToDouble(fspec64, dspec128, fin64, dout128); 2114 testVectorCastFloatToDouble(fspec64, dspec256, fin64, dout256); 2115 testVectorCastFloatToDouble(fspec64, dspec512, fin64, dout512); 2116 2117 testVectorCastFloatToDouble(fspec128, dspec64, fin128, dout64); 2118 testVectorCastFloatToDouble(fspec128, dspec128, fin128, dout128); 2119 testVectorCastFloatToDouble(fspec128, dspec256, fin128, dout256); 2120 testVectorCastFloatToDouble(fspec128, dspec512, fin128, dout512); 2121 2122 testVectorCastFloatToDouble(fspec256, dspec64, fin256, dout64); 2123 testVectorCastFloatToDouble(fspec256, dspec128, fin256, dout128); 2124 testVectorCastFloatToDouble(fspec256, dspec256, fin256, dout256); 2125 testVectorCastFloatToDouble(fspec256, dspec512, fin256, dout512); 2126 2127 testVectorCastFloatToDouble(fspec512, dspec64, fin512, dout64); 2128 testVectorCastFloatToDouble(fspec512, dspec128, fin512, dout128); 2129 testVectorCastFloatToDouble(fspec512, dspec256, fin512, dout256); 2130 testVectorCastFloatToDouble(fspec512, dspec512, fin512, dout512); 2131 } 2132 } 2133 2134 @Test(dataProvider = "doubleUnaryOpProvider") 2135 static void testCastFromDouble(IntFunction<double[]> fa) { 2136 double[] din64 = fa.apply(dspec64.length()); 2137 double[] din128 = fa.apply(dspec128.length()); 2138 double[] din256 = fa.apply(dspec256.length()); 2139 double[] din512 = fa.apply(dspec512.length()); 2140 2141 byte[] bout64 = new byte[bspec64.length()]; 2142 byte[] bout128 = new byte[bspec128.length()]; 2143 byte[] bout256 = new byte[bspec256.length()]; 2144 byte[] bout512 = new byte[bspec512.length()]; 2145 2146 short[] sout64 = new short[sspec64.length()]; 2147 short[] sout128 = new short[sspec128.length()]; 2148 short[] sout256 = new short[sspec256.length()]; 2149 short[] sout512 = new short[sspec512.length()]; 2150 2151 int[] iout64 = new int[ispec64.length()]; 2152 int[] iout128 = new int[ispec128.length()]; 2153 int[] iout256 = new int[ispec256.length()]; 2154 int[] iout512 = new int[ispec512.length()]; 2155 2156 long[] lout64 = new long[lspec64.length()]; 2157 long[] lout128 = new long[lspec128.length()]; 2158 long[] lout256 = new long[lspec256.length()]; 2159 long[] lout512 = new long[lspec512.length()]; 2160 2161 float[] fout64 = new float[fspec64.length()]; 2162 float[] fout128 = new float[fspec128.length()]; 2163 float[] fout256 = new float[fspec256.length()]; 2164 float[] fout512 = new float[fspec512.length()]; 2165 2166 double[] dout64 = new double[dspec64.length()]; 2167 double[] dout128 = new double[dspec128.length()]; 2168 double[] dout256 = new double[dspec256.length()]; 2169 double[] dout512 = new double[dspec512.length()]; 2170 2171 for (int i = 0; i < NUM_ITER; i++) { 2172 testVectorCastDoubleToByte(dspec64, bspec64, din64, bout64); 2173 testVectorCastDoubleToByte(dspec64, bspec128, din64, bout128); 2174 testVectorCastDoubleToByte(dspec64, bspec256, din64, bout256); 2175 testVectorCastDoubleToByte(dspec64, bspec512, din64, bout512); 2176 2177 testVectorCastDoubleToByte(dspec128, bspec64, din128, bout64); 2178 testVectorCastDoubleToByte(dspec128, bspec128, din128, bout128); 2179 testVectorCastDoubleToByte(dspec128, bspec256, din128, bout256); 2180 testVectorCastDoubleToByte(dspec128, bspec512, din128, bout512); 2181 2182 testVectorCastDoubleToByte(dspec256, bspec64, din256, bout64); 2183 testVectorCastDoubleToByte(dspec256, bspec128, din256, bout128); 2184 testVectorCastDoubleToByte(dspec256, bspec256, din256, bout256); 2185 testVectorCastDoubleToByte(dspec256, bspec512, din256, bout512); 2186 2187 testVectorCastDoubleToByte(dspec512, bspec64, din512, bout64); 2188 testVectorCastDoubleToByte(dspec512, bspec128, din512, bout128); 2189 testVectorCastDoubleToByte(dspec512, bspec256, din512, bout256); 2190 testVectorCastDoubleToByte(dspec512, bspec512, din512, bout512); 2191 2192 testVectorCastDoubleToShort(dspec64, sspec64, din64, sout64); 2193 testVectorCastDoubleToShort(dspec64, sspec128, din64, sout128); 2194 testVectorCastDoubleToShort(dspec64, sspec256, din64, sout256); 2195 testVectorCastDoubleToShort(dspec64, sspec512, din64, sout512); 2196 2197 testVectorCastDoubleToShort(dspec128, sspec64, din128, sout64); 2198 testVectorCastDoubleToShort(dspec128, sspec128, din128, sout128); 2199 testVectorCastDoubleToShort(dspec128, sspec256, din128, sout256); 2200 testVectorCastDoubleToShort(dspec128, sspec512, din128, sout512); 2201 2202 testVectorCastDoubleToShort(dspec256, sspec64, din256, sout64); 2203 testVectorCastDoubleToShort(dspec256, sspec128, din256, sout128); 2204 testVectorCastDoubleToShort(dspec256, sspec256, din256, sout256); 2205 testVectorCastDoubleToShort(dspec256, sspec512, din256, sout512); 2206 2207 testVectorCastDoubleToShort(dspec512, sspec64, din512, sout64); 2208 testVectorCastDoubleToShort(dspec512, sspec128, din512, sout128); 2209 testVectorCastDoubleToShort(dspec512, sspec256, din512, sout256); 2210 testVectorCastDoubleToShort(dspec512, sspec512, din512, sout512); 2211 2212 testVectorCastDoubleToInt(dspec64, ispec64, din64, iout64); 2213 testVectorCastDoubleToInt(dspec64, ispec128, din64, iout128); 2214 testVectorCastDoubleToInt(dspec64, ispec256, din64, iout256); 2215 testVectorCastDoubleToInt(dspec64, ispec512, din64, iout512); 2216 2217 testVectorCastDoubleToInt(dspec128, ispec64, din128, iout64); 2218 testVectorCastDoubleToInt(dspec128, ispec128, din128, iout128); 2219 testVectorCastDoubleToInt(dspec128, ispec256, din128, iout256); 2220 testVectorCastDoubleToInt(dspec128, ispec512, din128, iout512); 2221 2222 testVectorCastDoubleToInt(dspec256, ispec64, din256, iout64); 2223 testVectorCastDoubleToInt(dspec256, ispec128, din256, iout128); 2224 testVectorCastDoubleToInt(dspec256, ispec256, din256, iout256); 2225 testVectorCastDoubleToInt(dspec256, ispec512, din256, iout512); 2226 2227 testVectorCastDoubleToInt(dspec512, ispec64, din512, iout64); 2228 testVectorCastDoubleToInt(dspec512, ispec128, din512, iout128); 2229 testVectorCastDoubleToInt(dspec512, ispec256, din512, iout256); 2230 testVectorCastDoubleToInt(dspec512, ispec512, din512, iout512); 2231 2232 testVectorCastDoubleToLong(dspec64, lspec64, din64, lout64); 2233 testVectorCastDoubleToLong(dspec64, lspec128, din64, lout128); 2234 testVectorCastDoubleToLong(dspec64, lspec256, din64, lout256); 2235 testVectorCastDoubleToLong(dspec64, lspec512, din64, lout512); 2236 2237 testVectorCastDoubleToLong(dspec128, lspec64, din128, lout64); 2238 testVectorCastDoubleToLong(dspec128, lspec128, din128, lout128); 2239 testVectorCastDoubleToLong(dspec128, lspec256, din128, lout256); 2240 testVectorCastDoubleToLong(dspec128, lspec512, din128, lout512); 2241 2242 testVectorCastDoubleToLong(dspec256, lspec64, din256, lout64); 2243 testVectorCastDoubleToLong(dspec256, lspec128, din256, lout128); 2244 testVectorCastDoubleToLong(dspec256, lspec256, din256, lout256); 2245 testVectorCastDoubleToLong(dspec256, lspec512, din256, lout512); 2246 2247 testVectorCastDoubleToLong(dspec512, lspec64, din512, lout64); 2248 testVectorCastDoubleToLong(dspec512, lspec128, din512, lout128); 2249 testVectorCastDoubleToLong(dspec512, lspec256, din512, lout256); 2250 testVectorCastDoubleToLong(dspec512, lspec512, din512, lout512); 2251 2252 testVectorCastDoubleToFloat(dspec64, fspec64, din64, fout64); 2253 testVectorCastDoubleToFloat(dspec64, fspec128, din64, fout128); 2254 testVectorCastDoubleToFloat(dspec64, fspec256, din64, fout256); 2255 testVectorCastDoubleToFloat(dspec64, fspec512, din64, fout512); 2256 2257 testVectorCastDoubleToFloat(dspec128, fspec64, din128, fout64); 2258 testVectorCastDoubleToFloat(dspec128, fspec128, din128, fout128); 2259 testVectorCastDoubleToFloat(dspec128, fspec256, din128, fout256); 2260 testVectorCastDoubleToFloat(dspec128, fspec512, din128, fout512); 2261 2262 testVectorCastDoubleToFloat(dspec256, fspec64, din256, fout64); 2263 testVectorCastDoubleToFloat(dspec256, fspec128, din256, fout128); 2264 testVectorCastDoubleToFloat(dspec256, fspec256, din256, fout256); 2265 testVectorCastDoubleToFloat(dspec256, fspec512, din256, fout512); 2266 2267 testVectorCastDoubleToFloat(dspec512, fspec64, din512, fout64); 2268 testVectorCastDoubleToFloat(dspec512, fspec128, din512, fout128); 2269 testVectorCastDoubleToFloat(dspec512, fspec256, din512, fout256); 2270 testVectorCastDoubleToFloat(dspec512, fspec512, din512, fout512); 2271 2272 testVectorCastDoubleToDouble(dspec64, dspec64, din64, dout64); 2273 testVectorCastDoubleToDouble(dspec64, dspec128, din64, dout128); 2274 testVectorCastDoubleToDouble(dspec64, dspec256, din64, dout256); 2275 testVectorCastDoubleToDouble(dspec64, dspec512, din64, dout512); 2276 2277 testVectorCastDoubleToDouble(dspec128, dspec64, din128, dout64); 2278 testVectorCastDoubleToDouble(dspec128, dspec128, din128, dout128); 2279 testVectorCastDoubleToDouble(dspec128, dspec256, din128, dout256); 2280 testVectorCastDoubleToDouble(dspec128, dspec512, din128, dout512); 2281 2282 testVectorCastDoubleToDouble(dspec256, dspec64, din256, dout64); 2283 testVectorCastDoubleToDouble(dspec256, dspec128, din256, dout128); 2284 testVectorCastDoubleToDouble(dspec256, dspec256, din256, dout256); 2285 testVectorCastDoubleToDouble(dspec256, dspec512, din256, dout512); 2286 2287 testVectorCastDoubleToDouble(dspec512, dspec64, din512, dout64); 2288 testVectorCastDoubleToDouble(dspec512, dspec128, din512, dout128); 2289 testVectorCastDoubleToDouble(dspec512, dspec256, din512, dout256); 2290 testVectorCastDoubleToDouble(dspec512, dspec512, din512, dout512); 2291 } 2292 } 2293 }