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.lang.invoke.MethodHandles; 8 import java.lang.invoke.VarHandle; 9 import java.util.Arrays; 10 import java.util.List; 11 import java.util.function.IntFunction; 12 import jdk.incubator.vector.Vector.Shape; 13 14 /** 15 * @test 16 * @modules jdk.incubator.vector 17 * @modules java.base/jdk.internal.vm.annotation 18 * @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED 19 * VectorReshapeTests 20 */ 21 22 @Test 23 public class VectorReshapeTests { 24 static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); 25 static final int NUM_ITER = 200 * INVOC_COUNT; 26 27 static final Shape S_Max_BIT = getMaxBit(); 28 29 static final IntVector.IntSpecies ispec64 = IntVector.species(Shape.S_64_BIT); 30 static final FloatVector.FloatSpecies fspec64 = FloatVector.species(Shape.S_64_BIT); 31 static final LongVector.LongSpecies lspec64 = LongVector.species(Shape.S_64_BIT); 32 static final DoubleVector.DoubleSpecies dspec64 = DoubleVector.species(Shape.S_64_BIT); 33 static final ByteVector.ByteSpecies bspec64 = ByteVector.species(Shape.S_64_BIT); 34 static final ShortVector.ShortSpecies sspec64 = ShortVector.species(Shape.S_64_BIT); 35 36 static final IntVector.IntSpecies ispec128 = IntVector.species(Shape.S_128_BIT); 37 static final FloatVector.FloatSpecies fspec128 = FloatVector.species(Shape.S_128_BIT); 38 static final LongVector.LongSpecies lspec128 = LongVector.species(Shape.S_128_BIT); 39 static final DoubleVector.DoubleSpecies dspec128 = DoubleVector.species(Shape.S_128_BIT); 40 static final ByteVector.ByteSpecies bspec128 = ByteVector.species(Shape.S_128_BIT); 41 static final ShortVector.ShortSpecies sspec128 = ShortVector.species(Shape.S_128_BIT); 42 43 static final IntVector.IntSpecies ispec256 = IntVector.species(Shape.S_256_BIT); 44 static final FloatVector.FloatSpecies fspec256 = FloatVector.species(Shape.S_256_BIT); 45 static final LongVector.LongSpecies lspec256 = LongVector.species(Shape.S_256_BIT); 46 static final DoubleVector.DoubleSpecies dspec256 = DoubleVector.species(Shape.S_256_BIT); 47 static final ByteVector.ByteSpecies bspec256 = ByteVector.species(Shape.S_256_BIT); 48 static final ShortVector.ShortSpecies sspec256 = ShortVector.species(Shape.S_256_BIT); 49 50 static final IntVector.IntSpecies ispec512 = IntVector.species(Shape.S_512_BIT); 51 static final FloatVector.FloatSpecies fspec512 = FloatVector.species(Shape.S_512_BIT); 52 static final LongVector.LongSpecies lspec512 = LongVector.species(Shape.S_512_BIT); 53 static final DoubleVector.DoubleSpecies dspec512 = DoubleVector.species(Shape.S_512_BIT); 54 static final ByteVector.ByteSpecies bspec512 = ByteVector.species(Shape.S_512_BIT); 55 static final ShortVector.ShortSpecies sspec512 = ShortVector.species(Shape.S_512_BIT); 56 57 static final IntVector.IntSpecies ispecMax = IntVector.species(S_Max_BIT); 58 static final FloatVector.FloatSpecies fspecMax = FloatVector.species(S_Max_BIT); 59 static final LongVector.LongSpecies lspecMax = LongVector.species(S_Max_BIT); 60 static final DoubleVector.DoubleSpecies dspecMax = DoubleVector.species(S_Max_BIT); 61 static final ByteVector.ByteSpecies bspecMax = ByteVector.species(S_Max_BIT); 62 static final ShortVector.ShortSpecies sspecMax = ShortVector.species(S_Max_BIT); 63 64 static Shape getMaxBit() { 65 return Shape.S_Max_BIT; 66 } 67 68 static <T> IntFunction<T> withToString(String s, IntFunction<T> f) { 69 return new IntFunction<T>() { 70 @Override 71 public T apply(int v) { 72 return f.apply(v); 73 } 74 75 @Override 76 public String toString() { 77 return s; 78 } 79 }; 80 } 81 82 interface ToByteF { 83 byte apply(int i); 84 } 85 86 static byte[] fill_byte(int s , ToByteF f) { 87 return fill_byte(new byte[s], f); 88 } 89 90 static byte[] fill_byte(byte[] a, ToByteF f) { 91 for (int i = 0; i < a.length; i++) { 92 a[i] = f.apply(i); 93 } 94 return a; 95 } 96 97 interface ToBoolF { 98 boolean apply(int i); 99 } 100 101 static boolean[] fill_bool(int s , ToBoolF f) { 102 return fill_bool(new boolean[s], f); 103 } 104 105 static boolean[] fill_bool(boolean[] a, ToBoolF f) { 106 for (int i = 0; i < a.length; i++) { 107 a[i] = f.apply(i); 108 } 109 return a; 110 } 111 112 interface ToShortF { 113 short apply(int i); 114 } 115 116 static short[] fill_short(int s , ToShortF f) { 117 return fill_short(new short[s], f); 118 } 119 120 static short[] fill_short(short[] a, ToShortF f) { 121 for (int i = 0; i < a.length; i++) { 122 a[i] = f.apply(i); 123 } 124 return a; 125 } 126 127 interface ToIntF { 128 int apply(int i); 129 } 130 131 static int[] fill_int(int s , ToIntF f) { 132 return fill_int(new int[s], f); 133 } 134 135 static int[] fill_int(int[] a, ToIntF f) { 136 for (int i = 0; i < a.length; i++) { 137 a[i] = f.apply(i); 138 } 139 return a; 140 } 141 142 interface ToLongF { 143 long apply(int i); 144 } 145 146 static long[] fill_long(int s , ToLongF f) { 147 return fill_long(new long[s], f); 148 } 149 150 static long[] fill_long(long[] a, ToLongF f) { 151 for (int i = 0; i < a.length; i++) { 152 a[i] = f.apply(i); 153 } 154 return a; 155 } 156 157 interface ToFloatF { 158 float apply(int i); 159 } 160 161 static float[] fill_float(int s , ToFloatF f) { 162 return fill_float(new float[s], f); 163 } 164 165 static float[] fill_float(float[] a, ToFloatF f) { 166 for (int i = 0; i < a.length; i++) { 167 a[i] = f.apply(i); 168 } 169 return a; 170 } 171 172 interface ToDoubleF { 173 double apply(int i); 174 } 175 176 static double[] fill_double(int s , ToDoubleF f) { 177 return fill_double(new double[s], f); 178 } 179 180 static double[] fill_double(double[] a, ToDoubleF f) { 181 for (int i = 0; i < a.length; i++) { 182 a[i] = f.apply(i); 183 } 184 return a; 185 } 186 187 static final List<IntFunction<byte[]>> BYTE_GENERATORS = List.of( 188 withToString("byte(i)", (int s) -> { 189 return fill_byte(s, i -> (byte)i); 190 }) 191 ); 192 193 @DataProvider 194 public Object[][] byteUnaryOpProvider() { 195 return BYTE_GENERATORS.stream(). 196 map(f -> new Object[]{f}). 197 toArray(Object[][]::new); 198 } 199 200 static final List<IntFunction<boolean[]>> BOOL_GENERATORS = List.of( 201 withToString("boolean(i%3)", (int s) -> { 202 return fill_bool(s, i -> i % 3 == 0); 203 }) 204 ); 205 206 @DataProvider 207 public Object[][] booleanUnaryOpProvider() { 208 return BOOL_GENERATORS.stream(). 209 map(f -> new Object[]{f}). 210 toArray(Object[][]::new); 211 } 212 213 static final List<IntFunction<short[]>> SHORT_GENERATORS = List.of( 214 withToString("short(i)", (int s) -> { 215 return fill_short(s, i -> (short)i); 216 }) 217 ); 218 219 @DataProvider 220 public Object[][] shortUnaryOpProvider() { 221 return SHORT_GENERATORS.stream(). 222 map(f -> new Object[]{f}). 223 toArray(Object[][]::new); 224 } 225 226 static final List<IntFunction<int[]>> INT_GENERATORS = List.of( 227 withToString("int(i)", (int s) -> { 228 return fill_int(s, i -> (int)i); 229 }) 230 ); 231 232 @DataProvider 233 public Object[][] intUnaryOpProvider() { 234 return INT_GENERATORS.stream(). 235 map(f -> new Object[]{f}). 236 toArray(Object[][]::new); 237 } 238 239 static final List<IntFunction<long[]>> LONG_GENERATORS = List.of( 240 withToString("long(i)", (int s) -> { 241 return fill_long(s, i -> (long)i); 242 }) 243 ); 244 245 @DataProvider 246 public Object[][] longUnaryOpProvider() { 247 return LONG_GENERATORS.stream(). 248 map(f -> new Object[]{f}). 249 toArray(Object[][]::new); 250 } 251 252 static final List<IntFunction<float[]>> FLOAT_GENERATORS = List.of( 253 withToString("float(i)", (int s) -> { 254 return fill_float(s, i -> (float)i); 255 }) 256 ); 257 258 @DataProvider 259 public Object[][] floatUnaryOpProvider() { 260 return FLOAT_GENERATORS.stream(). 261 map(f -> new Object[]{f}). 262 toArray(Object[][]::new); 263 } 264 265 static final List<IntFunction<double[]>> DOUBLE_GENERATORS = List.of( 266 withToString("double(i)", (int s) -> { 267 return fill_double(s, i -> (double)i); 268 }) 269 ); 270 271 @DataProvider 272 public Object[][] doubleUnaryOpProvider() { 273 return DOUBLE_GENERATORS.stream(). 274 map(f -> new Object[]{f}). 275 toArray(Object[][]::new); 276 } 277 278 @ForceInline 279 static <E> 280 void testVectorReshape(Vector.Species<E> a, Vector.Species<E> b, byte[] input, byte[] output) { 281 Vector<E> av; 282 Class<?> stype = a.elementType(); 283 if (stype == byte.class) { 284 av = (Vector) ByteVector.fromByteArray((ByteVector.ByteSpecies)a, input, 0); 285 } else if (stype == short.class) { 286 av = (Vector) ShortVector.fromByteArray((ShortVector.ShortSpecies)a, input, 0); 287 } else if (stype == int.class) { 288 av = (Vector) IntVector.fromByteArray((IntVector.IntSpecies)a, input, 0); 289 } else if (stype == long.class) { 290 av = (Vector) LongVector.fromByteArray((LongVector.LongSpecies)a, input, 0); 291 } else if (stype == float.class) { 292 av = (Vector) FloatVector.fromByteArray((FloatVector.FloatSpecies)a, input, 0); 293 } else if (stype == double.class) { 294 av = (Vector) DoubleVector.fromByteArray((DoubleVector.DoubleSpecies)a, input, 0); 295 } else { 296 throw new UnsupportedOperationException("Bad lane type"); 297 } 298 Vector<E> bv = av.reshape(b); 299 bv.intoByteArray(output, 0); 300 301 byte[] expected = Arrays.copyOf(input, output.length); 302 303 304 Assert.assertEquals(expected, output); 305 } 306 307 @Test(dataProvider = "byteUnaryOpProvider") 308 static void testReshapeByte(IntFunction<byte[]> fa) { 309 byte[] bin64 = fa.apply(64/Byte.SIZE); 310 byte[] bin128 = fa.apply(128/Byte.SIZE); 311 byte[] bin256 = fa.apply(256/Byte.SIZE); 312 byte[] bin512 = fa.apply(512/Byte.SIZE); 313 byte[] binMax = fa.apply(S_Max_BIT.bitSize()/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 byte[] boutMax = new byte[binMax.length]; 319 320 for (int i = 0; i < NUM_ITER; i++) { 321 testVectorReshape(bspec64, bspec64, bin64, bout64); 322 testVectorReshape(bspec64, bspec128, bin64, bout128); 323 testVectorReshape(bspec64, bspec256, bin64, bout256); 324 testVectorReshape(bspec64, bspec512, bin64, bout512); 325 testVectorReshape(bspec64, bspecMax, bin64, boutMax); 326 327 testVectorReshape(bspec128, bspec64, bin128, bout64); 328 testVectorReshape(bspec128, bspec128, bin128, bout128); 329 testVectorReshape(bspec128, bspec256, bin128, bout256); 330 testVectorReshape(bspec128, bspec512, bin128, bout512); 331 testVectorReshape(bspec128, bspecMax, bin128, boutMax); 332 333 testVectorReshape(bspec256, bspec64, bin256, bout64); 334 testVectorReshape(bspec256, bspec128, bin256, bout128); 335 testVectorReshape(bspec256, bspec256, bin256, bout256); 336 testVectorReshape(bspec256, bspec512, bin256, bout512); 337 testVectorReshape(bspec256, bspecMax, bin256, boutMax); 338 339 testVectorReshape(bspec512, bspec64, bin512, bout64); 340 testVectorReshape(bspec512, bspec128, bin512, bout128); 341 testVectorReshape(bspec512, bspec256, bin512, bout256); 342 testVectorReshape(bspec512, bspec512, bin512, bout512); 343 testVectorReshape(bspec512, bspecMax, bin512, boutMax); 344 345 testVectorReshape(bspecMax, bspec64, binMax, bout64); 346 testVectorReshape(bspecMax, bspec128, binMax, bout128); 347 testVectorReshape(bspecMax, bspec256, binMax, bout256); 348 testVectorReshape(bspecMax, bspec512, binMax, bout512); 349 testVectorReshape(bspecMax, bspecMax, binMax, boutMax); 350 } 351 } 352 353 @Test(dataProvider = "byteUnaryOpProvider") 354 static void testReshapeShort(IntFunction<byte[]> fa) { 355 byte[] bin64 = fa.apply(64/Byte.SIZE); 356 byte[] bin128 = fa.apply(128/Byte.SIZE); 357 byte[] bin256 = fa.apply(256/Byte.SIZE); 358 byte[] bin512 = fa.apply(512/Byte.SIZE); 359 byte[] binMax = fa.apply(S_Max_BIT.bitSize()/Byte.SIZE); 360 byte[] bout64 = new byte[bin64.length]; 361 byte[] bout128 = new byte[bin128.length]; 362 byte[] bout256 = new byte[bin256.length]; 363 byte[] bout512 = new byte[bin512.length]; 364 byte[] boutMax = new byte[binMax.length]; 365 366 for (int i = 0; i < NUM_ITER; i++) { 367 testVectorReshape(sspec64, sspec64, bin64, bout64); 368 testVectorReshape(sspec64, sspec128, bin64, bout128); 369 testVectorReshape(sspec64, sspec256, bin64, bout256); 370 testVectorReshape(sspec64, sspec512, bin64, bout512); 371 testVectorReshape(sspec64, sspecMax, bin64, boutMax); 372 373 testVectorReshape(sspec128, sspec64, bin128, bout64); 374 testVectorReshape(sspec128, sspec128, bin128, bout128); 375 testVectorReshape(sspec128, sspec256, bin128, bout256); 376 testVectorReshape(sspec128, sspec512, bin128, bout512); 377 testVectorReshape(sspec128, sspecMax, bin128, boutMax); 378 379 testVectorReshape(sspec256, sspec64, bin256, bout64); 380 testVectorReshape(sspec256, sspec128, bin256, bout128); 381 testVectorReshape(sspec256, sspec256, bin256, bout256); 382 testVectorReshape(sspec256, sspec512, bin256, bout512); 383 testVectorReshape(sspec256, sspecMax, bin256, boutMax); 384 385 testVectorReshape(sspec512, sspec64, bin512, bout64); 386 testVectorReshape(sspec512, sspec128, bin512, bout128); 387 testVectorReshape(sspec512, sspec256, bin512, bout256); 388 testVectorReshape(sspec512, sspec512, bin512, bout512); 389 testVectorReshape(sspec512, sspecMax, bin512, boutMax); 390 391 testVectorReshape(sspecMax, sspec64, binMax, bout64); 392 testVectorReshape(sspecMax, sspec128, binMax, bout128); 393 testVectorReshape(sspecMax, sspec256, binMax, bout256); 394 testVectorReshape(sspecMax, sspec512, binMax, bout512); 395 testVectorReshape(sspecMax, sspecMax, binMax, boutMax); 396 } 397 } 398 399 @Test(dataProvider = "byteUnaryOpProvider") 400 static void testReshapeInt(IntFunction<byte[]> fa) { 401 byte[] bin64 = fa.apply(64/Byte.SIZE); 402 byte[] bin128 = fa.apply(128/Byte.SIZE); 403 byte[] bin256 = fa.apply(256/Byte.SIZE); 404 byte[] bin512 = fa.apply(512/Byte.SIZE); 405 byte[] binMax = fa.apply(S_Max_BIT.bitSize()/Byte.SIZE); 406 byte[] bout64 = new byte[bin64.length]; 407 byte[] bout128 = new byte[bin128.length]; 408 byte[] bout256 = new byte[bin256.length]; 409 byte[] bout512 = new byte[bin512.length]; 410 byte[] boutMax = new byte[binMax.length]; 411 412 for (int i = 0; i < NUM_ITER; i++) { 413 testVectorReshape(ispec64, ispec64, bin64, bout64); 414 testVectorReshape(ispec64, ispec128, bin64, bout128); 415 testVectorReshape(ispec64, ispec256, bin64, bout256); 416 testVectorReshape(ispec64, ispec512, bin64, bout512); 417 testVectorReshape(ispec64, ispecMax, bin64, boutMax); 418 419 testVectorReshape(ispec128, ispec64, bin128, bout64); 420 testVectorReshape(ispec128, ispec128, bin128, bout128); 421 testVectorReshape(ispec128, ispec256, bin128, bout256); 422 testVectorReshape(ispec128, ispec512, bin128, bout512); 423 testVectorReshape(ispec128, ispecMax, bin128, boutMax); 424 425 testVectorReshape(ispec256, ispec64, bin256, bout64); 426 testVectorReshape(ispec256, ispec128, bin256, bout128); 427 testVectorReshape(ispec256, ispec256, bin256, bout256); 428 testVectorReshape(ispec256, ispec512, bin256, bout512); 429 testVectorReshape(ispec256, ispecMax, bin256, boutMax); 430 431 testVectorReshape(ispec512, ispec64, bin512, bout64); 432 testVectorReshape(ispec512, ispec128, bin512, bout128); 433 testVectorReshape(ispec512, ispec256, bin512, bout256); 434 testVectorReshape(ispec512, ispec512, bin512, bout512); 435 testVectorReshape(ispec512, ispecMax, bin512, boutMax); 436 437 testVectorReshape(ispecMax, ispec64, binMax, bout64); 438 testVectorReshape(ispecMax, ispec128, binMax, bout128); 439 testVectorReshape(ispecMax, ispec256, binMax, bout256); 440 testVectorReshape(ispecMax, ispec512, binMax, bout512); 441 testVectorReshape(ispecMax, ispecMax, binMax, boutMax); 442 } 443 } 444 445 @Test(dataProvider = "byteUnaryOpProvider") 446 static void testReshapeLong(IntFunction<byte[]> fa) { 447 byte[] bin64 = fa.apply(64/Byte.SIZE); 448 byte[] bin128 = fa.apply(128/Byte.SIZE); 449 byte[] bin256 = fa.apply(256/Byte.SIZE); 450 byte[] bin512 = fa.apply(512/Byte.SIZE); 451 byte[] binMax = fa.apply(S_Max_BIT.bitSize()/Byte.SIZE); 452 byte[] bout64 = new byte[bin64.length]; 453 byte[] bout128 = new byte[bin128.length]; 454 byte[] bout256 = new byte[bin256.length]; 455 byte[] bout512 = new byte[bin512.length]; 456 byte[] boutMax = new byte[binMax.length]; 457 458 for (int i = 0; i < NUM_ITER; i++) { 459 testVectorReshape(lspec64, lspec64, bin64, bout64); 460 testVectorReshape(lspec64, lspec128, bin64, bout128); 461 testVectorReshape(lspec64, lspec256, bin64, bout256); 462 testVectorReshape(lspec64, lspec512, bin64, bout512); 463 testVectorReshape(lspec64, lspecMax, bin64, boutMax); 464 465 testVectorReshape(lspec128, lspec64, bin128, bout64); 466 testVectorReshape(lspec128, lspec128, bin128, bout128); 467 testVectorReshape(lspec128, lspec256, bin128, bout256); 468 testVectorReshape(lspec128, lspec512, bin128, bout512); 469 testVectorReshape(lspec128, lspecMax, bin128, boutMax); 470 471 testVectorReshape(lspec256, lspec64, bin256, bout64); 472 testVectorReshape(lspec256, lspec128, bin256, bout128); 473 testVectorReshape(lspec256, lspec256, bin256, bout256); 474 testVectorReshape(lspec256, lspec512, bin256, bout512); 475 testVectorReshape(lspec256, lspecMax, bin256, boutMax); 476 477 testVectorReshape(lspec512, lspec64, bin512, bout64); 478 testVectorReshape(lspec512, lspec128, bin512, bout128); 479 testVectorReshape(lspec512, lspec256, bin512, bout256); 480 testVectorReshape(lspec512, lspec512, bin512, bout512); 481 testVectorReshape(lspec512, lspecMax, bin512, boutMax); 482 483 testVectorReshape(lspecMax, lspec64, binMax, bout64); 484 testVectorReshape(lspecMax, lspec128, binMax, bout128); 485 testVectorReshape(lspecMax, lspec256, binMax, bout256); 486 testVectorReshape(lspecMax, lspec512, binMax, bout512); 487 testVectorReshape(lspecMax, lspecMax, binMax, boutMax); 488 } 489 } 490 491 @Test(dataProvider = "byteUnaryOpProvider") 492 static void testReshapeFloat(IntFunction<byte[]> fa) { 493 byte[] bin64 = fa.apply(64/Byte.SIZE); 494 byte[] bin128 = fa.apply(128/Byte.SIZE); 495 byte[] bin256 = fa.apply(256/Byte.SIZE); 496 byte[] bin512 = fa.apply(512/Byte.SIZE); 497 byte[] binMax = fa.apply(S_Max_BIT.bitSize()/Byte.SIZE); 498 byte[] bout64 = new byte[bin64.length]; 499 byte[] bout128 = new byte[bin128.length]; 500 byte[] bout256 = new byte[bin256.length]; 501 byte[] bout512 = new byte[bin512.length]; 502 byte[] boutMax = new byte[binMax.length]; 503 504 for (int i = 0; i < NUM_ITER; i++) { 505 testVectorReshape(fspec64, fspec64, bin64, bout64); 506 testVectorReshape(fspec64, fspec128, bin64, bout128); 507 testVectorReshape(fspec64, fspec256, bin64, bout256); 508 testVectorReshape(fspec64, fspec512, bin64, bout512); 509 testVectorReshape(fspec64, fspecMax, bin64, boutMax); 510 511 testVectorReshape(fspec128, fspec64, bin128, bout64); 512 testVectorReshape(fspec128, fspec128, bin128, bout128); 513 testVectorReshape(fspec128, fspec256, bin128, bout256); 514 testVectorReshape(fspec128, fspec512, bin128, bout512); 515 testVectorReshape(fspec128, fspecMax, bin128, boutMax); 516 517 testVectorReshape(fspec256, fspec64, bin256, bout64); 518 testVectorReshape(fspec256, fspec128, bin256, bout128); 519 testVectorReshape(fspec256, fspec256, bin256, bout256); 520 testVectorReshape(fspec256, fspec512, bin256, bout512); 521 testVectorReshape(fspec256, fspecMax, bin256, boutMax); 522 523 testVectorReshape(fspec512, fspec64, bin512, bout64); 524 testVectorReshape(fspec512, fspec128, bin512, bout128); 525 testVectorReshape(fspec512, fspec256, bin512, bout256); 526 testVectorReshape(fspec512, fspec512, bin512, bout512); 527 testVectorReshape(fspec512, fspecMax, bin512, boutMax); 528 529 testVectorReshape(fspecMax, fspec64, binMax, bout64); 530 testVectorReshape(fspecMax, fspec128, binMax, bout128); 531 testVectorReshape(fspecMax, fspec256, binMax, bout256); 532 testVectorReshape(fspecMax, fspec512, binMax, bout512); 533 testVectorReshape(fspecMax, fspecMax, binMax, boutMax); 534 } 535 } 536 537 @Test(dataProvider = "byteUnaryOpProvider") 538 static void testReshapeDouble(IntFunction<byte[]> fa) { 539 byte[] bin64 = fa.apply(64/Byte.SIZE); 540 byte[] bin128 = fa.apply(128/Byte.SIZE); 541 byte[] bin256 = fa.apply(256/Byte.SIZE); 542 byte[] bin512 = fa.apply(512/Byte.SIZE); 543 byte[] binMax = fa.apply(S_Max_BIT.bitSize()/Byte.SIZE); 544 byte[] bout64 = new byte[bin64.length]; 545 byte[] bout128 = new byte[bin128.length]; 546 byte[] bout256 = new byte[bin256.length]; 547 byte[] bout512 = new byte[bin512.length]; 548 byte[] boutMax = new byte[binMax.length]; 549 550 for (int i = 0; i < NUM_ITER; i++) { 551 testVectorReshape(dspec64, dspec64, bin64, bout64); 552 testVectorReshape(dspec64, dspec128, bin64, bout128); 553 testVectorReshape(dspec64, dspec256, bin64, bout256); 554 testVectorReshape(dspec64, dspec512, bin64, bout512); 555 testVectorReshape(dspec64, dspecMax, bin64, boutMax); 556 557 testVectorReshape(dspec128, dspec64, bin128, bout64); 558 testVectorReshape(dspec128, dspec128, bin128, bout128); 559 testVectorReshape(dspec128, dspec256, bin128, bout256); 560 testVectorReshape(dspec128, dspec512, bin128, bout512); 561 testVectorReshape(dspec128, dspecMax, bin128, boutMax); 562 563 testVectorReshape(dspec256, dspec64, bin256, bout64); 564 testVectorReshape(dspec256, dspec128, bin256, bout128); 565 testVectorReshape(dspec256, dspec256, bin256, bout256); 566 testVectorReshape(dspec256, dspec512, bin256, bout512); 567 testVectorReshape(dspec256, dspecMax, bin256, boutMax); 568 569 testVectorReshape(dspec512, dspec64, bin512, bout64); 570 testVectorReshape(dspec512, dspec128, bin512, bout128); 571 testVectorReshape(dspec512, dspec256, bin512, bout256); 572 testVectorReshape(dspec512, dspec512, bin512, bout512); 573 testVectorReshape(dspec512, dspecMax, bin512, boutMax); 574 575 testVectorReshape(dspecMax, dspec64, binMax, bout64); 576 testVectorReshape(dspecMax, dspec128, binMax, bout128); 577 testVectorReshape(dspecMax, dspec256, binMax, bout256); 578 testVectorReshape(dspecMax, dspec512, binMax, bout512); 579 testVectorReshape(dspecMax, dspecMax, binMax, boutMax); 580 } 581 } 582 583 @ForceInline 584 static <E,F> 585 void testVectorRebracket(Vector.Species<E> a, Vector.Species<F> b, byte[] input, byte[] output) { 586 assert(input.length == output.length); 587 Vector<E> av; 588 589 Class<?> stype = a.elementType(); 590 if (stype == byte.class) { 591 av = (Vector) ByteVector.fromByteArray((ByteVector.ByteSpecies)a, input, 0); 592 } else if (stype == short.class) { 593 av = (Vector) ShortVector.fromByteArray((ShortVector.ShortSpecies)a, input, 0); 594 } else if (stype == int.class) { 595 av = (Vector) IntVector.fromByteArray((IntVector.IntSpecies)a, input, 0); 596 } else if (stype == long.class) { 597 av = (Vector) LongVector.fromByteArray((LongVector.LongSpecies)a, input, 0); 598 } else if (stype == float.class) { 599 av = (Vector) FloatVector.fromByteArray((FloatVector.FloatSpecies)a, input, 0); 600 } else if (stype == double.class) { 601 av = (Vector) DoubleVector.fromByteArray((DoubleVector.DoubleSpecies)a, input, 0); 602 } else { 603 throw new UnsupportedOperationException("Bad lane type"); 604 } 605 Vector<F> bv = av.reinterpret(b); 606 bv.intoByteArray(output, 0); 607 608 Assert.assertEquals(input, output); 609 } 610 611 @Test(dataProvider = "byteUnaryOpProvider") 612 static void testRebracket64(IntFunction<byte[]> fa) { 613 byte[] barr = fa.apply(64/Byte.SIZE); 614 byte[] bout = new byte[barr.length]; 615 for (int i = 0; i < NUM_ITER; i++) { 616 testVectorRebracket(bspec64, bspec64, barr, bout); 617 testVectorRebracket(bspec64, sspec64, barr, bout); 618 testVectorRebracket(bspec64, ispec64, barr, bout); 619 testVectorRebracket(bspec64, lspec64, barr, bout); 620 testVectorRebracket(bspec64, fspec64, barr, bout); 621 testVectorRebracket(bspec64, dspec64, barr, bout); 622 623 testVectorRebracket(sspec64, bspec64, barr, bout); 624 testVectorRebracket(sspec64, sspec64, barr, bout); 625 testVectorRebracket(sspec64, ispec64, barr, bout); 626 testVectorRebracket(sspec64, lspec64, barr, bout); 627 testVectorRebracket(sspec64, fspec64, barr, bout); 628 testVectorRebracket(sspec64, dspec64, barr, bout); 629 630 testVectorRebracket(ispec64, bspec64, barr, bout); 631 testVectorRebracket(ispec64, sspec64, barr, bout); 632 testVectorRebracket(ispec64, ispec64, barr, bout); 633 testVectorRebracket(ispec64, lspec64, barr, bout); 634 testVectorRebracket(ispec64, fspec64, barr, bout); 635 testVectorRebracket(ispec64, dspec64, barr, bout); 636 637 testVectorRebracket(lspec64, bspec64, barr, bout); 638 testVectorRebracket(lspec64, sspec64, barr, bout); 639 testVectorRebracket(lspec64, ispec64, barr, bout); 640 testVectorRebracket(lspec64, lspec64, barr, bout); 641 testVectorRebracket(lspec64, fspec64, barr, bout); 642 testVectorRebracket(lspec64, dspec64, barr, bout); 643 644 testVectorRebracket(fspec64, bspec64, barr, bout); 645 testVectorRebracket(fspec64, sspec64, barr, bout); 646 testVectorRebracket(fspec64, ispec64, barr, bout); 647 testVectorRebracket(fspec64, lspec64, barr, bout); 648 testVectorRebracket(fspec64, fspec64, barr, bout); 649 testVectorRebracket(fspec64, dspec64, barr, bout); 650 651 testVectorRebracket(dspec64, bspec64, barr, bout); 652 testVectorRebracket(dspec64, sspec64, barr, bout); 653 testVectorRebracket(dspec64, ispec64, barr, bout); 654 testVectorRebracket(dspec64, lspec64, barr, bout); 655 testVectorRebracket(dspec64, fspec64, barr, bout); 656 testVectorRebracket(dspec64, dspec64, barr, bout); 657 } 658 } 659 660 @Test(dataProvider = "byteUnaryOpProvider") 661 static void testRebracket128(IntFunction<byte[]> fa) { 662 byte[] barr = fa.apply(128/Byte.SIZE); 663 byte[] bout = new byte[barr.length]; 664 for (int i = 0; i < NUM_ITER; i++) { 665 testVectorRebracket(bspec128, bspec128, barr, bout); 666 testVectorRebracket(bspec128, sspec128, barr, bout); 667 testVectorRebracket(bspec128, ispec128, barr, bout); 668 testVectorRebracket(bspec128, lspec128, barr, bout); 669 testVectorRebracket(bspec128, fspec128, barr, bout); 670 testVectorRebracket(bspec128, dspec128, barr, bout); 671 672 testVectorRebracket(sspec128, bspec128, barr, bout); 673 testVectorRebracket(sspec128, sspec128, barr, bout); 674 testVectorRebracket(sspec128, ispec128, barr, bout); 675 testVectorRebracket(sspec128, lspec128, barr, bout); 676 testVectorRebracket(sspec128, fspec128, barr, bout); 677 testVectorRebracket(sspec128, dspec128, barr, bout); 678 679 testVectorRebracket(ispec128, bspec128, barr, bout); 680 testVectorRebracket(ispec128, sspec128, barr, bout); 681 testVectorRebracket(ispec128, ispec128, barr, bout); 682 testVectorRebracket(ispec128, lspec128, barr, bout); 683 testVectorRebracket(ispec128, fspec128, barr, bout); 684 testVectorRebracket(ispec128, dspec128, barr, bout); 685 686 testVectorRebracket(lspec128, bspec128, barr, bout); 687 testVectorRebracket(lspec128, sspec128, barr, bout); 688 testVectorRebracket(lspec128, ispec128, barr, bout); 689 testVectorRebracket(lspec128, lspec128, barr, bout); 690 testVectorRebracket(lspec128, fspec128, barr, bout); 691 testVectorRebracket(lspec128, dspec128, barr, bout); 692 693 testVectorRebracket(fspec128, bspec128, barr, bout); 694 testVectorRebracket(fspec128, sspec128, barr, bout); 695 testVectorRebracket(fspec128, ispec128, barr, bout); 696 testVectorRebracket(fspec128, lspec128, barr, bout); 697 testVectorRebracket(fspec128, fspec128, barr, bout); 698 testVectorRebracket(fspec128, dspec128, barr, bout); 699 700 testVectorRebracket(dspec128, bspec128, barr, bout); 701 testVectorRebracket(dspec128, sspec128, barr, bout); 702 testVectorRebracket(dspec128, ispec128, barr, bout); 703 testVectorRebracket(dspec128, lspec128, barr, bout); 704 testVectorRebracket(dspec128, fspec128, barr, bout); 705 testVectorRebracket(dspec128, dspec128, barr, bout); 706 } 707 } 708 709 @Test(dataProvider = "byteUnaryOpProvider") 710 static void testRebracket256(IntFunction<byte[]> fa) { 711 byte[] barr = fa.apply(256/Byte.SIZE); 712 byte[] bout = new byte[barr.length]; 713 for (int i = 0; i < NUM_ITER; i++) { 714 testVectorRebracket(bspec256, bspec256, barr, bout); 715 testVectorRebracket(bspec256, sspec256, barr, bout); 716 testVectorRebracket(bspec256, ispec256, barr, bout); 717 testVectorRebracket(bspec256, lspec256, barr, bout); 718 testVectorRebracket(bspec256, fspec256, barr, bout); 719 testVectorRebracket(bspec256, dspec256, barr, bout); 720 721 testVectorRebracket(sspec256, bspec256, barr, bout); 722 testVectorRebracket(sspec256, sspec256, barr, bout); 723 testVectorRebracket(sspec256, ispec256, barr, bout); 724 testVectorRebracket(sspec256, lspec256, barr, bout); 725 testVectorRebracket(sspec256, fspec256, barr, bout); 726 testVectorRebracket(sspec256, dspec256, barr, bout); 727 728 testVectorRebracket(ispec256, bspec256, barr, bout); 729 testVectorRebracket(ispec256, sspec256, barr, bout); 730 testVectorRebracket(ispec256, ispec256, barr, bout); 731 testVectorRebracket(ispec256, lspec256, barr, bout); 732 testVectorRebracket(ispec256, fspec256, barr, bout); 733 testVectorRebracket(ispec256, dspec256, barr, bout); 734 735 testVectorRebracket(lspec256, bspec256, barr, bout); 736 testVectorRebracket(lspec256, sspec256, barr, bout); 737 testVectorRebracket(lspec256, ispec256, barr, bout); 738 testVectorRebracket(lspec256, lspec256, barr, bout); 739 testVectorRebracket(lspec256, fspec256, barr, bout); 740 testVectorRebracket(lspec256, dspec256, barr, bout); 741 742 testVectorRebracket(fspec256, bspec256, barr, bout); 743 testVectorRebracket(fspec256, sspec256, barr, bout); 744 testVectorRebracket(fspec256, ispec256, barr, bout); 745 testVectorRebracket(fspec256, lspec256, barr, bout); 746 testVectorRebracket(fspec256, fspec256, barr, bout); 747 testVectorRebracket(fspec256, dspec256, barr, bout); 748 749 testVectorRebracket(dspec256, bspec256, barr, bout); 750 testVectorRebracket(dspec256, sspec256, barr, bout); 751 testVectorRebracket(dspec256, ispec256, barr, bout); 752 testVectorRebracket(dspec256, lspec256, barr, bout); 753 testVectorRebracket(dspec256, fspec256, barr, bout); 754 testVectorRebracket(dspec256, dspec256, barr, bout); 755 } 756 } 757 758 @Test(dataProvider = "byteUnaryOpProvider") 759 static void testRebracket512(IntFunction<byte[]> fa) { 760 byte[] barr = fa.apply(512/Byte.SIZE); 761 byte[] bout = new byte[barr.length]; 762 for (int i = 0; i < NUM_ITER; i++) { 763 testVectorRebracket(bspec512, bspec512, barr, bout); 764 testVectorRebracket(bspec512, sspec512, barr, bout); 765 testVectorRebracket(bspec512, ispec512, barr, bout); 766 testVectorRebracket(bspec512, lspec512, barr, bout); 767 testVectorRebracket(bspec512, fspec512, barr, bout); 768 testVectorRebracket(bspec512, dspec512, barr, bout); 769 770 testVectorRebracket(sspec512, bspec512, barr, bout); 771 testVectorRebracket(sspec512, sspec512, barr, bout); 772 testVectorRebracket(sspec512, ispec512, barr, bout); 773 testVectorRebracket(sspec512, lspec512, barr, bout); 774 testVectorRebracket(sspec512, fspec512, barr, bout); 775 testVectorRebracket(sspec512, dspec512, barr, bout); 776 777 testVectorRebracket(ispec512, bspec512, barr, bout); 778 testVectorRebracket(ispec512, sspec512, barr, bout); 779 testVectorRebracket(ispec512, ispec512, barr, bout); 780 testVectorRebracket(ispec512, lspec512, barr, bout); 781 testVectorRebracket(ispec512, fspec512, barr, bout); 782 testVectorRebracket(ispec512, dspec512, barr, bout); 783 784 testVectorRebracket(lspec512, bspec512, barr, bout); 785 testVectorRebracket(lspec512, sspec512, barr, bout); 786 testVectorRebracket(lspec512, ispec512, barr, bout); 787 testVectorRebracket(lspec512, lspec512, barr, bout); 788 testVectorRebracket(lspec512, fspec512, barr, bout); 789 testVectorRebracket(lspec512, dspec512, barr, bout); 790 791 testVectorRebracket(fspec512, bspec512, barr, bout); 792 testVectorRebracket(fspec512, sspec512, barr, bout); 793 testVectorRebracket(fspec512, ispec512, barr, bout); 794 testVectorRebracket(fspec512, lspec512, barr, bout); 795 testVectorRebracket(fspec512, fspec512, barr, bout); 796 testVectorRebracket(fspec512, dspec512, barr, bout); 797 798 testVectorRebracket(dspec512, bspec512, barr, bout); 799 testVectorRebracket(dspec512, sspec512, barr, bout); 800 testVectorRebracket(dspec512, ispec512, barr, bout); 801 testVectorRebracket(dspec512, lspec512, barr, bout); 802 testVectorRebracket(dspec512, fspec512, barr, bout); 803 testVectorRebracket(dspec512, dspec512, barr, bout); 804 } 805 } 806 807 @Test(dataProvider = "byteUnaryOpProvider") 808 static void testRebracketMax(IntFunction<byte[]> fa) { 809 byte[] barr = fa.apply(S_Max_BIT.bitSize()/Byte.SIZE); 810 byte[] bout = new byte[barr.length]; 811 for (int i = 0; i < NUM_ITER; i++) { 812 testVectorRebracket(bspecMax, bspecMax, barr, bout); 813 testVectorRebracket(bspecMax, sspecMax, barr, bout); 814 testVectorRebracket(bspecMax, ispecMax, barr, bout); 815 testVectorRebracket(bspecMax, lspecMax, barr, bout); 816 testVectorRebracket(bspecMax, fspecMax, barr, bout); 817 testVectorRebracket(bspecMax, dspecMax, barr, bout); 818 819 testVectorRebracket(sspecMax, bspecMax, barr, bout); 820 testVectorRebracket(sspecMax, sspecMax, barr, bout); 821 testVectorRebracket(sspecMax, ispecMax, barr, bout); 822 testVectorRebracket(sspecMax, lspecMax, barr, bout); 823 testVectorRebracket(sspecMax, fspecMax, barr, bout); 824 testVectorRebracket(sspecMax, dspecMax, barr, bout); 825 826 testVectorRebracket(ispecMax, bspecMax, barr, bout); 827 testVectorRebracket(ispecMax, sspecMax, barr, bout); 828 testVectorRebracket(ispecMax, ispecMax, barr, bout); 829 testVectorRebracket(ispecMax, lspecMax, barr, bout); 830 testVectorRebracket(ispecMax, fspecMax, barr, bout); 831 testVectorRebracket(ispecMax, dspecMax, barr, bout); 832 833 testVectorRebracket(lspecMax, bspecMax, barr, bout); 834 testVectorRebracket(lspecMax, sspecMax, barr, bout); 835 testVectorRebracket(lspecMax, ispecMax, barr, bout); 836 testVectorRebracket(lspecMax, lspecMax, barr, bout); 837 testVectorRebracket(lspecMax, fspecMax, barr, bout); 838 testVectorRebracket(lspecMax, dspecMax, barr, bout); 839 840 testVectorRebracket(fspecMax, bspecMax, barr, bout); 841 testVectorRebracket(fspecMax, sspecMax, barr, bout); 842 testVectorRebracket(fspecMax, ispecMax, barr, bout); 843 testVectorRebracket(fspecMax, lspecMax, barr, bout); 844 testVectorRebracket(fspecMax, fspecMax, barr, bout); 845 testVectorRebracket(fspecMax, dspecMax, barr, bout); 846 847 testVectorRebracket(dspecMax, bspecMax, barr, bout); 848 testVectorRebracket(dspecMax, sspecMax, barr, bout); 849 testVectorRebracket(dspecMax, ispecMax, barr, bout); 850 testVectorRebracket(dspecMax, lspecMax, barr, bout); 851 testVectorRebracket(dspecMax, fspecMax, barr, bout); 852 testVectorRebracket(dspecMax, dspecMax, barr, bout); 853 } 854 } 855 856 @ForceInline 857 static 858 void testVectorCastByteToFloat(ByteVector.ByteSpecies a, FloatVector.FloatSpecies b, byte[] input, float[] output) { 859 assert(input.length == a.length()); 860 assert(output.length == b.length()); 861 862 ByteVector av = ByteVector.fromArray(a, input, 0); 863 FloatVector bv = (FloatVector) av.cast(b); 864 bv.intoArray(output, 0); 865 866 for (int i = 0; i < Math.min(input.length, output.length); i++) { 867 Assert.assertEquals(output[i], (float)input[i]); 868 } 869 for(int i = input.length; i < output.length; i++) { 870 Assert.assertEquals(output[i], (float)0); 871 } 872 } 873 874 @ForceInline 875 static 876 void testVectorCastByteToFloatFail(ByteVector.ByteSpecies a, FloatVector.FloatSpecies b, byte[] input) { 877 assert(input.length == a.length()); 878 879 ByteVector av = ByteVector.fromArray(a, input, 0); 880 try { 881 av.cast(b); 882 Assert.fail(String.format( 883 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 884 a, b)); 885 } catch (IllegalArgumentException e) { 886 } 887 } 888 889 @ForceInline 890 static 891 void testVectorCastShortToFloat(ShortVector.ShortSpecies a, FloatVector.FloatSpecies b, short[] input, float[] output) { 892 assert(input.length == a.length()); 893 assert(output.length == b.length()); 894 895 ShortVector av = ShortVector.fromArray(a, input, 0); 896 FloatVector bv = (FloatVector) av.cast(b); 897 bv.intoArray(output, 0); 898 899 for (int i = 0; i < Math.min(input.length, output.length); i++) { 900 Assert.assertEquals(output[i], (float)input[i]); 901 } 902 for(int i = input.length; i < output.length; i++) { 903 Assert.assertEquals(output[i], (float)0); 904 } 905 } 906 907 @ForceInline 908 static 909 void testVectorCastShortToFloatFail(ShortVector.ShortSpecies a, FloatVector.FloatSpecies b, short[] input) { 910 assert(input.length == a.length()); 911 912 ShortVector av = ShortVector.fromArray(a, input, 0); 913 try { 914 av.cast(b); 915 Assert.fail(String.format( 916 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 917 a, b)); 918 } catch (IllegalArgumentException e) { 919 } 920 } 921 922 @ForceInline 923 static 924 void testVectorCastIntToFloat(IntVector.IntSpecies a, FloatVector.FloatSpecies b, int[] input, float[] output) { 925 assert(input.length == a.length()); 926 assert(output.length == b.length()); 927 928 IntVector av = IntVector.fromArray(a, input, 0); 929 FloatVector bv = (FloatVector) av.cast(b); 930 bv.intoArray(output, 0); 931 932 for (int i = 0; i < Math.min(input.length, output.length); i++) { 933 Assert.assertEquals(output[i], (float)input[i]); 934 } 935 for(int i = input.length; i < output.length; i++) { 936 Assert.assertEquals(output[i], (float)0); 937 } 938 } 939 940 @ForceInline 941 static 942 void testVectorCastIntToFloatFail(IntVector.IntSpecies a, FloatVector.FloatSpecies b, int[] input) { 943 assert(input.length == a.length()); 944 945 IntVector av = IntVector.fromArray(a, input, 0); 946 try { 947 av.cast(b); 948 Assert.fail(String.format( 949 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 950 a, b)); 951 } catch (IllegalArgumentException e) { 952 } 953 } 954 955 @ForceInline 956 static 957 void testVectorCastLongToFloat(LongVector.LongSpecies a, FloatVector.FloatSpecies b, long[] input, float[] output) { 958 assert(input.length == a.length()); 959 assert(output.length == b.length()); 960 961 LongVector av = LongVector.fromArray(a, input, 0); 962 FloatVector bv = (FloatVector) av.cast(b); 963 bv.intoArray(output, 0); 964 965 for (int i = 0; i < Math.min(input.length, output.length); i++) { 966 Assert.assertEquals(output[i], (float)input[i]); 967 } 968 for(int i = input.length; i < output.length; i++) { 969 Assert.assertEquals(output[i], (float)0); 970 } 971 } 972 973 @ForceInline 974 static 975 void testVectorCastLongToFloatFail(LongVector.LongSpecies a, FloatVector.FloatSpecies b, long[] input) { 976 assert(input.length == a.length()); 977 978 LongVector av = LongVector.fromArray(a, input, 0); 979 try { 980 av.cast(b); 981 Assert.fail(String.format( 982 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 983 a, b)); 984 } catch (IllegalArgumentException e) { 985 } 986 } 987 988 @ForceInline 989 static 990 void testVectorCastFloatToFloat(FloatVector.FloatSpecies a, FloatVector.FloatSpecies b, float[] input, float[] output) { 991 assert(input.length == a.length()); 992 assert(output.length == b.length()); 993 994 FloatVector av = FloatVector.fromArray(a, input, 0); 995 FloatVector bv = (FloatVector) av.cast(b); 996 bv.intoArray(output, 0); 997 998 for (int i = 0; i < Math.min(input.length, output.length); i++) { 999 Assert.assertEquals(output[i], (float)input[i]); 1000 } 1001 for(int i = input.length; i < output.length; i++) { 1002 Assert.assertEquals(output[i], (float)0); 1003 } 1004 } 1005 1006 @ForceInline 1007 static 1008 void testVectorCastFloatToFloatFail(FloatVector.FloatSpecies a, FloatVector.FloatSpecies b, float[] input) { 1009 assert(input.length == a.length()); 1010 1011 FloatVector av = FloatVector.fromArray(a, input, 0); 1012 try { 1013 av.cast(b); 1014 Assert.fail(String.format( 1015 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1016 a, b)); 1017 } catch (IllegalArgumentException e) { 1018 } 1019 } 1020 1021 @ForceInline 1022 static 1023 void testVectorCastDoubleToFloat(DoubleVector.DoubleSpecies a, FloatVector.FloatSpecies b, double[] input, float[] output) { 1024 assert(input.length == a.length()); 1025 assert(output.length == b.length()); 1026 1027 DoubleVector av = DoubleVector.fromArray(a, input, 0); 1028 FloatVector bv = (FloatVector) av.cast(b); 1029 bv.intoArray(output, 0); 1030 1031 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1032 Assert.assertEquals(output[i], (float)input[i]); 1033 } 1034 for(int i = input.length; i < output.length; i++) { 1035 Assert.assertEquals(output[i], (float)0); 1036 } 1037 } 1038 1039 @ForceInline 1040 static 1041 void testVectorCastDoubleToFloatFail(DoubleVector.DoubleSpecies a, FloatVector.FloatSpecies b, double[] input) { 1042 assert(input.length == a.length()); 1043 1044 DoubleVector av = DoubleVector.fromArray(a, input, 0); 1045 try { 1046 av.cast(b); 1047 Assert.fail(String.format( 1048 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1049 a, b)); 1050 } catch (IllegalArgumentException e) { 1051 } 1052 } 1053 1054 @ForceInline 1055 static 1056 void testVectorCastByteToByte(ByteVector.ByteSpecies a, ByteVector.ByteSpecies b, byte[] input, byte[] output) { 1057 assert(input.length == a.length()); 1058 assert(output.length == b.length()); 1059 1060 ByteVector av = ByteVector.fromArray(a, input, 0); 1061 ByteVector bv = (ByteVector) av.cast(b); 1062 bv.intoArray(output, 0); 1063 1064 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1065 Assert.assertEquals(output[i], (byte)input[i]); 1066 } 1067 for(int i = input.length; i < output.length; i++) { 1068 Assert.assertEquals(output[i], (byte)0); 1069 } 1070 } 1071 1072 @ForceInline 1073 static 1074 void testVectorCastByteToByteFail(ByteVector.ByteSpecies a, ByteVector.ByteSpecies b, byte[] input) { 1075 assert(input.length == a.length()); 1076 1077 ByteVector av = ByteVector.fromArray(a, input, 0); 1078 try { 1079 av.cast(b); 1080 Assert.fail(String.format( 1081 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1082 a, b)); 1083 } catch (IllegalArgumentException e) { 1084 } 1085 } 1086 1087 @ForceInline 1088 static 1089 void testVectorCastShortToByte(ShortVector.ShortSpecies a, ByteVector.ByteSpecies b, short[] input, byte[] output) { 1090 assert(input.length == a.length()); 1091 assert(output.length == b.length()); 1092 1093 ShortVector av = ShortVector.fromArray(a, input, 0); 1094 ByteVector bv = (ByteVector) av.cast(b); 1095 bv.intoArray(output, 0); 1096 1097 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1098 Assert.assertEquals(output[i], (byte)input[i]); 1099 } 1100 for(int i = input.length; i < output.length; i++) { 1101 Assert.assertEquals(output[i], (byte)0); 1102 } 1103 } 1104 1105 @ForceInline 1106 static 1107 void testVectorCastShortToByteFail(ShortVector.ShortSpecies a, ByteVector.ByteSpecies b, short[] input) { 1108 assert(input.length == a.length()); 1109 1110 ShortVector av = ShortVector.fromArray(a, input, 0); 1111 try { 1112 av.cast(b); 1113 Assert.fail(String.format( 1114 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1115 a, b)); 1116 } catch (IllegalArgumentException e) { 1117 } 1118 } 1119 1120 @ForceInline 1121 static 1122 void testVectorCastIntToByte(IntVector.IntSpecies a, ByteVector.ByteSpecies b, int[] input, byte[] output) { 1123 assert(input.length == a.length()); 1124 assert(output.length == b.length()); 1125 1126 IntVector av = IntVector.fromArray(a, input, 0); 1127 ByteVector bv = (ByteVector) av.cast(b); 1128 bv.intoArray(output, 0); 1129 1130 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1131 Assert.assertEquals(output[i], (byte)input[i]); 1132 } 1133 for(int i = input.length; i < output.length; i++) { 1134 Assert.assertEquals(output[i], (byte)0); 1135 } 1136 } 1137 1138 @ForceInline 1139 static 1140 void testVectorCastIntToByteFail(IntVector.IntSpecies a, ByteVector.ByteSpecies b, int[] input) { 1141 assert(input.length == a.length()); 1142 1143 IntVector av = IntVector.fromArray(a, input, 0); 1144 try { 1145 av.cast(b); 1146 Assert.fail(String.format( 1147 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1148 a, b)); 1149 } catch (IllegalArgumentException e) { 1150 } 1151 } 1152 1153 @ForceInline 1154 static 1155 void testVectorCastLongToByte(LongVector.LongSpecies a, ByteVector.ByteSpecies b, long[] input, byte[] output) { 1156 assert(input.length == a.length()); 1157 assert(output.length == b.length()); 1158 1159 LongVector av = LongVector.fromArray(a, input, 0); 1160 ByteVector bv = (ByteVector) av.cast(b); 1161 bv.intoArray(output, 0); 1162 1163 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1164 Assert.assertEquals(output[i], (byte)input[i]); 1165 } 1166 for(int i = input.length; i < output.length; i++) { 1167 Assert.assertEquals(output[i], (byte)0); 1168 } 1169 } 1170 1171 @ForceInline 1172 static 1173 void testVectorCastLongToByteFail(LongVector.LongSpecies a, ByteVector.ByteSpecies b, long[] input) { 1174 assert(input.length == a.length()); 1175 1176 LongVector av = LongVector.fromArray(a, input, 0); 1177 try { 1178 av.cast(b); 1179 Assert.fail(String.format( 1180 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1181 a, b)); 1182 } catch (IllegalArgumentException e) { 1183 } 1184 } 1185 1186 @ForceInline 1187 static 1188 void testVectorCastFloatToByte(FloatVector.FloatSpecies a, ByteVector.ByteSpecies b, float[] input, byte[] output) { 1189 assert(input.length == a.length()); 1190 assert(output.length == b.length()); 1191 1192 FloatVector av = FloatVector.fromArray(a, input, 0); 1193 ByteVector bv = (ByteVector) av.cast(b); 1194 bv.intoArray(output, 0); 1195 1196 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1197 Assert.assertEquals(output[i], (byte)input[i]); 1198 } 1199 for(int i = input.length; i < output.length; i++) { 1200 Assert.assertEquals(output[i], (byte)0); 1201 } 1202 } 1203 1204 @ForceInline 1205 static 1206 void testVectorCastFloatToByteFail(FloatVector.FloatSpecies a, ByteVector.ByteSpecies b, float[] input) { 1207 assert(input.length == a.length()); 1208 1209 FloatVector av = FloatVector.fromArray(a, input, 0); 1210 try { 1211 av.cast(b); 1212 Assert.fail(String.format( 1213 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1214 a, b)); 1215 } catch (IllegalArgumentException e) { 1216 } 1217 } 1218 1219 @ForceInline 1220 static 1221 void testVectorCastDoubleToByte(DoubleVector.DoubleSpecies a, ByteVector.ByteSpecies b, double[] input, byte[] output) { 1222 assert(input.length == a.length()); 1223 assert(output.length == b.length()); 1224 1225 DoubleVector av = DoubleVector.fromArray(a, input, 0); 1226 ByteVector bv = (ByteVector) av.cast(b); 1227 bv.intoArray(output, 0); 1228 1229 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1230 Assert.assertEquals(output[i], (byte)input[i]); 1231 } 1232 for(int i = input.length; i < output.length; i++) { 1233 Assert.assertEquals(output[i], (byte)0); 1234 } 1235 } 1236 1237 @ForceInline 1238 static 1239 void testVectorCastDoubleToByteFail(DoubleVector.DoubleSpecies a, ByteVector.ByteSpecies b, double[] input) { 1240 assert(input.length == a.length()); 1241 1242 DoubleVector av = DoubleVector.fromArray(a, input, 0); 1243 try { 1244 av.cast(b); 1245 Assert.fail(String.format( 1246 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1247 a, b)); 1248 } catch (IllegalArgumentException e) { 1249 } 1250 } 1251 1252 @ForceInline 1253 static 1254 void testVectorCastByteToShort(ByteVector.ByteSpecies a, ShortVector.ShortSpecies b, byte[] input, short[] output) { 1255 assert(input.length == a.length()); 1256 assert(output.length == b.length()); 1257 1258 ByteVector av = ByteVector.fromArray(a, input, 0); 1259 ShortVector bv = (ShortVector) av.cast(b); 1260 bv.intoArray(output, 0); 1261 1262 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1263 Assert.assertEquals(output[i], (short)input[i]); 1264 } 1265 for(int i = input.length; i < output.length; i++) { 1266 Assert.assertEquals(output[i], (short)0); 1267 } 1268 } 1269 1270 @ForceInline 1271 static 1272 void testVectorCastByteToShortFail(ByteVector.ByteSpecies a, ShortVector.ShortSpecies b, byte[] input) { 1273 assert(input.length == a.length()); 1274 1275 ByteVector av = ByteVector.fromArray(a, input, 0); 1276 try { 1277 av.cast(b); 1278 Assert.fail(String.format( 1279 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1280 a, b)); 1281 } catch (IllegalArgumentException e) { 1282 } 1283 } 1284 1285 @ForceInline 1286 static 1287 void testVectorCastShortToShort(ShortVector.ShortSpecies a, ShortVector.ShortSpecies b, short[] input, short[] output) { 1288 assert(input.length == a.length()); 1289 assert(output.length == b.length()); 1290 1291 ShortVector av = ShortVector.fromArray(a, input, 0); 1292 ShortVector bv = (ShortVector) av.cast(b); 1293 bv.intoArray(output, 0); 1294 1295 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1296 Assert.assertEquals(output[i], (short)input[i]); 1297 } 1298 for(int i = input.length; i < output.length; i++) { 1299 Assert.assertEquals(output[i], (short)0); 1300 } 1301 } 1302 1303 @ForceInline 1304 static 1305 void testVectorCastShortToShortFail(ShortVector.ShortSpecies a, ShortVector.ShortSpecies b, short[] input) { 1306 assert(input.length == a.length()); 1307 1308 ShortVector av = ShortVector.fromArray(a, input, 0); 1309 try { 1310 av.cast(b); 1311 Assert.fail(String.format( 1312 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1313 a, b)); 1314 } catch (IllegalArgumentException e) { 1315 } 1316 } 1317 1318 @ForceInline 1319 static 1320 void testVectorCastIntToShort(IntVector.IntSpecies a, ShortVector.ShortSpecies b, int[] input, short[] output) { 1321 assert(input.length == a.length()); 1322 assert(output.length == b.length()); 1323 1324 IntVector av = IntVector.fromArray(a, input, 0); 1325 ShortVector bv = (ShortVector) av.cast(b); 1326 bv.intoArray(output, 0); 1327 1328 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1329 Assert.assertEquals(output[i], (short)input[i]); 1330 } 1331 for(int i = input.length; i < output.length; i++) { 1332 Assert.assertEquals(output[i], (short)0); 1333 } 1334 } 1335 1336 @ForceInline 1337 static 1338 void testVectorCastIntToShortFail(IntVector.IntSpecies a, ShortVector.ShortSpecies b, int[] input) { 1339 assert(input.length == a.length()); 1340 1341 IntVector av = IntVector.fromArray(a, input, 0); 1342 try { 1343 av.cast(b); 1344 Assert.fail(String.format( 1345 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1346 a, b)); 1347 } catch (IllegalArgumentException e) { 1348 } 1349 } 1350 1351 @ForceInline 1352 static 1353 void testVectorCastLongToShort(LongVector.LongSpecies a, ShortVector.ShortSpecies b, long[] input, short[] output) { 1354 assert(input.length == a.length()); 1355 assert(output.length == b.length()); 1356 1357 LongVector av = LongVector.fromArray(a, input, 0); 1358 ShortVector bv = (ShortVector) av.cast(b); 1359 bv.intoArray(output, 0); 1360 1361 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1362 Assert.assertEquals(output[i], (short)input[i]); 1363 } 1364 for(int i = input.length; i < output.length; i++) { 1365 Assert.assertEquals(output[i], (short)0); 1366 } 1367 } 1368 1369 @ForceInline 1370 static 1371 void testVectorCastLongToShortFail(LongVector.LongSpecies a, ShortVector.ShortSpecies b, long[] input) { 1372 assert(input.length == a.length()); 1373 1374 LongVector av = LongVector.fromArray(a, input, 0); 1375 try { 1376 av.cast(b); 1377 Assert.fail(String.format( 1378 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1379 a, b)); 1380 } catch (IllegalArgumentException e) { 1381 } 1382 } 1383 1384 @ForceInline 1385 static 1386 void testVectorCastFloatToShort(FloatVector.FloatSpecies a, ShortVector.ShortSpecies b, float[] input, short[] output) { 1387 assert(input.length == a.length()); 1388 assert(output.length == b.length()); 1389 1390 FloatVector av = FloatVector.fromArray(a, input, 0); 1391 ShortVector bv = (ShortVector) av.cast(b); 1392 bv.intoArray(output, 0); 1393 1394 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1395 Assert.assertEquals(output[i], (short)input[i]); 1396 } 1397 for(int i = input.length; i < output.length; i++) { 1398 Assert.assertEquals(output[i], (short)0); 1399 } 1400 } 1401 1402 @ForceInline 1403 static 1404 void testVectorCastFloatToShortFail(FloatVector.FloatSpecies a, ShortVector.ShortSpecies b, float[] input) { 1405 assert(input.length == a.length()); 1406 1407 FloatVector av = FloatVector.fromArray(a, input, 0); 1408 try { 1409 av.cast(b); 1410 Assert.fail(String.format( 1411 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1412 a, b)); 1413 } catch (IllegalArgumentException e) { 1414 } 1415 } 1416 1417 @ForceInline 1418 static 1419 void testVectorCastDoubleToShort(DoubleVector.DoubleSpecies a, ShortVector.ShortSpecies b, double[] input, short[] output) { 1420 assert(input.length == a.length()); 1421 assert(output.length == b.length()); 1422 1423 DoubleVector av = DoubleVector.fromArray(a, input, 0); 1424 ShortVector bv = (ShortVector) av.cast(b); 1425 bv.intoArray(output, 0); 1426 1427 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1428 Assert.assertEquals(output[i], (short)input[i]); 1429 } 1430 for(int i = input.length; i < output.length; i++) { 1431 Assert.assertEquals(output[i], (short)0); 1432 } 1433 } 1434 1435 @ForceInline 1436 static 1437 void testVectorCastDoubleToShortFail(DoubleVector.DoubleSpecies a, ShortVector.ShortSpecies b, double[] input) { 1438 assert(input.length == a.length()); 1439 1440 DoubleVector av = DoubleVector.fromArray(a, input, 0); 1441 try { 1442 av.cast(b); 1443 Assert.fail(String.format( 1444 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1445 a, b)); 1446 } catch (IllegalArgumentException e) { 1447 } 1448 } 1449 1450 @ForceInline 1451 static 1452 void testVectorCastByteToInt(ByteVector.ByteSpecies a, IntVector.IntSpecies b, byte[] input, int[] output) { 1453 assert(input.length == a.length()); 1454 assert(output.length == b.length()); 1455 1456 ByteVector av = ByteVector.fromArray(a, input, 0); 1457 IntVector bv = (IntVector) av.cast(b); 1458 bv.intoArray(output, 0); 1459 1460 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1461 Assert.assertEquals(output[i], (int)input[i]); 1462 } 1463 for(int i = input.length; i < output.length; i++) { 1464 Assert.assertEquals(output[i], (int)0); 1465 } 1466 } 1467 1468 @ForceInline 1469 static 1470 void testVectorCastByteToIntFail(ByteVector.ByteSpecies a, IntVector.IntSpecies b, byte[] input) { 1471 assert(input.length == a.length()); 1472 1473 ByteVector av = ByteVector.fromArray(a, input, 0); 1474 try { 1475 av.cast(b); 1476 Assert.fail(String.format( 1477 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1478 a, b)); 1479 } catch (IllegalArgumentException e) { 1480 } 1481 } 1482 1483 @ForceInline 1484 static 1485 void testVectorCastShortToInt(ShortVector.ShortSpecies a, IntVector.IntSpecies b, short[] input, int[] output) { 1486 assert(input.length == a.length()); 1487 assert(output.length == b.length()); 1488 1489 ShortVector av = ShortVector.fromArray(a, input, 0); 1490 IntVector bv = (IntVector) av.cast(b); 1491 bv.intoArray(output, 0); 1492 1493 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1494 Assert.assertEquals(output[i], (int)input[i]); 1495 } 1496 for(int i = input.length; i < output.length; i++) { 1497 Assert.assertEquals(output[i], (int)0); 1498 } 1499 } 1500 1501 @ForceInline 1502 static 1503 void testVectorCastShortToIntFail(ShortVector.ShortSpecies a, IntVector.IntSpecies b, short[] input) { 1504 assert(input.length == a.length()); 1505 1506 ShortVector av = ShortVector.fromArray(a, input, 0); 1507 try { 1508 av.cast(b); 1509 Assert.fail(String.format( 1510 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1511 a, b)); 1512 } catch (IllegalArgumentException e) { 1513 } 1514 } 1515 1516 @ForceInline 1517 static 1518 void testVectorCastIntToInt(IntVector.IntSpecies a, IntVector.IntSpecies b, int[] input, int[] output) { 1519 assert(input.length == a.length()); 1520 assert(output.length == b.length()); 1521 1522 IntVector av = IntVector.fromArray(a, input, 0); 1523 IntVector bv = (IntVector) av.cast(b); 1524 bv.intoArray(output, 0); 1525 1526 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1527 Assert.assertEquals(output[i], (int)input[i]); 1528 } 1529 for(int i = input.length; i < output.length; i++) { 1530 Assert.assertEquals(output[i], (int)0); 1531 } 1532 } 1533 1534 @ForceInline 1535 static 1536 void testVectorCastIntToIntFail(IntVector.IntSpecies a, IntVector.IntSpecies b, int[] input) { 1537 assert(input.length == a.length()); 1538 1539 IntVector av = IntVector.fromArray(a, input, 0); 1540 try { 1541 av.cast(b); 1542 Assert.fail(String.format( 1543 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1544 a, b)); 1545 } catch (IllegalArgumentException e) { 1546 } 1547 } 1548 1549 @ForceInline 1550 static 1551 void testVectorCastLongToInt(LongVector.LongSpecies a, IntVector.IntSpecies b, long[] input, int[] output) { 1552 assert(input.length == a.length()); 1553 assert(output.length == b.length()); 1554 1555 LongVector av = LongVector.fromArray(a, input, 0); 1556 IntVector bv = (IntVector) av.cast(b); 1557 bv.intoArray(output, 0); 1558 1559 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1560 Assert.assertEquals(output[i], (int)input[i]); 1561 } 1562 for(int i = input.length; i < output.length; i++) { 1563 Assert.assertEquals(output[i], (int)0); 1564 } 1565 } 1566 1567 @ForceInline 1568 static 1569 void testVectorCastLongToIntFail(LongVector.LongSpecies a, IntVector.IntSpecies b, long[] input) { 1570 assert(input.length == a.length()); 1571 1572 LongVector av = LongVector.fromArray(a, input, 0); 1573 try { 1574 av.cast(b); 1575 Assert.fail(String.format( 1576 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1577 a, b)); 1578 } catch (IllegalArgumentException e) { 1579 } 1580 } 1581 1582 @ForceInline 1583 static 1584 void testVectorCastFloatToInt(FloatVector.FloatSpecies a, IntVector.IntSpecies b, float[] input, int[] output) { 1585 assert(input.length == a.length()); 1586 assert(output.length == b.length()); 1587 1588 FloatVector av = FloatVector.fromArray(a, input, 0); 1589 IntVector bv = (IntVector) av.cast(b); 1590 bv.intoArray(output, 0); 1591 1592 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1593 Assert.assertEquals(output[i], (int)input[i]); 1594 } 1595 for(int i = input.length; i < output.length; i++) { 1596 Assert.assertEquals(output[i], (int)0); 1597 } 1598 } 1599 1600 @ForceInline 1601 static 1602 void testVectorCastFloatToIntFail(FloatVector.FloatSpecies a, IntVector.IntSpecies b, float[] input) { 1603 assert(input.length == a.length()); 1604 1605 FloatVector av = FloatVector.fromArray(a, input, 0); 1606 try { 1607 av.cast(b); 1608 Assert.fail(String.format( 1609 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1610 a, b)); 1611 } catch (IllegalArgumentException e) { 1612 } 1613 } 1614 1615 @ForceInline 1616 static 1617 void testVectorCastDoubleToInt(DoubleVector.DoubleSpecies a, IntVector.IntSpecies b, double[] input, int[] output) { 1618 assert(input.length == a.length()); 1619 assert(output.length == b.length()); 1620 1621 DoubleVector av = DoubleVector.fromArray(a, input, 0); 1622 IntVector bv = (IntVector) av.cast(b); 1623 bv.intoArray(output, 0); 1624 1625 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1626 Assert.assertEquals(output[i], (int)input[i]); 1627 } 1628 for(int i = input.length; i < output.length; i++) { 1629 Assert.assertEquals(output[i], (int)0); 1630 } 1631 } 1632 1633 @ForceInline 1634 static 1635 void testVectorCastDoubleToIntFail(DoubleVector.DoubleSpecies a, IntVector.IntSpecies b, double[] input) { 1636 assert(input.length == a.length()); 1637 1638 DoubleVector av = DoubleVector.fromArray(a, input, 0); 1639 try { 1640 av.cast(b); 1641 Assert.fail(String.format( 1642 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1643 a, b)); 1644 } catch (IllegalArgumentException e) { 1645 } 1646 } 1647 1648 @ForceInline 1649 static 1650 void testVectorCastByteToLong(ByteVector.ByteSpecies a, LongVector.LongSpecies b, byte[] input, long[] output) { 1651 assert(input.length == a.length()); 1652 assert(output.length == b.length()); 1653 1654 ByteVector av = ByteVector.fromArray(a, input, 0); 1655 LongVector bv = (LongVector) av.cast(b); 1656 bv.intoArray(output, 0); 1657 1658 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1659 Assert.assertEquals(output[i], (long)input[i]); 1660 } 1661 for(int i = input.length; i < output.length; i++) { 1662 Assert.assertEquals(output[i], (long)0); 1663 } 1664 } 1665 1666 @ForceInline 1667 static 1668 void testVectorCastByteToLongFail(ByteVector.ByteSpecies a, LongVector.LongSpecies b, byte[] input) { 1669 assert(input.length == a.length()); 1670 1671 ByteVector av = ByteVector.fromArray(a, input, 0); 1672 try { 1673 av.cast(b); 1674 Assert.fail(String.format( 1675 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1676 a, b)); 1677 } catch (IllegalArgumentException e) { 1678 } 1679 } 1680 1681 @ForceInline 1682 static 1683 void testVectorCastShortToLong(ShortVector.ShortSpecies a, LongVector.LongSpecies b, short[] input, long[] output) { 1684 assert(input.length == a.length()); 1685 assert(output.length == b.length()); 1686 1687 ShortVector av = ShortVector.fromArray(a, input, 0); 1688 LongVector bv = (LongVector) av.cast(b); 1689 bv.intoArray(output, 0); 1690 1691 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1692 Assert.assertEquals(output[i], (long)input[i]); 1693 } 1694 for(int i = input.length; i < output.length; i++) { 1695 Assert.assertEquals(output[i], (long)0); 1696 } 1697 } 1698 1699 @ForceInline 1700 static 1701 void testVectorCastShortToLongFail(ShortVector.ShortSpecies a, LongVector.LongSpecies b, short[] input) { 1702 assert(input.length == a.length()); 1703 1704 ShortVector av = ShortVector.fromArray(a, input, 0); 1705 try { 1706 av.cast(b); 1707 Assert.fail(String.format( 1708 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1709 a, b)); 1710 } catch (IllegalArgumentException e) { 1711 } 1712 } 1713 1714 @ForceInline 1715 static 1716 void testVectorCastIntToLong(IntVector.IntSpecies a, LongVector.LongSpecies b, int[] input, long[] output) { 1717 assert(input.length == a.length()); 1718 assert(output.length == b.length()); 1719 1720 IntVector av = IntVector.fromArray(a, input, 0); 1721 LongVector bv = (LongVector) av.cast(b); 1722 bv.intoArray(output, 0); 1723 1724 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1725 Assert.assertEquals(output[i], (long)input[i]); 1726 } 1727 for(int i = input.length; i < output.length; i++) { 1728 Assert.assertEquals(output[i], (long)0); 1729 } 1730 } 1731 1732 @ForceInline 1733 static 1734 void testVectorCastIntToLongFail(IntVector.IntSpecies a, LongVector.LongSpecies b, int[] input) { 1735 assert(input.length == a.length()); 1736 1737 IntVector av = IntVector.fromArray(a, input, 0); 1738 try { 1739 av.cast(b); 1740 Assert.fail(String.format( 1741 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1742 a, b)); 1743 } catch (IllegalArgumentException e) { 1744 } 1745 } 1746 1747 @ForceInline 1748 static 1749 void testVectorCastLongToLong(LongVector.LongSpecies a, LongVector.LongSpecies b, long[] input, long[] output) { 1750 assert(input.length == a.length()); 1751 assert(output.length == b.length()); 1752 1753 LongVector av = LongVector.fromArray(a, input, 0); 1754 LongVector bv = (LongVector) av.cast(b); 1755 bv.intoArray(output, 0); 1756 1757 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1758 Assert.assertEquals(output[i], (long)input[i]); 1759 } 1760 for(int i = input.length; i < output.length; i++) { 1761 Assert.assertEquals(output[i], (long)0); 1762 } 1763 } 1764 1765 @ForceInline 1766 static 1767 void testVectorCastLongToLongFail(LongVector.LongSpecies a, LongVector.LongSpecies b, long[] input) { 1768 assert(input.length == a.length()); 1769 1770 LongVector av = LongVector.fromArray(a, input, 0); 1771 try { 1772 av.cast(b); 1773 Assert.fail(String.format( 1774 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1775 a, b)); 1776 } catch (IllegalArgumentException e) { 1777 } 1778 } 1779 1780 @ForceInline 1781 static 1782 void testVectorCastFloatToLong(FloatVector.FloatSpecies a, LongVector.LongSpecies b, float[] input, long[] output) { 1783 assert(input.length == a.length()); 1784 assert(output.length == b.length()); 1785 1786 FloatVector av = FloatVector.fromArray(a, input, 0); 1787 LongVector bv = (LongVector) av.cast(b); 1788 bv.intoArray(output, 0); 1789 1790 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1791 Assert.assertEquals(output[i], (long)input[i]); 1792 } 1793 for(int i = input.length; i < output.length; i++) { 1794 Assert.assertEquals(output[i], (long)0); 1795 } 1796 } 1797 1798 @ForceInline 1799 static 1800 void testVectorCastFloatToLongFail(FloatVector.FloatSpecies a, LongVector.LongSpecies b, float[] input) { 1801 assert(input.length == a.length()); 1802 1803 FloatVector av = FloatVector.fromArray(a, input, 0); 1804 try { 1805 av.cast(b); 1806 Assert.fail(String.format( 1807 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1808 a, b)); 1809 } catch (IllegalArgumentException e) { 1810 } 1811 } 1812 1813 @ForceInline 1814 static 1815 void testVectorCastDoubleToLong(DoubleVector.DoubleSpecies a, LongVector.LongSpecies b, double[] input, long[] output) { 1816 assert(input.length == a.length()); 1817 assert(output.length == b.length()); 1818 1819 DoubleVector av = DoubleVector.fromArray(a, input, 0); 1820 LongVector bv = (LongVector) av.cast(b); 1821 bv.intoArray(output, 0); 1822 1823 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1824 Assert.assertEquals(output[i], (long)input[i]); 1825 } 1826 for(int i = input.length; i < output.length; i++) { 1827 Assert.assertEquals(output[i], (long)0); 1828 } 1829 } 1830 1831 @ForceInline 1832 static 1833 void testVectorCastDoubleToLongFail(DoubleVector.DoubleSpecies a, LongVector.LongSpecies b, double[] input) { 1834 assert(input.length == a.length()); 1835 1836 DoubleVector av = DoubleVector.fromArray(a, input, 0); 1837 try { 1838 av.cast(b); 1839 Assert.fail(String.format( 1840 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1841 a, b)); 1842 } catch (IllegalArgumentException e) { 1843 } 1844 } 1845 1846 @ForceInline 1847 static 1848 void testVectorCastByteToDouble(ByteVector.ByteSpecies a, DoubleVector.DoubleSpecies b, byte[] input, double[] output) { 1849 assert(input.length == a.length()); 1850 assert(output.length == b.length()); 1851 1852 ByteVector av = ByteVector.fromArray(a, input, 0); 1853 DoubleVector bv = (DoubleVector) av.cast(b); 1854 bv.intoArray(output, 0); 1855 1856 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1857 Assert.assertEquals(output[i], (double)input[i]); 1858 } 1859 for(int i = input.length; i < output.length; i++) { 1860 Assert.assertEquals(output[i], (double)0); 1861 } 1862 } 1863 1864 @ForceInline 1865 static 1866 void testVectorCastByteToDoubleFail(ByteVector.ByteSpecies a, DoubleVector.DoubleSpecies b, byte[] input) { 1867 assert(input.length == a.length()); 1868 1869 ByteVector av = ByteVector.fromArray(a, input, 0); 1870 try { 1871 av.cast(b); 1872 Assert.fail(String.format( 1873 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1874 a, b)); 1875 } catch (IllegalArgumentException e) { 1876 } 1877 } 1878 1879 @ForceInline 1880 static 1881 void testVectorCastShortToDouble(ShortVector.ShortSpecies a, DoubleVector.DoubleSpecies b, short[] input, double[] output) { 1882 assert(input.length == a.length()); 1883 assert(output.length == b.length()); 1884 1885 ShortVector av = ShortVector.fromArray(a, input, 0); 1886 DoubleVector bv = (DoubleVector) av.cast(b); 1887 bv.intoArray(output, 0); 1888 1889 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1890 Assert.assertEquals(output[i], (double)input[i]); 1891 } 1892 for(int i = input.length; i < output.length; i++) { 1893 Assert.assertEquals(output[i], (double)0); 1894 } 1895 } 1896 1897 @ForceInline 1898 static 1899 void testVectorCastShortToDoubleFail(ShortVector.ShortSpecies a, DoubleVector.DoubleSpecies b, short[] input) { 1900 assert(input.length == a.length()); 1901 1902 ShortVector av = ShortVector.fromArray(a, input, 0); 1903 try { 1904 av.cast(b); 1905 Assert.fail(String.format( 1906 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1907 a, b)); 1908 } catch (IllegalArgumentException e) { 1909 } 1910 } 1911 1912 @ForceInline 1913 static 1914 void testVectorCastIntToDouble(IntVector.IntSpecies a, DoubleVector.DoubleSpecies b, int[] input, double[] output) { 1915 assert(input.length == a.length()); 1916 assert(output.length == b.length()); 1917 1918 IntVector av = IntVector.fromArray(a, input, 0); 1919 DoubleVector bv = (DoubleVector) av.cast(b); 1920 bv.intoArray(output, 0); 1921 1922 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1923 Assert.assertEquals(output[i], (double)input[i]); 1924 } 1925 for(int i = input.length; i < output.length; i++) { 1926 Assert.assertEquals(output[i], (double)0); 1927 } 1928 } 1929 1930 @ForceInline 1931 static 1932 void testVectorCastIntToDoubleFail(IntVector.IntSpecies a, DoubleVector.DoubleSpecies b, int[] input) { 1933 assert(input.length == a.length()); 1934 1935 IntVector av = IntVector.fromArray(a, input, 0); 1936 try { 1937 av.cast(b); 1938 Assert.fail(String.format( 1939 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1940 a, b)); 1941 } catch (IllegalArgumentException e) { 1942 } 1943 } 1944 1945 @ForceInline 1946 static 1947 void testVectorCastLongToDouble(LongVector.LongSpecies a, DoubleVector.DoubleSpecies b, long[] input, double[] output) { 1948 assert(input.length == a.length()); 1949 assert(output.length == b.length()); 1950 1951 LongVector av = LongVector.fromArray(a, input, 0); 1952 DoubleVector bv = (DoubleVector) av.cast(b); 1953 bv.intoArray(output, 0); 1954 1955 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1956 Assert.assertEquals(output[i], (double)input[i]); 1957 } 1958 for(int i = input.length; i < output.length; i++) { 1959 Assert.assertEquals(output[i], (double)0); 1960 } 1961 } 1962 1963 @ForceInline 1964 static 1965 void testVectorCastLongToDoubleFail(LongVector.LongSpecies a, DoubleVector.DoubleSpecies b, long[] input) { 1966 assert(input.length == a.length()); 1967 1968 LongVector av = LongVector.fromArray(a, input, 0); 1969 try { 1970 av.cast(b); 1971 Assert.fail(String.format( 1972 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 1973 a, b)); 1974 } catch (IllegalArgumentException e) { 1975 } 1976 } 1977 1978 @ForceInline 1979 static 1980 void testVectorCastFloatToDouble(FloatVector.FloatSpecies a, DoubleVector.DoubleSpecies b, float[] input, double[] output) { 1981 assert(input.length == a.length()); 1982 assert(output.length == b.length()); 1983 1984 FloatVector av = FloatVector.fromArray(a, input, 0); 1985 DoubleVector bv = (DoubleVector) av.cast(b); 1986 bv.intoArray(output, 0); 1987 1988 for (int i = 0; i < Math.min(input.length, output.length); i++) { 1989 Assert.assertEquals(output[i], (double)input[i]); 1990 } 1991 for(int i = input.length; i < output.length; i++) { 1992 Assert.assertEquals(output[i], (double)0); 1993 } 1994 } 1995 1996 @ForceInline 1997 static 1998 void testVectorCastFloatToDoubleFail(FloatVector.FloatSpecies a, DoubleVector.DoubleSpecies b, float[] input) { 1999 assert(input.length == a.length()); 2000 2001 FloatVector av = FloatVector.fromArray(a, input, 0); 2002 try { 2003 av.cast(b); 2004 Assert.fail(String.format( 2005 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 2006 a, b)); 2007 } catch (IllegalArgumentException e) { 2008 } 2009 } 2010 2011 @ForceInline 2012 static 2013 void testVectorCastDoubleToDouble(DoubleVector.DoubleSpecies a, DoubleVector.DoubleSpecies b, double[] input, double[] output) { 2014 assert(input.length == a.length()); 2015 assert(output.length == b.length()); 2016 2017 DoubleVector av = DoubleVector.fromArray(a, input, 0); 2018 DoubleVector bv = (DoubleVector) av.cast(b); 2019 bv.intoArray(output, 0); 2020 2021 for (int i = 0; i < Math.min(input.length, output.length); i++) { 2022 Assert.assertEquals(output[i], (double)input[i]); 2023 } 2024 for(int i = input.length; i < output.length; i++) { 2025 Assert.assertEquals(output[i], (double)0); 2026 } 2027 } 2028 2029 @ForceInline 2030 static 2031 void testVectorCastDoubleToDoubleFail(DoubleVector.DoubleSpecies a, DoubleVector.DoubleSpecies b, double[] input) { 2032 assert(input.length == a.length()); 2033 2034 DoubleVector av = DoubleVector.fromArray(a, input, 0); 2035 try { 2036 av.cast(b); 2037 Assert.fail(String.format( 2038 "Cast failed to throw IllegalArgumentException for differing species lengths for %s and %s", 2039 a, b)); 2040 } catch (IllegalArgumentException e) { 2041 } 2042 } 2043 2044 @Test(dataProvider = "byteUnaryOpProvider") 2045 static void testCastFromByte(IntFunction<byte[]> fa) { 2046 byte[] bin64 = fa.apply(bspec64.length()); 2047 byte[] bin128 = fa.apply(bspec128.length()); 2048 byte[] bin256 = fa.apply(bspec256.length()); 2049 byte[] bin512 = fa.apply(bspec512.length()); 2050 2051 byte[] bout64 = new byte[bspec64.length()]; 2052 byte[] bout128 = new byte[bspec128.length()]; 2053 byte[] bout256 = new byte[bspec256.length()]; 2054 byte[] bout512 = new byte[bspec512.length()]; 2055 2056 short[] sout128 = new short[sspec128.length()]; 2057 short[] sout256 = new short[sspec256.length()]; 2058 short[] sout512 = new short[sspec512.length()]; 2059 2060 int[] iout256 = new int[ispec256.length()]; 2061 int[] iout512 = new int[ispec512.length()]; 2062 2063 long[] lout512 = new long[lspec512.length()]; 2064 2065 float[] fout256 = new float[fspec256.length()]; 2066 float[] fout512 = new float[fspec512.length()]; 2067 2068 double[] dout512 = new double[dspec512.length()]; 2069 2070 for (int i = 0; i < NUM_ITER; i++) { 2071 testVectorCastByteToByte(bspec64, bspec64, bin64, bout64); 2072 testVectorCastByteToByte(bspec128, bspec128, bin128, bout128); 2073 testVectorCastByteToByte(bspec256, bspec256, bin256, bout256); 2074 testVectorCastByteToByte(bspec512, bspec512, bin512, bout512); 2075 2076 testVectorCastByteToShort(bspec64, sspec128, bin64, sout128); 2077 testVectorCastByteToShort(bspec128, sspec256, bin128, sout256); 2078 testVectorCastByteToShort(bspec256, sspec512, bin256, sout512); 2079 2080 testVectorCastByteToInt(bspec64, ispec256, bin64, iout256); 2081 testVectorCastByteToInt(bspec128, ispec512, bin128, iout512); 2082 2083 testVectorCastByteToLong(bspec64, lspec512, bin64, lout512); 2084 2085 testVectorCastByteToFloat(bspec64, fspec256, bin64, fout256); 2086 testVectorCastByteToFloat(bspec128, fspec512, bin128, fout512); 2087 2088 testVectorCastByteToDouble(bspec64, dspec512, bin64, dout512); 2089 } 2090 } 2091 2092 @Test 2093 static void testCastFromByteFail() { 2094 byte[] bin64 = new byte[bspec64.length()]; 2095 byte[] bin128 = new byte[bspec128.length()]; 2096 byte[] bin256 = new byte[bspec256.length()]; 2097 byte[] bin512 = new byte[bspec512.length()]; 2098 2099 for (int i = 0; i < INVOC_COUNT; i++) { 2100 testVectorCastByteToByteFail(bspec64, bspec128, bin64); 2101 testVectorCastByteToByteFail(bspec64, bspec256, bin64); 2102 testVectorCastByteToByteFail(bspec64, bspec512, bin64); 2103 2104 testVectorCastByteToByteFail(bspec128, bspec64, bin128); 2105 testVectorCastByteToByteFail(bspec128, bspec256, bin128); 2106 testVectorCastByteToByteFail(bspec128, bspec512, bin128); 2107 2108 testVectorCastByteToByteFail(bspec256, bspec64, bin256); 2109 testVectorCastByteToByteFail(bspec256, bspec128, bin256); 2110 testVectorCastByteToByteFail(bspec256, bspec512, bin256); 2111 2112 testVectorCastByteToByteFail(bspec512, bspec64, bin512); 2113 testVectorCastByteToByteFail(bspec512, bspec128, bin512); 2114 testVectorCastByteToByteFail(bspec512, bspec256, bin512); 2115 2116 testVectorCastByteToShortFail(bspec64, sspec64, bin64); 2117 testVectorCastByteToShortFail(bspec64, sspec256, bin64); 2118 testVectorCastByteToShortFail(bspec64, sspec512, bin64); 2119 2120 testVectorCastByteToShortFail(bspec128, sspec64, bin128); 2121 testVectorCastByteToShortFail(bspec128, sspec128, bin128); 2122 testVectorCastByteToShortFail(bspec128, sspec512, bin128); 2123 2124 testVectorCastByteToShortFail(bspec256, sspec64, bin256); 2125 testVectorCastByteToShortFail(bspec256, sspec128, bin256); 2126 testVectorCastByteToShortFail(bspec256, sspec256, bin256); 2127 2128 testVectorCastByteToShortFail(bspec512, sspec64, bin512); 2129 testVectorCastByteToShortFail(bspec512, sspec128, bin512); 2130 testVectorCastByteToShortFail(bspec512, sspec256, bin512); 2131 testVectorCastByteToShortFail(bspec512, sspec512, bin512); 2132 2133 testVectorCastByteToIntFail(bspec64, ispec64, bin64); 2134 testVectorCastByteToIntFail(bspec64, ispec128, bin64); 2135 testVectorCastByteToIntFail(bspec64, ispec512, bin64); 2136 2137 testVectorCastByteToIntFail(bspec128, ispec64, bin128); 2138 testVectorCastByteToIntFail(bspec128, ispec128, bin128); 2139 testVectorCastByteToIntFail(bspec128, ispec256, bin128); 2140 2141 testVectorCastByteToIntFail(bspec256, ispec64, bin256); 2142 testVectorCastByteToIntFail(bspec256, ispec128, bin256); 2143 testVectorCastByteToIntFail(bspec256, ispec256, bin256); 2144 testVectorCastByteToIntFail(bspec256, ispec512, bin256); 2145 2146 testVectorCastByteToIntFail(bspec512, ispec64, bin512); 2147 testVectorCastByteToIntFail(bspec512, ispec128, bin512); 2148 testVectorCastByteToIntFail(bspec512, ispec256, bin512); 2149 testVectorCastByteToIntFail(bspec512, ispec512, bin512); 2150 2151 testVectorCastByteToLongFail(bspec64, lspec64, bin64); 2152 testVectorCastByteToLongFail(bspec64, lspec128, bin64); 2153 testVectorCastByteToLongFail(bspec64, lspec256, bin64); 2154 2155 testVectorCastByteToLongFail(bspec128, lspec64, bin128); 2156 testVectorCastByteToLongFail(bspec128, lspec128, bin128); 2157 testVectorCastByteToLongFail(bspec128, lspec256, bin128); 2158 testVectorCastByteToLongFail(bspec128, lspec512, bin128); 2159 2160 testVectorCastByteToLongFail(bspec256, lspec64, bin256); 2161 testVectorCastByteToLongFail(bspec256, lspec128, bin256); 2162 testVectorCastByteToLongFail(bspec256, lspec256, bin256); 2163 testVectorCastByteToLongFail(bspec256, lspec512, bin256); 2164 2165 testVectorCastByteToLongFail(bspec512, lspec64, bin512); 2166 testVectorCastByteToLongFail(bspec512, lspec128, bin512); 2167 testVectorCastByteToLongFail(bspec512, lspec256, bin512); 2168 testVectorCastByteToLongFail(bspec512, lspec512, bin512); 2169 2170 testVectorCastByteToFloatFail(bspec64, fspec64, bin64); 2171 testVectorCastByteToFloatFail(bspec64, fspec128, bin64); 2172 testVectorCastByteToFloatFail(bspec64, fspec512, bin64); 2173 2174 testVectorCastByteToFloatFail(bspec128, fspec64, bin128); 2175 testVectorCastByteToFloatFail(bspec128, fspec128, bin128); 2176 testVectorCastByteToFloatFail(bspec128, fspec256, bin128); 2177 2178 testVectorCastByteToFloatFail(bspec256, fspec64, bin256); 2179 testVectorCastByteToFloatFail(bspec256, fspec128, bin256); 2180 testVectorCastByteToFloatFail(bspec256, fspec256, bin256); 2181 testVectorCastByteToFloatFail(bspec256, fspec512, bin256); 2182 2183 testVectorCastByteToFloatFail(bspec512, fspec64, bin512); 2184 testVectorCastByteToFloatFail(bspec512, fspec128, bin512); 2185 testVectorCastByteToFloatFail(bspec512, fspec256, bin512); 2186 testVectorCastByteToFloatFail(bspec512, fspec512, bin512); 2187 2188 testVectorCastByteToDoubleFail(bspec64, dspec64, bin64); 2189 testVectorCastByteToDoubleFail(bspec64, dspec128, bin64); 2190 testVectorCastByteToDoubleFail(bspec64, dspec256, bin64); 2191 2192 testVectorCastByteToDoubleFail(bspec128, dspec64, bin128); 2193 testVectorCastByteToDoubleFail(bspec128, dspec128, bin128); 2194 testVectorCastByteToDoubleFail(bspec128, dspec256, bin128); 2195 testVectorCastByteToDoubleFail(bspec128, dspec512, bin128); 2196 2197 testVectorCastByteToDoubleFail(bspec256, dspec64, bin256); 2198 testVectorCastByteToDoubleFail(bspec256, dspec128, bin256); 2199 testVectorCastByteToDoubleFail(bspec256, dspec256, bin256); 2200 testVectorCastByteToDoubleFail(bspec256, dspec512, bin256); 2201 2202 testVectorCastByteToDoubleFail(bspec512, dspec64, bin512); 2203 testVectorCastByteToDoubleFail(bspec512, dspec128, bin512); 2204 testVectorCastByteToDoubleFail(bspec512, dspec256, bin512); 2205 testVectorCastByteToDoubleFail(bspec512, dspec512, bin512); 2206 } 2207 } 2208 2209 @Test(dataProvider = "shortUnaryOpProvider") 2210 static void testCastFromShort(IntFunction<short[]> fa) { 2211 short[] sin64 = fa.apply(sspec64.length()); 2212 short[] sin128 = fa.apply(sspec128.length()); 2213 short[] sin256 = fa.apply(sspec256.length()); 2214 short[] sin512 = fa.apply(sspec512.length()); 2215 2216 byte[] bout64 = new byte[bspec64.length()]; 2217 byte[] bout128 = new byte[bspec128.length()]; 2218 byte[] bout256 = new byte[bspec256.length()]; 2219 2220 short[] sout64 = new short[sspec64.length()]; 2221 short[] sout128 = new short[sspec128.length()]; 2222 short[] sout256 = new short[sspec256.length()]; 2223 short[] sout512 = new short[sspec512.length()]; 2224 2225 int[] iout128 = new int[ispec128.length()]; 2226 int[] iout256 = new int[ispec256.length()]; 2227 int[] iout512 = new int[ispec512.length()]; 2228 2229 long[] lout256 = new long[lspec256.length()]; 2230 long[] lout512 = new long[lspec512.length()]; 2231 2232 float[] fout128 = new float[fspec128.length()]; 2233 float[] fout256 = new float[fspec256.length()]; 2234 float[] fout512 = new float[fspec512.length()]; 2235 2236 double[] dout256 = new double[dspec256.length()]; 2237 double[] dout512 = new double[dspec512.length()]; 2238 2239 for (int i = 0; i < NUM_ITER; i++) { 2240 testVectorCastShortToByte(sspec128, bspec64, sin128, bout64); 2241 testVectorCastShortToByte(sspec256, bspec128, sin256, bout128); 2242 testVectorCastShortToByte(sspec512, bspec256, sin512, bout256); 2243 2244 testVectorCastShortToShort(sspec64, sspec64, sin64, sout64); 2245 testVectorCastShortToShort(sspec128, sspec128, sin128, sout128); 2246 testVectorCastShortToShort(sspec256, sspec256, sin256, sout256); 2247 testVectorCastShortToShort(sspec512, sspec512, sin512, sout512); 2248 2249 testVectorCastShortToInt(sspec64, ispec128, sin64, iout128); 2250 testVectorCastShortToInt(sspec128, ispec256, sin128, iout256); 2251 testVectorCastShortToInt(sspec256, ispec512, sin256, iout512); 2252 2253 testVectorCastShortToLong(sspec64, lspec256, sin64, lout256); 2254 testVectorCastShortToLong(sspec128, lspec512, sin128, lout512); 2255 2256 testVectorCastShortToFloat(sspec64, fspec128, sin64, fout128); 2257 testVectorCastShortToFloat(sspec128, fspec256, sin128, fout256); 2258 testVectorCastShortToFloat(sspec256, fspec512, sin256, fout512); 2259 2260 testVectorCastShortToDouble(sspec64, dspec256, sin64, dout256); 2261 testVectorCastShortToDouble(sspec128, dspec512, sin128, dout512); 2262 } 2263 } 2264 2265 @Test() 2266 static void testCastFromShortFail() { 2267 short[] sin64 = new short[sspec64.length()]; 2268 short[] sin128 = new short[sspec128.length()]; 2269 short[] sin256 = new short[sspec256.length()]; 2270 short[] sin512 = new short[sspec512.length()]; 2271 2272 for (int i = 0; i < INVOC_COUNT; i++) { 2273 testVectorCastShortToByteFail(sspec64, bspec64, sin64); 2274 testVectorCastShortToByteFail(sspec64, bspec128, sin64); 2275 testVectorCastShortToByteFail(sspec64, bspec256, sin64); 2276 testVectorCastShortToByteFail(sspec64, bspec512, sin64); 2277 2278 testVectorCastShortToByteFail(sspec128, bspec128, sin128); 2279 testVectorCastShortToByteFail(sspec128, bspec256, sin128); 2280 testVectorCastShortToByteFail(sspec128, bspec512, sin128); 2281 2282 testVectorCastShortToByteFail(sspec256, bspec64, sin256); 2283 testVectorCastShortToByteFail(sspec256, bspec256, sin256); 2284 testVectorCastShortToByteFail(sspec256, bspec512, sin256); 2285 2286 testVectorCastShortToByteFail(sspec512, bspec64, sin512); 2287 testVectorCastShortToByteFail(sspec512, bspec128, sin512); 2288 testVectorCastShortToByteFail(sspec512, bspec512, sin512); 2289 2290 testVectorCastShortToShortFail(sspec64, sspec128, sin64); 2291 testVectorCastShortToShortFail(sspec64, sspec256, sin64); 2292 testVectorCastShortToShortFail(sspec64, sspec512, sin64); 2293 2294 testVectorCastShortToShortFail(sspec128, sspec64, sin128); 2295 testVectorCastShortToShortFail(sspec128, sspec256, sin128); 2296 testVectorCastShortToShortFail(sspec128, sspec512, sin128); 2297 2298 testVectorCastShortToShortFail(sspec256, sspec64, sin256); 2299 testVectorCastShortToShortFail(sspec256, sspec128, sin256); 2300 testVectorCastShortToShortFail(sspec256, sspec512, sin256); 2301 2302 testVectorCastShortToShortFail(sspec512, sspec64, sin512); 2303 testVectorCastShortToShortFail(sspec512, sspec128, sin512); 2304 testVectorCastShortToShortFail(sspec512, sspec256, sin512); 2305 2306 testVectorCastShortToIntFail(sspec64, ispec64, sin64); 2307 testVectorCastShortToIntFail(sspec64, ispec256, sin64); 2308 testVectorCastShortToIntFail(sspec64, ispec512, sin64); 2309 2310 testVectorCastShortToIntFail(sspec128, ispec64, sin128); 2311 testVectorCastShortToIntFail(sspec128, ispec128, sin128); 2312 testVectorCastShortToIntFail(sspec128, ispec512, sin128); 2313 2314 testVectorCastShortToIntFail(sspec256, ispec64, sin256); 2315 testVectorCastShortToIntFail(sspec256, ispec128, sin256); 2316 testVectorCastShortToIntFail(sspec256, ispec256, sin256); 2317 2318 testVectorCastShortToIntFail(sspec512, ispec64, sin512); 2319 testVectorCastShortToIntFail(sspec512, ispec128, sin512); 2320 testVectorCastShortToIntFail(sspec512, ispec256, sin512); 2321 testVectorCastShortToIntFail(sspec512, ispec512, sin512); 2322 2323 testVectorCastShortToLongFail(sspec64, lspec64, sin64); 2324 testVectorCastShortToLongFail(sspec64, lspec128, sin64); 2325 testVectorCastShortToLongFail(sspec64, lspec512, sin64); 2326 2327 testVectorCastShortToLongFail(sspec128, lspec64, sin128); 2328 testVectorCastShortToLongFail(sspec128, lspec128, sin128); 2329 testVectorCastShortToLongFail(sspec128, lspec256, sin128); 2330 2331 testVectorCastShortToLongFail(sspec256, lspec64, sin256); 2332 testVectorCastShortToLongFail(sspec256, lspec128, sin256); 2333 testVectorCastShortToLongFail(sspec256, lspec256, sin256); 2334 testVectorCastShortToLongFail(sspec256, lspec512, sin256); 2335 2336 testVectorCastShortToLongFail(sspec512, lspec64, sin512); 2337 testVectorCastShortToLongFail(sspec512, lspec128, sin512); 2338 testVectorCastShortToLongFail(sspec512, lspec256, sin512); 2339 testVectorCastShortToLongFail(sspec512, lspec512, sin512); 2340 2341 testVectorCastShortToFloatFail(sspec64, fspec64, sin64); 2342 testVectorCastShortToFloatFail(sspec64, fspec256, sin64); 2343 testVectorCastShortToFloatFail(sspec64, fspec512, sin64); 2344 2345 testVectorCastShortToFloatFail(sspec128, fspec64, sin128); 2346 testVectorCastShortToFloatFail(sspec128, fspec128, sin128); 2347 testVectorCastShortToFloatFail(sspec128, fspec512, sin128); 2348 2349 testVectorCastShortToFloatFail(sspec256, fspec64, sin256); 2350 testVectorCastShortToFloatFail(sspec256, fspec128, sin256); 2351 testVectorCastShortToFloatFail(sspec256, fspec256, sin256); 2352 2353 testVectorCastShortToFloatFail(sspec512, fspec64, sin512); 2354 testVectorCastShortToFloatFail(sspec512, fspec128, sin512); 2355 testVectorCastShortToFloatFail(sspec512, fspec256, sin512); 2356 testVectorCastShortToFloatFail(sspec512, fspec512, sin512); 2357 2358 testVectorCastShortToDoubleFail(sspec64, dspec64, sin64); 2359 testVectorCastShortToDoubleFail(sspec64, dspec128, sin64); 2360 testVectorCastShortToDoubleFail(sspec64, dspec512, sin64); 2361 2362 testVectorCastShortToDoubleFail(sspec128, dspec64, sin128); 2363 testVectorCastShortToDoubleFail(sspec128, dspec128, sin128); 2364 testVectorCastShortToDoubleFail(sspec128, dspec256, sin128); 2365 2366 testVectorCastShortToDoubleFail(sspec256, dspec64, sin256); 2367 testVectorCastShortToDoubleFail(sspec256, dspec128, sin256); 2368 testVectorCastShortToDoubleFail(sspec256, dspec256, sin256); 2369 testVectorCastShortToDoubleFail(sspec256, dspec512, sin256); 2370 2371 testVectorCastShortToDoubleFail(sspec512, dspec64, sin512); 2372 testVectorCastShortToDoubleFail(sspec512, dspec128, sin512); 2373 testVectorCastShortToDoubleFail(sspec512, dspec256, sin512); 2374 testVectorCastShortToDoubleFail(sspec512, dspec512, sin512); 2375 } 2376 } 2377 2378 @Test(dataProvider = "intUnaryOpProvider") 2379 static void testCastFromInt(IntFunction<int[]> fa) { 2380 int[] iin64 = fa.apply(ispec64.length()); 2381 int[] iin128 = fa.apply(ispec128.length()); 2382 int[] iin256 = fa.apply(ispec256.length()); 2383 int[] iin512 = fa.apply(ispec512.length()); 2384 2385 byte[] bout64 = new byte[bspec64.length()]; 2386 byte[] bout128 = new byte[bspec128.length()]; 2387 2388 short[] sout64 = new short[sspec64.length()]; 2389 short[] sout128 = new short[sspec128.length()]; 2390 short[] sout256 = new short[sspec256.length()]; 2391 2392 int[] iout64 = new int[ispec64.length()]; 2393 int[] iout128 = new int[ispec128.length()]; 2394 int[] iout256 = new int[ispec256.length()]; 2395 int[] iout512 = new int[ispec512.length()]; 2396 2397 long[] lout128 = new long[lspec128.length()]; 2398 long[] lout256 = new long[lspec256.length()]; 2399 long[] lout512 = new long[lspec512.length()]; 2400 2401 float[] fout64 = new float[fspec64.length()]; 2402 float[] fout128 = new float[fspec128.length()]; 2403 float[] fout256 = new float[fspec256.length()]; 2404 float[] fout512 = new float[fspec512.length()]; 2405 2406 double[] dout128 = new double[dspec128.length()]; 2407 double[] dout256 = new double[dspec256.length()]; 2408 double[] dout512 = new double[dspec512.length()]; 2409 2410 for (int i = 0; i < NUM_ITER; i++) { 2411 testVectorCastIntToByte(ispec256, bspec64, iin256, bout64); 2412 testVectorCastIntToByte(ispec512, bspec128, iin512, bout128); 2413 2414 testVectorCastIntToShort(ispec128, sspec64, iin128, sout64); 2415 testVectorCastIntToShort(ispec256, sspec128, iin256, sout128); 2416 testVectorCastIntToShort(ispec512, sspec256, iin512, sout256); 2417 2418 testVectorCastIntToInt(ispec64, ispec64, iin64, iout64); 2419 testVectorCastIntToInt(ispec128, ispec128, iin128, iout128); 2420 testVectorCastIntToInt(ispec256, ispec256, iin256, iout256); 2421 testVectorCastIntToInt(ispec512, ispec512, iin512, iout512); 2422 2423 testVectorCastIntToLong(ispec64, lspec128, iin64, lout128); 2424 testVectorCastIntToLong(ispec128, lspec256, iin128, lout256); 2425 testVectorCastIntToLong(ispec256, lspec512, iin256, lout512); 2426 2427 testVectorCastIntToFloat(ispec64, fspec64, iin64, fout64); 2428 testVectorCastIntToFloat(ispec128, fspec128, iin128, fout128); 2429 testVectorCastIntToFloat(ispec256, fspec256, iin256, fout256); 2430 testVectorCastIntToFloat(ispec512, fspec512, iin512, fout512); 2431 2432 testVectorCastIntToDouble(ispec64, dspec128, iin64, dout128); 2433 testVectorCastIntToDouble(ispec128, dspec256, iin128, dout256); 2434 testVectorCastIntToDouble(ispec256, dspec512, iin256, dout512); 2435 } 2436 } 2437 2438 @Test 2439 static void testCastFromIntFail() { 2440 int[] iin64 = new int[ispec64.length()]; 2441 int[] iin128 = new int[ispec128.length()]; 2442 int[] iin256 = new int[ispec256.length()]; 2443 int[] iin512 = new int[ispec512.length()]; 2444 2445 for (int i = 0; i < INVOC_COUNT; i++) { 2446 testVectorCastIntToByteFail(ispec64, bspec64, iin64); 2447 testVectorCastIntToByteFail(ispec64, bspec128, iin64); 2448 testVectorCastIntToByteFail(ispec64, bspec256, iin64); 2449 testVectorCastIntToByteFail(ispec64, bspec512, iin64); 2450 2451 testVectorCastIntToByteFail(ispec128, bspec64, iin128); 2452 testVectorCastIntToByteFail(ispec128, bspec128, iin128); 2453 testVectorCastIntToByteFail(ispec128, bspec256, iin128); 2454 testVectorCastIntToByteFail(ispec128, bspec512, iin128); 2455 2456 testVectorCastIntToByteFail(ispec256, bspec128, iin256); 2457 testVectorCastIntToByteFail(ispec256, bspec256, iin256); 2458 testVectorCastIntToByteFail(ispec256, bspec512, iin256); 2459 2460 testVectorCastIntToByteFail(ispec512, bspec64, iin512); 2461 testVectorCastIntToByteFail(ispec512, bspec256, iin512); 2462 testVectorCastIntToByteFail(ispec512, bspec512, iin512); 2463 2464 testVectorCastIntToShortFail(ispec64, sspec64, iin64); 2465 testVectorCastIntToShortFail(ispec64, sspec128, iin64); 2466 testVectorCastIntToShortFail(ispec64, sspec256, iin64); 2467 testVectorCastIntToShortFail(ispec64, sspec512, iin64); 2468 2469 testVectorCastIntToShortFail(ispec128, sspec128, iin128); 2470 testVectorCastIntToShortFail(ispec128, sspec256, iin128); 2471 testVectorCastIntToShortFail(ispec128, sspec512, iin128); 2472 2473 testVectorCastIntToShortFail(ispec256, sspec64, iin256); 2474 testVectorCastIntToShortFail(ispec256, sspec256, iin256); 2475 testVectorCastIntToShortFail(ispec256, sspec512, iin256); 2476 2477 testVectorCastIntToShortFail(ispec512, sspec64, iin512); 2478 testVectorCastIntToShortFail(ispec512, sspec128, iin512); 2479 testVectorCastIntToShortFail(ispec512, sspec512, iin512); 2480 2481 testVectorCastIntToIntFail(ispec64, ispec128, iin64); 2482 testVectorCastIntToIntFail(ispec64, ispec256, iin64); 2483 testVectorCastIntToIntFail(ispec64, ispec512, iin64); 2484 2485 testVectorCastIntToIntFail(ispec128, ispec64, iin128); 2486 testVectorCastIntToIntFail(ispec128, ispec256, iin128); 2487 testVectorCastIntToIntFail(ispec128, ispec512, iin128); 2488 2489 testVectorCastIntToIntFail(ispec256, ispec64, iin256); 2490 testVectorCastIntToIntFail(ispec256, ispec128, iin256); 2491 testVectorCastIntToIntFail(ispec256, ispec512, iin256); 2492 2493 testVectorCastIntToIntFail(ispec512, ispec64, iin512); 2494 testVectorCastIntToIntFail(ispec512, ispec128, iin512); 2495 testVectorCastIntToIntFail(ispec512, ispec256, iin512); 2496 2497 testVectorCastIntToLongFail(ispec64, lspec64, iin64); 2498 testVectorCastIntToLongFail(ispec64, lspec256, iin64); 2499 testVectorCastIntToLongFail(ispec64, lspec512, iin64); 2500 2501 testVectorCastIntToLongFail(ispec128, lspec64, iin128); 2502 testVectorCastIntToLongFail(ispec128, lspec128, iin128); 2503 testVectorCastIntToLongFail(ispec128, lspec512, iin128); 2504 2505 testVectorCastIntToLongFail(ispec256, lspec64, iin256); 2506 testVectorCastIntToLongFail(ispec256, lspec128, iin256); 2507 testVectorCastIntToLongFail(ispec256, lspec256, iin256); 2508 2509 testVectorCastIntToLongFail(ispec512, lspec64, iin512); 2510 testVectorCastIntToLongFail(ispec512, lspec128, iin512); 2511 testVectorCastIntToLongFail(ispec512, lspec256, iin512); 2512 testVectorCastIntToLongFail(ispec512, lspec512, iin512); 2513 2514 testVectorCastIntToFloatFail(ispec64, fspec128, iin64); 2515 testVectorCastIntToFloatFail(ispec64, fspec256, iin64); 2516 testVectorCastIntToFloatFail(ispec64, fspec512, iin64); 2517 2518 testVectorCastIntToFloatFail(ispec128, fspec64, iin128); 2519 testVectorCastIntToFloatFail(ispec128, fspec256, iin128); 2520 testVectorCastIntToFloatFail(ispec128, fspec512, iin128); 2521 2522 testVectorCastIntToFloatFail(ispec256, fspec64, iin256); 2523 testVectorCastIntToFloatFail(ispec256, fspec128, iin256); 2524 testVectorCastIntToFloatFail(ispec256, fspec512, iin256); 2525 2526 testVectorCastIntToFloatFail(ispec512, fspec64, iin512); 2527 testVectorCastIntToFloatFail(ispec512, fspec128, iin512); 2528 testVectorCastIntToFloatFail(ispec512, fspec256, iin512); 2529 2530 testVectorCastIntToDoubleFail(ispec64, dspec64, iin64); 2531 testVectorCastIntToDoubleFail(ispec64, dspec256, iin64); 2532 testVectorCastIntToDoubleFail(ispec64, dspec512, iin64); 2533 2534 testVectorCastIntToDoubleFail(ispec128, dspec64, iin128); 2535 testVectorCastIntToDoubleFail(ispec128, dspec128, iin128); 2536 testVectorCastIntToDoubleFail(ispec128, dspec512, iin128); 2537 2538 testVectorCastIntToDoubleFail(ispec256, dspec64, iin256); 2539 testVectorCastIntToDoubleFail(ispec256, dspec128, iin256); 2540 testVectorCastIntToDoubleFail(ispec256, dspec256, iin256); 2541 2542 testVectorCastIntToDoubleFail(ispec512, dspec64, iin512); 2543 testVectorCastIntToDoubleFail(ispec512, dspec128, iin512); 2544 testVectorCastIntToDoubleFail(ispec512, dspec256, iin512); 2545 testVectorCastIntToDoubleFail(ispec512, dspec512, iin512); 2546 } 2547 } 2548 2549 @Test(dataProvider = "longUnaryOpProvider") 2550 static void testCastFromLong(IntFunction<long[]> fa) { 2551 long[] lin64 = fa.apply(lspec64.length()); 2552 long[] lin128 = fa.apply(lspec128.length()); 2553 long[] lin256 = fa.apply(lspec256.length()); 2554 long[] lin512 = fa.apply(lspec512.length()); 2555 2556 byte[] bout64 = new byte[bspec64.length()]; 2557 2558 short[] sout64 = new short[sspec64.length()]; 2559 short[] sout128 = new short[sspec128.length()]; 2560 2561 int[] iout64 = new int[ispec64.length()]; 2562 int[] iout128 = new int[ispec128.length()]; 2563 int[] iout256 = new int[ispec256.length()]; 2564 2565 long[] lout64 = new long[lspec64.length()]; 2566 long[] lout128 = new long[lspec128.length()]; 2567 long[] lout256 = new long[lspec256.length()]; 2568 long[] lout512 = new long[lspec512.length()]; 2569 2570 float[] fout64 = new float[fspec64.length()]; 2571 float[] fout128 = new float[fspec128.length()]; 2572 float[] fout256 = new float[fspec256.length()]; 2573 2574 double[] dout64 = new double[dspec64.length()]; 2575 double[] dout128 = new double[dspec128.length()]; 2576 double[] dout256 = new double[dspec256.length()]; 2577 double[] dout512 = new double[dspec512.length()]; 2578 2579 for (int i = 0; i < NUM_ITER; i++) { 2580 testVectorCastLongToByte(lspec512, bspec64, lin512, bout64); 2581 2582 testVectorCastLongToShort(lspec256, sspec64, lin256, sout64); 2583 testVectorCastLongToShort(lspec512, sspec128, lin512, sout128); 2584 2585 testVectorCastLongToInt(lspec128, ispec64, lin128, iout64); 2586 testVectorCastLongToInt(lspec256, ispec128, lin256, iout128); 2587 testVectorCastLongToInt(lspec512, ispec256, lin512, iout256); 2588 2589 testVectorCastLongToLong(lspec64, lspec64, lin64, lout64); 2590 testVectorCastLongToLong(lspec128, lspec128, lin128, lout128); 2591 testVectorCastLongToLong(lspec256, lspec256, lin256, lout256); 2592 testVectorCastLongToLong(lspec512, lspec512, lin512, lout512); 2593 2594 testVectorCastLongToFloat(lspec128, fspec64, lin128, fout64); 2595 testVectorCastLongToFloat(lspec256, fspec128, lin256, fout128); 2596 testVectorCastLongToFloat(lspec512, fspec256, lin512, fout256); 2597 2598 testVectorCastLongToDouble(lspec64, dspec64, lin64, dout64); 2599 testVectorCastLongToDouble(lspec128, dspec128, lin128, dout128); 2600 testVectorCastLongToDouble(lspec256, dspec256, lin256, dout256); 2601 testVectorCastLongToDouble(lspec512, dspec512, lin512, dout512); 2602 } 2603 } 2604 2605 @Test 2606 static void testCastFromLongFail() { 2607 long[] lin64 = new long[lspec64.length()]; 2608 long[] lin128 = new long[lspec128.length()]; 2609 long[] lin256 = new long[lspec256.length()]; 2610 long[] lin512 = new long[lspec512.length()]; 2611 2612 for (int i = 0; i < INVOC_COUNT; i++) { 2613 testVectorCastLongToByteFail(lspec64, bspec64, lin64); 2614 testVectorCastLongToByteFail(lspec64, bspec128, lin64); 2615 testVectorCastLongToByteFail(lspec64, bspec256, lin64); 2616 testVectorCastLongToByteFail(lspec64, bspec512, lin64); 2617 2618 testVectorCastLongToByteFail(lspec128, bspec64, lin128); 2619 testVectorCastLongToByteFail(lspec128, bspec128, lin128); 2620 testVectorCastLongToByteFail(lspec128, bspec256, lin128); 2621 testVectorCastLongToByteFail(lspec128, bspec512, lin128); 2622 2623 testVectorCastLongToByteFail(lspec256, bspec64, lin256); 2624 testVectorCastLongToByteFail(lspec256, bspec128, lin256); 2625 testVectorCastLongToByteFail(lspec256, bspec256, lin256); 2626 testVectorCastLongToByteFail(lspec256, bspec512, lin256); 2627 2628 testVectorCastLongToByteFail(lspec512, bspec128, lin512); 2629 testVectorCastLongToByteFail(lspec512, bspec256, lin512); 2630 testVectorCastLongToByteFail(lspec512, bspec512, lin512); 2631 2632 testVectorCastLongToShortFail(lspec64, sspec64, lin64); 2633 testVectorCastLongToShortFail(lspec64, sspec128, lin64); 2634 testVectorCastLongToShortFail(lspec64, sspec256, lin64); 2635 testVectorCastLongToShortFail(lspec64, sspec512, lin64); 2636 2637 testVectorCastLongToShortFail(lspec128, sspec64, lin128); 2638 testVectorCastLongToShortFail(lspec128, sspec128, lin128); 2639 testVectorCastLongToShortFail(lspec128, sspec256, lin128); 2640 testVectorCastLongToShortFail(lspec128, sspec512, lin128); 2641 2642 testVectorCastLongToShortFail(lspec256, sspec128, lin256); 2643 testVectorCastLongToShortFail(lspec256, sspec256, lin256); 2644 testVectorCastLongToShortFail(lspec256, sspec512, lin256); 2645 2646 testVectorCastLongToShortFail(lspec512, sspec64, lin512); 2647 testVectorCastLongToShortFail(lspec512, sspec256, lin512); 2648 testVectorCastLongToShortFail(lspec512, sspec512, lin512); 2649 2650 testVectorCastLongToIntFail(lspec64, ispec64, lin64); 2651 testVectorCastLongToIntFail(lspec64, ispec128, lin64); 2652 testVectorCastLongToIntFail(lspec64, ispec256, lin64); 2653 testVectorCastLongToIntFail(lspec64, ispec512, lin64); 2654 2655 testVectorCastLongToIntFail(lspec128, ispec128, lin128); 2656 testVectorCastLongToIntFail(lspec128, ispec256, lin128); 2657 testVectorCastLongToIntFail(lspec128, ispec512, lin128); 2658 2659 testVectorCastLongToIntFail(lspec256, ispec64, lin256); 2660 testVectorCastLongToIntFail(lspec256, ispec256, lin256); 2661 testVectorCastLongToIntFail(lspec256, ispec512, lin256); 2662 2663 testVectorCastLongToIntFail(lspec512, ispec64, lin512); 2664 testVectorCastLongToIntFail(lspec512, ispec128, lin512); 2665 testVectorCastLongToIntFail(lspec512, ispec512, lin512); 2666 2667 testVectorCastLongToLongFail(lspec64, lspec128, lin64); 2668 testVectorCastLongToLongFail(lspec64, lspec256, lin64); 2669 testVectorCastLongToLongFail(lspec64, lspec512, lin64); 2670 2671 testVectorCastLongToLongFail(lspec128, lspec64, lin128); 2672 testVectorCastLongToLongFail(lspec128, lspec256, lin128); 2673 testVectorCastLongToLongFail(lspec128, lspec512, lin128); 2674 2675 testVectorCastLongToLongFail(lspec256, lspec64, lin256); 2676 testVectorCastLongToLongFail(lspec256, lspec128, lin256); 2677 testVectorCastLongToLongFail(lspec256, lspec512, lin256); 2678 2679 testVectorCastLongToLongFail(lspec512, lspec64, lin512); 2680 testVectorCastLongToLongFail(lspec512, lspec128, lin512); 2681 testVectorCastLongToLongFail(lspec512, lspec256, lin512); 2682 2683 testVectorCastLongToFloatFail(lspec64, fspec64, lin64); 2684 testVectorCastLongToFloatFail(lspec64, fspec128, lin64); 2685 testVectorCastLongToFloatFail(lspec64, fspec256, lin64); 2686 testVectorCastLongToFloatFail(lspec64, fspec512, lin64); 2687 2688 testVectorCastLongToFloatFail(lspec128, fspec128, lin128); 2689 testVectorCastLongToFloatFail(lspec128, fspec256, lin128); 2690 testVectorCastLongToFloatFail(lspec128, fspec512, lin128); 2691 2692 testVectorCastLongToFloatFail(lspec256, fspec64, lin256); 2693 testVectorCastLongToFloatFail(lspec256, fspec256, lin256); 2694 testVectorCastLongToFloatFail(lspec256, fspec512, lin256); 2695 2696 testVectorCastLongToFloatFail(lspec512, fspec64, lin512); 2697 testVectorCastLongToFloatFail(lspec512, fspec128, lin512); 2698 testVectorCastLongToFloatFail(lspec512, fspec512, lin512); 2699 2700 testVectorCastLongToDoubleFail(lspec64, dspec128, lin64); 2701 testVectorCastLongToDoubleFail(lspec64, dspec256, lin64); 2702 testVectorCastLongToDoubleFail(lspec64, dspec512, lin64); 2703 2704 testVectorCastLongToDoubleFail(lspec128, dspec64, lin128); 2705 testVectorCastLongToDoubleFail(lspec128, dspec256, lin128); 2706 testVectorCastLongToDoubleFail(lspec128, dspec512, lin128); 2707 2708 testVectorCastLongToDoubleFail(lspec256, dspec64, lin256); 2709 testVectorCastLongToDoubleFail(lspec256, dspec128, lin256); 2710 testVectorCastLongToDoubleFail(lspec256, dspec512, lin256); 2711 2712 testVectorCastLongToDoubleFail(lspec512, dspec64, lin512); 2713 testVectorCastLongToDoubleFail(lspec512, dspec128, lin512); 2714 testVectorCastLongToDoubleFail(lspec512, dspec256, lin512); 2715 } 2716 } 2717 2718 @Test(dataProvider = "floatUnaryOpProvider") 2719 static void testCastFromFloat(IntFunction<float[]> fa) { 2720 float[] fin64 = fa.apply(fspec64.length()); 2721 float[] fin128 = fa.apply(fspec128.length()); 2722 float[] fin256 = fa.apply(fspec256.length()); 2723 float[] fin512 = fa.apply(fspec512.length()); 2724 2725 byte[] bout64 = new byte[bspec64.length()]; 2726 byte[] bout128 = new byte[bspec128.length()]; 2727 2728 short[] sout64 = new short[sspec64.length()]; 2729 short[] sout128 = new short[sspec128.length()]; 2730 short[] sout256 = new short[sspec256.length()]; 2731 2732 int[] iout64 = new int[ispec64.length()]; 2733 int[] iout128 = new int[ispec128.length()]; 2734 int[] iout256 = new int[ispec256.length()]; 2735 int[] iout512 = new int[ispec512.length()]; 2736 2737 long[] lout128 = new long[lspec128.length()]; 2738 long[] lout256 = new long[lspec256.length()]; 2739 long[] lout512 = new long[lspec512.length()]; 2740 2741 float[] fout64 = new float[fspec64.length()]; 2742 float[] fout128 = new float[fspec128.length()]; 2743 float[] fout256 = new float[fspec256.length()]; 2744 float[] fout512 = new float[fspec512.length()]; 2745 2746 double[] dout128 = new double[dspec128.length()]; 2747 double[] dout256 = new double[dspec256.length()]; 2748 double[] dout512 = new double[dspec512.length()]; 2749 2750 for (int i = 0; i < NUM_ITER; i++) { 2751 testVectorCastFloatToByte(fspec256, bspec64, fin256, bout64); 2752 testVectorCastFloatToByte(fspec512, bspec128, fin512, bout128); 2753 2754 testVectorCastFloatToShort(fspec128, sspec64, fin128, sout64); 2755 testVectorCastFloatToShort(fspec256, sspec128, fin256, sout128); 2756 testVectorCastFloatToShort(fspec512, sspec256, fin512, sout256); 2757 2758 testVectorCastFloatToInt(fspec64, ispec64, fin64, iout64); 2759 testVectorCastFloatToInt(fspec128, ispec128, fin128, iout128); 2760 testVectorCastFloatToInt(fspec256, ispec256, fin256, iout256); 2761 testVectorCastFloatToInt(fspec512, ispec512, fin512, iout512); 2762 2763 testVectorCastFloatToLong(fspec64, lspec128, fin64, lout128); 2764 testVectorCastFloatToLong(fspec128, lspec256, fin128, lout256); 2765 testVectorCastFloatToLong(fspec256, lspec512, fin256, lout512); 2766 2767 testVectorCastFloatToFloat(fspec64, fspec64, fin64, fout64); 2768 testVectorCastFloatToFloat(fspec128, fspec128, fin128, fout128); 2769 testVectorCastFloatToFloat(fspec256, fspec256, fin256, fout256); 2770 testVectorCastFloatToFloat(fspec512, fspec512, fin512, fout512); 2771 2772 testVectorCastFloatToDouble(fspec64, dspec128, fin64, dout128); 2773 testVectorCastFloatToDouble(fspec128, dspec256, fin128, dout256); 2774 testVectorCastFloatToDouble(fspec256, dspec512, fin256, dout512); 2775 } 2776 } 2777 2778 @Test 2779 static void testCastFromFloatFail() { 2780 float[] fin64 = new float[fspec64.length()]; 2781 float[] fin128 = new float[fspec128.length()]; 2782 float[] fin256 = new float[fspec256.length()]; 2783 float[] fin512 = new float[fspec512.length()]; 2784 2785 for (int i = 0; i < INVOC_COUNT; i++) { 2786 testVectorCastFloatToByteFail(fspec64, bspec64, fin64); 2787 testVectorCastFloatToByteFail(fspec64, bspec128, fin64); 2788 testVectorCastFloatToByteFail(fspec64, bspec256, fin64); 2789 testVectorCastFloatToByteFail(fspec64, bspec512, fin64); 2790 2791 testVectorCastFloatToByteFail(fspec128, bspec64, fin128); 2792 testVectorCastFloatToByteFail(fspec128, bspec128, fin128); 2793 testVectorCastFloatToByteFail(fspec128, bspec256, fin128); 2794 testVectorCastFloatToByteFail(fspec128, bspec512, fin128); 2795 2796 testVectorCastFloatToByteFail(fspec256, bspec128, fin256); 2797 testVectorCastFloatToByteFail(fspec256, bspec256, fin256); 2798 testVectorCastFloatToByteFail(fspec256, bspec512, fin256); 2799 2800 testVectorCastFloatToByteFail(fspec512, bspec64, fin512); 2801 testVectorCastFloatToByteFail(fspec512, bspec256, fin512); 2802 testVectorCastFloatToByteFail(fspec512, bspec512, fin512); 2803 2804 testVectorCastFloatToShortFail(fspec64, sspec64, fin64); 2805 testVectorCastFloatToShortFail(fspec64, sspec128, fin64); 2806 testVectorCastFloatToShortFail(fspec64, sspec256, fin64); 2807 testVectorCastFloatToShortFail(fspec64, sspec512, fin64); 2808 2809 testVectorCastFloatToShortFail(fspec128, sspec128, fin128); 2810 testVectorCastFloatToShortFail(fspec128, sspec256, fin128); 2811 testVectorCastFloatToShortFail(fspec128, sspec512, fin128); 2812 2813 testVectorCastFloatToShortFail(fspec256, sspec64, fin256); 2814 testVectorCastFloatToShortFail(fspec256, sspec256, fin256); 2815 testVectorCastFloatToShortFail(fspec256, sspec512, fin256); 2816 2817 testVectorCastFloatToShortFail(fspec512, sspec64, fin512); 2818 testVectorCastFloatToShortFail(fspec512, sspec128, fin512); 2819 testVectorCastFloatToShortFail(fspec512, sspec512, fin512); 2820 2821 testVectorCastFloatToIntFail(fspec64, ispec128, fin64); 2822 testVectorCastFloatToIntFail(fspec64, ispec256, fin64); 2823 testVectorCastFloatToIntFail(fspec64, ispec512, fin64); 2824 2825 testVectorCastFloatToIntFail(fspec128, ispec64, fin128); 2826 testVectorCastFloatToIntFail(fspec128, ispec256, fin128); 2827 testVectorCastFloatToIntFail(fspec128, ispec512, fin128); 2828 2829 testVectorCastFloatToIntFail(fspec256, ispec64, fin256); 2830 testVectorCastFloatToIntFail(fspec256, ispec128, fin256); 2831 testVectorCastFloatToIntFail(fspec256, ispec512, fin256); 2832 2833 testVectorCastFloatToIntFail(fspec512, ispec64, fin512); 2834 testVectorCastFloatToIntFail(fspec512, ispec128, fin512); 2835 testVectorCastFloatToIntFail(fspec512, ispec256, fin512); 2836 2837 testVectorCastFloatToLongFail(fspec64, lspec64, fin64); 2838 testVectorCastFloatToLongFail(fspec64, lspec256, fin64); 2839 testVectorCastFloatToLongFail(fspec64, lspec512, fin64); 2840 2841 testVectorCastFloatToLongFail(fspec128, lspec64, fin128); 2842 testVectorCastFloatToLongFail(fspec128, lspec128, fin128); 2843 testVectorCastFloatToLongFail(fspec128, lspec512, fin128); 2844 2845 testVectorCastFloatToLongFail(fspec256, lspec64, fin256); 2846 testVectorCastFloatToLongFail(fspec256, lspec128, fin256); 2847 testVectorCastFloatToLongFail(fspec256, lspec256, fin256); 2848 2849 testVectorCastFloatToLongFail(fspec512, lspec64, fin512); 2850 testVectorCastFloatToLongFail(fspec512, lspec128, fin512); 2851 testVectorCastFloatToLongFail(fspec512, lspec256, fin512); 2852 testVectorCastFloatToLongFail(fspec512, lspec512, fin512); 2853 2854 testVectorCastFloatToFloatFail(fspec64, fspec128, fin64); 2855 testVectorCastFloatToFloatFail(fspec64, fspec256, fin64); 2856 testVectorCastFloatToFloatFail(fspec64, fspec512, fin64); 2857 2858 testVectorCastFloatToFloatFail(fspec128, fspec64, fin128); 2859 testVectorCastFloatToFloatFail(fspec128, fspec256, fin128); 2860 testVectorCastFloatToFloatFail(fspec128, fspec512, fin128); 2861 2862 testVectorCastFloatToFloatFail(fspec256, fspec64, fin256); 2863 testVectorCastFloatToFloatFail(fspec256, fspec128, fin256); 2864 testVectorCastFloatToFloatFail(fspec256, fspec512, fin256); 2865 2866 testVectorCastFloatToFloatFail(fspec512, fspec64, fin512); 2867 testVectorCastFloatToFloatFail(fspec512, fspec128, fin512); 2868 testVectorCastFloatToFloatFail(fspec512, fspec256, fin512); 2869 2870 testVectorCastFloatToDoubleFail(fspec64, dspec64, fin64); 2871 testVectorCastFloatToDoubleFail(fspec64, dspec256, fin64); 2872 testVectorCastFloatToDoubleFail(fspec64, dspec512, fin64); 2873 2874 testVectorCastFloatToDoubleFail(fspec128, dspec64, fin128); 2875 testVectorCastFloatToDoubleFail(fspec128, dspec128, fin128); 2876 testVectorCastFloatToDoubleFail(fspec128, dspec512, fin128); 2877 2878 testVectorCastFloatToDoubleFail(fspec256, dspec64, fin256); 2879 testVectorCastFloatToDoubleFail(fspec256, dspec128, fin256); 2880 testVectorCastFloatToDoubleFail(fspec256, dspec256, fin256); 2881 2882 testVectorCastFloatToDoubleFail(fspec512, dspec64, fin512); 2883 testVectorCastFloatToDoubleFail(fspec512, dspec128, fin512); 2884 testVectorCastFloatToDoubleFail(fspec512, dspec256, fin512); 2885 testVectorCastFloatToDoubleFail(fspec512, dspec512, fin512); 2886 } 2887 } 2888 2889 @Test(dataProvider = "doubleUnaryOpProvider") 2890 static void testCastFromDouble(IntFunction<double[]> fa) { 2891 double[] din64 = fa.apply(dspec64.length()); 2892 double[] din128 = fa.apply(dspec128.length()); 2893 double[] din256 = fa.apply(dspec256.length()); 2894 double[] din512 = fa.apply(dspec512.length()); 2895 2896 byte[] bout64 = new byte[bspec64.length()]; 2897 2898 short[] sout64 = new short[sspec64.length()]; 2899 short[] sout128 = new short[sspec128.length()]; 2900 2901 int[] iout64 = new int[ispec64.length()]; 2902 int[] iout128 = new int[ispec128.length()]; 2903 int[] iout256 = new int[ispec256.length()]; 2904 2905 long[] lout64 = new long[lspec64.length()]; 2906 long[] lout128 = new long[lspec128.length()]; 2907 long[] lout256 = new long[lspec256.length()]; 2908 long[] lout512 = new long[lspec512.length()]; 2909 2910 float[] fout64 = new float[fspec64.length()]; 2911 float[] fout128 = new float[fspec128.length()]; 2912 float[] fout256 = new float[fspec256.length()]; 2913 2914 double[] dout64 = new double[dspec64.length()]; 2915 double[] dout128 = new double[dspec128.length()]; 2916 double[] dout256 = new double[dspec256.length()]; 2917 double[] dout512 = new double[dspec512.length()]; 2918 2919 for (int i = 0; i < NUM_ITER; i++) { 2920 testVectorCastDoubleToByte(dspec512, bspec64, din512, bout64); 2921 2922 testVectorCastDoubleToShort(dspec256, sspec64, din256, sout64); 2923 testVectorCastDoubleToShort(dspec512, sspec128, din512, sout128); 2924 2925 testVectorCastDoubleToInt(dspec128, ispec64, din128, iout64); 2926 testVectorCastDoubleToInt(dspec256, ispec128, din256, iout128); 2927 testVectorCastDoubleToInt(dspec512, ispec256, din512, iout256); 2928 2929 testVectorCastDoubleToLong(dspec64, lspec64, din64, lout64); 2930 testVectorCastDoubleToLong(dspec128, lspec128, din128, lout128); 2931 testVectorCastDoubleToLong(dspec256, lspec256, din256, lout256); 2932 testVectorCastDoubleToLong(dspec512, lspec512, din512, lout512); 2933 2934 testVectorCastDoubleToFloat(dspec128, fspec64, din128, fout64); 2935 testVectorCastDoubleToFloat(dspec256, fspec128, din256, fout128); 2936 testVectorCastDoubleToFloat(dspec512, fspec256, din512, fout256); 2937 2938 testVectorCastDoubleToDouble(dspec64, dspec64, din64, dout64); 2939 testVectorCastDoubleToDouble(dspec128, dspec128, din128, dout128); 2940 testVectorCastDoubleToDouble(dspec256, dspec256, din256, dout256); 2941 testVectorCastDoubleToDouble(dspec512, dspec512, din512, dout512); 2942 } 2943 } 2944 2945 @Test 2946 static void testCastFromDoubleFail() { 2947 double[] din64 = new double[dspec64.length()]; 2948 double[] din128 = new double[dspec128.length()]; 2949 double[] din256 = new double[dspec256.length()]; 2950 double[] din512 = new double[dspec512.length()]; 2951 2952 for (int i = 0; i < INVOC_COUNT; i++) { 2953 testVectorCastDoubleToByteFail(dspec64, bspec64, din64); 2954 testVectorCastDoubleToByteFail(dspec64, bspec128, din64); 2955 testVectorCastDoubleToByteFail(dspec64, bspec256, din64); 2956 testVectorCastDoubleToByteFail(dspec64, bspec512, din64); 2957 2958 testVectorCastDoubleToByteFail(dspec128, bspec64, din128); 2959 testVectorCastDoubleToByteFail(dspec128, bspec128, din128); 2960 testVectorCastDoubleToByteFail(dspec128, bspec256, din128); 2961 testVectorCastDoubleToByteFail(dspec128, bspec512, din128); 2962 2963 testVectorCastDoubleToByteFail(dspec256, bspec64, din256); 2964 testVectorCastDoubleToByteFail(dspec256, bspec128, din256); 2965 testVectorCastDoubleToByteFail(dspec256, bspec256, din256); 2966 testVectorCastDoubleToByteFail(dspec256, bspec512, din256); 2967 2968 testVectorCastDoubleToByteFail(dspec512, bspec128, din512); 2969 testVectorCastDoubleToByteFail(dspec512, bspec256, din512); 2970 testVectorCastDoubleToByteFail(dspec512, bspec512, din512); 2971 2972 testVectorCastDoubleToShortFail(dspec64, sspec64, din64); 2973 testVectorCastDoubleToShortFail(dspec64, sspec128, din64); 2974 testVectorCastDoubleToShortFail(dspec64, sspec256, din64); 2975 testVectorCastDoubleToShortFail(dspec64, sspec512, din64); 2976 2977 testVectorCastDoubleToShortFail(dspec128, sspec64, din128); 2978 testVectorCastDoubleToShortFail(dspec128, sspec128, din128); 2979 testVectorCastDoubleToShortFail(dspec128, sspec256, din128); 2980 testVectorCastDoubleToShortFail(dspec128, sspec512, din128); 2981 2982 testVectorCastDoubleToShortFail(dspec256, sspec128, din256); 2983 testVectorCastDoubleToShortFail(dspec256, sspec256, din256); 2984 testVectorCastDoubleToShortFail(dspec256, sspec512, din256); 2985 2986 testVectorCastDoubleToShortFail(dspec512, sspec64, din512); 2987 testVectorCastDoubleToShortFail(dspec512, sspec256, din512); 2988 testVectorCastDoubleToShortFail(dspec512, sspec512, din512); 2989 2990 testVectorCastDoubleToIntFail(dspec64, ispec64, din64); 2991 testVectorCastDoubleToIntFail(dspec64, ispec128, din64); 2992 testVectorCastDoubleToIntFail(dspec64, ispec256, din64); 2993 testVectorCastDoubleToIntFail(dspec64, ispec512, din64); 2994 2995 testVectorCastDoubleToIntFail(dspec128, ispec128, din128); 2996 testVectorCastDoubleToIntFail(dspec128, ispec256, din128); 2997 testVectorCastDoubleToIntFail(dspec128, ispec512, din128); 2998 2999 testVectorCastDoubleToIntFail(dspec256, ispec64, din256); 3000 testVectorCastDoubleToIntFail(dspec256, ispec256, din256); 3001 testVectorCastDoubleToIntFail(dspec256, ispec512, din256); 3002 3003 testVectorCastDoubleToIntFail(dspec512, ispec64, din512); 3004 testVectorCastDoubleToIntFail(dspec512, ispec128, din512); 3005 testVectorCastDoubleToIntFail(dspec512, ispec512, din512); 3006 3007 testVectorCastDoubleToLongFail(dspec64, lspec128, din64); 3008 testVectorCastDoubleToLongFail(dspec64, lspec256, din64); 3009 testVectorCastDoubleToLongFail(dspec64, lspec512, din64); 3010 3011 testVectorCastDoubleToLongFail(dspec128, lspec64, din128); 3012 testVectorCastDoubleToLongFail(dspec128, lspec256, din128); 3013 testVectorCastDoubleToLongFail(dspec128, lspec512, din128); 3014 3015 testVectorCastDoubleToLongFail(dspec256, lspec64, din256); 3016 testVectorCastDoubleToLongFail(dspec256, lspec128, din256); 3017 testVectorCastDoubleToLongFail(dspec256, lspec512, din256); 3018 3019 testVectorCastDoubleToLongFail(dspec512, lspec64, din512); 3020 testVectorCastDoubleToLongFail(dspec512, lspec128, din512); 3021 testVectorCastDoubleToLongFail(dspec512, lspec256, din512); 3022 3023 testVectorCastDoubleToFloatFail(dspec64, fspec64, din64); 3024 testVectorCastDoubleToFloatFail(dspec64, fspec128, din64); 3025 testVectorCastDoubleToFloatFail(dspec64, fspec256, din64); 3026 testVectorCastDoubleToFloatFail(dspec64, fspec512, din64); 3027 3028 testVectorCastDoubleToFloatFail(dspec128, fspec128, din128); 3029 testVectorCastDoubleToFloatFail(dspec128, fspec256, din128); 3030 testVectorCastDoubleToFloatFail(dspec128, fspec512, din128); 3031 3032 testVectorCastDoubleToFloatFail(dspec256, fspec64, din256); 3033 testVectorCastDoubleToFloatFail(dspec256, fspec256, din256); 3034 testVectorCastDoubleToFloatFail(dspec256, fspec512, din256); 3035 3036 testVectorCastDoubleToFloatFail(dspec512, fspec64, din512); 3037 testVectorCastDoubleToFloatFail(dspec512, fspec128, din512); 3038 testVectorCastDoubleToFloatFail(dspec512, fspec512, din512); 3039 3040 testVectorCastDoubleToDoubleFail(dspec64, dspec128, din64); 3041 testVectorCastDoubleToDoubleFail(dspec64, dspec256, din64); 3042 testVectorCastDoubleToDoubleFail(dspec64, dspec512, din64); 3043 3044 testVectorCastDoubleToDoubleFail(dspec128, dspec64, din128); 3045 testVectorCastDoubleToDoubleFail(dspec128, dspec256, din128); 3046 testVectorCastDoubleToDoubleFail(dspec128, dspec512, din128); 3047 3048 testVectorCastDoubleToDoubleFail(dspec256, dspec64, din256); 3049 testVectorCastDoubleToDoubleFail(dspec256, dspec128, din256); 3050 testVectorCastDoubleToDoubleFail(dspec256, dspec512, din256); 3051 3052 testVectorCastDoubleToDoubleFail(dspec512, dspec64, din512); 3053 testVectorCastDoubleToDoubleFail(dspec512, dspec128, din512); 3054 testVectorCastDoubleToDoubleFail(dspec512, dspec256, din512); 3055 } 3056 } 3057 3058 static 3059 void testVectorCastByteMaxToByte(ByteVector.ByteSpecies a, ByteVector.ByteSpecies b, 3060 byte[] input, byte[] output) { 3061 if (S_Max_BIT.bitSize() == b.length() * Byte.SIZE) { 3062 testVectorCastByteToByte(a, b, input, output); 3063 } else { 3064 testVectorCastByteToByteFail(a, b, input); 3065 } 3066 } 3067 3068 static 3069 void testVectorCastByteMaxToShort(ByteVector.ByteSpecies a, ShortVector.ShortSpecies b, 3070 byte[] input, short[] output) { 3071 if (S_Max_BIT.bitSize() == b.length() * Byte.SIZE) { 3072 testVectorCastByteToShort(a, b, input, output); 3073 } else { 3074 testVectorCastByteToShortFail(a, b, input); 3075 } 3076 } 3077 3078 static 3079 void testVectorCastByteMaxToInt(ByteVector.ByteSpecies a, IntVector.IntSpecies b, 3080 byte[] input, int[] output) { 3081 if (S_Max_BIT.bitSize() == b.length() * Byte.SIZE) { 3082 testVectorCastByteToInt(a, b, input, output); 3083 } else { 3084 testVectorCastByteToIntFail(a, b, input); 3085 } 3086 } 3087 3088 static 3089 void testVectorCastByteMaxToLong(ByteVector.ByteSpecies a, LongVector.LongSpecies b, 3090 byte[] input, long[] output) { 3091 if (S_Max_BIT.bitSize() == b.length() * Byte.SIZE) { 3092 testVectorCastByteToLong(a, b, input, output); 3093 } else { 3094 testVectorCastByteToLongFail(a, b, input); 3095 } 3096 } 3097 3098 static 3099 void testVectorCastByteMaxToFloat(ByteVector.ByteSpecies a, FloatVector.FloatSpecies b, 3100 byte[] input, float[] output) { 3101 if (S_Max_BIT.bitSize() == b.length() * Byte.SIZE) { 3102 testVectorCastByteToFloat(a, b, input, output); 3103 } else { 3104 testVectorCastByteToFloatFail(a, b, input); 3105 } 3106 } 3107 3108 static 3109 void testVectorCastByteMaxToDouble(ByteVector.ByteSpecies a, DoubleVector.DoubleSpecies b, 3110 byte[] input, double[] output) { 3111 if (S_Max_BIT.bitSize() == b.length() * Byte.SIZE) { 3112 testVectorCastByteToDouble(a, b, input, output); 3113 } else { 3114 testVectorCastByteToDoubleFail(a, b, input); 3115 } 3116 } 3117 3118 static 3119 void testVectorCastShortMaxToByte(ShortVector.ShortSpecies a, ByteVector.ByteSpecies b, 3120 short[] input, byte[] output) { 3121 if (S_Max_BIT.bitSize() == b.length() * Short.SIZE) { 3122 testVectorCastShortToByte(a, b, input, output); 3123 } else { 3124 testVectorCastShortToByteFail(a, b, input); 3125 } 3126 } 3127 3128 static 3129 void testVectorCastShortMaxToShort(ShortVector.ShortSpecies a, ShortVector.ShortSpecies b, 3130 short[] input, short[] output) { 3131 if (S_Max_BIT.bitSize() == b.length() * Short.SIZE) { 3132 testVectorCastShortToShort(a, b, input, output); 3133 } else { 3134 testVectorCastShortToShortFail(a, b, input); 3135 } 3136 } 3137 3138 static 3139 void testVectorCastShortMaxToInt(ShortVector.ShortSpecies a, IntVector.IntSpecies b, 3140 short[] input, int[] output) { 3141 if (S_Max_BIT.bitSize() == b.length() * Short.SIZE) { 3142 testVectorCastShortToInt(a, b, input, output); 3143 } else { 3144 testVectorCastShortToIntFail(a, b, input); 3145 } 3146 } 3147 3148 static 3149 void testVectorCastShortMaxToLong(ShortVector.ShortSpecies a, LongVector.LongSpecies b, 3150 short[] input, long[] output) { 3151 if (S_Max_BIT.bitSize() == b.length() * Short.SIZE) { 3152 testVectorCastShortToLong(a, b, input, output); 3153 } else { 3154 testVectorCastShortToLongFail(a, b, input); 3155 } 3156 } 3157 3158 static 3159 void testVectorCastShortMaxToFloat(ShortVector.ShortSpecies a, FloatVector.FloatSpecies b, 3160 short[] input, float[] output) { 3161 if (S_Max_BIT.bitSize() == b.length() * Short.SIZE) { 3162 testVectorCastShortToFloat(a, b, input, output); 3163 } else { 3164 testVectorCastShortToFloatFail(a, b, input); 3165 } 3166 } 3167 3168 static 3169 void testVectorCastShortMaxToDouble(ShortVector.ShortSpecies a, DoubleVector.DoubleSpecies b, 3170 short[] input, double[] output) { 3171 if (S_Max_BIT.bitSize() == b.length() * Short.SIZE) { 3172 testVectorCastShortToDouble(a, b, input, output); 3173 } else { 3174 testVectorCastShortToDoubleFail(a, b, input); 3175 } 3176 } 3177 3178 static 3179 void testVectorCastIntMaxToByte(IntVector.IntSpecies a, ByteVector.ByteSpecies b, 3180 int[] input, byte[] output) { 3181 if (S_Max_BIT.bitSize() == b.length() * Integer.SIZE) { 3182 testVectorCastIntToByte(a, b, input, output); 3183 } else { 3184 testVectorCastIntToByteFail(a, b, input); 3185 } 3186 } 3187 3188 static 3189 void testVectorCastIntMaxToShort(IntVector.IntSpecies a, ShortVector.ShortSpecies b, 3190 int[] input, short[] output) { 3191 if (S_Max_BIT.bitSize() == b.length() * Integer.SIZE) { 3192 testVectorCastIntToShort(a, b, input, output); 3193 } else { 3194 testVectorCastIntToShortFail(a, b, input); 3195 } 3196 } 3197 3198 static 3199 void testVectorCastIntMaxToInt(IntVector.IntSpecies a, IntVector.IntSpecies b, 3200 int[] input, int[] output) { 3201 if (S_Max_BIT.bitSize() == b.length() * Integer.SIZE) { 3202 testVectorCastIntToInt(a, b, input, output); 3203 } else { 3204 testVectorCastIntToIntFail(a, b, input); 3205 } 3206 } 3207 3208 static 3209 void testVectorCastIntMaxToLong(IntVector.IntSpecies a, LongVector.LongSpecies b, 3210 int[] input, long[] output) { 3211 if (S_Max_BIT.bitSize() == b.length() * Integer.SIZE) { 3212 testVectorCastIntToLong(a, b, input, output); 3213 } else { 3214 testVectorCastIntToLongFail(a, b, input); 3215 } 3216 } 3217 3218 static 3219 void testVectorCastIntMaxToFloat(IntVector.IntSpecies a, FloatVector.FloatSpecies b, 3220 int[] input, float[] output) { 3221 if (S_Max_BIT.bitSize() == b.length() * Integer.SIZE) { 3222 testVectorCastIntToFloat(a, b, input, output); 3223 } else { 3224 testVectorCastIntToFloatFail(a, b, input); 3225 } 3226 } 3227 3228 static 3229 void testVectorCastIntMaxToDouble(IntVector.IntSpecies a, DoubleVector.DoubleSpecies b, 3230 int[] input, double[] output) { 3231 if (S_Max_BIT.bitSize() == b.length() * Integer.SIZE) { 3232 testVectorCastIntToDouble(a, b, input, output); 3233 } else { 3234 testVectorCastIntToDoubleFail(a, b, input); 3235 } 3236 } 3237 3238 static 3239 void testVectorCastLongMaxToByte(LongVector.LongSpecies a, ByteVector.ByteSpecies b, 3240 long[] input, byte[] output) { 3241 if (S_Max_BIT.bitSize() == b.length() * Long.SIZE) { 3242 testVectorCastLongToByte(a, b, input, output); 3243 } else { 3244 testVectorCastLongToByteFail(a, b, input); 3245 } 3246 } 3247 3248 static 3249 void testVectorCastLongMaxToShort(LongVector.LongSpecies a, ShortVector.ShortSpecies b, 3250 long[] input, short[] output) { 3251 if (S_Max_BIT.bitSize() == b.length() * Long.SIZE) { 3252 testVectorCastLongToShort(a, b, input, output); 3253 } else { 3254 testVectorCastLongToShortFail(a, b, input); 3255 } 3256 } 3257 3258 static 3259 void testVectorCastLongMaxToInt(LongVector.LongSpecies a, IntVector.IntSpecies b, 3260 long[] input, int[] output) { 3261 if (S_Max_BIT.bitSize() == b.length() * Long.SIZE) { 3262 testVectorCastLongToInt(a, b, input, output); 3263 } else { 3264 testVectorCastLongToIntFail(a, b, input); 3265 } 3266 } 3267 3268 static 3269 void testVectorCastLongMaxToLong(LongVector.LongSpecies a, LongVector.LongSpecies b, 3270 long[] input, long[] output) { 3271 if (S_Max_BIT.bitSize() == b.length() * Long.SIZE) { 3272 testVectorCastLongToLong(a, b, input, output); 3273 } else { 3274 testVectorCastLongToLongFail(a, b, input); 3275 } 3276 } 3277 3278 static 3279 void testVectorCastLongMaxToFloat(LongVector.LongSpecies a, FloatVector.FloatSpecies b, 3280 long[] input, float[] output) { 3281 if (S_Max_BIT.bitSize() == b.length() * Long.SIZE) { 3282 testVectorCastLongToFloat(a, b, input, output); 3283 } else { 3284 testVectorCastLongToFloatFail(a, b, input); 3285 } 3286 } 3287 3288 static 3289 void testVectorCastLongMaxToDouble(LongVector.LongSpecies a, DoubleVector.DoubleSpecies b, 3290 long[] input, double[] output) { 3291 if (S_Max_BIT.bitSize() == b.length() * Long.SIZE) { 3292 testVectorCastLongToDouble(a, b, input, output); 3293 } else { 3294 testVectorCastLongToDoubleFail(a, b, input); 3295 } 3296 } 3297 3298 static 3299 void testVectorCastFloatMaxToByte(FloatVector.FloatSpecies a, ByteVector.ByteSpecies b, 3300 float[] input, byte[] output) { 3301 if (S_Max_BIT.bitSize() == b.length() * Float.SIZE) { 3302 testVectorCastFloatToByte(a, b, input, output); 3303 } else { 3304 testVectorCastFloatToByteFail(a, b, input); 3305 } 3306 } 3307 3308 static 3309 void testVectorCastFloatMaxToShort(FloatVector.FloatSpecies a, ShortVector.ShortSpecies b, 3310 float[] input, short[] output) { 3311 if (S_Max_BIT.bitSize() == b.length() * Float.SIZE) { 3312 testVectorCastFloatToShort(a, b, input, output); 3313 } else { 3314 testVectorCastFloatToShortFail(a, b, input); 3315 } 3316 } 3317 3318 static 3319 void testVectorCastFloatMaxToInt(FloatVector.FloatSpecies a, IntVector.IntSpecies b, 3320 float[] input, int[] output) { 3321 if (S_Max_BIT.bitSize() == b.length() * Float.SIZE) { 3322 testVectorCastFloatToInt(a, b, input, output); 3323 } else { 3324 testVectorCastFloatToIntFail(a, b, input); 3325 } 3326 } 3327 3328 static 3329 void testVectorCastFloatMaxToLong(FloatVector.FloatSpecies a, LongVector.LongSpecies b, 3330 float[] input, long[] output) { 3331 if (S_Max_BIT.bitSize() == b.length() * Float.SIZE) { 3332 testVectorCastFloatToLong(a, b, input, output); 3333 } else { 3334 testVectorCastFloatToLongFail(a, b, input); 3335 } 3336 } 3337 3338 static 3339 void testVectorCastFloatMaxToFloat(FloatVector.FloatSpecies a, FloatVector.FloatSpecies b, 3340 float[] input, float[] output) { 3341 if (S_Max_BIT.bitSize() == b.length() * Float.SIZE) { 3342 testVectorCastFloatToFloat(a, b, input, output); 3343 } else { 3344 testVectorCastFloatToFloatFail(a, b, input); 3345 } 3346 } 3347 3348 static 3349 void testVectorCastFloatMaxToDouble(FloatVector.FloatSpecies a, DoubleVector.DoubleSpecies b, 3350 float[] input, double[] output) { 3351 if (S_Max_BIT.bitSize() == b.length() * Float.SIZE) { 3352 testVectorCastFloatToDouble(a, b, input, output); 3353 } else { 3354 testVectorCastFloatToDoubleFail(a, b, input); 3355 } 3356 } 3357 3358 static 3359 void testVectorCastDoubleMaxToByte(DoubleVector.DoubleSpecies a, ByteVector.ByteSpecies b, 3360 double[] input, byte[] output) { 3361 if (S_Max_BIT.bitSize() == b.length() * Double.SIZE) { 3362 testVectorCastDoubleToByte(a, b, input, output); 3363 } else { 3364 testVectorCastDoubleToByteFail(a, b, input); 3365 } 3366 } 3367 3368 static 3369 void testVectorCastDoubleMaxToShort(DoubleVector.DoubleSpecies a, ShortVector.ShortSpecies b, 3370 double[] input, short[] output) { 3371 if (S_Max_BIT.bitSize() == b.length() * Double.SIZE) { 3372 testVectorCastDoubleToShort(a, b, input, output); 3373 } else { 3374 testVectorCastDoubleToShortFail(a, b, input); 3375 } 3376 } 3377 3378 static 3379 void testVectorCastDoubleMaxToInt(DoubleVector.DoubleSpecies a, IntVector.IntSpecies b, 3380 double[] input, int[] output) { 3381 if (S_Max_BIT.bitSize() == b.length() * Double.SIZE) { 3382 testVectorCastDoubleToInt(a, b, input, output); 3383 } else { 3384 testVectorCastDoubleToIntFail(a, b, input); 3385 } 3386 } 3387 3388 static 3389 void testVectorCastDoubleMaxToLong(DoubleVector.DoubleSpecies a, LongVector.LongSpecies b, 3390 double[] input, long[] output) { 3391 if (S_Max_BIT.bitSize() == b.length() * Double.SIZE) { 3392 testVectorCastDoubleToLong(a, b, input, output); 3393 } else { 3394 testVectorCastDoubleToLongFail(a, b, input); 3395 } 3396 } 3397 3398 static 3399 void testVectorCastDoubleMaxToFloat(DoubleVector.DoubleSpecies a, FloatVector.FloatSpecies b, 3400 double[] input, float[] output) { 3401 if (S_Max_BIT.bitSize() == b.length() * Double.SIZE) { 3402 testVectorCastDoubleToFloat(a, b, input, output); 3403 } else { 3404 testVectorCastDoubleToFloatFail(a, b, input); 3405 } 3406 } 3407 3408 static 3409 void testVectorCastDoubleMaxToDouble(DoubleVector.DoubleSpecies a, DoubleVector.DoubleSpecies b, 3410 double[] input, double[] output) { 3411 if (S_Max_BIT.bitSize() == b.length() * Double.SIZE) { 3412 testVectorCastDoubleToDouble(a, b, input, output); 3413 } else { 3414 testVectorCastDoubleToDoubleFail(a, b, input); 3415 } 3416 } 3417 3418 @Test(dataProvider = "byteUnaryOpProvider") 3419 static void testCastFromByteMax(IntFunction<byte[]> fa) { 3420 byte[] binMax = fa.apply(bspecMax.length()); 3421 3422 byte[] bout64 = new byte[bspec64.length()]; 3423 byte[] bout128 = new byte[bspec128.length()]; 3424 byte[] bout256 = new byte[bspec256.length()]; 3425 byte[] bout512 = new byte[bspec512.length()]; 3426 byte[] boutMax = new byte[bspecMax.length()]; 3427 3428 short[] sout64 = new short[sspec64.length()]; 3429 short[] sout128 = new short[sspec128.length()]; 3430 short[] sout256 = new short[sspec256.length()]; 3431 short[] sout512 = new short[sspec512.length()]; 3432 short[] soutMax = new short[sspecMax.length()]; 3433 3434 int[] iout64 = new int[ispec64.length()]; 3435 int[] iout128 = new int[ispec128.length()]; 3436 int[] iout256 = new int[ispec256.length()]; 3437 int[] iout512 = new int[ispec512.length()]; 3438 int[] ioutMax = new int[ispecMax.length()]; 3439 3440 long[] lout64 = new long[lspec64.length()]; 3441 long[] lout128 = new long[lspec128.length()]; 3442 long[] lout256 = new long[lspec256.length()]; 3443 long[] lout512 = new long[lspec512.length()]; 3444 long[] loutMax = new long[lspecMax.length()]; 3445 3446 float[] fout64 = new float[fspec64.length()]; 3447 float[] fout128 = new float[fspec128.length()]; 3448 float[] fout256 = new float[fspec256.length()]; 3449 float[] fout512 = new float[fspec512.length()]; 3450 float[] foutMax = new float[fspecMax.length()]; 3451 3452 double[] dout64 = new double[dspec64.length()]; 3453 double[] dout128 = new double[dspec128.length()]; 3454 double[] dout256 = new double[dspec256.length()]; 3455 double[] dout512 = new double[dspec512.length()]; 3456 double[] doutMax = new double[dspecMax.length()]; 3457 3458 for (int i = 0; i < NUM_ITER; i++) { 3459 testVectorCastByteMaxToByte(bspecMax, bspec64, binMax, bout64); 3460 testVectorCastByteMaxToByte(bspecMax, bspec128, binMax, bout128); 3461 testVectorCastByteMaxToByte(bspecMax, bspec256, binMax, bout256); 3462 testVectorCastByteMaxToByte(bspecMax, bspec512, binMax, bout512); 3463 testVectorCastByteMaxToByte(bspecMax, bspecMax, binMax, boutMax); 3464 3465 testVectorCastByteMaxToShort(bspecMax, sspec64, binMax, sout64); 3466 testVectorCastByteMaxToShort(bspecMax, sspec128, binMax, sout128); 3467 testVectorCastByteMaxToShort(bspecMax, sspec256, binMax, sout256); 3468 testVectorCastByteMaxToShort(bspecMax, sspec512, binMax, sout512); 3469 testVectorCastByteMaxToShort(bspecMax, sspecMax, binMax, soutMax); 3470 3471 testVectorCastByteMaxToInt(bspecMax, ispec64, binMax, iout64); 3472 testVectorCastByteMaxToInt(bspecMax, ispec128, binMax, iout128); 3473 testVectorCastByteMaxToInt(bspecMax, ispec256, binMax, iout256); 3474 testVectorCastByteMaxToInt(bspecMax, ispec512, binMax, iout512); 3475 testVectorCastByteMaxToInt(bspecMax, ispecMax, binMax, ioutMax); 3476 3477 testVectorCastByteMaxToLong(bspecMax, lspec64, binMax, lout64); 3478 testVectorCastByteMaxToLong(bspecMax, lspec128, binMax, lout128); 3479 testVectorCastByteMaxToLong(bspecMax, lspec256, binMax, lout256); 3480 testVectorCastByteMaxToLong(bspecMax, lspec512, binMax, lout512); 3481 testVectorCastByteMaxToLong(bspecMax, lspecMax, binMax, loutMax); 3482 3483 testVectorCastByteMaxToFloat(bspecMax, fspec64, binMax, fout64); 3484 testVectorCastByteMaxToFloat(bspecMax, fspec128, binMax, fout128); 3485 testVectorCastByteMaxToFloat(bspecMax, fspec256, binMax, fout256); 3486 testVectorCastByteMaxToFloat(bspecMax, fspec512, binMax, fout512); 3487 testVectorCastByteMaxToFloat(bspecMax, fspecMax, binMax, foutMax); 3488 3489 testVectorCastByteMaxToDouble(bspecMax, dspec64, binMax, dout64); 3490 testVectorCastByteMaxToDouble(bspecMax, dspec128, binMax, dout128); 3491 testVectorCastByteMaxToDouble(bspecMax, dspec256, binMax, dout256); 3492 testVectorCastByteMaxToDouble(bspecMax, dspec512, binMax, dout512); 3493 testVectorCastByteMaxToDouble(bspecMax, dspecMax, binMax, doutMax); 3494 } 3495 } 3496 3497 @Test(dataProvider = "shortUnaryOpProvider") 3498 static void testCastFromShortMax(IntFunction<short[]> fa) { 3499 short[] sinMax = fa.apply(sspecMax.length()); 3500 3501 byte[] bout64 = new byte[bspec64.length()]; 3502 byte[] bout128 = new byte[bspec128.length()]; 3503 byte[] bout256 = new byte[bspec256.length()]; 3504 byte[] bout512 = new byte[bspec512.length()]; 3505 byte[] boutMax = new byte[bspecMax.length()]; 3506 3507 short[] sout64 = new short[sspec64.length()]; 3508 short[] sout128 = new short[sspec128.length()]; 3509 short[] sout256 = new short[sspec256.length()]; 3510 short[] sout512 = new short[sspec512.length()]; 3511 short[] soutMax = new short[sspecMax.length()]; 3512 3513 int[] iout64 = new int[ispec64.length()]; 3514 int[] iout128 = new int[ispec128.length()]; 3515 int[] iout256 = new int[ispec256.length()]; 3516 int[] iout512 = new int[ispec512.length()]; 3517 int[] ioutMax = new int[ispecMax.length()]; 3518 3519 long[] lout64 = new long[lspec64.length()]; 3520 long[] lout128 = new long[lspec128.length()]; 3521 long[] lout256 = new long[lspec256.length()]; 3522 long[] lout512 = new long[lspec512.length()]; 3523 long[] loutMax = new long[lspecMax.length()]; 3524 3525 float[] fout64 = new float[fspec64.length()]; 3526 float[] fout128 = new float[fspec128.length()]; 3527 float[] fout256 = new float[fspec256.length()]; 3528 float[] fout512 = new float[fspec512.length()]; 3529 float[] foutMax = new float[fspecMax.length()]; 3530 3531 double[] dout64 = new double[dspec64.length()]; 3532 double[] dout128 = new double[dspec128.length()]; 3533 double[] dout256 = new double[dspec256.length()]; 3534 double[] dout512 = new double[dspec512.length()]; 3535 double[] doutMax = new double[dspecMax.length()]; 3536 3537 for (int i = 0; i < NUM_ITER; i++) { 3538 testVectorCastShortMaxToByte(sspecMax, bspec64, sinMax, bout64); 3539 testVectorCastShortMaxToByte(sspecMax, bspec128, sinMax, bout128); 3540 testVectorCastShortMaxToByte(sspecMax, bspec256, sinMax, bout256); 3541 testVectorCastShortMaxToByte(sspecMax, bspec512, sinMax, bout512); 3542 testVectorCastShortMaxToByte(sspecMax, bspecMax, sinMax, boutMax); 3543 3544 testVectorCastShortMaxToShort(sspecMax, sspec64, sinMax, sout64); 3545 testVectorCastShortMaxToShort(sspecMax, sspec128, sinMax, sout128); 3546 testVectorCastShortMaxToShort(sspecMax, sspec256, sinMax, sout256); 3547 testVectorCastShortMaxToShort(sspecMax, sspec512, sinMax, sout512); 3548 testVectorCastShortMaxToShort(sspecMax, sspecMax, sinMax, soutMax); 3549 3550 testVectorCastShortMaxToInt(sspecMax, ispec64, sinMax, iout64); 3551 testVectorCastShortMaxToInt(sspecMax, ispec128, sinMax, iout128); 3552 testVectorCastShortMaxToInt(sspecMax, ispec256, sinMax, iout256); 3553 testVectorCastShortMaxToInt(sspecMax, ispec512, sinMax, iout512); 3554 testVectorCastShortMaxToInt(sspecMax, ispecMax, sinMax, ioutMax); 3555 3556 testVectorCastShortMaxToLong(sspecMax, lspec64, sinMax, lout64); 3557 testVectorCastShortMaxToLong(sspecMax, lspec128, sinMax, lout128); 3558 testVectorCastShortMaxToLong(sspecMax, lspec256, sinMax, lout256); 3559 testVectorCastShortMaxToLong(sspecMax, lspec512, sinMax, lout512); 3560 testVectorCastShortMaxToLong(sspecMax, lspecMax, sinMax, loutMax); 3561 3562 testVectorCastShortMaxToFloat(sspecMax, fspec64, sinMax, fout64); 3563 testVectorCastShortMaxToFloat(sspecMax, fspec128, sinMax, fout128); 3564 testVectorCastShortMaxToFloat(sspecMax, fspec256, sinMax, fout256); 3565 testVectorCastShortMaxToFloat(sspecMax, fspec512, sinMax, fout512); 3566 testVectorCastShortMaxToFloat(sspecMax, fspecMax, sinMax, foutMax); 3567 3568 testVectorCastShortMaxToDouble(sspecMax, dspec64, sinMax, dout64); 3569 testVectorCastShortMaxToDouble(sspecMax, dspec128, sinMax, dout128); 3570 testVectorCastShortMaxToDouble(sspecMax, dspec256, sinMax, dout256); 3571 testVectorCastShortMaxToDouble(sspecMax, dspec512, sinMax, dout512); 3572 testVectorCastShortMaxToDouble(sspecMax, dspecMax, sinMax, doutMax); 3573 } 3574 } 3575 3576 @Test(dataProvider = "intUnaryOpProvider") 3577 static void testCastFromIntMax(IntFunction<int[]> fa) { 3578 int[] iinMax = fa.apply(ispecMax.length()); 3579 3580 byte[] bout64 = new byte[bspec64.length()]; 3581 byte[] bout128 = new byte[bspec128.length()]; 3582 byte[] bout256 = new byte[bspec256.length()]; 3583 byte[] bout512 = new byte[bspec512.length()]; 3584 byte[] boutMax = new byte[bspecMax.length()]; 3585 3586 short[] sout64 = new short[sspec64.length()]; 3587 short[] sout128 = new short[sspec128.length()]; 3588 short[] sout256 = new short[sspec256.length()]; 3589 short[] sout512 = new short[sspec512.length()]; 3590 short[] soutMax = new short[sspecMax.length()]; 3591 3592 int[] iout64 = new int[ispec64.length()]; 3593 int[] iout128 = new int[ispec128.length()]; 3594 int[] iout256 = new int[ispec256.length()]; 3595 int[] iout512 = new int[ispec512.length()]; 3596 int[] ioutMax = new int[ispecMax.length()]; 3597 3598 long[] lout64 = new long[lspec64.length()]; 3599 long[] lout128 = new long[lspec128.length()]; 3600 long[] lout256 = new long[lspec256.length()]; 3601 long[] lout512 = new long[lspec512.length()]; 3602 long[] loutMax = new long[lspecMax.length()]; 3603 3604 float[] fout64 = new float[fspec64.length()]; 3605 float[] fout128 = new float[fspec128.length()]; 3606 float[] fout256 = new float[fspec256.length()]; 3607 float[] fout512 = new float[fspec512.length()]; 3608 float[] foutMax = new float[fspecMax.length()]; 3609 3610 double[] dout64 = new double[dspec64.length()]; 3611 double[] dout128 = new double[dspec128.length()]; 3612 double[] dout256 = new double[dspec256.length()]; 3613 double[] dout512 = new double[dspec512.length()]; 3614 double[] doutMax = new double[dspecMax.length()]; 3615 3616 for (int i = 0; i < NUM_ITER; i++) { 3617 testVectorCastIntMaxToByte(ispecMax, bspec64, iinMax, bout64); 3618 testVectorCastIntMaxToByte(ispecMax, bspec128, iinMax, bout128); 3619 testVectorCastIntMaxToByte(ispecMax, bspec256, iinMax, bout256); 3620 testVectorCastIntMaxToByte(ispecMax, bspec512, iinMax, bout512); 3621 testVectorCastIntMaxToByte(ispecMax, bspecMax, iinMax, boutMax); 3622 3623 testVectorCastIntMaxToShort(ispecMax, sspec64, iinMax, sout64); 3624 testVectorCastIntMaxToShort(ispecMax, sspec128, iinMax, sout128); 3625 testVectorCastIntMaxToShort(ispecMax, sspec256, iinMax, sout256); 3626 testVectorCastIntMaxToShort(ispecMax, sspec512, iinMax, sout512); 3627 testVectorCastIntMaxToShort(ispecMax, sspecMax, iinMax, soutMax); 3628 3629 testVectorCastIntMaxToInt(ispecMax, ispec64, iinMax, iout64); 3630 testVectorCastIntMaxToInt(ispecMax, ispec128, iinMax, iout128); 3631 testVectorCastIntMaxToInt(ispecMax, ispec256, iinMax, iout256); 3632 testVectorCastIntMaxToInt(ispecMax, ispec512, iinMax, iout512); 3633 testVectorCastIntMaxToInt(ispecMax, ispecMax, iinMax, ioutMax); 3634 3635 testVectorCastIntMaxToLong(ispecMax, lspec64, iinMax, lout64); 3636 testVectorCastIntMaxToLong(ispecMax, lspec128, iinMax, lout128); 3637 testVectorCastIntMaxToLong(ispecMax, lspec256, iinMax, lout256); 3638 testVectorCastIntMaxToLong(ispecMax, lspec512, iinMax, lout512); 3639 testVectorCastIntMaxToLong(ispecMax, lspecMax, iinMax, loutMax); 3640 3641 testVectorCastIntMaxToFloat(ispecMax, fspec64, iinMax, fout64); 3642 testVectorCastIntMaxToFloat(ispecMax, fspec128, iinMax, fout128); 3643 testVectorCastIntMaxToFloat(ispecMax, fspec256, iinMax, fout256); 3644 testVectorCastIntMaxToFloat(ispecMax, fspec512, iinMax, fout512); 3645 testVectorCastIntMaxToFloat(ispecMax, fspecMax, iinMax, foutMax); 3646 3647 testVectorCastIntMaxToDouble(ispecMax, dspec64, iinMax, dout64); 3648 testVectorCastIntMaxToDouble(ispecMax, dspec128, iinMax, dout128); 3649 testVectorCastIntMaxToDouble(ispecMax, dspec256, iinMax, dout256); 3650 testVectorCastIntMaxToDouble(ispecMax, dspec512, iinMax, dout512); 3651 testVectorCastIntMaxToDouble(ispecMax, dspecMax, iinMax, doutMax); 3652 } 3653 } 3654 3655 @Test(dataProvider = "longUnaryOpProvider") 3656 static void testCastFromLongMax(IntFunction<long[]> fa) { 3657 long[] linMax = fa.apply(lspecMax.length()); 3658 3659 byte[] bout64 = new byte[bspec64.length()]; 3660 byte[] bout128 = new byte[bspec128.length()]; 3661 byte[] bout256 = new byte[bspec256.length()]; 3662 byte[] bout512 = new byte[bspec512.length()]; 3663 byte[] boutMax = new byte[bspecMax.length()]; 3664 3665 short[] sout64 = new short[sspec64.length()]; 3666 short[] sout128 = new short[sspec128.length()]; 3667 short[] sout256 = new short[sspec256.length()]; 3668 short[] sout512 = new short[sspec512.length()]; 3669 short[] soutMax = new short[sspecMax.length()]; 3670 3671 int[] iout64 = new int[ispec64.length()]; 3672 int[] iout128 = new int[ispec128.length()]; 3673 int[] iout256 = new int[ispec256.length()]; 3674 int[] iout512 = new int[ispec512.length()]; 3675 int[] ioutMax = new int[ispecMax.length()]; 3676 3677 long[] lout64 = new long[lspec64.length()]; 3678 long[] lout128 = new long[lspec128.length()]; 3679 long[] lout256 = new long[lspec256.length()]; 3680 long[] lout512 = new long[lspec512.length()]; 3681 long[] loutMax = new long[lspecMax.length()]; 3682 3683 float[] fout64 = new float[fspec64.length()]; 3684 float[] fout128 = new float[fspec128.length()]; 3685 float[] fout256 = new float[fspec256.length()]; 3686 float[] fout512 = new float[fspec512.length()]; 3687 float[] foutMax = new float[fspecMax.length()]; 3688 3689 double[] dout64 = new double[dspec64.length()]; 3690 double[] dout128 = new double[dspec128.length()]; 3691 double[] dout256 = new double[dspec256.length()]; 3692 double[] dout512 = new double[dspec512.length()]; 3693 double[] doutMax = new double[dspecMax.length()]; 3694 3695 for (int i = 0; i < NUM_ITER; i++) { 3696 testVectorCastLongMaxToByte(lspecMax, bspec64, linMax, bout64); 3697 testVectorCastLongMaxToByte(lspecMax, bspec128, linMax, bout128); 3698 testVectorCastLongMaxToByte(lspecMax, bspec256, linMax, bout256); 3699 testVectorCastLongMaxToByte(lspecMax, bspec512, linMax, bout512); 3700 testVectorCastLongMaxToByte(lspecMax, bspecMax, linMax, boutMax); 3701 3702 testVectorCastLongMaxToShort(lspecMax, sspec64, linMax, sout64); 3703 testVectorCastLongMaxToShort(lspecMax, sspec128, linMax, sout128); 3704 testVectorCastLongMaxToShort(lspecMax, sspec256, linMax, sout256); 3705 testVectorCastLongMaxToShort(lspecMax, sspec512, linMax, sout512); 3706 testVectorCastLongMaxToShort(lspecMax, sspecMax, linMax, soutMax); 3707 3708 testVectorCastLongMaxToInt(lspecMax, ispec64, linMax, iout64); 3709 testVectorCastLongMaxToInt(lspecMax, ispec128, linMax, iout128); 3710 testVectorCastLongMaxToInt(lspecMax, ispec256, linMax, iout256); 3711 testVectorCastLongMaxToInt(lspecMax, ispec512, linMax, iout512); 3712 testVectorCastLongMaxToInt(lspecMax, ispecMax, linMax, ioutMax); 3713 3714 testVectorCastLongMaxToLong(lspecMax, lspec64, linMax, lout64); 3715 testVectorCastLongMaxToLong(lspecMax, lspec128, linMax, lout128); 3716 testVectorCastLongMaxToLong(lspecMax, lspec256, linMax, lout256); 3717 testVectorCastLongMaxToLong(lspecMax, lspec512, linMax, lout512); 3718 testVectorCastLongMaxToLong(lspecMax, lspecMax, linMax, loutMax); 3719 3720 testVectorCastLongMaxToFloat(lspecMax, fspec64, linMax, fout64); 3721 testVectorCastLongMaxToFloat(lspecMax, fspec128, linMax, fout128); 3722 testVectorCastLongMaxToFloat(lspecMax, fspec256, linMax, fout256); 3723 testVectorCastLongMaxToFloat(lspecMax, fspec512, linMax, fout512); 3724 testVectorCastLongMaxToFloat(lspecMax, fspecMax, linMax, foutMax); 3725 3726 testVectorCastLongMaxToDouble(lspecMax, dspec64, linMax, dout64); 3727 testVectorCastLongMaxToDouble(lspecMax, dspec128, linMax, dout128); 3728 testVectorCastLongMaxToDouble(lspecMax, dspec256, linMax, dout256); 3729 testVectorCastLongMaxToDouble(lspecMax, dspec512, linMax, dout512); 3730 testVectorCastLongMaxToDouble(lspecMax, dspecMax, linMax, doutMax); 3731 } 3732 } 3733 3734 @Test(dataProvider = "floatUnaryOpProvider") 3735 static void testCastFromFloatMax(IntFunction<float[]> fa) { 3736 float[] finMax = fa.apply(fspecMax.length()); 3737 3738 byte[] bout64 = new byte[bspec64.length()]; 3739 byte[] bout128 = new byte[bspec128.length()]; 3740 byte[] bout256 = new byte[bspec256.length()]; 3741 byte[] bout512 = new byte[bspec512.length()]; 3742 byte[] boutMax = new byte[bspecMax.length()]; 3743 3744 short[] sout64 = new short[sspec64.length()]; 3745 short[] sout128 = new short[sspec128.length()]; 3746 short[] sout256 = new short[sspec256.length()]; 3747 short[] sout512 = new short[sspec512.length()]; 3748 short[] soutMax = new short[sspecMax.length()]; 3749 3750 int[] iout64 = new int[ispec64.length()]; 3751 int[] iout128 = new int[ispec128.length()]; 3752 int[] iout256 = new int[ispec256.length()]; 3753 int[] iout512 = new int[ispec512.length()]; 3754 int[] ioutMax = new int[ispecMax.length()]; 3755 3756 long[] lout64 = new long[lspec64.length()]; 3757 long[] lout128 = new long[lspec128.length()]; 3758 long[] lout256 = new long[lspec256.length()]; 3759 long[] lout512 = new long[lspec512.length()]; 3760 long[] loutMax = new long[lspecMax.length()]; 3761 3762 float[] fout64 = new float[fspec64.length()]; 3763 float[] fout128 = new float[fspec128.length()]; 3764 float[] fout256 = new float[fspec256.length()]; 3765 float[] fout512 = new float[fspec512.length()]; 3766 float[] foutMax = new float[fspecMax.length()]; 3767 3768 double[] dout64 = new double[dspec64.length()]; 3769 double[] dout128 = new double[dspec128.length()]; 3770 double[] dout256 = new double[dspec256.length()]; 3771 double[] dout512 = new double[dspec512.length()]; 3772 double[] doutMax = new double[dspecMax.length()]; 3773 3774 for (int i = 0; i < NUM_ITER; i++) { 3775 testVectorCastFloatMaxToByte(fspecMax, bspec64, finMax, bout64); 3776 testVectorCastFloatMaxToByte(fspecMax, bspec128, finMax, bout128); 3777 testVectorCastFloatMaxToByte(fspecMax, bspec256, finMax, bout256); 3778 testVectorCastFloatMaxToByte(fspecMax, bspec512, finMax, bout512); 3779 testVectorCastFloatMaxToByte(fspecMax, bspecMax, finMax, boutMax); 3780 3781 testVectorCastFloatMaxToShort(fspecMax, sspec64, finMax, sout64); 3782 testVectorCastFloatMaxToShort(fspecMax, sspec128, finMax, sout128); 3783 testVectorCastFloatMaxToShort(fspecMax, sspec256, finMax, sout256); 3784 testVectorCastFloatMaxToShort(fspecMax, sspec512, finMax, sout512); 3785 testVectorCastFloatMaxToShort(fspecMax, sspecMax, finMax, soutMax); 3786 3787 testVectorCastFloatMaxToInt(fspecMax, ispec64, finMax, iout64); 3788 testVectorCastFloatMaxToInt(fspecMax, ispec128, finMax, iout128); 3789 testVectorCastFloatMaxToInt(fspecMax, ispec256, finMax, iout256); 3790 testVectorCastFloatMaxToInt(fspecMax, ispec512, finMax, iout512); 3791 testVectorCastFloatMaxToInt(fspecMax, ispecMax, finMax, ioutMax); 3792 3793 testVectorCastFloatMaxToLong(fspecMax, lspec64, finMax, lout64); 3794 testVectorCastFloatMaxToLong(fspecMax, lspec128, finMax, lout128); 3795 testVectorCastFloatMaxToLong(fspecMax, lspec256, finMax, lout256); 3796 testVectorCastFloatMaxToLong(fspecMax, lspec512, finMax, lout512); 3797 testVectorCastFloatMaxToLong(fspecMax, lspecMax, finMax, loutMax); 3798 3799 testVectorCastFloatMaxToFloat(fspecMax, fspec64, finMax, fout64); 3800 testVectorCastFloatMaxToFloat(fspecMax, fspec128, finMax, fout128); 3801 testVectorCastFloatMaxToFloat(fspecMax, fspec256, finMax, fout256); 3802 testVectorCastFloatMaxToFloat(fspecMax, fspec512, finMax, fout512); 3803 testVectorCastFloatMaxToFloat(fspecMax, fspecMax, finMax, foutMax); 3804 3805 testVectorCastFloatMaxToDouble(fspecMax, dspec64, finMax, dout64); 3806 testVectorCastFloatMaxToDouble(fspecMax, dspec128, finMax, dout128); 3807 testVectorCastFloatMaxToDouble(fspecMax, dspec256, finMax, dout256); 3808 testVectorCastFloatMaxToDouble(fspecMax, dspec512, finMax, dout512); 3809 testVectorCastFloatMaxToDouble(fspecMax, dspecMax, finMax, doutMax); 3810 } 3811 } 3812 3813 @Test(dataProvider = "doubleUnaryOpProvider") 3814 static void testCastFromDoubleMax(IntFunction<double[]> fa) { 3815 double[] dinMax = fa.apply(dspecMax.length()); 3816 3817 byte[] bout64 = new byte[bspec64.length()]; 3818 byte[] bout128 = new byte[bspec128.length()]; 3819 byte[] bout256 = new byte[bspec256.length()]; 3820 byte[] bout512 = new byte[bspec512.length()]; 3821 byte[] boutMax = new byte[bspecMax.length()]; 3822 3823 short[] sout64 = new short[sspec64.length()]; 3824 short[] sout128 = new short[sspec128.length()]; 3825 short[] sout256 = new short[sspec256.length()]; 3826 short[] sout512 = new short[sspec512.length()]; 3827 short[] soutMax = new short[sspecMax.length()]; 3828 3829 int[] iout64 = new int[ispec64.length()]; 3830 int[] iout128 = new int[ispec128.length()]; 3831 int[] iout256 = new int[ispec256.length()]; 3832 int[] iout512 = new int[ispec512.length()]; 3833 int[] ioutMax = new int[ispecMax.length()]; 3834 3835 long[] lout64 = new long[lspec64.length()]; 3836 long[] lout128 = new long[lspec128.length()]; 3837 long[] lout256 = new long[lspec256.length()]; 3838 long[] lout512 = new long[lspec512.length()]; 3839 long[] loutMax = new long[lspecMax.length()]; 3840 3841 float[] fout64 = new float[fspec64.length()]; 3842 float[] fout128 = new float[fspec128.length()]; 3843 float[] fout256 = new float[fspec256.length()]; 3844 float[] fout512 = new float[fspec512.length()]; 3845 float[] foutMax = new float[fspecMax.length()]; 3846 3847 double[] dout64 = new double[dspec64.length()]; 3848 double[] dout128 = new double[dspec128.length()]; 3849 double[] dout256 = new double[dspec256.length()]; 3850 double[] dout512 = new double[dspec512.length()]; 3851 double[] doutMax = new double[dspecMax.length()]; 3852 3853 for (int i = 0; i < NUM_ITER; i++) { 3854 testVectorCastDoubleMaxToByte(dspecMax, bspec64, dinMax, bout64); 3855 testVectorCastDoubleMaxToByte(dspecMax, bspec128, dinMax, bout128); 3856 testVectorCastDoubleMaxToByte(dspecMax, bspec256, dinMax, bout256); 3857 testVectorCastDoubleMaxToByte(dspecMax, bspec512, dinMax, bout512); 3858 testVectorCastDoubleMaxToByte(dspecMax, bspecMax, dinMax, boutMax); 3859 3860 testVectorCastDoubleMaxToShort(dspecMax, sspec64, dinMax, sout64); 3861 testVectorCastDoubleMaxToShort(dspecMax, sspec128, dinMax, sout128); 3862 testVectorCastDoubleMaxToShort(dspecMax, sspec256, dinMax, sout256); 3863 testVectorCastDoubleMaxToShort(dspecMax, sspec512, dinMax, sout512); 3864 testVectorCastDoubleMaxToShort(dspecMax, sspecMax, dinMax, soutMax); 3865 3866 testVectorCastDoubleMaxToInt(dspecMax, ispec64, dinMax, iout64); 3867 testVectorCastDoubleMaxToInt(dspecMax, ispec128, dinMax, iout128); 3868 testVectorCastDoubleMaxToInt(dspecMax, ispec256, dinMax, iout256); 3869 testVectorCastDoubleMaxToInt(dspecMax, ispec512, dinMax, iout512); 3870 testVectorCastDoubleMaxToInt(dspecMax, ispecMax, dinMax, ioutMax); 3871 3872 testVectorCastDoubleMaxToLong(dspecMax, lspec64, dinMax, lout64); 3873 testVectorCastDoubleMaxToLong(dspecMax, lspec128, dinMax, lout128); 3874 testVectorCastDoubleMaxToLong(dspecMax, lspec256, dinMax, lout256); 3875 testVectorCastDoubleMaxToLong(dspecMax, lspec512, dinMax, lout512); 3876 testVectorCastDoubleMaxToLong(dspecMax, lspecMax, dinMax, loutMax); 3877 3878 testVectorCastDoubleMaxToFloat(dspecMax, fspec64, dinMax, fout64); 3879 testVectorCastDoubleMaxToFloat(dspecMax, fspec128, dinMax, fout128); 3880 testVectorCastDoubleMaxToFloat(dspecMax, fspec256, dinMax, fout256); 3881 testVectorCastDoubleMaxToFloat(dspecMax, fspec512, dinMax, fout512); 3882 testVectorCastDoubleMaxToFloat(dspecMax, fspecMax, dinMax, foutMax); 3883 3884 testVectorCastDoubleMaxToDouble(dspecMax, dspec64, dinMax, dout64); 3885 testVectorCastDoubleMaxToDouble(dspecMax, dspec128, dinMax, dout128); 3886 testVectorCastDoubleMaxToDouble(dspecMax, dspec256, dinMax, dout256); 3887 testVectorCastDoubleMaxToDouble(dspecMax, dspec512, dinMax, dout512); 3888 testVectorCastDoubleMaxToDouble(dspecMax, dspecMax, dinMax, doutMax); 3889 } 3890 } 3891 }