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