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 Double256VectorTests
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.DoubleVector;
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 Double256VectorTests extends AbstractVectorTest {
50
51 static final Species<Double> SPECIES =
52 DoubleVector.SPECIES_256;
53
54 static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
55
56 interface FUnOp {
57 double apply(double a);
58 }
59
60 static void assertArraysEquals(double[] a, double[] 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(double[] a, double[] r, boolean[] mask, FUnOp f) {
545 double[] r = fr.apply(SPECIES.length());
546
547 for (int ic = 0; ic < INVOC_COUNT; ic++) {
548 for (int i = 0; i < a.length; i += SPECIES.length()) {
549 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
550 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
551 av.add(bv).intoArray(r, i);
552 }
553 }
554
555 assertArraysEquals(a, b, r, Double256VectorTests::add);
556 }
557
558 @Test(dataProvider = "doubleBinaryOpMaskProvider")
559 static void addDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
560 IntFunction<boolean[]> fm) {
561 double[] a = fa.apply(SPECIES.length());
562 double[] b = fb.apply(SPECIES.length());
563 double[] r = fr.apply(SPECIES.length());
564 boolean[] mask = fm.apply(SPECIES.length());
565 Vector.Mask<Double> vmask = DoubleVector.maskFromValues(SPECIES, mask);
566
567 for (int ic = 0; ic < INVOC_COUNT; ic++) {
568 for (int i = 0; i < a.length; i += SPECIES.length()) {
569 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
570 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
571 av.add(bv, vmask).intoArray(r, i);
572 }
573 }
574
575 assertArraysEquals(a, b, r, mask, Double256VectorTests::add);
576 }
577 static double sub(double a, double b) {
578 return (double)(a - b);
579 }
580
581 @Test(dataProvider = "doubleBinaryOpProvider")
582 static void subDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
583 double[] a = fa.apply(SPECIES.length());
584 double[] b = fb.apply(SPECIES.length());
585 double[] r = fr.apply(SPECIES.length());
586
587 for (int ic = 0; ic < INVOC_COUNT; ic++) {
588 for (int i = 0; i < a.length; i += SPECIES.length()) {
589 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
590 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
591 av.sub(bv).intoArray(r, i);
592 }
593 }
594
595 assertArraysEquals(a, b, r, Double256VectorTests::sub);
596 }
597
598 @Test(dataProvider = "doubleBinaryOpMaskProvider")
599 static void subDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
600 IntFunction<boolean[]> fm) {
601 double[] a = fa.apply(SPECIES.length());
602 double[] b = fb.apply(SPECIES.length());
603 double[] r = fr.apply(SPECIES.length());
604 boolean[] mask = fm.apply(SPECIES.length());
605 Vector.Mask<Double> vmask = DoubleVector.maskFromValues(SPECIES, mask);
606
607 for (int ic = 0; ic < INVOC_COUNT; ic++) {
608 for (int i = 0; i < a.length; i += SPECIES.length()) {
609 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
610 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
611 av.sub(bv, vmask).intoArray(r, i);
612 }
613 }
614
615 assertArraysEquals(a, b, r, mask, Double256VectorTests::sub);
616 }
617
618 static double div(double a, double b) {
619 return (double)(a / b);
620 }
621
622 @Test(dataProvider = "doubleBinaryOpProvider")
623 static void divDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
624 double[] a = fa.apply(SPECIES.length());
625 double[] b = fb.apply(SPECIES.length());
628 for (int ic = 0; ic < INVOC_COUNT; ic++) {
629 for (int i = 0; i < a.length; i += SPECIES.length()) {
630 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
631 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
632 av.div(bv).intoArray(r, i);
633 }
634 }
635
636 assertArraysEquals(a, b, r, Double256VectorTests::div);
637 }
638
639
640
641 @Test(dataProvider = "doubleBinaryOpMaskProvider")
642 static void divDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
643 IntFunction<boolean[]> fm) {
644 double[] a = fa.apply(SPECIES.length());
645 double[] b = fb.apply(SPECIES.length());
646 double[] r = fr.apply(SPECIES.length());
647 boolean[] mask = fm.apply(SPECIES.length());
648 Vector.Mask<Double> vmask = DoubleVector.maskFromValues(SPECIES, mask);
649
650 for (int ic = 0; ic < INVOC_COUNT; ic++) {
651 for (int i = 0; i < a.length; i += SPECIES.length()) {
652 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
653 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
654 av.div(bv, vmask).intoArray(r, i);
655 }
656 }
657
658 assertArraysEquals(a, b, r, mask, Double256VectorTests::div);
659 }
660
661 static double mul(double a, double b) {
662 return (double)(a * b);
663 }
664
665 @Test(dataProvider = "doubleBinaryOpProvider")
666 static void mulDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
667 double[] a = fa.apply(SPECIES.length());
668 double[] b = fb.apply(SPECIES.length());
669 double[] r = fr.apply(SPECIES.length());
670
671 for (int ic = 0; ic < INVOC_COUNT; ic++) {
672 for (int i = 0; i < a.length; i += SPECIES.length()) {
673 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
674 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
675 av.mul(bv).intoArray(r, i);
676 }
677 }
678
679 assertArraysEquals(a, b, r, Double256VectorTests::mul);
680 }
681
682 @Test(dataProvider = "doubleBinaryOpMaskProvider")
683 static void mulDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
684 IntFunction<boolean[]> fm) {
685 double[] a = fa.apply(SPECIES.length());
686 double[] b = fb.apply(SPECIES.length());
687 double[] r = fr.apply(SPECIES.length());
688 boolean[] mask = fm.apply(SPECIES.length());
689 Vector.Mask<Double> vmask = DoubleVector.maskFromValues(SPECIES, mask);
690
691 for (int ic = 0; ic < INVOC_COUNT; ic++) {
692 for (int i = 0; i < a.length; i += SPECIES.length()) {
693 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
694 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
695 av.mul(bv, vmask).intoArray(r, i);
696 }
697 }
698
699 assertArraysEquals(a, b, r, mask, Double256VectorTests::mul);
700 }
701
702
703
704
705
706
707
708
709
954
955 for (int ic = 0; ic < INVOC_COUNT; ic++) {
956 for (int i = 0; i < a.length; i += SPECIES.length()) {
957 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
958 av.with(0, (double)4).intoArray(r, i);
959 }
960 }
961
962 assertInsertArraysEquals(a, r, (double)4, 0);
963 }
964
965 @Test(dataProvider = "doubleCompareOpProvider")
966 static void lessThanDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
967 double[] a = fa.apply(SPECIES.length());
968 double[] b = fb.apply(SPECIES.length());
969
970 for (int ic = 0; ic < INVOC_COUNT; ic++) {
971 for (int i = 0; i < a.length; i += SPECIES.length()) {
972 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
973 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
974 Vector.Mask<Double> mv = av.lessThan(bv);
975
976 // Check results as part of computation.
977 for (int j = 0; j < SPECIES.length(); j++) {
978 Assert.assertEquals(mv.getElement(j), a[i + j] < b[i + j]);
979 }
980 }
981 }
982 }
983
984
985 @Test(dataProvider = "doubleCompareOpProvider")
986 static void greaterThanDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
987 double[] a = fa.apply(SPECIES.length());
988 double[] b = fb.apply(SPECIES.length());
989
990 for (int ic = 0; ic < INVOC_COUNT; ic++) {
991 for (int i = 0; i < a.length; i += SPECIES.length()) {
992 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
993 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
994 Vector.Mask<Double> mv = av.greaterThan(bv);
995
996 // Check results as part of computation.
997 for (int j = 0; j < SPECIES.length(); j++) {
998 Assert.assertEquals(mv.getElement(j), a[i + j] > b[i + j]);
999 }
1000 }
1001 }
1002 }
1003
1004
1005 @Test(dataProvider = "doubleCompareOpProvider")
1006 static void equalDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1007 double[] a = fa.apply(SPECIES.length());
1008 double[] b = fb.apply(SPECIES.length());
1009
1010 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1011 for (int i = 0; i < a.length; i += SPECIES.length()) {
1012 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1013 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1014 Vector.Mask<Double> mv = av.equal(bv);
1015
1016 // Check results as part of computation.
1017 for (int j = 0; j < SPECIES.length(); j++) {
1018 Assert.assertEquals(mv.getElement(j), a[i + j] == b[i + j]);
1019 }
1020 }
1021 }
1022 }
1023
1024
1025 @Test(dataProvider = "doubleCompareOpProvider")
1026 static void notEqualDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1027 double[] a = fa.apply(SPECIES.length());
1028 double[] b = fb.apply(SPECIES.length());
1029
1030 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1031 for (int i = 0; i < a.length; i += SPECIES.length()) {
1032 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1033 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1034 Vector.Mask<Double> mv = av.notEqual(bv);
1035
1036 // Check results as part of computation.
1037 for (int j = 0; j < SPECIES.length(); j++) {
1038 Assert.assertEquals(mv.getElement(j), a[i + j] != b[i + j]);
1039 }
1040 }
1041 }
1042 }
1043
1044
1045 @Test(dataProvider = "doubleCompareOpProvider")
1046 static void lessThanEqDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1047 double[] a = fa.apply(SPECIES.length());
1048 double[] b = fb.apply(SPECIES.length());
1049
1050 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1051 for (int i = 0; i < a.length; i += SPECIES.length()) {
1052 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1053 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1054 Vector.Mask<Double> mv = av.lessThanEq(bv);
1055
1056 // Check results as part of computation.
1057 for (int j = 0; j < SPECIES.length(); j++) {
1058 Assert.assertEquals(mv.getElement(j), a[i + j] <= b[i + j]);
1059 }
1060 }
1061 }
1062 }
1063
1064
1065 @Test(dataProvider = "doubleCompareOpProvider")
1066 static void greaterThanEqDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1067 double[] a = fa.apply(SPECIES.length());
1068 double[] b = fb.apply(SPECIES.length());
1069
1070 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1071 for (int i = 0; i < a.length; i += SPECIES.length()) {
1072 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1073 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1074 Vector.Mask<Double> mv = av.greaterThanEq(bv);
1075
1076 // Check results as part of computation.
1077 for (int j = 0; j < SPECIES.length(); j++) {
1078 Assert.assertEquals(mv.getElement(j), a[i + j] >= b[i + j]);
1079 }
1080 }
1081 }
1082 }
1083
1084
1085 static double blend(double a, double b, boolean mask) {
1086 return mask ? b : a;
1087 }
1088
1089 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1090 static void blendDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
1091 IntFunction<boolean[]> fm) {
1092 double[] a = fa.apply(SPECIES.length());
1093 double[] b = fb.apply(SPECIES.length());
1094 double[] r = fr.apply(SPECIES.length());
1095 boolean[] mask = fm.apply(SPECIES.length());
1096 Vector.Mask<Double> vmask = DoubleVector.maskFromValues(SPECIES, mask);
1097
1098 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1099 for (int i = 0; i < a.length; i += SPECIES.length()) {
1100 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1101 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1102 av.blend(bv, vmask).intoArray(r, i);
1103 }
1104 }
1105
1106 assertArraysEquals(a, b, r, mask, Double256VectorTests::blend);
1107 }
1108
1109 @Test(dataProvider = "doubleUnaryOpShuffleProvider")
1110 static void RearrangeDouble256VectorTests(IntFunction<double[]> fa,
1111 BiFunction<Integer,Integer,int[]> fs) {
1112 double[] a = fa.apply(SPECIES.length());
1113 int[] order = fs.apply(a.length, SPECIES.length());
1114 double[] r = fr.apply(SPECIES.length());
1115
1116 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1117 for (int i = 0; i < a.length; i += SPECIES.length()) {
1118 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1119 av.rearrange(DoubleVector.shuffleFromArray(SPECIES, order, i)).intoArray(r, i);
1120 }
1121 }
1122
1123 assertRearrangeArraysEquals(a, r, order, SPECIES.length());
1124 }
1125
1126
1127
1128
1129 @Test(dataProvider = "doubleUnaryOpProvider")
1130 static void getDouble256VectorTests(IntFunction<double[]> fa) {
1131 double[] a = fa.apply(SPECIES.length());
1132 double[] r = fr.apply(SPECIES.length());
1133
1134 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1135 for (int i = 0; i < a.length; i += SPECIES.length()) {
1136 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1137 int num_lanes = SPECIES.length();
1138 // Manually unroll because full unroll happens after intrinsification.
1139 // Unroll is needed because get intrinsic requires for index to be a known constant.
1739 for (int i = 0; i < a.length; i += SPECIES.length()) {
1740 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1741 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1742 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
1743 av.fma(bv, cv).intoArray(r, i);
1744 }
1745 }
1746
1747 assertArraysEquals(a, b, c, r, Double256VectorTests::fma);
1748 }
1749
1750
1751 @Test(dataProvider = "doubleTernaryOpMaskProvider")
1752 static void fmaDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
1753 IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
1754 double[] a = fa.apply(SPECIES.length());
1755 double[] b = fb.apply(SPECIES.length());
1756 double[] c = fc.apply(SPECIES.length());
1757 double[] r = fr.apply(SPECIES.length());
1758 boolean[] mask = fm.apply(SPECIES.length());
1759 Vector.Mask<Double> vmask = DoubleVector.maskFromValues(SPECIES, mask);
1760
1761 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1762 for (int i = 0; i < a.length; i += SPECIES.length()) {
1763 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1764 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1765 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
1766 av.fma(bv, cv, vmask).intoArray(r, i);
1767 }
1768 }
1769
1770 assertArraysEquals(a, b, c, r, mask, Double256VectorTests::fma);
1771 }
1772
1773
1774 static double neg(double a) {
1775 return (double)(-((double)a));
1776 }
1777
1778 @Test(dataProvider = "doubleUnaryOpProvider")
1779 static void negDouble256VectorTests(IntFunction<double[]> fa) {
1780 double[] a = fa.apply(SPECIES.length());
1781 double[] r = fr.apply(SPECIES.length());
1782
1783 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1784 for (int i = 0; i < a.length; i += SPECIES.length()) {
1785 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1786 av.neg().intoArray(r, i);
1787 }
1788 }
1789
1790 assertArraysEquals(a, r, Double256VectorTests::neg);
1791 }
1792
1793 @Test(dataProvider = "doubleUnaryOpMaskProvider")
1794 static void negMaskedDouble256VectorTests(IntFunction<double[]> fa,
1795 IntFunction<boolean[]> fm) {
1796 double[] a = fa.apply(SPECIES.length());
1797 double[] r = fr.apply(SPECIES.length());
1798 boolean[] mask = fm.apply(SPECIES.length());
1799 Vector.Mask<Double> vmask = DoubleVector.maskFromValues(SPECIES, mask);
1800
1801 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1802 for (int i = 0; i < a.length; i += SPECIES.length()) {
1803 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1804 av.neg(vmask).intoArray(r, i);
1805 }
1806 }
1807
1808 assertArraysEquals(a, r, mask, Double256VectorTests::neg);
1809 }
1810
1811 static double abs(double a) {
1812 return (double)(Math.abs((double)a));
1813 }
1814
1815 @Test(dataProvider = "doubleUnaryOpProvider")
1816 static void absDouble256VectorTests(IntFunction<double[]> fa) {
1817 double[] a = fa.apply(SPECIES.length());
1818 double[] r = fr.apply(SPECIES.length());
1819
1820 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1821 for (int i = 0; i < a.length; i += SPECIES.length()) {
1822 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1823 av.abs().intoArray(r, i);
1824 }
1825 }
1826
1827 assertArraysEquals(a, r, Double256VectorTests::abs);
1828 }
1829
1830 @Test(dataProvider = "doubleUnaryOpMaskProvider")
1831 static void absMaskedDouble256VectorTests(IntFunction<double[]> fa,
1832 IntFunction<boolean[]> fm) {
1833 double[] a = fa.apply(SPECIES.length());
1834 double[] r = fr.apply(SPECIES.length());
1835 boolean[] mask = fm.apply(SPECIES.length());
1836 Vector.Mask<Double> vmask = DoubleVector.maskFromValues(SPECIES, mask);
1837
1838 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1839 for (int i = 0; i < a.length; i += SPECIES.length()) {
1840 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1841 av.abs(vmask).intoArray(r, i);
1842 }
1843 }
1844
1845 assertArraysEquals(a, r, mask, Double256VectorTests::abs);
1846 }
1847
1848
1849
1850
1851
1852 static double sqrt(double a) {
1853 return (double)(Math.sqrt((double)a));
1854 }
1855
1856
1861 double[] r = fr.apply(SPECIES.length());
1862
1863 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1864 for (int i = 0; i < a.length; i += SPECIES.length()) {
1865 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1866 av.sqrt().intoArray(r, i);
1867 }
1868 }
1869
1870 assertArraysEquals(a, r, Double256VectorTests::sqrt);
1871 }
1872
1873
1874
1875 @Test(dataProvider = "doubleUnaryOpMaskProvider")
1876 static void sqrtMaskedDouble256VectorTests(IntFunction<double[]> fa,
1877 IntFunction<boolean[]> fm) {
1878 double[] a = fa.apply(SPECIES.length());
1879 double[] r = fr.apply(SPECIES.length());
1880 boolean[] mask = fm.apply(SPECIES.length());
1881 Vector.Mask<Double> vmask = DoubleVector.maskFromValues(SPECIES, mask);
1882
1883 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1884 for (int i = 0; i < a.length; i += SPECIES.length()) {
1885 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1886 av.sqrt(vmask).intoArray(r, i);
1887 }
1888 }
1889
1890 assertArraysEquals(a, r, mask, Double256VectorTests::sqrt);
1891 }
1892
1893
1894 static double[] gather(double a[], int ix, int[] b, int iy) {
1895 double[] res = new double[SPECIES.length()];
1896 for (int i = 0; i < SPECIES.length(); i++) {
1897 int bi = iy + i;
1898 res[i] = a[b[bi] + ix];
1899 }
1900 return res;
1901 }
|
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 Double256VectorTests
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.DoubleVector;
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 Double256VectorTests extends AbstractVectorTest {
52
53 static final VectorSpecies<Double> SPECIES =
54 DoubleVector.SPECIES_256;
55
56 static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
57
58 interface FUnOp {
59 double apply(double a);
60 }
61
62 static void assertArraysEquals(double[] a, double[] 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(double[] a, double[] r, boolean[] mask, FUnOp f) {
547 double[] r = fr.apply(SPECIES.length());
548
549 for (int ic = 0; ic < INVOC_COUNT; ic++) {
550 for (int i = 0; i < a.length; i += SPECIES.length()) {
551 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
552 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
553 av.add(bv).intoArray(r, i);
554 }
555 }
556
557 assertArraysEquals(a, b, r, Double256VectorTests::add);
558 }
559
560 @Test(dataProvider = "doubleBinaryOpMaskProvider")
561 static void addDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
562 IntFunction<boolean[]> fm) {
563 double[] a = fa.apply(SPECIES.length());
564 double[] b = fb.apply(SPECIES.length());
565 double[] r = fr.apply(SPECIES.length());
566 boolean[] mask = fm.apply(SPECIES.length());
567 VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask);
568
569 for (int ic = 0; ic < INVOC_COUNT; ic++) {
570 for (int i = 0; i < a.length; i += SPECIES.length()) {
571 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
572 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
573 av.add(bv, vmask).intoArray(r, i);
574 }
575 }
576
577 assertArraysEquals(a, b, r, mask, Double256VectorTests::add);
578 }
579 static double sub(double a, double b) {
580 return (double)(a - b);
581 }
582
583 @Test(dataProvider = "doubleBinaryOpProvider")
584 static void subDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
585 double[] a = fa.apply(SPECIES.length());
586 double[] b = fb.apply(SPECIES.length());
587 double[] r = fr.apply(SPECIES.length());
588
589 for (int ic = 0; ic < INVOC_COUNT; ic++) {
590 for (int i = 0; i < a.length; i += SPECIES.length()) {
591 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
592 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
593 av.sub(bv).intoArray(r, i);
594 }
595 }
596
597 assertArraysEquals(a, b, r, Double256VectorTests::sub);
598 }
599
600 @Test(dataProvider = "doubleBinaryOpMaskProvider")
601 static void subDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
602 IntFunction<boolean[]> fm) {
603 double[] a = fa.apply(SPECIES.length());
604 double[] b = fb.apply(SPECIES.length());
605 double[] r = fr.apply(SPECIES.length());
606 boolean[] mask = fm.apply(SPECIES.length());
607 VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask);
608
609 for (int ic = 0; ic < INVOC_COUNT; ic++) {
610 for (int i = 0; i < a.length; i += SPECIES.length()) {
611 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
612 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
613 av.sub(bv, vmask).intoArray(r, i);
614 }
615 }
616
617 assertArraysEquals(a, b, r, mask, Double256VectorTests::sub);
618 }
619
620 static double div(double a, double b) {
621 return (double)(a / b);
622 }
623
624 @Test(dataProvider = "doubleBinaryOpProvider")
625 static void divDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
626 double[] a = fa.apply(SPECIES.length());
627 double[] b = fb.apply(SPECIES.length());
630 for (int ic = 0; ic < INVOC_COUNT; ic++) {
631 for (int i = 0; i < a.length; i += SPECIES.length()) {
632 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
633 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
634 av.div(bv).intoArray(r, i);
635 }
636 }
637
638 assertArraysEquals(a, b, r, Double256VectorTests::div);
639 }
640
641
642
643 @Test(dataProvider = "doubleBinaryOpMaskProvider")
644 static void divDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
645 IntFunction<boolean[]> fm) {
646 double[] a = fa.apply(SPECIES.length());
647 double[] b = fb.apply(SPECIES.length());
648 double[] r = fr.apply(SPECIES.length());
649 boolean[] mask = fm.apply(SPECIES.length());
650 VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask);
651
652 for (int ic = 0; ic < INVOC_COUNT; ic++) {
653 for (int i = 0; i < a.length; i += SPECIES.length()) {
654 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
655 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
656 av.div(bv, vmask).intoArray(r, i);
657 }
658 }
659
660 assertArraysEquals(a, b, r, mask, Double256VectorTests::div);
661 }
662
663 static double mul(double a, double b) {
664 return (double)(a * b);
665 }
666
667 @Test(dataProvider = "doubleBinaryOpProvider")
668 static void mulDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
669 double[] a = fa.apply(SPECIES.length());
670 double[] b = fb.apply(SPECIES.length());
671 double[] r = fr.apply(SPECIES.length());
672
673 for (int ic = 0; ic < INVOC_COUNT; ic++) {
674 for (int i = 0; i < a.length; i += SPECIES.length()) {
675 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
676 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
677 av.mul(bv).intoArray(r, i);
678 }
679 }
680
681 assertArraysEquals(a, b, r, Double256VectorTests::mul);
682 }
683
684 @Test(dataProvider = "doubleBinaryOpMaskProvider")
685 static void mulDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
686 IntFunction<boolean[]> fm) {
687 double[] a = fa.apply(SPECIES.length());
688 double[] b = fb.apply(SPECIES.length());
689 double[] r = fr.apply(SPECIES.length());
690 boolean[] mask = fm.apply(SPECIES.length());
691 VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask);
692
693 for (int ic = 0; ic < INVOC_COUNT; ic++) {
694 for (int i = 0; i < a.length; i += SPECIES.length()) {
695 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
696 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
697 av.mul(bv, vmask).intoArray(r, i);
698 }
699 }
700
701 assertArraysEquals(a, b, r, mask, Double256VectorTests::mul);
702 }
703
704
705
706
707
708
709
710
711
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 }
966
967 @Test(dataProvider = "doubleCompareOpProvider")
968 static void lessThanDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
969 double[] a = fa.apply(SPECIES.length());
970 double[] b = fb.apply(SPECIES.length());
971
972 for (int ic = 0; ic < INVOC_COUNT; ic++) {
973 for (int i = 0; i < a.length; i += SPECIES.length()) {
974 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
975 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
976 VectorMask<Double> mv = av.lessThan(bv);
977
978 // Check results as part of computation.
979 for (int j = 0; j < SPECIES.length(); j++) {
980 Assert.assertEquals(mv.getElement(j), a[i + j] < b[i + j]);
981 }
982 }
983 }
984 }
985
986
987 @Test(dataProvider = "doubleCompareOpProvider")
988 static void greaterThanDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
989 double[] a = fa.apply(SPECIES.length());
990 double[] b = fb.apply(SPECIES.length());
991
992 for (int ic = 0; ic < INVOC_COUNT; ic++) {
993 for (int i = 0; i < a.length; i += SPECIES.length()) {
994 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
995 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
996 VectorMask<Double> mv = av.greaterThan(bv);
997
998 // Check results as part of computation.
999 for (int j = 0; j < SPECIES.length(); j++) {
1000 Assert.assertEquals(mv.getElement(j), a[i + j] > b[i + j]);
1001 }
1002 }
1003 }
1004 }
1005
1006
1007 @Test(dataProvider = "doubleCompareOpProvider")
1008 static void equalDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1009 double[] a = fa.apply(SPECIES.length());
1010 double[] b = fb.apply(SPECIES.length());
1011
1012 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1013 for (int i = 0; i < a.length; i += SPECIES.length()) {
1014 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1015 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1016 VectorMask<Double> mv = av.equal(bv);
1017
1018 // Check results as part of computation.
1019 for (int j = 0; j < SPECIES.length(); j++) {
1020 Assert.assertEquals(mv.getElement(j), a[i + j] == b[i + j]);
1021 }
1022 }
1023 }
1024 }
1025
1026
1027 @Test(dataProvider = "doubleCompareOpProvider")
1028 static void notEqualDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1029 double[] a = fa.apply(SPECIES.length());
1030 double[] b = fb.apply(SPECIES.length());
1031
1032 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1033 for (int i = 0; i < a.length; i += SPECIES.length()) {
1034 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1035 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1036 VectorMask<Double> mv = av.notEqual(bv);
1037
1038 // Check results as part of computation.
1039 for (int j = 0; j < SPECIES.length(); j++) {
1040 Assert.assertEquals(mv.getElement(j), a[i + j] != b[i + j]);
1041 }
1042 }
1043 }
1044 }
1045
1046
1047 @Test(dataProvider = "doubleCompareOpProvider")
1048 static void lessThanEqDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1049 double[] a = fa.apply(SPECIES.length());
1050 double[] b = fb.apply(SPECIES.length());
1051
1052 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1053 for (int i = 0; i < a.length; i += SPECIES.length()) {
1054 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1055 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1056 VectorMask<Double> mv = av.lessThanEq(bv);
1057
1058 // Check results as part of computation.
1059 for (int j = 0; j < SPECIES.length(); j++) {
1060 Assert.assertEquals(mv.getElement(j), a[i + j] <= b[i + j]);
1061 }
1062 }
1063 }
1064 }
1065
1066
1067 @Test(dataProvider = "doubleCompareOpProvider")
1068 static void greaterThanEqDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1069 double[] a = fa.apply(SPECIES.length());
1070 double[] b = fb.apply(SPECIES.length());
1071
1072 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1073 for (int i = 0; i < a.length; i += SPECIES.length()) {
1074 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1075 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1076 VectorMask<Double> mv = av.greaterThanEq(bv);
1077
1078 // Check results as part of computation.
1079 for (int j = 0; j < SPECIES.length(); j++) {
1080 Assert.assertEquals(mv.getElement(j), a[i + j] >= b[i + j]);
1081 }
1082 }
1083 }
1084 }
1085
1086
1087 static double blend(double a, double b, boolean mask) {
1088 return mask ? b : a;
1089 }
1090
1091 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1092 static void blendDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
1093 IntFunction<boolean[]> fm) {
1094 double[] a = fa.apply(SPECIES.length());
1095 double[] b = fb.apply(SPECIES.length());
1096 double[] r = fr.apply(SPECIES.length());
1097 boolean[] mask = fm.apply(SPECIES.length());
1098 VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask);
1099
1100 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1101 for (int i = 0; i < a.length; i += SPECIES.length()) {
1102 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1103 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1104 av.blend(bv, vmask).intoArray(r, i);
1105 }
1106 }
1107
1108 assertArraysEquals(a, b, r, mask, Double256VectorTests::blend);
1109 }
1110
1111 @Test(dataProvider = "doubleUnaryOpShuffleProvider")
1112 static void RearrangeDouble256VectorTests(IntFunction<double[]> fa,
1113 BiFunction<Integer,Integer,int[]> fs) {
1114 double[] a = fa.apply(SPECIES.length());
1115 int[] order = fs.apply(a.length, SPECIES.length());
1116 double[] r = fr.apply(SPECIES.length());
1117
1118 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1119 for (int i = 0; i < a.length; i += SPECIES.length()) {
1120 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1121 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);
1122 }
1123 }
1124
1125 assertRearrangeArraysEquals(a, r, order, SPECIES.length());
1126 }
1127
1128
1129
1130
1131 @Test(dataProvider = "doubleUnaryOpProvider")
1132 static void getDouble256VectorTests(IntFunction<double[]> fa) {
1133 double[] a = fa.apply(SPECIES.length());
1134 double[] r = fr.apply(SPECIES.length());
1135
1136 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1137 for (int i = 0; i < a.length; i += SPECIES.length()) {
1138 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1139 int num_lanes = SPECIES.length();
1140 // Manually unroll because full unroll happens after intrinsification.
1141 // Unroll is needed because get intrinsic requires for index to be a known constant.
1741 for (int i = 0; i < a.length; i += SPECIES.length()) {
1742 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1743 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1744 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
1745 av.fma(bv, cv).intoArray(r, i);
1746 }
1747 }
1748
1749 assertArraysEquals(a, b, c, r, Double256VectorTests::fma);
1750 }
1751
1752
1753 @Test(dataProvider = "doubleTernaryOpMaskProvider")
1754 static void fmaDouble256VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb,
1755 IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
1756 double[] a = fa.apply(SPECIES.length());
1757 double[] b = fb.apply(SPECIES.length());
1758 double[] c = fc.apply(SPECIES.length());
1759 double[] r = fr.apply(SPECIES.length());
1760 boolean[] mask = fm.apply(SPECIES.length());
1761 VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask);
1762
1763 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1764 for (int i = 0; i < a.length; i += SPECIES.length()) {
1765 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1766 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1767 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
1768 av.fma(bv, cv, vmask).intoArray(r, i);
1769 }
1770 }
1771
1772 assertArraysEquals(a, b, c, r, mask, Double256VectorTests::fma);
1773 }
1774
1775
1776 static double neg(double a) {
1777 return (double)(-((double)a));
1778 }
1779
1780 @Test(dataProvider = "doubleUnaryOpProvider")
1781 static void negDouble256VectorTests(IntFunction<double[]> fa) {
1782 double[] a = fa.apply(SPECIES.length());
1783 double[] r = fr.apply(SPECIES.length());
1784
1785 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1786 for (int i = 0; i < a.length; i += SPECIES.length()) {
1787 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1788 av.neg().intoArray(r, i);
1789 }
1790 }
1791
1792 assertArraysEquals(a, r, Double256VectorTests::neg);
1793 }
1794
1795 @Test(dataProvider = "doubleUnaryOpMaskProvider")
1796 static void negMaskedDouble256VectorTests(IntFunction<double[]> fa,
1797 IntFunction<boolean[]> fm) {
1798 double[] a = fa.apply(SPECIES.length());
1799 double[] r = fr.apply(SPECIES.length());
1800 boolean[] mask = fm.apply(SPECIES.length());
1801 VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask);
1802
1803 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1804 for (int i = 0; i < a.length; i += SPECIES.length()) {
1805 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1806 av.neg(vmask).intoArray(r, i);
1807 }
1808 }
1809
1810 assertArraysEquals(a, r, mask, Double256VectorTests::neg);
1811 }
1812
1813 static double abs(double a) {
1814 return (double)(Math.abs((double)a));
1815 }
1816
1817 @Test(dataProvider = "doubleUnaryOpProvider")
1818 static void absDouble256VectorTests(IntFunction<double[]> fa) {
1819 double[] a = fa.apply(SPECIES.length());
1820 double[] r = fr.apply(SPECIES.length());
1821
1822 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1823 for (int i = 0; i < a.length; i += SPECIES.length()) {
1824 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1825 av.abs().intoArray(r, i);
1826 }
1827 }
1828
1829 assertArraysEquals(a, r, Double256VectorTests::abs);
1830 }
1831
1832 @Test(dataProvider = "doubleUnaryOpMaskProvider")
1833 static void absMaskedDouble256VectorTests(IntFunction<double[]> fa,
1834 IntFunction<boolean[]> fm) {
1835 double[] a = fa.apply(SPECIES.length());
1836 double[] r = fr.apply(SPECIES.length());
1837 boolean[] mask = fm.apply(SPECIES.length());
1838 VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask);
1839
1840 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1841 for (int i = 0; i < a.length; i += SPECIES.length()) {
1842 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1843 av.abs(vmask).intoArray(r, i);
1844 }
1845 }
1846
1847 assertArraysEquals(a, r, mask, Double256VectorTests::abs);
1848 }
1849
1850
1851
1852
1853
1854 static double sqrt(double a) {
1855 return (double)(Math.sqrt((double)a));
1856 }
1857
1858
1863 double[] r = fr.apply(SPECIES.length());
1864
1865 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1866 for (int i = 0; i < a.length; i += SPECIES.length()) {
1867 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1868 av.sqrt().intoArray(r, i);
1869 }
1870 }
1871
1872 assertArraysEquals(a, r, Double256VectorTests::sqrt);
1873 }
1874
1875
1876
1877 @Test(dataProvider = "doubleUnaryOpMaskProvider")
1878 static void sqrtMaskedDouble256VectorTests(IntFunction<double[]> fa,
1879 IntFunction<boolean[]> fm) {
1880 double[] a = fa.apply(SPECIES.length());
1881 double[] r = fr.apply(SPECIES.length());
1882 boolean[] mask = fm.apply(SPECIES.length());
1883 VectorMask<Double> vmask = VectorMask.fromValues(SPECIES, mask);
1884
1885 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1886 for (int i = 0; i < a.length; i += SPECIES.length()) {
1887 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1888 av.sqrt(vmask).intoArray(r, i);
1889 }
1890 }
1891
1892 assertArraysEquals(a, r, mask, Double256VectorTests::sqrt);
1893 }
1894
1895
1896 static double[] gather(double a[], int ix, int[] b, int iy) {
1897 double[] res = new double[SPECIES.length()];
1898 for (int i = 0; i < SPECIES.length(); i++) {
1899 int bi = iy + i;
1900 res[i] = a[b[bi] + ix];
1901 }
1902 return res;
1903 }
|