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