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