1 /*
   2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @modules jdk.incubator.vector
  27  * @run testng/othervm -ea -esa Float256VectorTests
  28  */
  29 
  30 import jdk.incubator.vector.VectorShape;
  31 import jdk.incubator.vector.VectorSpecies;
  32 import jdk.incubator.vector.VectorShuffle;
  33 import jdk.incubator.vector.VectorMask;
  34 import jdk.incubator.vector.Vector;
  35 
  36 import jdk.incubator.vector.FloatVector;
  37 
  38 import org.testng.Assert;
  39 import org.testng.annotations.DataProvider;
  40 import org.testng.annotations.Test;
  41 
  42 import java.lang.Integer;
  43 import java.util.List;
  44 import java.util.Arrays;
  45 import java.util.function.BiFunction;
  46 import java.util.function.IntFunction;
  47 import java.util.stream.Collectors;
  48 import java.util.stream.Stream;
  49 
  50 @Test
  51 public class Float256VectorTests extends AbstractVectorTest {
  52 
  53     static final VectorSpecies<Float> SPECIES =
  54                 FloatVector.SPECIES_256;
  55 
  56     static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
  57 
  58     interface FUnOp {
  59         float apply(float a);
  60     }
  61 
  62     static void assertArraysEquals(float[] a, float[] r, FUnOp f) {
  63         int i = 0;
  64         try {
  65             for (; i < a.length; i++) {
  66                 Assert.assertEquals(r[i], f.apply(a[i]));
  67             }
  68         } catch (AssertionError e) {
  69             Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);
  70         }
  71     }
  72 
  73     static void assertArraysEquals(float[] a, float[] r, boolean[] mask, FUnOp f) {
  74         int i = 0;
  75         try {
  76             for (; i < a.length; i++) {
  77                 Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]);
  78             }
  79         } catch (AssertionError e) {
  80             Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]);
  81         }
  82     }
  83 
  84     interface FReductionOp {
  85         float apply(float[] a, int idx);
  86     }
  87 
  88     interface FReductionAllOp {
  89         float apply(float[] a);
  90     }
  91 
  92     static void assertReductionArraysEquals(float[] a, float[] b, float c,
  93                                             FReductionOp f, FReductionAllOp fa) {
  94         int i = 0;
  95         try {
  96             Assert.assertEquals(c, fa.apply(a));
  97             for (; i < a.length; i += SPECIES.length()) {
  98                 Assert.assertEquals(b[i], f.apply(a, i));
  99             }
 100         } catch (AssertionError e) {
 101             Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!");
 102             Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i);
 103         }
 104     }
 105 
 106     interface FBoolReductionOp {
 107         boolean apply(boolean[] a, int idx);
 108     }
 109 
 110     static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) {
 111         int i = 0;
 112         try {
 113             for (; i < a.length; i += SPECIES.length()) {
 114                 Assert.assertEquals(f.apply(a, i), b[i]);
 115             }
 116         } catch (AssertionError e) {
 117             Assert.assertEquals(f.apply(a, i), b[i], "at index #" + i);
 118         }
 119     }
 120 
 121     static void assertInsertArraysEquals(float[] a, float[] b, float element, int index) {
 122         int i = 0;
 123         try {
 124             for (; i < a.length; i += 1) {
 125                 if(i%SPECIES.length() == index) {
 126                     Assert.assertEquals(b[i], element);
 127                 } else {
 128                     Assert.assertEquals(b[i], a[i]);
 129                 }
 130             }
 131         } catch (AssertionError e) {
 132             if (i%SPECIES.length() == index) {
 133                 Assert.assertEquals(b[i], element, "at index #" + i);
 134             } else {
 135                 Assert.assertEquals(b[i], a[i], "at index #" + i);
 136             }
 137         }
 138     }
 139 
 140     static void assertRearrangeArraysEquals(float[] a, float[] r, int[] order, int vector_len) {
 141         int i = 0, j = 0;
 142         try {
 143             for (; i < a.length; i += vector_len) {
 144                 for (j = 0; j < vector_len; j++) {
 145                     Assert.assertEquals(r[i+j], a[i+order[i+j]]);
 146                 }
 147             }
 148         } catch (AssertionError e) {
 149             int idx = i + j;
 150             Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
 151         }
 152     }
 153 
 154     interface FBinOp {
 155         float apply(float a, float b);
 156     }
 157 
 158     interface FBinMaskOp {
 159         float apply(float a, float b, boolean m);
 160 
 161         static FBinMaskOp lift(FBinOp f) {
 162             return (a, b, m) -> m ? f.apply(a, b) : a;
 163         }
 164     }
 165 
 166     static void assertArraysEquals(float[] a, float[] b, float[] r, FBinOp f) {
 167         int i = 0;
 168         try {
 169             for (; i < a.length; i++) {
 170                 Assert.assertEquals(r[i], f.apply(a[i], b[i]));
 171             }
 172         } catch (AssertionError e) {
 173             Assert.assertEquals(f.apply(a[i], b[i]), r[i], "(" + a[i] + ", " + b[i] + ") at index #" + i);
 174         }
 175     }
 176 
 177     static void assertArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) {
 178         assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
 179     }
 180 
 181     static void assertArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) {
 182         int i = 0;
 183         try {
 184             for (; i < a.length; i++) {
 185                 Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]));
 186             }
 187         } catch (AssertionError err) {
 188             Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]);
 189         }
 190     }
 191 
 192     static void assertShiftArraysEquals(float[] a, float[] b, float[] r, FBinOp f) {
 193         int i = 0;
 194         int j = 0;
 195         try {
 196             for (; j < a.length; j += SPECIES.length()) {
 197                 for (i = 0; i < SPECIES.length(); i++) {
 198                     Assert.assertEquals(f.apply(a[i+j], b[j]), r[i+j]);
 199                 }
 200             }
 201         } catch (AssertionError e) {
 202             Assert.assertEquals(f.apply(a[i+j], b[j]), r[i+j], "at index #" + i + ", " + j);
 203         }
 204     }
 205 
 206     static void assertShiftArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinOp f) {
 207         assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
 208     }
 209 
 210     static void assertShiftArraysEquals(float[] a, float[] b, float[] r, boolean[] mask, FBinMaskOp f) {
 211         int i = 0;
 212         int j = 0;
 213         try {
 214             for (; j < a.length; j += SPECIES.length()) {
 215                 for (i = 0; i < SPECIES.length(); i++) {
 216                     Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]));
 217                 }
 218             }
 219         } catch (AssertionError err) {
 220             Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]);
 221         }
 222     }
 223 
 224     interface FTernOp {
 225         float apply(float a, float b, float c);
 226     }
 227 
 228     interface FTernMaskOp {
 229         float apply(float a, float b, float c, boolean m);
 230 
 231         static FTernMaskOp lift(FTernOp f) {
 232             return (a, b, c, m) -> m ? f.apply(a, b, c) : a;
 233         }
 234     }
 235 
 236     static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, FTernOp f) {
 237         int i = 0;
 238         try {
 239             for (; i < a.length; i++) {
 240                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]));
 241             }
 242         } catch (AssertionError e) {
 243             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]);
 244         }
 245     }
 246 
 247     static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, FTernOp f) {
 248         assertArraysEquals(a, b, c, r, mask, FTernMaskOp.lift(f));
 249     }
 250 
 251     static void assertArraysEquals(float[] a, float[] b, float[] c, float[] r, boolean[] mask, FTernMaskOp f) {
 252         int i = 0;
 253         try {
 254             for (; i < a.length; i++) {
 255                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]));
 256             }
 257         } catch (AssertionError err) {
 258             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = "
 259               + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);
 260         }
 261     }
 262 
 263     static boolean isWithin1Ulp(float actual, float expected) {
 264         if (Float.isNaN(expected) && !Float.isNaN(actual)) {
 265             return false;
 266         } else if (!Float.isNaN(expected) && Float.isNaN(actual)) {
 267             return false;
 268         }
 269 
 270         float low = Math.nextDown(expected);
 271         float high = Math.nextUp(expected);
 272 
 273         if (Float.compare(low, expected) > 0) {
 274             return false;
 275         }
 276 
 277         if (Float.compare(high, expected) < 0) {
 278             return false;
 279         }
 280 
 281         return true;
 282     }
 283 
 284     static void assertArraysEqualsWithinOneUlp(float[] a, float[] r, FUnOp mathf, FUnOp strictmathf) {
 285         int i = 0;
 286         try {
 287             // Check that result is within 1 ulp of strict math or equivalent to math implementation.
 288             for (; i < a.length; i++) {
 289                 Assert.assertTrue(Float.compare(r[i], mathf.apply(a[i])) == 0 ||
 290                                     isWithin1Ulp(r[i], strictmathf.apply(a[i])));
 291             }
 292         } catch (AssertionError e) {
 293             Assert.assertTrue(Float.compare(r[i], mathf.apply(a[i])) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i]));
 294             Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i])), "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i]));
 295         }
 296     }
 297 
 298     static void assertArraysEqualsWithinOneUlp(float[] a, float[] b, float[] r, FBinOp mathf, FBinOp strictmathf) {
 299         int i = 0;
 300         try {
 301             // Check that result is within 1 ulp of strict math or equivalent to math implementation.
 302             for (; i < a.length; i++) {
 303                 Assert.assertTrue(Float.compare(r[i], mathf.apply(a[i], b[i])) == 0 ||
 304                                     isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])));
 305             }
 306         } catch (AssertionError e) {
 307             Assert.assertTrue(Float.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i]));
 308             Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i]));
 309         }
 310     }
 311 
 312     interface FBinArrayOp {
 313         float apply(float[] a, int b);
 314     }
 315 
 316     static void assertArraysEquals(float[] a, float[] r, FBinArrayOp f) {
 317         int i = 0;
 318         try {
 319             for (; i < a.length; i++) {
 320                 Assert.assertEquals(f.apply(a, i), r[i]);
 321             }
 322         } catch (AssertionError e) {
 323             Assert.assertEquals(f.apply(a,i), r[i], "at index #" + i);
 324         }
 325     }
 326     interface FGatherScatterOp {
 327         float[] apply(float[] a, int ix, int[] b, int iy);
 328     }
 329 
 330     static void assertArraysEquals(float[] a, int[] b, float[] r, FGatherScatterOp f) {
 331         int i = 0;
 332         try {
 333             for (; i < a.length; i += SPECIES.length()) {
 334                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 335                   f.apply(a, i, b, i));
 336             }
 337         } catch (AssertionError e) {
 338             float[] ref = f.apply(a, i, b, i);
 339             float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 340             Assert.assertEquals(ref, res,
 341               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 342               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 343               + ", b: "
 344               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 345               + " at index #" + i);
 346         }
 347     }
 348 
 349 
 350     static final List<IntFunction<float[]>> FLOAT_GENERATORS = List.of(
 351             withToString("float[-i * 5]", (int s) -> {
 352                 return fill(s * 1000,
 353                             i -> (float)(-i * 5));
 354             }),
 355             withToString("float[i * 5]", (int s) -> {
 356                 return fill(s * 1000,
 357                             i -> (float)(i * 5));
 358             }),
 359             withToString("float[i + 1]", (int s) -> {
 360                 return fill(s * 1000,
 361                             i -> (((float)(i + 1) == 0) ? 1 : (float)(i + 1)));
 362             }),
 363             withToString("float[cornerCaseValue(i)]", (int s) -> {
 364                 return fill(s * 1000,
 365                             i -> cornerCaseValue(i));
 366             })
 367     );
 368 
 369     // Create combinations of pairs
 370     // @@@ Might be sensitive to order e.g. div by 0
 371     static final List<List<IntFunction<float[]>>> FLOAT_GENERATOR_PAIRS =
 372         Stream.of(FLOAT_GENERATORS.get(0)).
 373                 flatMap(fa -> FLOAT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))).
 374                 collect(Collectors.toList());
 375 
 376     @DataProvider
 377     public Object[][] boolUnaryOpProvider() {
 378         return BOOL_ARRAY_GENERATORS.stream().
 379                 map(f -> new Object[]{f}).
 380                 toArray(Object[][]::new);
 381     }
 382 
 383     static final List<List<IntFunction<float[]>>> FLOAT_GENERATOR_TRIPLES =
 384         FLOAT_GENERATOR_PAIRS.stream().
 385                 flatMap(pair -> FLOAT_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))).
 386                 collect(Collectors.toList());
 387 
 388     @DataProvider
 389     public Object[][] floatBinaryOpProvider() {
 390         return FLOAT_GENERATOR_PAIRS.stream().map(List::toArray).
 391                 toArray(Object[][]::new);
 392     }
 393 
 394     @DataProvider
 395     public Object[][] floatIndexedOpProvider() {
 396         return FLOAT_GENERATOR_PAIRS.stream().map(List::toArray).
 397                 toArray(Object[][]::new);
 398     }
 399 
 400     @DataProvider
 401     public Object[][] floatBinaryOpMaskProvider() {
 402         return BOOLEAN_MASK_GENERATORS.stream().
 403                 flatMap(fm -> FLOAT_GENERATOR_PAIRS.stream().map(lfa -> {
 404                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
 405                 })).
 406                 toArray(Object[][]::new);
 407     }
 408 
 409     @DataProvider
 410     public Object[][] floatTernaryOpProvider() {
 411         return FLOAT_GENERATOR_TRIPLES.stream().map(List::toArray).
 412                 toArray(Object[][]::new);
 413     }
 414 
 415     @DataProvider
 416     public Object[][] floatTernaryOpMaskProvider() {
 417         return BOOLEAN_MASK_GENERATORS.stream().
 418                 flatMap(fm -> FLOAT_GENERATOR_TRIPLES.stream().map(lfa -> {
 419                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
 420                 })).
 421                 toArray(Object[][]::new);
 422     }
 423 
 424     @DataProvider
 425     public Object[][] floatUnaryOpProvider() {
 426         return FLOAT_GENERATORS.stream().
 427                 map(f -> new Object[]{f}).
 428                 toArray(Object[][]::new);
 429     }
 430 
 431     @DataProvider
 432     public Object[][] floatUnaryOpMaskProvider() {
 433         return BOOLEAN_MASK_GENERATORS.stream().
 434                 flatMap(fm -> FLOAT_GENERATORS.stream().map(fa -> {
 435                     return new Object[] {fa, fm};
 436                 })).
 437                 toArray(Object[][]::new);
 438     }
 439 
 440     @DataProvider
 441     public Object[][] floatUnaryOpShuffleProvider() {
 442         return INT_SHUFFLE_GENERATORS.stream().
 443                 flatMap(fs -> FLOAT_GENERATORS.stream().map(fa -> {
 444                     return new Object[] {fa, fs};
 445                 })).
 446                 toArray(Object[][]::new);
 447     }
 448 
 449     @DataProvider
 450     public Object[][] floatUnaryOpIndexProvider() {
 451         return INT_INDEX_GENERATORS.stream().
 452                 flatMap(fs -> FLOAT_GENERATORS.stream().map(fa -> {
 453                     return new Object[] {fa, fs};
 454                 })).
 455                 toArray(Object[][]::new);
 456     }
 457 
 458 
 459     static final List<IntFunction<float[]>> FLOAT_COMPARE_GENERATORS = List.of(
 460             withToString("float[i]", (int s) -> {
 461                 return fill(s * 1000,
 462                             i -> (float)i);
 463             }),
 464             withToString("float[i + 1]", (int s) -> {
 465                 return fill(s * 1000,
 466                             i -> (float)(i + 1));
 467             }),
 468             withToString("float[i - 2]", (int s) -> {
 469                 return fill(s * 1000,
 470                             i -> (float)(i - 2));
 471             }),
 472             withToString("float[zigZag(i)]", (int s) -> {
 473                 return fill(s * 1000,
 474                             i -> i%3 == 0 ? (float)i : (i%3 == 1 ? (float)(i + 1) : (float)(i - 2)));
 475             }),
 476             withToString("float[cornerCaseValue(i)]", (int s) -> {
 477                 return fill(s * 1000,
 478                             i -> cornerCaseValue(i));
 479             })
 480     );
 481 
 482     static final List<List<IntFunction<float[]>>> FLOAT_COMPARE_GENERATOR_PAIRS =
 483         FLOAT_COMPARE_GENERATORS.stream().
 484                 flatMap(fa -> FLOAT_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))).
 485                 collect(Collectors.toList());
 486 
 487     @DataProvider
 488     public Object[][] floatCompareOpProvider() {
 489         return FLOAT_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
 490                 toArray(Object[][]::new);
 491     }
 492 
 493     interface ToFloatF {
 494         float apply(int i);
 495     }
 496 
 497     static float[] fill(int s , ToFloatF f) {
 498         return fill(new float[s], f);
 499     }
 500 
 501     static float[] fill(float[] a, ToFloatF f) {
 502         for (int i = 0; i < a.length; i++) {
 503             a[i] = f.apply(i);
 504         }
 505         return a;
 506     }
 507 
 508     static float cornerCaseValue(int i) {
 509         switch(i % 7) {
 510             case 0:
 511                 return Float.MAX_VALUE;
 512             case 1:
 513                 return Float.MIN_VALUE;
 514             case 2:
 515                 return Float.NEGATIVE_INFINITY;
 516             case 3:
 517                 return Float.POSITIVE_INFINITY;
 518             case 4:
 519                 return Float.NaN;
 520             case 5:
 521                 return (float)0.0;
 522             default:
 523                 return (float)-0.0;
 524         }
 525     }
 526    static float get(float[] a, int i) {
 527        return (float) a[i];
 528    }
 529 
 530    static final IntFunction<float[]> fr = (vl) -> {
 531         int length = 1000 * vl;
 532         return new float[length];
 533     };
 534 
 535     static final IntFunction<boolean[]> fmr = (vl) -> {
 536         int length = 1000 * vl;
 537         return new boolean[length];
 538     };
 539     static float add(float a, float b) {
 540         return (float)(a + b);
 541     }
 542 
 543     @Test(dataProvider = "floatBinaryOpProvider")
 544     static void addFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
 545         float[] a = fa.apply(SPECIES.length());
 546         float[] b = fb.apply(SPECIES.length());
 547         float[] r = fr.apply(SPECIES.length());
 548 
 549         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 550             for (int i = 0; i < a.length; i += SPECIES.length()) {
 551                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 552                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
 553                 av.add(bv).intoArray(r, i);
 554             }
 555         }
 556 
 557         assertArraysEquals(a, b, r, Float256VectorTests::add);
 558     }
 559 
 560     @Test(dataProvider = "floatBinaryOpMaskProvider")
 561     static void addFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb,
 562                                           IntFunction<boolean[]> fm) {
 563         float[] a = fa.apply(SPECIES.length());
 564         float[] b = fb.apply(SPECIES.length());
 565         float[] r = fr.apply(SPECIES.length());
 566         boolean[] mask = fm.apply(SPECIES.length());
 567         VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask);
 568 
 569         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 570             for (int i = 0; i < a.length; i += SPECIES.length()) {
 571                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 572                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
 573                 av.add(bv, vmask).intoArray(r, i);
 574             }
 575         }
 576 
 577         assertArraysEquals(a, b, r, mask, Float256VectorTests::add);
 578     }
 579     static float sub(float a, float b) {
 580         return (float)(a - b);
 581     }
 582 
 583     @Test(dataProvider = "floatBinaryOpProvider")
 584     static void subFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
 585         float[] a = fa.apply(SPECIES.length());
 586         float[] b = fb.apply(SPECIES.length());
 587         float[] r = fr.apply(SPECIES.length());
 588 
 589         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 590             for (int i = 0; i < a.length; i += SPECIES.length()) {
 591                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 592                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
 593                 av.sub(bv).intoArray(r, i);
 594             }
 595         }
 596 
 597         assertArraysEquals(a, b, r, Float256VectorTests::sub);
 598     }
 599 
 600     @Test(dataProvider = "floatBinaryOpMaskProvider")
 601     static void subFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb,
 602                                           IntFunction<boolean[]> fm) {
 603         float[] a = fa.apply(SPECIES.length());
 604         float[] b = fb.apply(SPECIES.length());
 605         float[] r = fr.apply(SPECIES.length());
 606         boolean[] mask = fm.apply(SPECIES.length());
 607         VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask);
 608 
 609         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 610             for (int i = 0; i < a.length; i += SPECIES.length()) {
 611                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 612                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
 613                 av.sub(bv, vmask).intoArray(r, i);
 614             }
 615         }
 616 
 617         assertArraysEquals(a, b, r, mask, Float256VectorTests::sub);
 618     }
 619 
 620     static float div(float a, float b) {
 621         return (float)(a / b);
 622     }
 623 
 624     @Test(dataProvider = "floatBinaryOpProvider")
 625     static void divFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
 626         float[] a = fa.apply(SPECIES.length());
 627         float[] b = fb.apply(SPECIES.length());
 628         float[] r = fr.apply(SPECIES.length());
 629 
 630         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 631             for (int i = 0; i < a.length; i += SPECIES.length()) {
 632                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 633                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
 634                 av.div(bv).intoArray(r, i);
 635             }
 636         }
 637 
 638         assertArraysEquals(a, b, r, Float256VectorTests::div);
 639     }
 640 
 641 
 642 
 643     @Test(dataProvider = "floatBinaryOpMaskProvider")
 644     static void divFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb,
 645                                           IntFunction<boolean[]> fm) {
 646         float[] a = fa.apply(SPECIES.length());
 647         float[] b = fb.apply(SPECIES.length());
 648         float[] r = fr.apply(SPECIES.length());
 649         boolean[] mask = fm.apply(SPECIES.length());
 650         VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask);
 651 
 652         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 653             for (int i = 0; i < a.length; i += SPECIES.length()) {
 654                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 655                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
 656                 av.div(bv, vmask).intoArray(r, i);
 657             }
 658         }
 659 
 660         assertArraysEquals(a, b, r, mask, Float256VectorTests::div);
 661     }
 662 
 663     static float mul(float a, float b) {
 664         return (float)(a * b);
 665     }
 666 
 667     @Test(dataProvider = "floatBinaryOpProvider")
 668     static void mulFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
 669         float[] a = fa.apply(SPECIES.length());
 670         float[] b = fb.apply(SPECIES.length());
 671         float[] r = fr.apply(SPECIES.length());
 672 
 673         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 674             for (int i = 0; i < a.length; i += SPECIES.length()) {
 675                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 676                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
 677                 av.mul(bv).intoArray(r, i);
 678             }
 679         }
 680 
 681         assertArraysEquals(a, b, r, Float256VectorTests::mul);
 682     }
 683 
 684     @Test(dataProvider = "floatBinaryOpMaskProvider")
 685     static void mulFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb,
 686                                           IntFunction<boolean[]> fm) {
 687         float[] a = fa.apply(SPECIES.length());
 688         float[] b = fb.apply(SPECIES.length());
 689         float[] r = fr.apply(SPECIES.length());
 690         boolean[] mask = fm.apply(SPECIES.length());
 691         VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask);
 692 
 693         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 694             for (int i = 0; i < a.length; i += SPECIES.length()) {
 695                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 696                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
 697                 av.mul(bv, vmask).intoArray(r, i);
 698             }
 699         }
 700 
 701         assertArraysEquals(a, b, r, mask, Float256VectorTests::mul);
 702     }
 703 
 704 
 705 
 706 
 707 
 708 
 709 
 710 
 711 
 712 
 713 
 714 
 715 
 716 
 717 
 718 
 719 
 720 
 721 
 722 
 723 
 724 
 725 
 726 
 727 
 728 
 729 
 730 
 731 
 732 
 733     static float max(float a, float b) {
 734         return (float)(Math.max(a, b));
 735     }
 736 
 737     @Test(dataProvider = "floatBinaryOpProvider")
 738     static void maxFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
 739         float[] a = fa.apply(SPECIES.length());
 740         float[] b = fb.apply(SPECIES.length());
 741         float[] r = fr.apply(SPECIES.length());
 742 
 743         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 744             for (int i = 0; i < a.length; i += SPECIES.length()) {
 745                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 746                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
 747                 av.max(bv).intoArray(r, i);
 748             }
 749         }
 750 
 751         assertArraysEquals(a, b, r, Float256VectorTests::max);
 752     }
 753     static float min(float a, float b) {
 754         return (float)(Math.min(a, b));
 755     }
 756 
 757     @Test(dataProvider = "floatBinaryOpProvider")
 758     static void minFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
 759         float[] a = fa.apply(SPECIES.length());
 760         float[] b = fb.apply(SPECIES.length());
 761         float[] r = fr.apply(SPECIES.length());
 762 
 763         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 764             for (int i = 0; i < a.length; i += SPECIES.length()) {
 765                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 766                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
 767                 av.min(bv).intoArray(r, i);
 768             }
 769         }
 770 
 771         assertArraysEquals(a, b, r, Float256VectorTests::min);
 772     }
 773 
 774 
 775 
 776 
 777 
 778 
 779     static float addAll(float[] a, int idx) {
 780         float res = 0;
 781         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 782             res += a[i];
 783         }
 784 
 785         return res;
 786     }
 787 
 788     static float addAll(float[] a) {
 789         float res = 0;
 790         for (int i = 0; i < a.length; i += SPECIES.length()) {
 791             float tmp = 0;
 792             for (int j = 0; j < SPECIES.length(); j++) {
 793                 tmp += a[i + j];
 794             }
 795             res += tmp;
 796         }
 797 
 798         return res;
 799     }
 800     @Test(dataProvider = "floatUnaryOpProvider")
 801     static void addAllFloat256VectorTests(IntFunction<float[]> fa) {
 802         float[] a = fa.apply(SPECIES.length());
 803         float[] r = fr.apply(SPECIES.length());
 804         float ra = 0;
 805 
 806         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 807             for (int i = 0; i < a.length; i += SPECIES.length()) {
 808                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 809                 r[i] = av.addAll();
 810             }
 811         }
 812 
 813         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 814             ra = 0;
 815             for (int i = 0; i < a.length; i += SPECIES.length()) {
 816                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 817                 ra += av.addAll();
 818             }
 819         }
 820 
 821         assertReductionArraysEquals(a, r, ra, Float256VectorTests::addAll, Float256VectorTests::addAll);
 822     }
 823     static float mulAll(float[] a, int idx) {
 824         float res = 1;
 825         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 826             res *= a[i];
 827         }
 828 
 829         return res;
 830     }
 831 
 832     static float mulAll(float[] a) {
 833         float res = 1;
 834         for (int i = 0; i < a.length; i += SPECIES.length()) {
 835             float tmp = 1;
 836             for (int j = 0; j < SPECIES.length(); j++) {
 837                 tmp *= a[i + j];
 838             }
 839             res *= tmp;
 840         }
 841 
 842         return res;
 843     }
 844     @Test(dataProvider = "floatUnaryOpProvider")
 845     static void mulAllFloat256VectorTests(IntFunction<float[]> fa) {
 846         float[] a = fa.apply(SPECIES.length());
 847         float[] r = fr.apply(SPECIES.length());
 848         float ra = 1;
 849 
 850         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 851             for (int i = 0; i < a.length; i += SPECIES.length()) {
 852                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 853                 r[i] = av.mulAll();
 854             }
 855         }
 856 
 857         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 858             ra = 1;
 859             for (int i = 0; i < a.length; i += SPECIES.length()) {
 860                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 861                 ra *= av.mulAll();
 862             }
 863         }
 864 
 865         assertReductionArraysEquals(a, r, ra, Float256VectorTests::mulAll, Float256VectorTests::mulAll);
 866     }
 867     static float minAll(float[] a, int idx) {
 868         float res = Float.POSITIVE_INFINITY;
 869         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 870             res = (float)Math.min(res, a[i]);
 871         }
 872 
 873         return res;
 874     }
 875 
 876     static float minAll(float[] a) {
 877         float res = Float.POSITIVE_INFINITY;
 878         for (int i = 0; i < a.length; i++) {
 879             res = (float)Math.min(res, a[i]);
 880         }
 881 
 882         return res;
 883     }
 884     @Test(dataProvider = "floatUnaryOpProvider")
 885     static void minAllFloat256VectorTests(IntFunction<float[]> fa) {
 886         float[] a = fa.apply(SPECIES.length());
 887         float[] r = fr.apply(SPECIES.length());
 888         float ra = Float.POSITIVE_INFINITY;
 889 
 890         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 891             for (int i = 0; i < a.length; i += SPECIES.length()) {
 892                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 893                 r[i] = av.minAll();
 894             }
 895         }
 896 
 897         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 898             ra = Float.POSITIVE_INFINITY;
 899             for (int i = 0; i < a.length; i += SPECIES.length()) {
 900                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 901                 ra = (float)Math.min(ra, av.minAll());
 902             }
 903         }
 904 
 905         assertReductionArraysEquals(a, r, ra, Float256VectorTests::minAll, Float256VectorTests::minAll);
 906     }
 907     static float maxAll(float[] a, int idx) {
 908         float res = Float.NEGATIVE_INFINITY;
 909         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 910             res = (float)Math.max(res, a[i]);
 911         }
 912 
 913         return res;
 914     }
 915 
 916     static float maxAll(float[] a) {
 917         float res = Float.NEGATIVE_INFINITY;
 918         for (int i = 0; i < a.length; i++) {
 919             res = (float)Math.max(res, a[i]);
 920         }
 921 
 922         return res;
 923     }
 924     @Test(dataProvider = "floatUnaryOpProvider")
 925     static void maxAllFloat256VectorTests(IntFunction<float[]> fa) {
 926         float[] a = fa.apply(SPECIES.length());
 927         float[] r = fr.apply(SPECIES.length());
 928         float ra = Float.NEGATIVE_INFINITY;
 929 
 930         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 931             for (int i = 0; i < a.length; i += SPECIES.length()) {
 932                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 933                 r[i] = av.maxAll();
 934             }
 935         }
 936 
 937         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 938             ra = Float.NEGATIVE_INFINITY;
 939             for (int i = 0; i < a.length; i += SPECIES.length()) {
 940                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 941                 ra = (float)Math.max(ra, av.maxAll());
 942             }
 943         }
 944 
 945         assertReductionArraysEquals(a, r, ra, Float256VectorTests::maxAll, Float256VectorTests::maxAll);
 946     }
 947 
 948 
 949 
 950 
 951 
 952     @Test(dataProvider = "floatUnaryOpProvider")
 953     static void withFloat256VectorTests(IntFunction<float []> fa) {
 954         float[] a = fa.apply(SPECIES.length());
 955         float[] r = fr.apply(SPECIES.length());
 956 
 957         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 958             for (int i = 0; i < a.length; i += SPECIES.length()) {
 959                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 960                 av.with(0, (float)4).intoArray(r, i);
 961             }
 962         }
 963 
 964         assertInsertArraysEquals(a, r, (float)4, 0);
 965     }
 966 
 967     @Test(dataProvider = "floatCompareOpProvider")
 968     static void lessThanFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
 969         float[] a = fa.apply(SPECIES.length());
 970         float[] b = fb.apply(SPECIES.length());
 971 
 972         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 973             for (int i = 0; i < a.length; i += SPECIES.length()) {
 974                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 975                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
 976                 VectorMask<Float> mv = av.lessThan(bv);
 977 
 978                 // Check results as part of computation.
 979                 for (int j = 0; j < SPECIES.length(); j++) {
 980                     Assert.assertEquals(mv.lane(j), a[i + j] < b[i + j]);
 981                 }
 982             }
 983         }
 984     }
 985 
 986 
 987     @Test(dataProvider = "floatCompareOpProvider")
 988     static void greaterThanFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
 989         float[] a = fa.apply(SPECIES.length());
 990         float[] b = fb.apply(SPECIES.length());
 991 
 992         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 993             for (int i = 0; i < a.length; i += SPECIES.length()) {
 994                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
 995                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
 996                 VectorMask<Float> mv = av.greaterThan(bv);
 997 
 998                 // Check results as part of computation.
 999                 for (int j = 0; j < SPECIES.length(); j++) {
1000                     Assert.assertEquals(mv.lane(j), a[i + j] > b[i + j]);
1001                 }
1002             }
1003         }
1004     }
1005 
1006 
1007     @Test(dataProvider = "floatCompareOpProvider")
1008     static void equalFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
1009         float[] a = fa.apply(SPECIES.length());
1010         float[] b = fb.apply(SPECIES.length());
1011 
1012         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1013             for (int i = 0; i < a.length; i += SPECIES.length()) {
1014                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1015                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
1016                 VectorMask<Float> mv = av.equal(bv);
1017 
1018                 // Check results as part of computation.
1019                 for (int j = 0; j < SPECIES.length(); j++) {
1020                     Assert.assertEquals(mv.lane(j), a[i + j] == b[i + j]);
1021                 }
1022             }
1023         }
1024     }
1025 
1026 
1027     @Test(dataProvider = "floatCompareOpProvider")
1028     static void notEqualFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
1029         float[] a = fa.apply(SPECIES.length());
1030         float[] b = fb.apply(SPECIES.length());
1031 
1032         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1033             for (int i = 0; i < a.length; i += SPECIES.length()) {
1034                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1035                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
1036                 VectorMask<Float> mv = av.notEqual(bv);
1037 
1038                 // Check results as part of computation.
1039                 for (int j = 0; j < SPECIES.length(); j++) {
1040                     Assert.assertEquals(mv.lane(j), a[i + j] != b[i + j]);
1041                 }
1042             }
1043         }
1044     }
1045 
1046 
1047     @Test(dataProvider = "floatCompareOpProvider")
1048     static void lessThanEqFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
1049         float[] a = fa.apply(SPECIES.length());
1050         float[] b = fb.apply(SPECIES.length());
1051 
1052         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1053             for (int i = 0; i < a.length; i += SPECIES.length()) {
1054                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1055                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
1056                 VectorMask<Float> mv = av.lessThanEq(bv);
1057 
1058                 // Check results as part of computation.
1059                 for (int j = 0; j < SPECIES.length(); j++) {
1060                     Assert.assertEquals(mv.lane(j), a[i + j] <= b[i + j]);
1061                 }
1062             }
1063         }
1064     }
1065 
1066 
1067     @Test(dataProvider = "floatCompareOpProvider")
1068     static void greaterThanEqFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
1069         float[] a = fa.apply(SPECIES.length());
1070         float[] b = fb.apply(SPECIES.length());
1071 
1072         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1073             for (int i = 0; i < a.length; i += SPECIES.length()) {
1074                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1075                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
1076                 VectorMask<Float> mv = av.greaterThanEq(bv);
1077 
1078                 // Check results as part of computation.
1079                 for (int j = 0; j < SPECIES.length(); j++) {
1080                     Assert.assertEquals(mv.lane(j), a[i + j] >= b[i + j]);
1081                 }
1082             }
1083         }
1084     }
1085 
1086 
1087     static float blend(float a, float b, boolean mask) {
1088         return mask ? b : a;
1089     }
1090 
1091     @Test(dataProvider = "floatBinaryOpMaskProvider")
1092     static void blendFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb,
1093                                           IntFunction<boolean[]> fm) {
1094         float[] a = fa.apply(SPECIES.length());
1095         float[] b = fb.apply(SPECIES.length());
1096         float[] r = fr.apply(SPECIES.length());
1097         boolean[] mask = fm.apply(SPECIES.length());
1098         VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask);
1099 
1100         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1101             for (int i = 0; i < a.length; i += SPECIES.length()) {
1102                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1103                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
1104                 av.blend(bv, vmask).intoArray(r, i);
1105             }
1106         }
1107 
1108         assertArraysEquals(a, b, r, mask, Float256VectorTests::blend);
1109     }
1110 
1111     @Test(dataProvider = "floatUnaryOpShuffleProvider")
1112     static void RearrangeFloat256VectorTests(IntFunction<float[]> fa,
1113                                            BiFunction<Integer,Integer,int[]> fs) {
1114         float[] a = fa.apply(SPECIES.length());
1115         int[] order = fs.apply(a.length, SPECIES.length());
1116         float[] r = fr.apply(SPECIES.length());
1117 
1118         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1119             for (int i = 0; i < a.length; i += SPECIES.length()) {
1120                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1121                 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);
1122             }
1123         }
1124 
1125         assertRearrangeArraysEquals(a, r, order, SPECIES.length());
1126     }
1127 
1128 
1129 
1130 
1131     @Test(dataProvider = "floatUnaryOpProvider")
1132     static void getFloat256VectorTests(IntFunction<float[]> fa) {
1133         float[] a = fa.apply(SPECIES.length());
1134         float[] r = fr.apply(SPECIES.length());
1135 
1136         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1137             for (int i = 0; i < a.length; i += SPECIES.length()) {
1138                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1139                 int num_lanes = SPECIES.length();
1140                 // Manually unroll because full unroll happens after intrinsification.
1141                 // Unroll is needed because get intrinsic requires for index to be a known constant.
1142                 if (num_lanes == 1) {
1143                     r[i]=av.lane(0);
1144                 } else if (num_lanes == 2) {
1145                     r[i]=av.lane(0);
1146                     r[i+1]=av.lane(1);
1147                 } else if (num_lanes == 4) {
1148                     r[i]=av.lane(0);
1149                     r[i+1]=av.lane(1);
1150                     r[i+2]=av.lane(2);
1151                     r[i+3]=av.lane(3);
1152                 } else if (num_lanes == 8) {
1153                     r[i]=av.lane(0);
1154                     r[i+1]=av.lane(1);
1155                     r[i+2]=av.lane(2);
1156                     r[i+3]=av.lane(3);
1157                     r[i+4]=av.lane(4);
1158                     r[i+5]=av.lane(5);
1159                     r[i+6]=av.lane(6);
1160                     r[i+7]=av.lane(7);
1161                 } else if (num_lanes == 16) {
1162                     r[i]=av.lane(0);
1163                     r[i+1]=av.lane(1);
1164                     r[i+2]=av.lane(2);
1165                     r[i+3]=av.lane(3);
1166                     r[i+4]=av.lane(4);
1167                     r[i+5]=av.lane(5);
1168                     r[i+6]=av.lane(6);
1169                     r[i+7]=av.lane(7);
1170                     r[i+8]=av.lane(8);
1171                     r[i+9]=av.lane(9);
1172                     r[i+10]=av.lane(10);
1173                     r[i+11]=av.lane(11);
1174                     r[i+12]=av.lane(12);
1175                     r[i+13]=av.lane(13);
1176                     r[i+14]=av.lane(14);
1177                     r[i+15]=av.lane(15);
1178                 } else if (num_lanes == 32) {
1179                     r[i]=av.lane(0);
1180                     r[i+1]=av.lane(1);
1181                     r[i+2]=av.lane(2);
1182                     r[i+3]=av.lane(3);
1183                     r[i+4]=av.lane(4);
1184                     r[i+5]=av.lane(5);
1185                     r[i+6]=av.lane(6);
1186                     r[i+7]=av.lane(7);
1187                     r[i+8]=av.lane(8);
1188                     r[i+9]=av.lane(9);
1189                     r[i+10]=av.lane(10);
1190                     r[i+11]=av.lane(11);
1191                     r[i+12]=av.lane(12);
1192                     r[i+13]=av.lane(13);
1193                     r[i+14]=av.lane(14);
1194                     r[i+15]=av.lane(15);
1195                     r[i+16]=av.lane(16);
1196                     r[i+17]=av.lane(17);
1197                     r[i+18]=av.lane(18);
1198                     r[i+19]=av.lane(19);
1199                     r[i+20]=av.lane(20);
1200                     r[i+21]=av.lane(21);
1201                     r[i+22]=av.lane(22);
1202                     r[i+23]=av.lane(23);
1203                     r[i+24]=av.lane(24);
1204                     r[i+25]=av.lane(25);
1205                     r[i+26]=av.lane(26);
1206                     r[i+27]=av.lane(27);
1207                     r[i+28]=av.lane(28);
1208                     r[i+29]=av.lane(29);
1209                     r[i+30]=av.lane(30);
1210                     r[i+31]=av.lane(31);
1211                 } else if (num_lanes == 64) {
1212                     r[i]=av.lane(0);
1213                     r[i+1]=av.lane(1);
1214                     r[i+2]=av.lane(2);
1215                     r[i+3]=av.lane(3);
1216                     r[i+4]=av.lane(4);
1217                     r[i+5]=av.lane(5);
1218                     r[i+6]=av.lane(6);
1219                     r[i+7]=av.lane(7);
1220                     r[i+8]=av.lane(8);
1221                     r[i+9]=av.lane(9);
1222                     r[i+10]=av.lane(10);
1223                     r[i+11]=av.lane(11);
1224                     r[i+12]=av.lane(12);
1225                     r[i+13]=av.lane(13);
1226                     r[i+14]=av.lane(14);
1227                     r[i+15]=av.lane(15);
1228                     r[i+16]=av.lane(16);
1229                     r[i+17]=av.lane(17);
1230                     r[i+18]=av.lane(18);
1231                     r[i+19]=av.lane(19);
1232                     r[i+20]=av.lane(20);
1233                     r[i+21]=av.lane(21);
1234                     r[i+22]=av.lane(22);
1235                     r[i+23]=av.lane(23);
1236                     r[i+24]=av.lane(24);
1237                     r[i+25]=av.lane(25);
1238                     r[i+26]=av.lane(26);
1239                     r[i+27]=av.lane(27);
1240                     r[i+28]=av.lane(28);
1241                     r[i+29]=av.lane(29);
1242                     r[i+30]=av.lane(30);
1243                     r[i+31]=av.lane(31);
1244                     r[i+32]=av.lane(32);
1245                     r[i+33]=av.lane(33);
1246                     r[i+34]=av.lane(34);
1247                     r[i+35]=av.lane(35);
1248                     r[i+36]=av.lane(36);
1249                     r[i+37]=av.lane(37);
1250                     r[i+38]=av.lane(38);
1251                     r[i+39]=av.lane(39);
1252                     r[i+40]=av.lane(40);
1253                     r[i+41]=av.lane(41);
1254                     r[i+42]=av.lane(42);
1255                     r[i+43]=av.lane(43);
1256                     r[i+44]=av.lane(44);
1257                     r[i+45]=av.lane(45);
1258                     r[i+46]=av.lane(46);
1259                     r[i+47]=av.lane(47);
1260                     r[i+48]=av.lane(48);
1261                     r[i+49]=av.lane(49);
1262                     r[i+50]=av.lane(50);
1263                     r[i+51]=av.lane(51);
1264                     r[i+52]=av.lane(52);
1265                     r[i+53]=av.lane(53);
1266                     r[i+54]=av.lane(54);
1267                     r[i+55]=av.lane(55);
1268                     r[i+56]=av.lane(56);
1269                     r[i+57]=av.lane(57);
1270                     r[i+58]=av.lane(58);
1271                     r[i+59]=av.lane(59);
1272                     r[i+60]=av.lane(60);
1273                     r[i+61]=av.lane(61);
1274                     r[i+62]=av.lane(62);
1275                     r[i+63]=av.lane(63);
1276                 } else {
1277                     for (int j = 0; j < SPECIES.length(); j++) {
1278                         r[i+j]=av.lane(j);
1279                     }
1280                 }
1281             }
1282         }
1283 
1284         assertArraysEquals(a, r, Float256VectorTests::get);
1285     }
1286 
1287     static float sin(float a) {
1288         return (float)(Math.sin((double)a));
1289     }
1290 
1291     static float strictsin(float a) {
1292         return (float)(StrictMath.sin((double)a));
1293     }
1294 
1295     @Test(dataProvider = "floatUnaryOpProvider")
1296     static void sinFloat256VectorTests(IntFunction<float[]> fa) {
1297         float[] a = fa.apply(SPECIES.length());
1298         float[] r = fr.apply(SPECIES.length());
1299 
1300         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1301             for (int i = 0; i < a.length; i += SPECIES.length()) {
1302                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1303                 av.sin().intoArray(r, i);
1304             }
1305         }
1306 
1307         assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::sin, Float256VectorTests::strictsin);
1308     }
1309 
1310 
1311     static float exp(float a) {
1312         return (float)(Math.exp((double)a));
1313     }
1314 
1315     static float strictexp(float a) {
1316         return (float)(StrictMath.exp((double)a));
1317     }
1318 
1319     @Test(dataProvider = "floatUnaryOpProvider")
1320     static void expFloat256VectorTests(IntFunction<float[]> fa) {
1321         float[] a = fa.apply(SPECIES.length());
1322         float[] r = fr.apply(SPECIES.length());
1323 
1324         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1325             for (int i = 0; i < a.length; i += SPECIES.length()) {
1326                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1327                 av.exp().intoArray(r, i);
1328             }
1329         }
1330 
1331         assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::exp, Float256VectorTests::strictexp);
1332     }
1333 
1334 
1335     static float log1p(float a) {
1336         return (float)(Math.log1p((double)a));
1337     }
1338 
1339     static float strictlog1p(float a) {
1340         return (float)(StrictMath.log1p((double)a));
1341     }
1342 
1343     @Test(dataProvider = "floatUnaryOpProvider")
1344     static void log1pFloat256VectorTests(IntFunction<float[]> fa) {
1345         float[] a = fa.apply(SPECIES.length());
1346         float[] r = fr.apply(SPECIES.length());
1347 
1348         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1349             for (int i = 0; i < a.length; i += SPECIES.length()) {
1350                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1351                 av.log1p().intoArray(r, i);
1352             }
1353         }
1354 
1355         assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::log1p, Float256VectorTests::strictlog1p);
1356     }
1357 
1358 
1359     static float log(float a) {
1360         return (float)(Math.log((double)a));
1361     }
1362 
1363     static float strictlog(float a) {
1364         return (float)(StrictMath.log((double)a));
1365     }
1366 
1367     @Test(dataProvider = "floatUnaryOpProvider")
1368     static void logFloat256VectorTests(IntFunction<float[]> fa) {
1369         float[] a = fa.apply(SPECIES.length());
1370         float[] r = fr.apply(SPECIES.length());
1371 
1372         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1373             for (int i = 0; i < a.length; i += SPECIES.length()) {
1374                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1375                 av.log().intoArray(r, i);
1376             }
1377         }
1378 
1379         assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::log, Float256VectorTests::strictlog);
1380     }
1381 
1382 
1383     static float log10(float a) {
1384         return (float)(Math.log10((double)a));
1385     }
1386 
1387     static float strictlog10(float a) {
1388         return (float)(StrictMath.log10((double)a));
1389     }
1390 
1391     @Test(dataProvider = "floatUnaryOpProvider")
1392     static void log10Float256VectorTests(IntFunction<float[]> fa) {
1393         float[] a = fa.apply(SPECIES.length());
1394         float[] r = fr.apply(SPECIES.length());
1395 
1396         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1397             for (int i = 0; i < a.length; i += SPECIES.length()) {
1398                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1399                 av.log10().intoArray(r, i);
1400             }
1401         }
1402 
1403         assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::log10, Float256VectorTests::strictlog10);
1404     }
1405 
1406 
1407     static float expm1(float a) {
1408         return (float)(Math.expm1((double)a));
1409     }
1410 
1411     static float strictexpm1(float a) {
1412         return (float)(StrictMath.expm1((double)a));
1413     }
1414 
1415     @Test(dataProvider = "floatUnaryOpProvider")
1416     static void expm1Float256VectorTests(IntFunction<float[]> fa) {
1417         float[] a = fa.apply(SPECIES.length());
1418         float[] r = fr.apply(SPECIES.length());
1419 
1420         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1421             for (int i = 0; i < a.length; i += SPECIES.length()) {
1422                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1423                 av.expm1().intoArray(r, i);
1424             }
1425         }
1426 
1427         assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::expm1, Float256VectorTests::strictexpm1);
1428     }
1429 
1430 
1431     static float cos(float a) {
1432         return (float)(Math.cos((double)a));
1433     }
1434 
1435     static float strictcos(float a) {
1436         return (float)(StrictMath.cos((double)a));
1437     }
1438 
1439     @Test(dataProvider = "floatUnaryOpProvider")
1440     static void cosFloat256VectorTests(IntFunction<float[]> fa) {
1441         float[] a = fa.apply(SPECIES.length());
1442         float[] r = fr.apply(SPECIES.length());
1443 
1444         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1445             for (int i = 0; i < a.length; i += SPECIES.length()) {
1446                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1447                 av.cos().intoArray(r, i);
1448             }
1449         }
1450 
1451         assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::cos, Float256VectorTests::strictcos);
1452     }
1453 
1454 
1455     static float tan(float a) {
1456         return (float)(Math.tan((double)a));
1457     }
1458 
1459     static float stricttan(float a) {
1460         return (float)(StrictMath.tan((double)a));
1461     }
1462 
1463     @Test(dataProvider = "floatUnaryOpProvider")
1464     static void tanFloat256VectorTests(IntFunction<float[]> fa) {
1465         float[] a = fa.apply(SPECIES.length());
1466         float[] r = fr.apply(SPECIES.length());
1467 
1468         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1469             for (int i = 0; i < a.length; i += SPECIES.length()) {
1470                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1471                 av.tan().intoArray(r, i);
1472             }
1473         }
1474 
1475         assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::tan, Float256VectorTests::stricttan);
1476     }
1477 
1478 
1479     static float sinh(float a) {
1480         return (float)(Math.sinh((double)a));
1481     }
1482 
1483     static float strictsinh(float a) {
1484         return (float)(StrictMath.sinh((double)a));
1485     }
1486 
1487     @Test(dataProvider = "floatUnaryOpProvider")
1488     static void sinhFloat256VectorTests(IntFunction<float[]> fa) {
1489         float[] a = fa.apply(SPECIES.length());
1490         float[] r = fr.apply(SPECIES.length());
1491 
1492         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1493             for (int i = 0; i < a.length; i += SPECIES.length()) {
1494                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1495                 av.sinh().intoArray(r, i);
1496             }
1497         }
1498 
1499         assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::sinh, Float256VectorTests::strictsinh);
1500     }
1501 
1502 
1503     static float cosh(float a) {
1504         return (float)(Math.cosh((double)a));
1505     }
1506 
1507     static float strictcosh(float a) {
1508         return (float)(StrictMath.cosh((double)a));
1509     }
1510 
1511     @Test(dataProvider = "floatUnaryOpProvider")
1512     static void coshFloat256VectorTests(IntFunction<float[]> fa) {
1513         float[] a = fa.apply(SPECIES.length());
1514         float[] r = fr.apply(SPECIES.length());
1515 
1516         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1517             for (int i = 0; i < a.length; i += SPECIES.length()) {
1518                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1519                 av.cosh().intoArray(r, i);
1520             }
1521         }
1522 
1523         assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::cosh, Float256VectorTests::strictcosh);
1524     }
1525 
1526 
1527     static float tanh(float a) {
1528         return (float)(Math.tanh((double)a));
1529     }
1530 
1531     static float stricttanh(float a) {
1532         return (float)(StrictMath.tanh((double)a));
1533     }
1534 
1535     @Test(dataProvider = "floatUnaryOpProvider")
1536     static void tanhFloat256VectorTests(IntFunction<float[]> fa) {
1537         float[] a = fa.apply(SPECIES.length());
1538         float[] r = fr.apply(SPECIES.length());
1539 
1540         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1541             for (int i = 0; i < a.length; i += SPECIES.length()) {
1542                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1543                 av.tanh().intoArray(r, i);
1544             }
1545         }
1546 
1547         assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::tanh, Float256VectorTests::stricttanh);
1548     }
1549 
1550 
1551     static float asin(float a) {
1552         return (float)(Math.asin((double)a));
1553     }
1554 
1555     static float strictasin(float a) {
1556         return (float)(StrictMath.asin((double)a));
1557     }
1558 
1559     @Test(dataProvider = "floatUnaryOpProvider")
1560     static void asinFloat256VectorTests(IntFunction<float[]> fa) {
1561         float[] a = fa.apply(SPECIES.length());
1562         float[] r = fr.apply(SPECIES.length());
1563 
1564         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1565             for (int i = 0; i < a.length; i += SPECIES.length()) {
1566                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1567                 av.asin().intoArray(r, i);
1568             }
1569         }
1570 
1571         assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::asin, Float256VectorTests::strictasin);
1572     }
1573 
1574 
1575     static float acos(float a) {
1576         return (float)(Math.acos((double)a));
1577     }
1578 
1579     static float strictacos(float a) {
1580         return (float)(StrictMath.acos((double)a));
1581     }
1582 
1583     @Test(dataProvider = "floatUnaryOpProvider")
1584     static void acosFloat256VectorTests(IntFunction<float[]> fa) {
1585         float[] a = fa.apply(SPECIES.length());
1586         float[] r = fr.apply(SPECIES.length());
1587 
1588         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1589             for (int i = 0; i < a.length; i += SPECIES.length()) {
1590                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1591                 av.acos().intoArray(r, i);
1592             }
1593         }
1594 
1595         assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::acos, Float256VectorTests::strictacos);
1596     }
1597 
1598 
1599     static float atan(float a) {
1600         return (float)(Math.atan((double)a));
1601     }
1602 
1603     static float strictatan(float a) {
1604         return (float)(StrictMath.atan((double)a));
1605     }
1606 
1607     @Test(dataProvider = "floatUnaryOpProvider")
1608     static void atanFloat256VectorTests(IntFunction<float[]> fa) {
1609         float[] a = fa.apply(SPECIES.length());
1610         float[] r = fr.apply(SPECIES.length());
1611 
1612         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1613             for (int i = 0; i < a.length; i += SPECIES.length()) {
1614                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1615                 av.atan().intoArray(r, i);
1616             }
1617         }
1618 
1619         assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::atan, Float256VectorTests::strictatan);
1620     }
1621 
1622 
1623     static float cbrt(float a) {
1624         return (float)(Math.cbrt((double)a));
1625     }
1626 
1627     static float strictcbrt(float a) {
1628         return (float)(StrictMath.cbrt((double)a));
1629     }
1630 
1631     @Test(dataProvider = "floatUnaryOpProvider")
1632     static void cbrtFloat256VectorTests(IntFunction<float[]> fa) {
1633         float[] a = fa.apply(SPECIES.length());
1634         float[] r = fr.apply(SPECIES.length());
1635 
1636         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1637             for (int i = 0; i < a.length; i += SPECIES.length()) {
1638                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1639                 av.cbrt().intoArray(r, i);
1640             }
1641         }
1642 
1643         assertArraysEqualsWithinOneUlp(a, r, Float256VectorTests::cbrt, Float256VectorTests::strictcbrt);
1644     }
1645 
1646 
1647     static float hypot(float a, float b) {
1648         return (float)(Math.hypot((double)a, (double)b));
1649     }
1650 
1651     static float stricthypot(float a, float b) {
1652         return (float)(StrictMath.hypot((double)a, (double)b));
1653     }
1654 
1655     @Test(dataProvider = "floatBinaryOpProvider")
1656     static void hypotFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
1657         float[] a = fa.apply(SPECIES.length());
1658         float[] b = fb.apply(SPECIES.length());
1659         float[] r = fr.apply(SPECIES.length());
1660 
1661         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1662             for (int i = 0; i < a.length; i += SPECIES.length()) {
1663                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1664                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
1665                 av.hypot(bv).intoArray(r, i);
1666             }
1667         }
1668 
1669         assertArraysEqualsWithinOneUlp(a, b, r, Float256VectorTests::hypot, Float256VectorTests::stricthypot);
1670     }
1671 
1672 
1673 
1674     static float pow(float a, float b) {
1675         return (float)(Math.pow((double)a, (double)b));
1676     }
1677 
1678     static float strictpow(float a, float b) {
1679         return (float)(StrictMath.pow((double)a, (double)b));
1680     }
1681 
1682     @Test(dataProvider = "floatBinaryOpProvider")
1683     static void powFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
1684         float[] a = fa.apply(SPECIES.length());
1685         float[] b = fb.apply(SPECIES.length());
1686         float[] r = fr.apply(SPECIES.length());
1687 
1688         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1689             for (int i = 0; i < a.length; i += SPECIES.length()) {
1690                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1691                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
1692                 av.pow(bv).intoArray(r, i);
1693             }
1694         }
1695 
1696         assertArraysEqualsWithinOneUlp(a, b, r, Float256VectorTests::pow, Float256VectorTests::strictpow);
1697     }
1698 
1699 
1700 
1701     static float atan2(float a, float b) {
1702         return (float)(Math.atan2((double)a, (double)b));
1703     }
1704 
1705     static float strictatan2(float a, float b) {
1706         return (float)(StrictMath.atan2((double)a, (double)b));
1707     }
1708 
1709     @Test(dataProvider = "floatBinaryOpProvider")
1710     static void atan2Float256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {
1711         float[] a = fa.apply(SPECIES.length());
1712         float[] b = fb.apply(SPECIES.length());
1713         float[] r = fr.apply(SPECIES.length());
1714 
1715         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1716             for (int i = 0; i < a.length; i += SPECIES.length()) {
1717                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1718                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
1719                 av.atan2(bv).intoArray(r, i);
1720             }
1721         }
1722 
1723         assertArraysEqualsWithinOneUlp(a, b, r, Float256VectorTests::atan2, Float256VectorTests::strictatan2);
1724     }
1725 
1726 
1727 
1728     static float fma(float a, float b, float c) {
1729         return (float)(Math.fma(a, b, c));
1730     }
1731 
1732 
1733     @Test(dataProvider = "floatTernaryOpProvider")
1734     static void fmaFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb, IntFunction<float[]> fc) {
1735         float[] a = fa.apply(SPECIES.length());
1736         float[] b = fb.apply(SPECIES.length());
1737         float[] c = fc.apply(SPECIES.length());
1738         float[] r = fr.apply(SPECIES.length());
1739 
1740         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1741             for (int i = 0; i < a.length; i += SPECIES.length()) {
1742                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1743                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
1744                 FloatVector cv = FloatVector.fromArray(SPECIES, c, i);
1745                 av.fma(bv, cv).intoArray(r, i);
1746             }
1747         }
1748 
1749         assertArraysEquals(a, b, c, r, Float256VectorTests::fma);
1750     }
1751 
1752 
1753     @Test(dataProvider = "floatTernaryOpMaskProvider")
1754     static void fmaFloat256VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb,
1755                                           IntFunction<float[]> fc, IntFunction<boolean[]> fm) {
1756         float[] a = fa.apply(SPECIES.length());
1757         float[] b = fb.apply(SPECIES.length());
1758         float[] c = fc.apply(SPECIES.length());
1759         float[] r = fr.apply(SPECIES.length());
1760         boolean[] mask = fm.apply(SPECIES.length());
1761         VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask);
1762 
1763         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1764             for (int i = 0; i < a.length; i += SPECIES.length()) {
1765                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1766                 FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
1767                 FloatVector cv = FloatVector.fromArray(SPECIES, c, i);
1768                 av.fma(bv, cv, vmask).intoArray(r, i);
1769             }
1770         }
1771 
1772         assertArraysEquals(a, b, c, r, mask, Float256VectorTests::fma);
1773     }
1774 
1775 
1776     static float neg(float a) {
1777         return (float)(-((float)a));
1778     }
1779 
1780     @Test(dataProvider = "floatUnaryOpProvider")
1781     static void negFloat256VectorTests(IntFunction<float[]> fa) {
1782         float[] a = fa.apply(SPECIES.length());
1783         float[] r = fr.apply(SPECIES.length());
1784 
1785         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1786             for (int i = 0; i < a.length; i += SPECIES.length()) {
1787                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1788                 av.neg().intoArray(r, i);
1789             }
1790         }
1791 
1792         assertArraysEquals(a, r, Float256VectorTests::neg);
1793     }
1794 
1795     @Test(dataProvider = "floatUnaryOpMaskProvider")
1796     static void negMaskedFloat256VectorTests(IntFunction<float[]> fa,
1797                                                 IntFunction<boolean[]> fm) {
1798         float[] a = fa.apply(SPECIES.length());
1799         float[] r = fr.apply(SPECIES.length());
1800         boolean[] mask = fm.apply(SPECIES.length());
1801         VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask);
1802 
1803         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1804             for (int i = 0; i < a.length; i += SPECIES.length()) {
1805                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1806                 av.neg(vmask).intoArray(r, i);
1807             }
1808         }
1809 
1810         assertArraysEquals(a, r, mask, Float256VectorTests::neg);
1811     }
1812 
1813     static float abs(float a) {
1814         return (float)(Math.abs((float)a));
1815     }
1816 
1817     @Test(dataProvider = "floatUnaryOpProvider")
1818     static void absFloat256VectorTests(IntFunction<float[]> fa) {
1819         float[] a = fa.apply(SPECIES.length());
1820         float[] r = fr.apply(SPECIES.length());
1821 
1822         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1823             for (int i = 0; i < a.length; i += SPECIES.length()) {
1824                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1825                 av.abs().intoArray(r, i);
1826             }
1827         }
1828 
1829         assertArraysEquals(a, r, Float256VectorTests::abs);
1830     }
1831 
1832     @Test(dataProvider = "floatUnaryOpMaskProvider")
1833     static void absMaskedFloat256VectorTests(IntFunction<float[]> fa,
1834                                                 IntFunction<boolean[]> fm) {
1835         float[] a = fa.apply(SPECIES.length());
1836         float[] r = fr.apply(SPECIES.length());
1837         boolean[] mask = fm.apply(SPECIES.length());
1838         VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask);
1839 
1840         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1841             for (int i = 0; i < a.length; i += SPECIES.length()) {
1842                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1843                 av.abs(vmask).intoArray(r, i);
1844             }
1845         }
1846 
1847         assertArraysEquals(a, r, mask, Float256VectorTests::abs);
1848     }
1849 
1850 
1851 
1852 
1853 
1854     static float sqrt(float a) {
1855         return (float)(Math.sqrt((double)a));
1856     }
1857 
1858 
1859 
1860     @Test(dataProvider = "floatUnaryOpProvider")
1861     static void sqrtFloat256VectorTests(IntFunction<float[]> fa) {
1862         float[] a = fa.apply(SPECIES.length());
1863         float[] r = fr.apply(SPECIES.length());
1864 
1865         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1866             for (int i = 0; i < a.length; i += SPECIES.length()) {
1867                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1868                 av.sqrt().intoArray(r, i);
1869             }
1870         }
1871 
1872         assertArraysEquals(a, r, Float256VectorTests::sqrt);
1873     }
1874 
1875 
1876 
1877     @Test(dataProvider = "floatUnaryOpMaskProvider")
1878     static void sqrtMaskedFloat256VectorTests(IntFunction<float[]> fa,
1879                                                 IntFunction<boolean[]> fm) {
1880         float[] a = fa.apply(SPECIES.length());
1881         float[] r = fr.apply(SPECIES.length());
1882         boolean[] mask = fm.apply(SPECIES.length());
1883         VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask);
1884 
1885         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1886             for (int i = 0; i < a.length; i += SPECIES.length()) {
1887                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1888                 av.sqrt(vmask).intoArray(r, i);
1889             }
1890         }
1891 
1892         assertArraysEquals(a, r, mask, Float256VectorTests::sqrt);
1893     }
1894 
1895 
1896     static float[] gather(float a[], int ix, int[] b, int iy) {
1897         float[] res = new float[SPECIES.length()];
1898         for (int i = 0; i < SPECIES.length(); i++) {
1899             int bi = iy + i;
1900             res[i] = a[b[bi] + ix];
1901         }
1902         return res;
1903     }
1904 
1905     @Test(dataProvider = "floatUnaryOpIndexProvider")
1906     static void gatherFloat256VectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
1907         float[] a = fa.apply(SPECIES.length());
1908         int[] b    = fs.apply(a.length, SPECIES.length());
1909         float[] r = new float[a.length];
1910 
1911         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1912             for (int i = 0; i < a.length; i += SPECIES.length()) {
1913                 FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i);
1914                 av.intoArray(r, i);
1915             }
1916         }
1917 
1918         assertArraysEquals(a, b, r, Float256VectorTests::gather);
1919     }
1920 
1921 
1922     static float[] scatter(float a[], int ix, int[] b, int iy) {
1923       float[] res = new float[SPECIES.length()];
1924       for (int i = 0; i < SPECIES.length(); i++) {
1925         int bi = iy + i;
1926         res[b[bi]] = a[i + ix];
1927       }
1928       return res;
1929     }
1930 
1931     @Test(dataProvider = "floatUnaryOpIndexProvider")
1932     static void scatterFloat256VectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {
1933         float[] a = fa.apply(SPECIES.length());
1934         int[] b = fs.apply(a.length, SPECIES.length());
1935         float[] r = new float[a.length];
1936 
1937         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1938             for (int i = 0; i < a.length; i += SPECIES.length()) {
1939                 FloatVector av = FloatVector.fromArray(SPECIES, a, i);
1940                 av.intoArray(r, i, b, i);
1941             }
1942         }
1943 
1944         assertArraysEquals(a, b, r, Float256VectorTests::scatter);
1945     }
1946 
1947 }
1948