< prev index next >

test/jdk/jdk/incubator/vector/Long256VectorTests.java

Print this page
rev 54658 : refactored mask and shuffle creation methods, moved classes to top-level


  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 Long256VectorTests
  28  */
  29 
  30 import jdk.incubator.vector.Vector.Shape;
  31 import jdk.incubator.vector.Vector.Species;


  32 import jdk.incubator.vector.Vector;
  33 
  34 import jdk.incubator.vector.LongVector;
  35 
  36 import org.testng.Assert;
  37 import org.testng.annotations.DataProvider;
  38 import org.testng.annotations.Test;
  39 
  40 import java.lang.Integer;
  41 import java.util.List;
  42 import java.util.Arrays;
  43 import java.util.function.BiFunction;
  44 import java.util.function.IntFunction;
  45 import java.util.stream.Collectors;
  46 import java.util.stream.Stream;
  47 
  48 @Test
  49 public class Long256VectorTests extends AbstractVectorTest {
  50 
  51     static final Species<Long> SPECIES =
  52                 LongVector.SPECIES_256;
  53 
  54     static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
  55 
  56     interface FUnOp {
  57         long apply(long a);
  58     }
  59 
  60     static void assertArraysEquals(long[] a, long[] r, FUnOp f) {
  61         int i = 0;
  62         try {
  63             for (; i < a.length; i++) {
  64                 Assert.assertEquals(r[i], f.apply(a[i]));
  65             }
  66         } catch (AssertionError e) {
  67             Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);
  68         }
  69     }
  70 
  71     static void assertArraysEquals(long[] a, long[] r, boolean[] mask, FUnOp f) {


 436         long[] r = fr.apply(SPECIES.length());
 437 
 438         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 439             for (int i = 0; i < a.length; i += SPECIES.length()) {
 440                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 441                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 442                 av.add(bv).intoArray(r, i);
 443             }
 444         }
 445 
 446         assertArraysEquals(a, b, r, Long256VectorTests::add);
 447     }
 448 
 449     @Test(dataProvider = "longBinaryOpMaskProvider")
 450     static void addLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 451                                           IntFunction<boolean[]> fm) {
 452         long[] a = fa.apply(SPECIES.length());
 453         long[] b = fb.apply(SPECIES.length());
 454         long[] r = fr.apply(SPECIES.length());
 455         boolean[] mask = fm.apply(SPECIES.length());
 456         Vector.Mask<Long> vmask = LongVector.maskFromValues(SPECIES, mask);
 457 
 458         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 459             for (int i = 0; i < a.length; i += SPECIES.length()) {
 460                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 461                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 462                 av.add(bv, vmask).intoArray(r, i);
 463             }
 464         }
 465 
 466         assertArraysEquals(a, b, r, mask, Long256VectorTests::add);
 467     }
 468     static long sub(long a, long b) {
 469         return (long)(a - b);
 470     }
 471 
 472     @Test(dataProvider = "longBinaryOpProvider")
 473     static void subLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 474         long[] a = fa.apply(SPECIES.length());
 475         long[] b = fb.apply(SPECIES.length());
 476         long[] r = fr.apply(SPECIES.length());
 477 
 478         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 479             for (int i = 0; i < a.length; i += SPECIES.length()) {
 480                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 481                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 482                 av.sub(bv).intoArray(r, i);
 483             }
 484         }
 485 
 486         assertArraysEquals(a, b, r, Long256VectorTests::sub);
 487     }
 488 
 489     @Test(dataProvider = "longBinaryOpMaskProvider")
 490     static void subLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 491                                           IntFunction<boolean[]> fm) {
 492         long[] a = fa.apply(SPECIES.length());
 493         long[] b = fb.apply(SPECIES.length());
 494         long[] r = fr.apply(SPECIES.length());
 495         boolean[] mask = fm.apply(SPECIES.length());
 496         Vector.Mask<Long> vmask = LongVector.maskFromValues(SPECIES, mask);
 497 
 498         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 499             for (int i = 0; i < a.length; i += SPECIES.length()) {
 500                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 501                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 502                 av.sub(bv, vmask).intoArray(r, i);
 503             }
 504         }
 505 
 506         assertArraysEquals(a, b, r, mask, Long256VectorTests::sub);
 507     }
 508 
 509 
 510     static long mul(long a, long b) {
 511         return (long)(a * b);
 512     }
 513 
 514     @Test(dataProvider = "longBinaryOpProvider")
 515     static void mulLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 516         long[] a = fa.apply(SPECIES.length());


 518         long[] r = fr.apply(SPECIES.length());
 519 
 520         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 521             for (int i = 0; i < a.length; i += SPECIES.length()) {
 522                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 523                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 524                 av.mul(bv).intoArray(r, i);
 525             }
 526         }
 527 
 528         assertArraysEquals(a, b, r, Long256VectorTests::mul);
 529     }
 530 
 531     @Test(dataProvider = "longBinaryOpMaskProvider")
 532     static void mulLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 533                                           IntFunction<boolean[]> fm) {
 534         long[] a = fa.apply(SPECIES.length());
 535         long[] b = fb.apply(SPECIES.length());
 536         long[] r = fr.apply(SPECIES.length());
 537         boolean[] mask = fm.apply(SPECIES.length());
 538         Vector.Mask<Long> vmask = LongVector.maskFromValues(SPECIES, mask);
 539 
 540         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 541             for (int i = 0; i < a.length; i += SPECIES.length()) {
 542                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 543                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 544                 av.mul(bv, vmask).intoArray(r, i);
 545             }
 546         }
 547 
 548         assertArraysEquals(a, b, r, mask, Long256VectorTests::mul);
 549     }
 550 
 551     static long and(long a, long b) {
 552         return (long)(a & b);
 553     }
 554 
 555     @Test(dataProvider = "longBinaryOpProvider")
 556     static void andLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 557         long[] a = fa.apply(SPECIES.length());
 558         long[] b = fb.apply(SPECIES.length());


 561         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 562             for (int i = 0; i < a.length; i += SPECIES.length()) {
 563                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 564                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 565                 av.and(bv).intoArray(r, i);
 566             }
 567         }
 568 
 569         assertArraysEquals(a, b, r, Long256VectorTests::and);
 570     }
 571 
 572 
 573 
 574     @Test(dataProvider = "longBinaryOpMaskProvider")
 575     static void andLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 576                                           IntFunction<boolean[]> fm) {
 577         long[] a = fa.apply(SPECIES.length());
 578         long[] b = fb.apply(SPECIES.length());
 579         long[] r = fr.apply(SPECIES.length());
 580         boolean[] mask = fm.apply(SPECIES.length());
 581         Vector.Mask<Long> vmask = LongVector.maskFromValues(SPECIES, mask);
 582 
 583         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 584             for (int i = 0; i < a.length; i += SPECIES.length()) {
 585                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 586                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 587                 av.and(bv, vmask).intoArray(r, i);
 588             }
 589         }
 590 
 591         assertArraysEquals(a, b, r, mask, Long256VectorTests::and);
 592     }
 593 
 594 
 595     static long or(long a, long b) {
 596         return (long)(a | b);
 597     }
 598 
 599     @Test(dataProvider = "longBinaryOpProvider")
 600     static void orLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 601         long[] a = fa.apply(SPECIES.length());


 605         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 606             for (int i = 0; i < a.length; i += SPECIES.length()) {
 607                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 608                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 609                 av.or(bv).intoArray(r, i);
 610             }
 611         }
 612 
 613         assertArraysEquals(a, b, r, Long256VectorTests::or);
 614     }
 615 
 616 
 617 
 618     @Test(dataProvider = "longBinaryOpMaskProvider")
 619     static void orLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 620                                           IntFunction<boolean[]> fm) {
 621         long[] a = fa.apply(SPECIES.length());
 622         long[] b = fb.apply(SPECIES.length());
 623         long[] r = fr.apply(SPECIES.length());
 624         boolean[] mask = fm.apply(SPECIES.length());
 625         Vector.Mask<Long> vmask = LongVector.maskFromValues(SPECIES, mask);
 626 
 627         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 628             for (int i = 0; i < a.length; i += SPECIES.length()) {
 629                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 630                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 631                 av.or(bv, vmask).intoArray(r, i);
 632             }
 633         }
 634 
 635         assertArraysEquals(a, b, r, mask, Long256VectorTests::or);
 636     }
 637 
 638 
 639     static long xor(long a, long b) {
 640         return (long)(a ^ b);
 641     }
 642 
 643     @Test(dataProvider = "longBinaryOpProvider")
 644     static void xorLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 645         long[] a = fa.apply(SPECIES.length());


 649         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 650             for (int i = 0; i < a.length; i += SPECIES.length()) {
 651                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 652                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 653                 av.xor(bv).intoArray(r, i);
 654             }
 655         }
 656 
 657         assertArraysEquals(a, b, r, Long256VectorTests::xor);
 658     }
 659 
 660 
 661 
 662     @Test(dataProvider = "longBinaryOpMaskProvider")
 663     static void xorLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 664                                           IntFunction<boolean[]> fm) {
 665         long[] a = fa.apply(SPECIES.length());
 666         long[] b = fb.apply(SPECIES.length());
 667         long[] r = fr.apply(SPECIES.length());
 668         boolean[] mask = fm.apply(SPECIES.length());
 669         Vector.Mask<Long> vmask = LongVector.maskFromValues(SPECIES, mask);
 670 
 671         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 672             for (int i = 0; i < a.length; i += SPECIES.length()) {
 673                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 674                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 675                 av.xor(bv, vmask).intoArray(r, i);
 676             }
 677         }
 678 
 679         assertArraysEquals(a, b, r, mask, Long256VectorTests::xor);
 680     }
 681 
 682 
 683     static long shiftR(long a, long b) {
 684         return (long)((a >>> b));
 685     }
 686 
 687     @Test(dataProvider = "longBinaryOpProvider")
 688     static void shiftRLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 689         long[] a = fa.apply(SPECIES.length());


 693         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 694             for (int i = 0; i < a.length; i += SPECIES.length()) {
 695                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 696                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 697                 av.shiftR(bv).intoArray(r, i);
 698             }
 699         }
 700 
 701         assertArraysEquals(a, b, r, Long256VectorTests::shiftR);
 702     }
 703 
 704 
 705 
 706     @Test(dataProvider = "longBinaryOpMaskProvider")
 707     static void shiftRLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 708                                           IntFunction<boolean[]> fm) {
 709         long[] a = fa.apply(SPECIES.length());
 710         long[] b = fb.apply(SPECIES.length());
 711         long[] r = fr.apply(SPECIES.length());
 712         boolean[] mask = fm.apply(SPECIES.length());
 713         Vector.Mask<Long> vmask = LongVector.maskFromValues(SPECIES, mask);
 714 
 715         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 716             for (int i = 0; i < a.length; i += SPECIES.length()) {
 717                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 718                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 719                 av.shiftR(bv, vmask).intoArray(r, i);
 720             }
 721         }
 722 
 723         assertArraysEquals(a, b, r, mask, Long256VectorTests::shiftR);
 724     }
 725 
 726 
 727     static long shiftL(long a, long b) {
 728         return (long)((a << b));
 729     }
 730 
 731     @Test(dataProvider = "longBinaryOpProvider")
 732     static void shiftLLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 733         long[] a = fa.apply(SPECIES.length());


 737         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 738             for (int i = 0; i < a.length; i += SPECIES.length()) {
 739                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 740                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 741                 av.shiftL(bv).intoArray(r, i);
 742             }
 743         }
 744 
 745         assertArraysEquals(a, b, r, Long256VectorTests::shiftL);
 746     }
 747 
 748 
 749 
 750     @Test(dataProvider = "longBinaryOpMaskProvider")
 751     static void shiftLLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 752                                           IntFunction<boolean[]> fm) {
 753         long[] a = fa.apply(SPECIES.length());
 754         long[] b = fb.apply(SPECIES.length());
 755         long[] r = fr.apply(SPECIES.length());
 756         boolean[] mask = fm.apply(SPECIES.length());
 757         Vector.Mask<Long> vmask = LongVector.maskFromValues(SPECIES, mask);
 758 
 759         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 760             for (int i = 0; i < a.length; i += SPECIES.length()) {
 761                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 762                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 763                 av.shiftL(bv, vmask).intoArray(r, i);
 764             }
 765         }
 766 
 767         assertArraysEquals(a, b, r, mask, Long256VectorTests::shiftL);
 768     }
 769 
 770 
 771     static long aShiftR(long a, long b) {
 772         return (long)((a >> b));
 773     }
 774 
 775     @Test(dataProvider = "longBinaryOpProvider")
 776     static void aShiftRLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 777         long[] a = fa.apply(SPECIES.length());


 781         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 782             for (int i = 0; i < a.length; i += SPECIES.length()) {
 783                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 784                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 785                 av.aShiftR(bv).intoArray(r, i);
 786             }
 787         }
 788 
 789         assertArraysEquals(a, b, r, Long256VectorTests::aShiftR);
 790     }
 791 
 792 
 793 
 794     @Test(dataProvider = "longBinaryOpMaskProvider")
 795     static void aShiftRLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 796                                           IntFunction<boolean[]> fm) {
 797         long[] a = fa.apply(SPECIES.length());
 798         long[] b = fb.apply(SPECIES.length());
 799         long[] r = fr.apply(SPECIES.length());
 800         boolean[] mask = fm.apply(SPECIES.length());
 801         Vector.Mask<Long> vmask = LongVector.maskFromValues(SPECIES, mask);
 802 
 803         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 804             for (int i = 0; i < a.length; i += SPECIES.length()) {
 805                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 806                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 807                 av.aShiftR(bv, vmask).intoArray(r, i);
 808             }
 809         }
 810 
 811         assertArraysEquals(a, b, r, mask, Long256VectorTests::aShiftR);
 812     }
 813 
 814 
 815     static long aShiftR_unary(long a, long b) {
 816         return (long)((a >> b));
 817     }
 818 
 819     @Test(dataProvider = "longBinaryOpProvider")
 820     static void aShiftRLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 821         long[] a = fa.apply(SPECIES.length());


 824 
 825         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 826             for (int i = 0; i < a.length; i += SPECIES.length()) {
 827                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 828                 av.aShiftR((int)b[i]).intoArray(r, i);
 829             }
 830         }
 831 
 832         assertShiftArraysEquals(a, b, r, Long256VectorTests::aShiftR_unary);
 833     }
 834 
 835 
 836 
 837     @Test(dataProvider = "longBinaryOpMaskProvider")
 838     static void aShiftRLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb,
 839                                           IntFunction<boolean[]> fm) {
 840         long[] a = fa.apply(SPECIES.length());
 841         long[] b = fb.apply(SPECIES.length());
 842         long[] r = fr.apply(SPECIES.length());
 843         boolean[] mask = fm.apply(SPECIES.length());
 844         Vector.Mask<Long> vmask = LongVector.maskFromValues(SPECIES, mask);
 845 
 846         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 847             for (int i = 0; i < a.length; i += SPECIES.length()) {
 848                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 849                 av.aShiftR((int)b[i], vmask).intoArray(r, i);
 850             }
 851         }
 852 
 853         assertShiftArraysEquals(a, b, r, mask, Long256VectorTests::aShiftR_unary);
 854     }
 855 
 856 
 857     static long shiftR_unary(long a, long b) {
 858         return (long)((a >>> b));
 859     }
 860 
 861     @Test(dataProvider = "longBinaryOpProvider")
 862     static void shiftRLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 863         long[] a = fa.apply(SPECIES.length());
 864         long[] b = fb.apply(SPECIES.length());


 866 
 867         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 868             for (int i = 0; i < a.length; i += SPECIES.length()) {
 869                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 870                 av.shiftR((int)b[i]).intoArray(r, i);
 871             }
 872         }
 873 
 874         assertShiftArraysEquals(a, b, r, Long256VectorTests::shiftR_unary);
 875     }
 876 
 877 
 878 
 879     @Test(dataProvider = "longBinaryOpMaskProvider")
 880     static void shiftRLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb,
 881                                           IntFunction<boolean[]> fm) {
 882         long[] a = fa.apply(SPECIES.length());
 883         long[] b = fb.apply(SPECIES.length());
 884         long[] r = fr.apply(SPECIES.length());
 885         boolean[] mask = fm.apply(SPECIES.length());
 886         Vector.Mask<Long> vmask = LongVector.maskFromValues(SPECIES, mask);
 887 
 888         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 889             for (int i = 0; i < a.length; i += SPECIES.length()) {
 890                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 891                 av.shiftR((int)b[i], vmask).intoArray(r, i);
 892             }
 893         }
 894 
 895         assertShiftArraysEquals(a, b, r, mask, Long256VectorTests::shiftR_unary);
 896     }
 897 
 898 
 899     static long shiftL_unary(long a, long b) {
 900         return (long)((a << b));
 901     }
 902 
 903     @Test(dataProvider = "longBinaryOpProvider")
 904     static void shiftLLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 905         long[] a = fa.apply(SPECIES.length());
 906         long[] b = fb.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                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 912                 av.shiftL((int)b[i]).intoArray(r, i);
 913             }
 914         }
 915 
 916         assertShiftArraysEquals(a, b, r, Long256VectorTests::shiftL_unary);
 917     }
 918 
 919 
 920 
 921     @Test(dataProvider = "longBinaryOpMaskProvider")
 922     static void shiftLLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb,
 923                                           IntFunction<boolean[]> fm) {
 924         long[] a = fa.apply(SPECIES.length());
 925         long[] b = fb.apply(SPECIES.length());
 926         long[] r = fr.apply(SPECIES.length());
 927         boolean[] mask = fm.apply(SPECIES.length());
 928         Vector.Mask<Long> vmask = LongVector.maskFromValues(SPECIES, mask);
 929 
 930         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 931             for (int i = 0; i < a.length; i += SPECIES.length()) {
 932                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 933                 av.shiftL((int)b[i], vmask).intoArray(r, i);
 934             }
 935         }
 936 
 937         assertShiftArraysEquals(a, b, r, mask, Long256VectorTests::shiftL_unary);
 938     }
 939 
 940 
 941 
 942 
 943 
 944 
 945 
 946 
 947 
 948 


