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