< prev index next >

test/jdk/jdk/incubator/vector/Double128VectorTests.java

Print this page
rev 55894 : 8222897: [vector] Renaming of shift, rotate operations. Few other api changes.
Summary: Renaming of shift, rotate operations. Few other api changes.
Reviewed-by: jrose, briangoetz


 713 
 714 
 715 
 716 
 717 
 718 
 719 
 720 
 721 
 722 
 723 
 724 
 725 
 726 
 727 
 728 
 729 
 730 
 731 
 732 












 733     static double max(double a, double b) {
 734         return (double)(Math.max(a, b));
 735     }
 736 
 737     @Test(dataProvider = "doubleBinaryOpProvider")
 738     static void maxDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
 739         double[] a = fa.apply(SPECIES.length());
 740         double[] b = fb.apply(SPECIES.length());
 741         double[] r = fr.apply(SPECIES.length());
 742 
 743         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 744             for (int i = 0; i < a.length; i += SPECIES.length()) {
 745                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 746                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 747                 av.max(bv).intoArray(r, i);
 748             }
 749         }
 750 
 751         assertArraysEquals(a, b, r, Double128VectorTests::max);
 752     }


 759         double[] a = fa.apply(SPECIES.length());
 760         double[] b = fb.apply(SPECIES.length());
 761         double[] r = fr.apply(SPECIES.length());
 762 
 763         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 764             for (int i = 0; i < a.length; i += SPECIES.length()) {
 765                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 766                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 767                 av.min(bv).intoArray(r, i);
 768             }
 769         }
 770 
 771         assertArraysEquals(a, b, r, Double128VectorTests::min);
 772     }
 773 
 774 
 775 
 776 
 777 
 778 
 779     static double addAll(double[] a, int idx) {
 780         double res = 0;
 781         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 782             res += a[i];
 783         }
 784 
 785         return res;
 786     }
 787 
 788     static double addAll(double[] a) {
 789         double res = 0;
 790         for (int i = 0; i < a.length; i += SPECIES.length()) {
 791             double tmp = 0;
 792             for (int j = 0; j < SPECIES.length(); j++) {
 793                 tmp += a[i + j];
 794             }
 795             res += tmp;
 796         }
 797 
 798         return res;
 799     }
 800     @Test(dataProvider = "doubleUnaryOpProvider")
 801     static void addAllDouble128VectorTests(IntFunction<double[]> fa) {
 802         double[] a = fa.apply(SPECIES.length());
 803         double[] r = fr.apply(SPECIES.length());
 804         double ra = 0;
 805 
 806         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 807             for (int i = 0; i < a.length; i += SPECIES.length()) {
 808                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 809                 r[i] = av.addAll();
 810             }
 811         }
 812 
 813         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 814             ra = 0;
 815             for (int i = 0; i < a.length; i += SPECIES.length()) {
 816                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 817                 ra += av.addAll();
 818             }
 819         }
 820 
 821         assertReductionArraysEquals(a, r, ra, Double128VectorTests::addAll, Double128VectorTests::addAll);
 822     }
 823     static double mulAll(double[] a, int idx) {
 824         double res = 1;
 825         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 826             res *= a[i];
 827         }
 828 
 829         return res;
 830     }
 831 
 832     static double mulAll(double[] a) {
 833         double res = 1;
 834         for (int i = 0; i < a.length; i += SPECIES.length()) {
 835             double tmp = 1;
 836             for (int j = 0; j < SPECIES.length(); j++) {
 837                 tmp *= a[i + j];
 838             }
 839             res *= tmp;
 840         }
 841 
 842         return res;
 843     }
 844     @Test(dataProvider = "doubleUnaryOpProvider")
 845     static void mulAllDouble128VectorTests(IntFunction<double[]> fa) {
 846         double[] a = fa.apply(SPECIES.length());
 847         double[] r = fr.apply(SPECIES.length());
 848         double ra = 1;
 849 
 850         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 851             for (int i = 0; i < a.length; i += SPECIES.length()) {
 852                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 853                 r[i] = av.mulAll();
 854             }
 855         }
 856 
 857         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 858             ra = 1;
 859             for (int i = 0; i < a.length; i += SPECIES.length()) {
 860                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 861                 ra *= av.mulAll();
 862             }
 863         }
 864 
 865         assertReductionArraysEquals(a, r, ra, Double128VectorTests::mulAll, Double128VectorTests::mulAll);
 866     }
 867     static double minAll(double[] a, int idx) {
 868         double res = Double.POSITIVE_INFINITY;
 869         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 870             res = (double)Math.min(res, a[i]);
 871         }
 872 
 873         return res;
 874     }
 875 
 876     static double minAll(double[] a) {
 877         double res = Double.POSITIVE_INFINITY;
 878         for (int i = 0; i < a.length; i++) {
 879             res = (double)Math.min(res, a[i]);
 880         }
 881 
 882         return res;
 883     }
 884     @Test(dataProvider = "doubleUnaryOpProvider")
 885     static void minAllDouble128VectorTests(IntFunction<double[]> fa) {
 886         double[] a = fa.apply(SPECIES.length());
 887         double[] r = fr.apply(SPECIES.length());
 888         double ra = Double.POSITIVE_INFINITY;
 889 
 890         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 891             for (int i = 0; i < a.length; i += SPECIES.length()) {
 892                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 893                 r[i] = av.minAll();
 894             }
 895         }
 896 
 897         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 898             ra = Double.POSITIVE_INFINITY;
 899             for (int i = 0; i < a.length; i += SPECIES.length()) {
 900                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 901                 ra = (double)Math.min(ra, av.minAll());
 902             }
 903         }
 904 
 905         assertReductionArraysEquals(a, r, ra, Double128VectorTests::minAll, Double128VectorTests::minAll);
 906     }
 907     static double maxAll(double[] a, int idx) {
 908         double res = Double.NEGATIVE_INFINITY;
 909         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 910             res = (double)Math.max(res, a[i]);
 911         }
 912 
 913         return res;
 914     }
 915 
 916     static double maxAll(double[] a) {
 917         double res = Double.NEGATIVE_INFINITY;
 918         for (int i = 0; i < a.length; i++) {
 919             res = (double)Math.max(res, a[i]);
 920         }
 921 
 922         return res;
 923     }
 924     @Test(dataProvider = "doubleUnaryOpProvider")
 925     static void maxAllDouble128VectorTests(IntFunction<double[]> fa) {
 926         double[] a = fa.apply(SPECIES.length());
 927         double[] r = fr.apply(SPECIES.length());
 928         double ra = Double.NEGATIVE_INFINITY;
 929 
 930         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 931             for (int i = 0; i < a.length; i += SPECIES.length()) {
 932                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 933                 r[i] = av.maxAll();
 934             }
 935         }
 936 
 937         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 938             ra = Double.NEGATIVE_INFINITY;
 939             for (int i = 0; i < a.length; i += SPECIES.length()) {
 940                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 941                 ra = (double)Math.max(ra, av.maxAll());
 942             }
 943         }
 944 
 945         assertReductionArraysEquals(a, r, ra, Double128VectorTests::maxAll, Double128VectorTests::maxAll);
 946     }
 947 
 948 
 949 
 950 
 951 
 952     @Test(dataProvider = "doubleUnaryOpProvider")
 953     static void withDouble128VectorTests(IntFunction<double []> fa) {
 954         double[] a = fa.apply(SPECIES.length());
 955         double[] r = fr.apply(SPECIES.length());
 956 
 957         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 958             for (int i = 0; i < a.length; i += SPECIES.length()) {
 959                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 960                 av.with(0, (double)4).intoArray(r, i);
 961             }
 962         }
 963 
 964         assertInsertArraysEquals(a, r, (double)4, 0);
 965     }




 713 
 714 
 715 
 716 
 717 
 718 
 719 
 720 
 721 
 722 
 723 
 724 
 725 
 726 
 727 
 728 
 729 
 730 
 731 
 732 
 733 
 734 
 735 
 736 
 737 
 738 
 739 
 740 
 741 
 742 
 743 
 744 
 745     static double max(double a, double b) {
 746         return (double)(Math.max(a, b));
 747     }
 748 
 749     @Test(dataProvider = "doubleBinaryOpProvider")
 750     static void maxDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
 751         double[] a = fa.apply(SPECIES.length());
 752         double[] b = fb.apply(SPECIES.length());
 753         double[] r = fr.apply(SPECIES.length());
 754 
 755         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 756             for (int i = 0; i < a.length; i += SPECIES.length()) {
 757                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 758                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 759                 av.max(bv).intoArray(r, i);
 760             }
 761         }
 762 
 763         assertArraysEquals(a, b, r, Double128VectorTests::max);
 764     }


 771         double[] a = fa.apply(SPECIES.length());
 772         double[] b = fb.apply(SPECIES.length());
 773         double[] r = fr.apply(SPECIES.length());
 774 
 775         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 776             for (int i = 0; i < a.length; i += SPECIES.length()) {
 777                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 778                 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
 779                 av.min(bv).intoArray(r, i);
 780             }
 781         }
 782 
 783         assertArraysEquals(a, b, r, Double128VectorTests::min);
 784     }
 785 
 786 
 787 
 788 
 789 
 790 
 791     static double addLanes(double[] a, int idx) {
 792         double res = 0;
 793         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 794             res += a[i];
 795         }
 796 
 797         return res;
 798     }
 799 
 800     static double addLanes(double[] a) {
 801         double res = 0;
 802         for (int i = 0; i < a.length; i += SPECIES.length()) {
 803             double tmp = 0;
 804             for (int j = 0; j < SPECIES.length(); j++) {
 805                 tmp += a[i + j];
 806             }
 807             res += tmp;
 808         }
 809 
 810         return res;
 811     }
 812     @Test(dataProvider = "doubleUnaryOpProvider")
 813     static void addLanesDouble128VectorTests(IntFunction<double[]> fa) {
 814         double[] a = fa.apply(SPECIES.length());
 815         double[] r = fr.apply(SPECIES.length());
 816         double ra = 0;
 817 
 818         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 819             for (int i = 0; i < a.length; i += SPECIES.length()) {
 820                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 821                 r[i] = av.addLanes();
 822             }
 823         }
 824 
 825         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 826             ra = 0;
 827             for (int i = 0; i < a.length; i += SPECIES.length()) {
 828                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 829                 ra += av.addLanes();
 830             }
 831         }
 832 
 833         assertReductionArraysEquals(a, r, ra, Double128VectorTests::addLanes, Double128VectorTests::addLanes);
 834     }
 835     static double mulLanes(double[] a, int idx) {
 836         double res = 1;
 837         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 838             res *= a[i];
 839         }
 840 
 841         return res;
 842     }
 843 
 844     static double mulLanes(double[] a) {
 845         double res = 1;
 846         for (int i = 0; i < a.length; i += SPECIES.length()) {
 847             double tmp = 1;
 848             for (int j = 0; j < SPECIES.length(); j++) {
 849                 tmp *= a[i + j];
 850             }
 851             res *= tmp;
 852         }
 853 
 854         return res;
 855     }
 856     @Test(dataProvider = "doubleUnaryOpProvider")
 857     static void mulLanesDouble128VectorTests(IntFunction<double[]> fa) {
 858         double[] a = fa.apply(SPECIES.length());
 859         double[] r = fr.apply(SPECIES.length());
 860         double ra = 1;
 861 
 862         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 863             for (int i = 0; i < a.length; i += SPECIES.length()) {
 864                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 865                 r[i] = av.mulLanes();
 866             }
 867         }
 868 
 869         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 870             ra = 1;
 871             for (int i = 0; i < a.length; i += SPECIES.length()) {
 872                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 873                 ra *= av.mulLanes();
 874             }
 875         }
 876 
 877         assertReductionArraysEquals(a, r, ra, Double128VectorTests::mulLanes, Double128VectorTests::mulLanes);
 878     }
 879     static double minLanes(double[] a, int idx) {
 880         double res = Double.POSITIVE_INFINITY;
 881         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 882             res = (double)Math.min(res, a[i]);
 883         }
 884 
 885         return res;
 886     }
 887 
 888     static double minLanes(double[] a) {
 889         double res = Double.POSITIVE_INFINITY;
 890         for (int i = 0; i < a.length; i++) {
 891             res = (double)Math.min(res, a[i]);
 892         }
 893 
 894         return res;
 895     }
 896     @Test(dataProvider = "doubleUnaryOpProvider")
 897     static void minLanesDouble128VectorTests(IntFunction<double[]> fa) {
 898         double[] a = fa.apply(SPECIES.length());
 899         double[] r = fr.apply(SPECIES.length());
 900         double ra = Double.POSITIVE_INFINITY;
 901 
 902         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 903             for (int i = 0; i < a.length; i += SPECIES.length()) {
 904                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 905                 r[i] = av.minLanes();
 906             }
 907         }
 908 
 909         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 910             ra = Double.POSITIVE_INFINITY;
 911             for (int i = 0; i < a.length; i += SPECIES.length()) {
 912                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 913                 ra = (double)Math.min(ra, av.minLanes());
 914             }
 915         }
 916 
 917         assertReductionArraysEquals(a, r, ra, Double128VectorTests::minLanes, Double128VectorTests::minLanes);
 918     }
 919     static double maxLanes(double[] a, int idx) {
 920         double res = Double.NEGATIVE_INFINITY;
 921         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 922             res = (double)Math.max(res, a[i]);
 923         }
 924 
 925         return res;
 926     }
 927 
 928     static double maxLanes(double[] a) {
 929         double res = Double.NEGATIVE_INFINITY;
 930         for (int i = 0; i < a.length; i++) {
 931             res = (double)Math.max(res, a[i]);
 932         }
 933 
 934         return res;
 935     }
 936     @Test(dataProvider = "doubleUnaryOpProvider")
 937     static void maxLanesDouble128VectorTests(IntFunction<double[]> fa) {
 938         double[] a = fa.apply(SPECIES.length());
 939         double[] r = fr.apply(SPECIES.length());
 940         double ra = Double.NEGATIVE_INFINITY;
 941 
 942         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 943             for (int i = 0; i < a.length; i += SPECIES.length()) {
 944                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 945                 r[i] = av.maxLanes();
 946             }
 947         }
 948 
 949         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 950             ra = Double.NEGATIVE_INFINITY;
 951             for (int i = 0; i < a.length; i += SPECIES.length()) {
 952                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 953                 ra = (double)Math.max(ra, av.maxLanes());
 954             }
 955         }
 956 
 957         assertReductionArraysEquals(a, r, ra, Double128VectorTests::maxLanes, Double128VectorTests::maxLanes);
 958     }
 959 
 960 
 961 
 962 
 963 
 964     @Test(dataProvider = "doubleUnaryOpProvider")
 965     static void withDouble128VectorTests(IntFunction<double []> fa) {
 966         double[] a = fa.apply(SPECIES.length());
 967         double[] r = fr.apply(SPECIES.length());
 968 
 969         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 970             for (int i = 0; i < a.length; i += SPECIES.length()) {
 971                 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
 972                 av.with(0, (double)4).intoArray(r, i);
 973             }
 974         }
 975 
 976         assertInsertArraysEquals(a, r, (double)4, 0);
 977     }


< prev index next >