1302         assertReductionArraysEquals(a, r, ra, Long256VectorTests::maxAll, Long256VectorTests::maxAll);
1303     }
1304 
1305     static boolean anyTrue(boolean[] a, int idx) {
1306         boolean res = false;
1307         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1308             res |= a[i];
1309         }
1310 
1311         return res;
1312     }
1313 
1314 
1315     @Test(dataProvider = "boolUnaryOpProvider")
1316     static void anyTrueLong256VectorTests(IntFunction<boolean[]> fm) {
1317         boolean[] mask = fm.apply(SPECIES.length());
1318         boolean[] r = fmr.apply(SPECIES.length());
1319 
1320         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1321             for (int i = 0; i < mask.length; i += SPECIES.length()) {
1322                 Vector.Mask<Long> vmask = LongVector.maskFromArray(SPECIES, mask, i);
1323                 r[i] = vmask.anyTrue();
1324             }
1325         }
1326 
1327         assertReductionBoolArraysEquals(mask, r, Long256VectorTests::anyTrue);
1328     }
1329 
1330 
1331     static boolean allTrue(boolean[] a, int idx) {
1332         boolean res = true;
1333         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1334             res &= a[i];
1335         }
1336 
1337         return res;
1338     }
1339 
1340 
1341     @Test(dataProvider = "boolUnaryOpProvider")
1342     static void allTrueLong256VectorTests(IntFunction<boolean[]> fm) {
1343         boolean[] mask = fm.apply(SPECIES.length());
1344         boolean[] r = fmr.apply(SPECIES.length());
1345 
1346         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1347             for (int i = 0; i < mask.length; i += SPECIES.length()) {
1348                 Vector.Mask<Long> vmask = LongVector.maskFromArray(SPECIES, mask, i);
1349                 r[i] = vmask.allTrue();
1350             }
1351         }
1352 
1353         assertReductionBoolArraysEquals(mask, r, Long256VectorTests::allTrue);
1354     }
1355 
1356 
1357     @Test(dataProvider = "longUnaryOpProvider")
1358     static void withLong256VectorTests(IntFunction<long []> fa) {
1359         long[] a = fa.apply(SPECIES.length());
1360         long[] r = fr.apply(SPECIES.length());
1361 
1362         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1363             for (int i = 0; i < a.length; i += SPECIES.length()) {
1364                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1365                 av.with(0, (long)4).intoArray(r, i);
1366             }
1367         }
1368 
1369         assertInsertArraysEquals(a, r, (long)4, 0);
1370     }
1371 
1372     @Test(dataProvider = "longCompareOpProvider")
1373     static void lessThanLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1374         long[] a = fa.apply(SPECIES.length());
1375         long[] b = fb.apply(SPECIES.length());
1376 
1377         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1378             for (int i = 0; i < a.length; i += SPECIES.length()) {
1379                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1380                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1381                 Vector.Mask<Long> mv = av.lessThan(bv);
1382 
1383                 // Check results as part of computation.
1384                 for (int j = 0; j < SPECIES.length(); j++) {
1385                     Assert.assertEquals(mv.getElement(j), a[i + j] < b[i + j]);
1386                 }
1387             }
1388         }
1389     }
1390 
1391 
1392     @Test(dataProvider = "longCompareOpProvider")
1393     static void greaterThanLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1394         long[] a = fa.apply(SPECIES.length());
1395         long[] b = fb.apply(SPECIES.length());
1396 
1397         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1398             for (int i = 0; i < a.length; i += SPECIES.length()) {
1399                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1400                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1401                 Vector.Mask<Long> mv = av.greaterThan(bv);
1402 
1403                 // Check results as part of computation.
1404                 for (int j = 0; j < SPECIES.length(); j++) {
1405                     Assert.assertEquals(mv.getElement(j), a[i + j] > b[i + j]);
1406                 }
1407             }
1408         }
1409     }
1410 
1411 
1412     @Test(dataProvider = "longCompareOpProvider")
1413     static void equalLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1414         long[] a = fa.apply(SPECIES.length());
1415         long[] b = fb.apply(SPECIES.length());
1416 
1417         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1418             for (int i = 0; i < a.length; i += SPECIES.length()) {
1419                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1420                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1421                 Vector.Mask<Long> mv = av.equal(bv);
1422 
1423                 // Check results as part of computation.
1424                 for (int j = 0; j < SPECIES.length(); j++) {
1425                     Assert.assertEquals(mv.getElement(j), a[i + j] == b[i + j]);
1426                 }
1427             }
1428         }
1429     }
1430 
1431 
1432     @Test(dataProvider = "longCompareOpProvider")
1433     static void notEqualLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1434         long[] a = fa.apply(SPECIES.length());
1435         long[] b = fb.apply(SPECIES.length());
1436 
1437         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1438             for (int i = 0; i < a.length; i += SPECIES.length()) {
1439                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1440                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1441                 Vector.Mask<Long> mv = av.notEqual(bv);
1442 
1443                 // Check results as part of computation.
1444                 for (int j = 0; j < SPECIES.length(); j++) {
1445                     Assert.assertEquals(mv.getElement(j), a[i + j] != b[i + j]);
1446                 }
1447             }
1448         }
1449     }
1450 
1451 
1452     @Test(dataProvider = "longCompareOpProvider")
1453     static void lessThanEqLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1454         long[] a = fa.apply(SPECIES.length());
1455         long[] b = fb.apply(SPECIES.length());
1456 
1457         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1458             for (int i = 0; i < a.length; i += SPECIES.length()) {
1459                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1460                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1461                 Vector.Mask<Long> mv = av.lessThanEq(bv);
1462 
1463                 // Check results as part of computation.
1464                 for (int j = 0; j < SPECIES.length(); j++) {
1465                     Assert.assertEquals(mv.getElement(j), a[i + j] <= b[i + j]);
1466                 }
1467             }
1468         }
1469     }
1470 
1471 
1472     @Test(dataProvider = "longCompareOpProvider")
1473     static void greaterThanEqLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1474         long[] a = fa.apply(SPECIES.length());
1475         long[] b = fb.apply(SPECIES.length());
1476 
1477         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1478             for (int i = 0; i < a.length; i += SPECIES.length()) {
1479                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1480                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1481                 Vector.Mask<Long> mv = av.greaterThanEq(bv);
1482 
1483                 // Check results as part of computation.
1484                 for (int j = 0; j < SPECIES.length(); j++) {
1485                     Assert.assertEquals(mv.getElement(j), a[i + j] >= b[i + j]);
1486                 }
1487             }
1488         }
1489     }
1490 
1491 
1492     static long blend(long a, long b, boolean mask) {
1493         return mask ? b : a;
1494     }
1495 
1496     @Test(dataProvider = "longBinaryOpMaskProvider")
1497     static void blendLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
1498                                           IntFunction<boolean[]> fm) {
1499         long[] a = fa.apply(SPECIES.length());
1500         long[] b = fb.apply(SPECIES.length());
1501         long[] r = fr.apply(SPECIES.length());
1502         boolean[] mask = fm.apply(SPECIES.length());
1503         Vector.Mask<Long> vmask = LongVector.maskFromValues(SPECIES, mask);
1504 
1505         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1506             for (int i = 0; i < a.length; i += SPECIES.length()) {
1507                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1508                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1509                 av.blend(bv, vmask).intoArray(r, i);
1510             }
1511         }
1512 
1513         assertArraysEquals(a, b, r, mask, Long256VectorTests::blend);
1514     }
1515 
1516     @Test(dataProvider = "longUnaryOpShuffleProvider")
1517     static void RearrangeLong256VectorTests(IntFunction<long[]> fa,
1518                                            BiFunction<Integer,Integer,int[]> fs) {
1519         long[] a = fa.apply(SPECIES.length());
1520         int[] order = fs.apply(a.length, SPECIES.length());
1521         long[] r = fr.apply(SPECIES.length());
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                 av.rearrange(LongVector.shuffleFromArray(SPECIES, order, i)).intoArray(r, i);
1527             }
1528         }
1529 
1530         assertRearrangeArraysEquals(a, r, order, SPECIES.length());
1531     }
1532 
1533 
1534 
1535 
1536     @Test(dataProvider = "longUnaryOpProvider")
1537     static void getLong256VectorTests(IntFunction<long[]> fa) {
1538         long[] a = fa.apply(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                 int num_lanes = SPECIES.length();
1545                 // Manually unroll because full unroll happens after intrinsification.
1546                 // Unroll is needed because get intrinsic requires for index to be a known constant.


1718     static void negLong256VectorTests(IntFunction<long[]> fa) {
1719         long[] a = fa.apply(SPECIES.length());
1720         long[] r = fr.apply(SPECIES.length());
1721 
1722         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1723             for (int i = 0; i < a.length; i += SPECIES.length()) {
1724                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1725                 av.neg().intoArray(r, i);
1726             }
1727         }
1728 
1729         assertArraysEquals(a, r, Long256VectorTests::neg);
1730     }
1731 
1732     @Test(dataProvider = "longUnaryOpMaskProvider")
1733     static void negMaskedLong256VectorTests(IntFunction<long[]> fa,
1734                                                 IntFunction<boolean[]> fm) {
1735         long[] a = fa.apply(SPECIES.length());
1736         long[] r = fr.apply(SPECIES.length());
1737         boolean[] mask = fm.apply(SPECIES.length());
1738         Vector.Mask<Long> vmask = LongVector.maskFromValues(SPECIES, mask);
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(vmask).intoArray(r, i);
1744             }
1745         }
1746 
1747         assertArraysEquals(a, r, mask, Long256VectorTests::neg);
1748     }
1749 
1750     static long abs(long a) {
1751         return (long)(Math.abs((long)a));
1752     }
1753 
1754     @Test(dataProvider = "longUnaryOpProvider")
1755     static void absLong256VectorTests(IntFunction<long[]> fa) {
1756         long[] a = fa.apply(SPECIES.length());
1757         long[] r = fr.apply(SPECIES.length());
1758 
1759         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1760             for (int i = 0; i < a.length; i += SPECIES.length()) {
1761                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1762                 av.abs().intoArray(r, i);
1763             }
1764         }
1765 
1766         assertArraysEquals(a, r, Long256VectorTests::abs);
1767     }
1768 
1769     @Test(dataProvider = "longUnaryOpMaskProvider")
1770     static void absMaskedLong256VectorTests(IntFunction<long[]> fa,
1771                                                 IntFunction<boolean[]> fm) {
1772         long[] a = fa.apply(SPECIES.length());
1773         long[] r = fr.apply(SPECIES.length());
1774         boolean[] mask = fm.apply(SPECIES.length());
1775         Vector.Mask<Long> vmask = LongVector.maskFromValues(SPECIES, mask);
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(vmask).intoArray(r, i);
1781             }
1782         }
1783 
1784         assertArraysEquals(a, r, mask, Long256VectorTests::abs);
1785     }
1786 
1787 
1788     static long not(long a) {
1789         return (long)(~((long)a));
1790     }
1791 
1792 
1793 
1794     @Test(dataProvider = "longUnaryOpProvider")
1795     static void notLong256VectorTests(IntFunction<long[]> fa) {


1797         long[] r = fr.apply(SPECIES.length());
1798 
1799         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1800             for (int i = 0; i < a.length; i += SPECIES.length()) {
1801                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1802                 av.not().intoArray(r, i);
1803             }
1804         }
1805 
1806         assertArraysEquals(a, r, Long256VectorTests::not);
1807     }
1808 
1809 
1810 
1811     @Test(dataProvider = "longUnaryOpMaskProvider")
1812     static void notMaskedLong256VectorTests(IntFunction<long[]> fa,
1813                                                 IntFunction<boolean[]> fm) {
1814         long[] a = fa.apply(SPECIES.length());
1815         long[] r = fr.apply(SPECIES.length());
1816         boolean[] mask = fm.apply(SPECIES.length());
1817         Vector.Mask<Long> vmask = LongVector.maskFromValues(SPECIES, mask);
1818 
1819         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1820             for (int i = 0; i < a.length; i += SPECIES.length()) {
1821                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1822                 av.not(vmask).intoArray(r, i);
1823             }
1824         }
1825 
1826         assertArraysEquals(a, r, mask, Long256VectorTests::not);
1827     }
1828 
1829 
1830 
1831 
1832 
1833     static long[] gather(long a[], int ix, int[] b, int iy) {
1834         long[] res = new long[SPECIES.length()];
1835         for (int i = 0; i < SPECIES.length(); i++) {
1836             int bi = iy + i;
1837             res[i] = a[b[bi] + ix];




  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 Long256VectorTests
  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 Long256VectorTests extends AbstractVectorTest {
  52 
  53     static final VectorSpecies<Long> SPECIES =
  54                 LongVector.SPECIES_256;
  55 
  56     static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
  57 
  58     interface FUnOp {
  59         long apply(long a);
  60     }
  61 
  62     static void assertArraysEquals(long[] a, long[] r, FUnOp f) {
  63         int i = 0;
  64         try {
  65             for (; i < a.length; i++) {
  66                 Assert.assertEquals(r[i], f.apply(a[i]));
  67             }
  68         } catch (AssertionError e) {
  69             Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);
  70         }
  71     }
  72 
  73     static void assertArraysEquals(long[] a, long[] r, boolean[] mask, FUnOp f) {


 438         long[] r = fr.apply(SPECIES.length());
 439 
 440         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 441             for (int i = 0; i < a.length; i += SPECIES.length()) {
 442                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 443                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 444                 av.add(bv).intoArray(r, i);
 445             }
 446         }
 447 
 448         assertArraysEquals(a, b, r, Long256VectorTests::add);
 449     }
 450 
 451     @Test(dataProvider = "longBinaryOpMaskProvider")
 452     static void addLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 453                                           IntFunction<boolean[]> fm) {
 454         long[] a = fa.apply(SPECIES.length());
 455         long[] b = fb.apply(SPECIES.length());
 456         long[] r = fr.apply(SPECIES.length());
 457         boolean[] mask = fm.apply(SPECIES.length());
 458         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 459 
 460         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 461             for (int i = 0; i < a.length; i += SPECIES.length()) {
 462                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 463                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 464                 av.add(bv, vmask).intoArray(r, i);
 465             }
 466         }
 467 
 468         assertArraysEquals(a, b, r, mask, Long256VectorTests::add);
 469     }
 470     static long sub(long a, long b) {
 471         return (long)(a - b);
 472     }
 473 
 474     @Test(dataProvider = "longBinaryOpProvider")
 475     static void subLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 476         long[] a = fa.apply(SPECIES.length());
 477         long[] b = fb.apply(SPECIES.length());
 478         long[] r = fr.apply(SPECIES.length());
 479 
 480         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 481             for (int i = 0; i < a.length; i += SPECIES.length()) {
 482                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 483                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 484                 av.sub(bv).intoArray(r, i);
 485             }
 486         }
 487 
 488         assertArraysEquals(a, b, r, Long256VectorTests::sub);
 489     }
 490 
 491     @Test(dataProvider = "longBinaryOpMaskProvider")
 492     static void subLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 493                                           IntFunction<boolean[]> fm) {
 494         long[] a = fa.apply(SPECIES.length());
 495         long[] b = fb.apply(SPECIES.length());
 496         long[] r = fr.apply(SPECIES.length());
 497         boolean[] mask = fm.apply(SPECIES.length());
 498         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 499 
 500         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 501             for (int i = 0; i < a.length; i += SPECIES.length()) {
 502                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 503                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 504                 av.sub(bv, vmask).intoArray(r, i);
 505             }
 506         }
 507 
 508         assertArraysEquals(a, b, r, mask, Long256VectorTests::sub);
 509     }
 510 
 511 
 512     static long mul(long a, long b) {
 513         return (long)(a * b);
 514     }
 515 
 516     @Test(dataProvider = "longBinaryOpProvider")
 517     static void mulLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 518         long[] a = fa.apply(SPECIES.length());


 520         long[] r = fr.apply(SPECIES.length());
 521 
 522         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 523             for (int i = 0; i < a.length; i += SPECIES.length()) {
 524                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 525                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 526                 av.mul(bv).intoArray(r, i);
 527             }
 528         }
 529 
 530         assertArraysEquals(a, b, r, Long256VectorTests::mul);
 531     }
 532 
 533     @Test(dataProvider = "longBinaryOpMaskProvider")
 534     static void mulLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 535                                           IntFunction<boolean[]> fm) {
 536         long[] a = fa.apply(SPECIES.length());
 537         long[] b = fb.apply(SPECIES.length());
 538         long[] r = fr.apply(SPECIES.length());
 539         boolean[] mask = fm.apply(SPECIES.length());
 540         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 541 
 542         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 543             for (int i = 0; i < a.length; i += SPECIES.length()) {
 544                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 545                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 546                 av.mul(bv, vmask).intoArray(r, i);
 547             }
 548         }
 549 
 550         assertArraysEquals(a, b, r, mask, Long256VectorTests::mul);
 551     }
 552 
 553     static long and(long a, long b) {
 554         return (long)(a & b);
 555     }
 556 
 557     @Test(dataProvider = "longBinaryOpProvider")
 558     static void andLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 559         long[] a = fa.apply(SPECIES.length());
 560         long[] b = fb.apply(SPECIES.length());


 563         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 564             for (int i = 0; i < a.length; i += SPECIES.length()) {
 565                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 566                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 567                 av.and(bv).intoArray(r, i);
 568             }
 569         }
 570 
 571         assertArraysEquals(a, b, r, Long256VectorTests::and);
 572     }
 573 
 574 
 575 
 576     @Test(dataProvider = "longBinaryOpMaskProvider")
 577     static void andLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 578                                           IntFunction<boolean[]> fm) {
 579         long[] a = fa.apply(SPECIES.length());
 580         long[] b = fb.apply(SPECIES.length());
 581         long[] r = fr.apply(SPECIES.length());
 582         boolean[] mask = fm.apply(SPECIES.length());
 583         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 584 
 585         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 586             for (int i = 0; i < a.length; i += SPECIES.length()) {
 587                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 588                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 589                 av.and(bv, vmask).intoArray(r, i);
 590             }
 591         }
 592 
 593         assertArraysEquals(a, b, r, mask, Long256VectorTests::and);
 594     }
 595 
 596 
 597     static long or(long a, long b) {
 598         return (long)(a | b);
 599     }
 600 
 601     @Test(dataProvider = "longBinaryOpProvider")
 602     static void orLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 603         long[] a = fa.apply(SPECIES.length());


 607         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 608             for (int i = 0; i < a.length; i += SPECIES.length()) {
 609                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 610                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 611                 av.or(bv).intoArray(r, i);
 612             }
 613         }
 614 
 615         assertArraysEquals(a, b, r, Long256VectorTests::or);
 616     }
 617 
 618 
 619 
 620     @Test(dataProvider = "longBinaryOpMaskProvider")
 621     static void orLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 622                                           IntFunction<boolean[]> fm) {
 623         long[] a = fa.apply(SPECIES.length());
 624         long[] b = fb.apply(SPECIES.length());
 625         long[] r = fr.apply(SPECIES.length());
 626         boolean[] mask = fm.apply(SPECIES.length());
 627         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 628 
 629         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 630             for (int i = 0; i < a.length; i += SPECIES.length()) {
 631                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 632                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 633                 av.or(bv, vmask).intoArray(r, i);
 634             }
 635         }
 636 
 637         assertArraysEquals(a, b, r, mask, Long256VectorTests::or);
 638     }
 639 
 640 
 641     static long xor(long a, long b) {
 642         return (long)(a ^ b);
 643     }
 644 
 645     @Test(dataProvider = "longBinaryOpProvider")
 646     static void xorLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 647         long[] a = fa.apply(SPECIES.length());


 651         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 652             for (int i = 0; i < a.length; i += SPECIES.length()) {
 653                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 654                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 655                 av.xor(bv).intoArray(r, i);
 656             }
 657         }
 658 
 659         assertArraysEquals(a, b, r, Long256VectorTests::xor);
 660     }
 661 
 662 
 663 
 664     @Test(dataProvider = "longBinaryOpMaskProvider")
 665     static void xorLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 666                                           IntFunction<boolean[]> fm) {
 667         long[] a = fa.apply(SPECIES.length());
 668         long[] b = fb.apply(SPECIES.length());
 669         long[] r = fr.apply(SPECIES.length());
 670         boolean[] mask = fm.apply(SPECIES.length());
 671         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 672 
 673         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 674             for (int i = 0; i < a.length; i += SPECIES.length()) {
 675                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 676                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 677                 av.xor(bv, vmask).intoArray(r, i);
 678             }
 679         }
 680 
 681         assertArraysEquals(a, b, r, mask, Long256VectorTests::xor);
 682     }
 683 
 684 
 685     static long shiftR(long a, long b) {
 686         return (long)((a >>> b));
 687     }
 688 
 689     @Test(dataProvider = "longBinaryOpProvider")
 690     static void shiftRLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 691         long[] a = fa.apply(SPECIES.length());


 695         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 696             for (int i = 0; i < a.length; i += SPECIES.length()) {
 697                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 698                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 699                 av.shiftR(bv).intoArray(r, i);
 700             }
 701         }
 702 
 703         assertArraysEquals(a, b, r, Long256VectorTests::shiftR);
 704     }
 705 
 706 
 707 
 708     @Test(dataProvider = "longBinaryOpMaskProvider")
 709     static void shiftRLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 710                                           IntFunction<boolean[]> fm) {
 711         long[] a = fa.apply(SPECIES.length());
 712         long[] b = fb.apply(SPECIES.length());
 713         long[] r = fr.apply(SPECIES.length());
 714         boolean[] mask = fm.apply(SPECIES.length());
 715         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 716 
 717         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 718             for (int i = 0; i < a.length; i += SPECIES.length()) {
 719                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 720                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 721                 av.shiftR(bv, vmask).intoArray(r, i);
 722             }
 723         }
 724 
 725         assertArraysEquals(a, b, r, mask, Long256VectorTests::shiftR);
 726     }
 727 
 728 
 729     static long shiftL(long a, long b) {
 730         return (long)((a << b));
 731     }
 732 
 733     @Test(dataProvider = "longBinaryOpProvider")
 734     static void shiftLLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 735         long[] a = fa.apply(SPECIES.length());


 739         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 740             for (int i = 0; i < a.length; i += SPECIES.length()) {
 741                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 742                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 743                 av.shiftL(bv).intoArray(r, i);
 744             }
 745         }
 746 
 747         assertArraysEquals(a, b, r, Long256VectorTests::shiftL);
 748     }
 749 
 750 
 751 
 752     @Test(dataProvider = "longBinaryOpMaskProvider")
 753     static void shiftLLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 754                                           IntFunction<boolean[]> fm) {
 755         long[] a = fa.apply(SPECIES.length());
 756         long[] b = fb.apply(SPECIES.length());
 757         long[] r = fr.apply(SPECIES.length());
 758         boolean[] mask = fm.apply(SPECIES.length());
 759         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 760 
 761         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 762             for (int i = 0; i < a.length; i += SPECIES.length()) {
 763                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 764                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 765                 av.shiftL(bv, vmask).intoArray(r, i);
 766             }
 767         }
 768 
 769         assertArraysEquals(a, b, r, mask, Long256VectorTests::shiftL);
 770     }
 771 
 772 
 773     static long aShiftR(long a, long b) {
 774         return (long)((a >> b));
 775     }
 776 
 777     @Test(dataProvider = "longBinaryOpProvider")
 778     static void aShiftRLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 779         long[] a = fa.apply(SPECIES.length());


 783         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 784             for (int i = 0; i < a.length; i += SPECIES.length()) {
 785                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 786                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 787                 av.aShiftR(bv).intoArray(r, i);
 788             }
 789         }
 790 
 791         assertArraysEquals(a, b, r, Long256VectorTests::aShiftR);
 792     }
 793 
 794 
 795 
 796     @Test(dataProvider = "longBinaryOpMaskProvider")
 797     static void aShiftRLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 798                                           IntFunction<boolean[]> fm) {
 799         long[] a = fa.apply(SPECIES.length());
 800         long[] b = fb.apply(SPECIES.length());
 801         long[] r = fr.apply(SPECIES.length());
 802         boolean[] mask = fm.apply(SPECIES.length());
 803         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 804 
 805         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 806             for (int i = 0; i < a.length; i += SPECIES.length()) {
 807                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 808                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 809                 av.aShiftR(bv, vmask).intoArray(r, i);
 810             }
 811         }
 812 
 813         assertArraysEquals(a, b, r, mask, Long256VectorTests::aShiftR);
 814     }
 815 
 816 
 817     static long aShiftR_unary(long a, long b) {
 818         return (long)((a >> b));
 819     }
 820 
 821     @Test(dataProvider = "longBinaryOpProvider")
 822     static void aShiftRLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 823         long[] a = fa.apply(SPECIES.length());


 826 
 827         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 828             for (int i = 0; i < a.length; i += SPECIES.length()) {
 829                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 830                 av.aShiftR((int)b[i]).intoArray(r, i);
 831             }
 832         }
 833 
 834         assertShiftArraysEquals(a, b, r, Long256VectorTests::aShiftR_unary);
 835     }
 836 
 837 
 838 
 839     @Test(dataProvider = "longBinaryOpMaskProvider")
 840     static void aShiftRLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb,
 841                                           IntFunction<boolean[]> fm) {
 842         long[] a = fa.apply(SPECIES.length());
 843         long[] b = fb.apply(SPECIES.length());
 844         long[] r = fr.apply(SPECIES.length());
 845         boolean[] mask = fm.apply(SPECIES.length());
 846         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 847 
 848         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 849             for (int i = 0; i < a.length; i += SPECIES.length()) {
 850                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 851                 av.aShiftR((int)b[i], vmask).intoArray(r, i);
 852             }
 853         }
 854 
 855         assertShiftArraysEquals(a, b, r, mask, Long256VectorTests::aShiftR_unary);
 856     }
 857 
 858 
 859     static long shiftR_unary(long a, long b) {
 860         return (long)((a >>> b));
 861     }
 862 
 863     @Test(dataProvider = "longBinaryOpProvider")
 864     static void shiftRLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 865         long[] a = fa.apply(SPECIES.length());
 866         long[] b = fb.apply(SPECIES.length());


 868 
 869         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 870             for (int i = 0; i < a.length; i += SPECIES.length()) {
 871                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 872                 av.shiftR((int)b[i]).intoArray(r, i);
 873             }
 874         }
 875 
 876         assertShiftArraysEquals(a, b, r, Long256VectorTests::shiftR_unary);
 877     }
 878 
 879 
 880 
 881     @Test(dataProvider = "longBinaryOpMaskProvider")
 882     static void shiftRLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb,
 883                                           IntFunction<boolean[]> fm) {
 884         long[] a = fa.apply(SPECIES.length());
 885         long[] b = fb.apply(SPECIES.length());
 886         long[] r = fr.apply(SPECIES.length());
 887         boolean[] mask = fm.apply(SPECIES.length());
 888         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 889 
 890         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 891             for (int i = 0; i < a.length; i += SPECIES.length()) {
 892                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 893                 av.shiftR((int)b[i], vmask).intoArray(r, i);
 894             }
 895         }
 896 
 897         assertShiftArraysEquals(a, b, r, mask, Long256VectorTests::shiftR_unary);
 898     }
 899 
 900 
 901     static long shiftL_unary(long a, long b) {
 902         return (long)((a << b));
 903     }
 904 
 905     @Test(dataProvider = "longBinaryOpProvider")
 906     static void shiftLLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 907         long[] a = fa.apply(SPECIES.length());
 908         long[] b = fb.apply(SPECIES.length());


 910 
 911         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 912             for (int i = 0; i < a.length; i += SPECIES.length()) {
 913                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 914                 av.shiftL((int)b[i]).intoArray(r, i);
 915             }
 916         }
 917 
 918         assertShiftArraysEquals(a, b, r, Long256VectorTests::shiftL_unary);
 919     }
 920 
 921 
 922 
 923     @Test(dataProvider = "longBinaryOpMaskProvider")
 924     static void shiftLLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb,
 925                                           IntFunction<boolean[]> fm) {
 926         long[] a = fa.apply(SPECIES.length());
 927         long[] b = fb.apply(SPECIES.length());
 928         long[] r = fr.apply(SPECIES.length());
 929         boolean[] mask = fm.apply(SPECIES.length());
 930         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 931 
 932         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 933             for (int i = 0; i < a.length; i += SPECIES.length()) {
 934                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 935                 av.shiftL((int)b[i], vmask).intoArray(r, i);
 936             }
 937         }
 938 
 939         assertShiftArraysEquals(a, b, r, mask, Long256VectorTests::shiftL_unary);
 940     }
 941 
 942 
 943 
 944 
 945 
 946 
 947 
 948 
 949 
 950 


1304         assertReductionArraysEquals(a, r, ra, Long256VectorTests::maxAll, Long256VectorTests::maxAll);
1305     }
1306 
1307     static boolean anyTrue(boolean[] a, int idx) {
1308         boolean res = false;
1309         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1310             res |= a[i];
1311         }
1312 
1313         return res;
1314     }
1315 
1316 
1317     @Test(dataProvider = "boolUnaryOpProvider")
1318     static void anyTrueLong256VectorTests(IntFunction<boolean[]> fm) {
1319         boolean[] mask = fm.apply(SPECIES.length());
1320         boolean[] r = fmr.apply(SPECIES.length());
1321 
1322         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1323             for (int i = 0; i < mask.length; i += SPECIES.length()) {
1324                 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, i);
1325                 r[i] = vmask.anyTrue();
1326             }
1327         }
1328 
1329         assertReductionBoolArraysEquals(mask, r, Long256VectorTests::anyTrue);
1330     }
1331 
1332 
1333     static boolean allTrue(boolean[] a, int idx) {
1334         boolean res = true;
1335         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1336             res &= a[i];
1337         }
1338 
1339         return res;
1340     }
1341 
1342 
1343     @Test(dataProvider = "boolUnaryOpProvider")
1344     static void allTrueLong256VectorTests(IntFunction<boolean[]> fm) {
1345         boolean[] mask = fm.apply(SPECIES.length());
1346         boolean[] r = fmr.apply(SPECIES.length());
1347 
1348         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1349             for (int i = 0; i < mask.length; i += SPECIES.length()) {
1350                 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, i);
1351                 r[i] = vmask.allTrue();
1352             }
1353         }
1354 
1355         assertReductionBoolArraysEquals(mask, r, Long256VectorTests::allTrue);
1356     }
1357 
1358 
1359     @Test(dataProvider = "longUnaryOpProvider")
1360     static void withLong256VectorTests(IntFunction<long []> fa) {
1361         long[] a = fa.apply(SPECIES.length());
1362         long[] r = fr.apply(SPECIES.length());
1363 
1364         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1365             for (int i = 0; i < a.length; i += SPECIES.length()) {
1366                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1367                 av.with(0, (long)4).intoArray(r, i);
1368             }
1369         }
1370 
1371         assertInsertArraysEquals(a, r, (long)4, 0);
1372     }
1373 
1374     @Test(dataProvider = "longCompareOpProvider")
1375     static void lessThanLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1376         long[] a = fa.apply(SPECIES.length());
1377         long[] b = fb.apply(SPECIES.length());
1378 
1379         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1380             for (int i = 0; i < a.length; i += SPECIES.length()) {
1381                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1382                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1383                 VectorMask<Long> mv = av.lessThan(bv);
1384 
1385                 // Check results as part of computation.
1386                 for (int j = 0; j < SPECIES.length(); j++) {
1387                     Assert.assertEquals(mv.getElement(j), a[i + j] < b[i + j]);
1388                 }
1389             }
1390         }
1391     }
1392 
1393 
1394     @Test(dataProvider = "longCompareOpProvider")
1395     static void greaterThanLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1396         long[] a = fa.apply(SPECIES.length());
1397         long[] b = fb.apply(SPECIES.length());
1398 
1399         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1400             for (int i = 0; i < a.length; i += SPECIES.length()) {
1401                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1402                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1403                 VectorMask<Long> mv = av.greaterThan(bv);
1404 
1405                 // Check results as part of computation.
1406                 for (int j = 0; j < SPECIES.length(); j++) {
1407                     Assert.assertEquals(mv.getElement(j), a[i + j] > b[i + j]);
1408                 }
1409             }
1410         }
1411     }
1412 
1413 
1414     @Test(dataProvider = "longCompareOpProvider")
1415     static void equalLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1416         long[] a = fa.apply(SPECIES.length());
1417         long[] b = fb.apply(SPECIES.length());
1418 
1419         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1420             for (int i = 0; i < a.length; i += SPECIES.length()) {
1421                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1422                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1423                 VectorMask<Long> mv = av.equal(bv);
1424 
1425                 // Check results as part of computation.
1426                 for (int j = 0; j < SPECIES.length(); j++) {
1427                     Assert.assertEquals(mv.getElement(j), a[i + j] == b[i + j]);
1428                 }
1429             }
1430         }
1431     }
1432 
1433 
1434     @Test(dataProvider = "longCompareOpProvider")
1435     static void notEqualLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1436         long[] a = fa.apply(SPECIES.length());
1437         long[] b = fb.apply(SPECIES.length());
1438 
1439         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1440             for (int i = 0; i < a.length; i += SPECIES.length()) {
1441                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1442                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1443                 VectorMask<Long> mv = av.notEqual(bv);
1444 
1445                 // Check results as part of computation.
1446                 for (int j = 0; j < SPECIES.length(); j++) {
1447                     Assert.assertEquals(mv.getElement(j), a[i + j] != b[i + j]);
1448                 }
1449             }
1450         }
1451     }
1452 
1453 
1454     @Test(dataProvider = "longCompareOpProvider")
1455     static void lessThanEqLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1456         long[] a = fa.apply(SPECIES.length());
1457         long[] b = fb.apply(SPECIES.length());
1458 
1459         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1460             for (int i = 0; i < a.length; i += SPECIES.length()) {
1461                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1462                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1463                 VectorMask<Long> mv = av.lessThanEq(bv);
1464 
1465                 // Check results as part of computation.
1466                 for (int j = 0; j < SPECIES.length(); j++) {
1467                     Assert.assertEquals(mv.getElement(j), a[i + j] <= b[i + j]);
1468                 }
1469             }
1470         }
1471     }
1472 
1473 
1474     @Test(dataProvider = "longCompareOpProvider")
1475     static void greaterThanEqLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1476         long[] a = fa.apply(SPECIES.length());
1477         long[] b = fb.apply(SPECIES.length());
1478 
1479         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1480             for (int i = 0; i < a.length; i += SPECIES.length()) {
1481                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1482                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1483                 VectorMask<Long> mv = av.greaterThanEq(bv);
1484 
1485                 // Check results as part of computation.
1486                 for (int j = 0; j < SPECIES.length(); j++) {
1487                     Assert.assertEquals(mv.getElement(j), a[i + j] >= b[i + j]);
1488                 }
1489             }
1490         }
1491     }
1492 
1493 
1494     static long blend(long a, long b, boolean mask) {
1495         return mask ? b : a;
1496     }
1497 
1498     @Test(dataProvider = "longBinaryOpMaskProvider")
1499     static void blendLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
1500                                           IntFunction<boolean[]> fm) {
1501         long[] a = fa.apply(SPECIES.length());
1502         long[] b = fb.apply(SPECIES.length());
1503         long[] r = fr.apply(SPECIES.length());
1504         boolean[] mask = fm.apply(SPECIES.length());
1505         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
1506 
1507         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1508             for (int i = 0; i < a.length; i += SPECIES.length()) {
1509                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1510                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1511                 av.blend(bv, vmask).intoArray(r, i);
1512             }
1513         }
1514 
1515         assertArraysEquals(a, b, r, mask, Long256VectorTests::blend);
1516     }
1517 
1518     @Test(dataProvider = "longUnaryOpShuffleProvider")
1519     static void RearrangeLong256VectorTests(IntFunction<long[]> fa,
1520                                            BiFunction<Integer,Integer,int[]> fs) {
1521         long[] a = fa.apply(SPECIES.length());
1522         int[] order = fs.apply(a.length, SPECIES.length());
1523         long[] r = fr.apply(SPECIES.length());
1524 
1525         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1526             for (int i = 0; i < a.length; i += SPECIES.length()) {
1527                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1528                 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);
1529             }
1530         }
1531 
1532         assertRearrangeArraysEquals(a, r, order, SPECIES.length());
1533     }
1534 
1535 
1536 
1537 
1538     @Test(dataProvider = "longUnaryOpProvider")
1539     static void getLong256VectorTests(IntFunction<long[]> fa) {
1540         long[] a = fa.apply(SPECIES.length());
1541         long[] r = fr.apply(SPECIES.length());
1542 
1543         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1544             for (int i = 0; i < a.length; i += SPECIES.length()) {
1545                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1546                 int num_lanes = SPECIES.length();
1547                 // Manually unroll because full unroll happens after intrinsification.
1548                 // Unroll is needed because get intrinsic requires for index to be a known constant.


1720     static void negLong256VectorTests(IntFunction<long[]> fa) {
1721         long[] a = fa.apply(SPECIES.length());
1722         long[] r = fr.apply(SPECIES.length());
1723 
1724         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1725             for (int i = 0; i < a.length; i += SPECIES.length()) {
1726                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1727                 av.neg().intoArray(r, i);
1728             }
1729         }
1730 
1731         assertArraysEquals(a, r, Long256VectorTests::neg);
1732     }
1733 
1734     @Test(dataProvider = "longUnaryOpMaskProvider")
1735     static void negMaskedLong256VectorTests(IntFunction<long[]> fa,
1736                                                 IntFunction<boolean[]> fm) {
1737         long[] a = fa.apply(SPECIES.length());
1738         long[] r = fr.apply(SPECIES.length());
1739         boolean[] mask = fm.apply(SPECIES.length());
1740         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
1741 
1742         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1743             for (int i = 0; i < a.length; i += SPECIES.length()) {
1744                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1745                 av.neg(vmask).intoArray(r, i);
1746             }
1747         }
1748 
1749         assertArraysEquals(a, r, mask, Long256VectorTests::neg);
1750     }
1751 
1752     static long abs(long a) {
1753         return (long)(Math.abs((long)a));
1754     }
1755 
1756     @Test(dataProvider = "longUnaryOpProvider")
1757     static void absLong256VectorTests(IntFunction<long[]> fa) {
1758         long[] a = fa.apply(SPECIES.length());
1759         long[] r = fr.apply(SPECIES.length());
1760 
1761         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1762             for (int i = 0; i < a.length; i += SPECIES.length()) {
1763                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1764                 av.abs().intoArray(r, i);
1765             }
1766         }
1767 
1768         assertArraysEquals(a, r, Long256VectorTests::abs);
1769     }
1770 
1771     @Test(dataProvider = "longUnaryOpMaskProvider")
1772     static void absMaskedLong256VectorTests(IntFunction<long[]> fa,
1773                                                 IntFunction<boolean[]> fm) {
1774         long[] a = fa.apply(SPECIES.length());
1775         long[] r = fr.apply(SPECIES.length());
1776         boolean[] mask = fm.apply(SPECIES.length());
1777         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
1778 
1779         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1780             for (int i = 0; i < a.length; i += SPECIES.length()) {
1781                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1782                 av.abs(vmask).intoArray(r, i);
1783             }
1784         }
1785 
1786         assertArraysEquals(a, r, mask, Long256VectorTests::abs);
1787     }
1788 
1789 
1790     static long not(long a) {
1791         return (long)(~((long)a));
1792     }
1793 
1794 
1795 
1796     @Test(dataProvider = "longUnaryOpProvider")
1797     static void notLong256VectorTests(IntFunction<long[]> fa) {


1799         long[] r = fr.apply(SPECIES.length());
1800 
1801         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1802             for (int i = 0; i < a.length; i += SPECIES.length()) {
1803                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1804                 av.not().intoArray(r, i);
1805             }
1806         }
1807 
1808         assertArraysEquals(a, r, Long256VectorTests::not);
1809     }
1810 
1811 
1812 
1813     @Test(dataProvider = "longUnaryOpMaskProvider")
1814     static void notMaskedLong256VectorTests(IntFunction<long[]> fa,
1815                                                 IntFunction<boolean[]> fm) {
1816         long[] a = fa.apply(SPECIES.length());
1817         long[] r = fr.apply(SPECIES.length());
1818         boolean[] mask = fm.apply(SPECIES.length());
1819         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
1820 
1821         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1822             for (int i = 0; i < a.length; i += SPECIES.length()) {
1823                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1824                 av.not(vmask).intoArray(r, i);
1825             }
1826         }
1827 
1828         assertArraysEquals(a, r, mask, Long256VectorTests::not);
1829     }
1830 
1831 
1832 
1833 
1834 
1835     static long[] gather(long a[], int ix, int[] b, int iy) {
1836         long[] res = new long[SPECIES.length()];
1837         for (int i = 0; i < SPECIES.length(); i++) {
1838             int bi = iy + i;
1839             res[i] = a[b[bi] + ix];


< prev index next >