43 import org.testng.annotations.Test;
44
45 import java.lang.Integer;
46 import java.util.List;
47 import java.util.Arrays;
48 import java.util.function.BiFunction;
49 import java.util.function.IntFunction;
50 import java.util.Objects;
51 import java.util.stream.Collectors;
52 import java.util.stream.Stream;
53
54 @Test
55 public class Double128VectorTests extends AbstractVectorTest {
56
57 static final VectorSpecies<Double> SPECIES =
58 DoubleVector.SPECIES_128;
59
60 static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
61
62
63 private static final double CONST_SHIFT = Double.SIZE / 2;
64
65 static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
66
67 interface FUnOp {
68 double apply(double a);
69 }
70
71 static void assertArraysEquals(double[] r, double[] a, FUnOp f) {
72 int i = 0;
73 try {
74 for (; i < a.length; i++) {
75 Assert.assertEquals(r[i], f.apply(a[i]));
76 }
77 } catch (AssertionError e) {
78 Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);
79 }
80 }
81
82 interface FUnArrayOp {
83 double[] apply(double a);
244 } else {
245 Assert.assertEquals(r[i], a[i], "at index #" + i);
246 }
247 }
248 }
249
250 static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int vector_len) {
251 int i = 0, j = 0;
252 try {
253 for (; i < a.length; i += vector_len) {
254 for (j = 0; j < vector_len; j++) {
255 Assert.assertEquals(r[i+j], a[i+order[i+j]]);
256 }
257 }
258 } catch (AssertionError e) {
259 int idx = i + j;
260 Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
261 }
262 }
263
264 static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, int vector_len) {
265 int i = 0, j = 0;
266 try {
267 for (; i < a.length; i += vector_len) {
268 for (j = 0; j < vector_len; j++) {
269 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
270 }
271 }
272 } catch (AssertionError e) {
273 int idx = i + j;
274 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]);
275 }
276 }
277
278 static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boolean[] mask, int vector_len) {
279 int i = 0, j = 0;
280 try {
281 for (; i < a.length; i += vector_len) {
282 for (j = 0; j < vector_len; j++) {
283 if (mask[j % SPECIES.length()])
996 i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1)));
997 }),
998 withToString("double[cornerCaseValue(i)]", (int s) -> {
999 return fill(s * BUFFER_REPS,
1000 i -> (double)longCornerCaseValue(i));
1001 })
1002 );
1003
1004
1005 static void assertArraysEquals(long[] r, double[] a, int offs) {
1006 int i = 0;
1007 try {
1008 for (; i < r.length; i++) {
1009 Assert.assertEquals(r[i], (long)(a[i+offs]));
1010 }
1011 } catch (AssertionError e) {
1012 Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
1013 }
1014 }
1015
1016
1017
1018 static long bits(double e) {
1019 return Double.doubleToLongBits(e);
1020 }
1021
1022 static final List<IntFunction<double[]>> DOUBLE_GENERATORS = List.of(
1023 withToString("double[-i * 5]", (int s) -> {
1024 return fill(s * BUFFER_REPS,
1025 i -> (double)(-i * 5));
1026 }),
1027 withToString("double[i * 5]", (int s) -> {
1028 return fill(s * BUFFER_REPS,
1029 i -> (double)(i * 5));
1030 }),
1031 withToString("double[i + 1]", (int s) -> {
1032 return fill(s * BUFFER_REPS,
1033 i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1)));
1034 }),
1035 withToString("double[cornerCaseValue(i)]", (int s) -> {
1036 return fill(s * BUFFER_REPS,
1037 i -> cornerCaseValue(i));
1181
1182 @DataProvider
1183 public Object[][] doubleUnaryOpSelectFromProvider() {
1184 return DOUBLE_SHUFFLE_GENERATORS.stream().
1185 flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
1186 return new Object[] {fa, fs};
1187 })).
1188 toArray(Object[][]::new);
1189 }
1190
1191 @DataProvider
1192 public Object[][] doubleUnaryOpSelectFromMaskProvider() {
1193 return BOOLEAN_MASK_GENERATORS.stream().
1194 flatMap(fm -> DOUBLE_SHUFFLE_GENERATORS.stream().
1195 flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
1196 return new Object[] {fa, fs, fm};
1197 }))).
1198 toArray(Object[][]::new);
1199 }
1200
1201
1202 static final List<IntFunction<double[]>> DOUBLE_COMPARE_GENERATORS = List.of(
1203 withToString("double[i]", (int s) -> {
1204 return fill(s * BUFFER_REPS,
1205 i -> (double)i);
1206 }),
1207 withToString("double[i - length / 2]", (int s) -> {
1208 return fill(s * BUFFER_REPS,
1209 i -> (double)(i - (s * BUFFER_REPS / 2)));
1210 }),
1211 withToString("double[i + 1]", (int s) -> {
1212 return fill(s * BUFFER_REPS,
1213 i -> (double)(i + 1));
1214 }),
1215 withToString("double[i - 2]", (int s) -> {
1216 return fill(s * BUFFER_REPS,
1217 i -> (double)(i - 2));
1218 }),
1219 withToString("double[zigZag(i)]", (int s) -> {
1220 return fill(s * BUFFER_REPS,
1221 i -> i%3 == 0 ? (double)i : (i%3 == 1 ? (double)(i + 1) : (double)(i - 2)));
1302
1303 static double get(double[] a, int i) {
1304 return (double) a[i];
1305 }
1306
1307 static final IntFunction<double[]> fr = (vl) -> {
1308 int length = BUFFER_REPS * vl;
1309 return new double[length];
1310 };
1311
1312 static final IntFunction<boolean[]> fmr = (vl) -> {
1313 int length = BUFFER_REPS * vl;
1314 return new boolean[length];
1315 };
1316
1317 static final IntFunction<long[]> lfr = (vl) -> {
1318 int length = BUFFER_REPS * vl;
1319 return new long[length];
1320 };
1321
1322
1323 static boolean eq(double a, double b) {
1324 return a == b;
1325 }
1326
1327 static boolean neq(double a, double b) {
1328 return a != b;
1329 }
1330
1331 static boolean lt(double a, double b) {
1332 return a < b;
1333 }
1334
1335 static boolean le(double a, double b) {
1336 return a <= b;
1337 }
1338
1339 static boolean gt(double a, double b) {
1340 return a > b;
1341 }
1342
1343 static boolean ge(double a, double b) {
1344 return a >= b;
1345 }
1346
1347
1348 static double firstNonZero(double a, double b) {
1349 return Double.compare(a, (double) 0) != 0 ? a : b;
1350 }
1351
1352 @Test
1353 static void smokeTest1() {
1354 DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3);
1355 DoubleVector three2 = (DoubleVector) SPECIES.broadcast(-3);
1356 assert(three.eq(three2).allTrue());
1357 DoubleVector three3 = three2.broadcast(1).broadcast(-3);
1358 assert(three.eq(three3).allTrue());
1359 int scale = 2;
1360 Class<?> ETYPE = double.class;
1361 if (ETYPE == double.class || ETYPE == long.class)
1362 scale = 1000000;
1363 else if (ETYPE == byte.class && SPECIES.length() >= 64)
1364 scale = 1;
1365 DoubleVector higher = three.addIndex(scale);
1366 VectorMask<Double> m = three.compare(VectorOperators.LE, higher);
1367 assert(m.allTrue());
1444 static double ADD(double a, double b) {
1445 return (double)(a + b);
1446 }
1447
1448 @Test(dataProvider = "doubleBinaryOpProvider")
1449 static void ADDDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1450 double[] a = fa.apply(SPECIES.length());
1451 double[] b = fb.apply(SPECIES.length());
1452 double[] r = fr.apply(SPECIES.length());
1453
1454 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1455 for (int i = 0; i < a.length; i += SPECIES.length()) {
1456 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1457 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1458 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
1459 }
1460 }
1461
1462 assertArraysEquals(r, a, b, Double128VectorTests::ADD);
1463 }
1464 static double add(double a, double b) {
1465 return (double)(a + b);
1466 }
1467
1468 @Test(dataProvider = "doubleBinaryOpProvider")
1469 static void addDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1470 double[] a = fa.apply(SPECIES.length());
1471 double[] b = fb.apply(SPECIES.length());
1472 double[] r = fr.apply(SPECIES.length());
1473
1474 for (int i = 0; i < a.length; i += SPECIES.length()) {
1475 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1476 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1477 av.add(bv).intoArray(r, i);
1478 }
1479
1480 assertArraysEquals(r, a, b, Double128VectorTests::add);
1481 }
1482
1483 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1500 assertArraysEquals(r, a, b, mask, Double128VectorTests::ADD);
1501 }
1502
1503 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1504 static void addDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1505 IntFunction<boolean[]> fm) {
1506 double[] a = fa.apply(SPECIES.length());
1507 double[] b = fb.apply(SPECIES.length());
1508 double[] r = fr.apply(SPECIES.length());
1509 boolean[] mask = fm.apply(SPECIES.length());
1510 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1511
1512 for (int i = 0; i < a.length; i += SPECIES.length()) {
1513 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1514 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1515 av.add(bv, vmask).intoArray(r, i);
1516 }
1517
1518 assertArraysEquals(r, a, b, mask, Double128VectorTests::add);
1519 }
1520 static double SUB(double a, double b) {
1521 return (double)(a - b);
1522 }
1523
1524 @Test(dataProvider = "doubleBinaryOpProvider")
1525 static void SUBDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1526 double[] a = fa.apply(SPECIES.length());
1527 double[] b = fb.apply(SPECIES.length());
1528 double[] r = fr.apply(SPECIES.length());
1529
1530 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1531 for (int i = 0; i < a.length; i += SPECIES.length()) {
1532 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1533 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1534 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
1535 }
1536 }
1537
1538 assertArraysEquals(r, a, b, Double128VectorTests::SUB);
1539 }
1540 static double sub(double a, double b) {
1541 return (double)(a - b);
1542 }
1543
1544 @Test(dataProvider = "doubleBinaryOpProvider")
1545 static void subDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1546 double[] a = fa.apply(SPECIES.length());
1547 double[] b = fb.apply(SPECIES.length());
1548 double[] r = fr.apply(SPECIES.length());
1549
1550 for (int i = 0; i < a.length; i += SPECIES.length()) {
1551 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1552 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1553 av.sub(bv).intoArray(r, i);
1554 }
1555
1556 assertArraysEquals(r, a, b, Double128VectorTests::sub);
1557 }
1558
1559 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1576 assertArraysEquals(r, a, b, mask, Double128VectorTests::SUB);
1577 }
1578
1579 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1580 static void subDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1581 IntFunction<boolean[]> fm) {
1582 double[] a = fa.apply(SPECIES.length());
1583 double[] b = fb.apply(SPECIES.length());
1584 double[] r = fr.apply(SPECIES.length());
1585 boolean[] mask = fm.apply(SPECIES.length());
1586 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1587
1588 for (int i = 0; i < a.length; i += SPECIES.length()) {
1589 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1590 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1591 av.sub(bv, vmask).intoArray(r, i);
1592 }
1593
1594 assertArraysEquals(r, a, b, mask, Double128VectorTests::sub);
1595 }
1596 static double MUL(double a, double b) {
1597 return (double)(a * b);
1598 }
1599
1600 @Test(dataProvider = "doubleBinaryOpProvider")
1601 static void MULDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1602 double[] a = fa.apply(SPECIES.length());
1603 double[] b = fb.apply(SPECIES.length());
1604 double[] r = fr.apply(SPECIES.length());
1605
1606 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1607 for (int i = 0; i < a.length; i += SPECIES.length()) {
1608 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1609 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1610 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
1611 }
1612 }
1613
1614 assertArraysEquals(r, a, b, Double128VectorTests::MUL);
1615 }
1616 static double mul(double a, double b) {
1617 return (double)(a * b);
1618 }
1619
1620 @Test(dataProvider = "doubleBinaryOpProvider")
1621 static void mulDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1622 double[] a = fa.apply(SPECIES.length());
1623 double[] b = fb.apply(SPECIES.length());
1624 double[] r = fr.apply(SPECIES.length());
1625
1626 for (int i = 0; i < a.length; i += SPECIES.length()) {
1627 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1628 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1629 av.mul(bv).intoArray(r, i);
1630 }
1631
1632 assertArraysEquals(r, a, b, Double128VectorTests::mul);
1633 }
1634
1635 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1673 static double DIV(double a, double b) {
1674 return (double)(a / b);
1675 }
1676
1677 @Test(dataProvider = "doubleBinaryOpProvider")
1678 static void DIVDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1679 double[] a = fa.apply(SPECIES.length());
1680 double[] b = fb.apply(SPECIES.length());
1681 double[] r = fr.apply(SPECIES.length());
1682
1683 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1684 for (int i = 0; i < a.length; i += SPECIES.length()) {
1685 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1686 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1687 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
1688 }
1689 }
1690
1691 assertArraysEquals(r, a, b, Double128VectorTests::DIV);
1692 }
1693 static double div(double a, double b) {
1694 return (double)(a / b);
1695 }
1696
1697 @Test(dataProvider = "doubleBinaryOpProvider")
1698 static void divDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1699 double[] a = fa.apply(SPECIES.length());
1700 double[] b = fb.apply(SPECIES.length());
1701 double[] r = fr.apply(SPECIES.length());
1702
1703 for (int i = 0; i < a.length; i += SPECIES.length()) {
1704 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1705 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1706 av.div(bv).intoArray(r, i);
1707 }
1708
1709 assertArraysEquals(r, a, b, Double128VectorTests::div);
1710 }
1711
1712
1713
1714 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1715 static void DIVDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1716 IntFunction<boolean[]> fm) {
1717 double[] a = fa.apply(SPECIES.length());
1718 double[] b = fb.apply(SPECIES.length());
1719 double[] r = fr.apply(SPECIES.length());
1720 boolean[] mask = fm.apply(SPECIES.length());
1721 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1722
1723 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1724 for (int i = 0; i < a.length; i += SPECIES.length()) {
1725 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1726 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1727 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
1728 }
1729 }
1730
1731 assertArraysEquals(r, a, b, mask, Double128VectorTests::DIV);
1732 }
1733
1734 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1735 static void divDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1736 IntFunction<boolean[]> fm) {
1737 double[] a = fa.apply(SPECIES.length());
1738 double[] b = fb.apply(SPECIES.length());
1739 double[] r = fr.apply(SPECIES.length());
1740 boolean[] mask = fm.apply(SPECIES.length());
1741 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1742
1743 for (int i = 0; i < a.length; i += SPECIES.length()) {
1744 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1745 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1746 av.div(bv, vmask).intoArray(r, i);
1747 }
1748
1749 assertArraysEquals(r, a, b, mask, Double128VectorTests::div);
1750 }
1751
1752
1753
1754 static double FIRST_NONZERO(double a, double b) {
1755 return (double)(Double.doubleToLongBits(a)!=0?a:b);
1756 }
1757
1758 @Test(dataProvider = "doubleBinaryOpProvider")
1759 static void FIRST_NONZERODouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1760 double[] a = fa.apply(SPECIES.length());
1761 double[] b = fb.apply(SPECIES.length());
1762 double[] r = fr.apply(SPECIES.length());
1763
1764 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1765 for (int i = 0; i < a.length; i += SPECIES.length()) {
1766 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1767 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1768 av.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i);
1769 }
1770 }
1771
1772 assertArraysEquals(r, a, b, Double128VectorTests::FIRST_NONZERO);
1773 }
1775 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1776 static void FIRST_NONZERODouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1777 IntFunction<boolean[]> fm) {
1778 double[] a = fa.apply(SPECIES.length());
1779 double[] b = fb.apply(SPECIES.length());
1780 double[] r = fr.apply(SPECIES.length());
1781 boolean[] mask = fm.apply(SPECIES.length());
1782 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1783
1784 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1785 for (int i = 0; i < a.length; i += SPECIES.length()) {
1786 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1787 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1788 av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i);
1789 }
1790 }
1791
1792 assertArraysEquals(r, a, b, mask, Double128VectorTests::FIRST_NONZERO);
1793 }
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803 @Test(dataProvider = "doubleBinaryOpProvider")
1804 static void addDouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1805 double[] a = fa.apply(SPECIES.length());
1806 double[] b = fb.apply(SPECIES.length());
1807 double[] r = fr.apply(SPECIES.length());
1808
1809 for (int i = 0; i < a.length; i += SPECIES.length()) {
1810 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1811 av.add(b[i]).intoArray(r, i);
1812 }
1813
1814 assertBroadcastArraysEquals(r, a, b, Double128VectorTests::add);
1815 }
1816
1817 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1818 static void addDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1819 IntFunction<boolean[]> fm) {
1820 double[] a = fa.apply(SPECIES.length());
1821 double[] b = fb.apply(SPECIES.length());
1822 double[] r = fr.apply(SPECIES.length());
1876 assertBroadcastArraysEquals(r, a, b, Double128VectorTests::mul);
1877 }
1878
1879 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1880 static void mulDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1881 IntFunction<boolean[]> fm) {
1882 double[] a = fa.apply(SPECIES.length());
1883 double[] b = fb.apply(SPECIES.length());
1884 double[] r = fr.apply(SPECIES.length());
1885 boolean[] mask = fm.apply(SPECIES.length());
1886 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1887
1888 for (int i = 0; i < a.length; i += SPECIES.length()) {
1889 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1890 av.mul(b[i], vmask).intoArray(r, i);
1891 }
1892
1893 assertBroadcastArraysEquals(r, a, b, mask, Double128VectorTests::mul);
1894 }
1895
1896
1897 @Test(dataProvider = "doubleBinaryOpProvider")
1898 static void divDouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1899 double[] a = fa.apply(SPECIES.length());
1900 double[] b = fb.apply(SPECIES.length());
1901 double[] r = fr.apply(SPECIES.length());
1902
1903 for (int i = 0; i < a.length; i += SPECIES.length()) {
1904 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1905 av.div(b[i]).intoArray(r, i);
1906 }
1907
1908 assertBroadcastArraysEquals(r, a, b, Double128VectorTests::div);
1909 }
1910
1911
1912
1913 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1914 static void divDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1915 IntFunction<boolean[]> fm) {
1916 double[] a = fa.apply(SPECIES.length());
1917 double[] b = fb.apply(SPECIES.length());
1918 double[] r = fr.apply(SPECIES.length());
1919 boolean[] mask = fm.apply(SPECIES.length());
1920 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1921
1922 for (int i = 0; i < a.length; i += SPECIES.length()) {
1923 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1924 av.div(b[i], vmask).intoArray(r, i);
1925 }
1926
1927 assertBroadcastArraysEquals(r, a, b, mask, Double128VectorTests::div);
1928 }
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939 @Test(dataProvider = "doubleBinaryOpProvider")
1940 static void ADDDouble128VectorTestsBroadcastLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1941 double[] a = fa.apply(SPECIES.length());
1942 double[] b = fb.apply(SPECIES.length());
1943 double[] r = fr.apply(SPECIES.length());
1944
1945 for (int i = 0; i < a.length; i += SPECIES.length()) {
1946 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1947 av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);
1948 }
1949
1950 assertBroadcastLongArraysEquals(r, a, b, Double128VectorTests::ADD);
1951 }
1952
1953 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1954 static void ADDDouble128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1955 IntFunction<boolean[]> fm) {
1956 double[] a = fa.apply(SPECIES.length());
1957 double[] b = fb.apply(SPECIES.length());
1958 double[] r = fr.apply(SPECIES.length());
1959 boolean[] mask = fm.apply(SPECIES.length());
1960 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1961
1962 for (int i = 0; i < a.length; i += SPECIES.length()) {
1963 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1964 av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i);
1965 }
1966
1967 assertBroadcastLongArraysEquals(r, a, b, mask, Double128VectorTests::ADD);
1968 }
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027 static double MIN(double a, double b) {
2028 return (double)(Math.min(a, b));
2029 }
2030
2031 @Test(dataProvider = "doubleBinaryOpProvider")
2032 static void MINDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2033 double[] a = fa.apply(SPECIES.length());
2034 double[] b = fb.apply(SPECIES.length());
2035 double[] r = fr.apply(SPECIES.length());
2036
2037 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2038 for (int i = 0; i < a.length; i += SPECIES.length()) {
2039 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2040 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2041 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
2042 }
2043 }
2044
2045 assertArraysEquals(r, a, b, Double128VectorTests::MIN);
2046 }
2047 static double min(double a, double b) {
2048 return (double)(Math.min(a, b));
2049 }
2050
2051 @Test(dataProvider = "doubleBinaryOpProvider")
2052 static void minDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2053 double[] a = fa.apply(SPECIES.length());
2054 double[] b = fb.apply(SPECIES.length());
2055 double[] r = fr.apply(SPECIES.length());
2056
2057 for (int i = 0; i < a.length; i += SPECIES.length()) {
2058 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2059 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2060 av.min(bv).intoArray(r, i);
2061 }
2062
2063 assertArraysEquals(r, a, b, Double128VectorTests::min);
2064 }
2065 static double MAX(double a, double b) {
2066 return (double)(Math.max(a, b));
2067 }
2068
2069 @Test(dataProvider = "doubleBinaryOpProvider")
2070 static void MAXDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2071 double[] a = fa.apply(SPECIES.length());
2072 double[] b = fb.apply(SPECIES.length());
2073 double[] r = fr.apply(SPECIES.length());
2074
2075 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2076 for (int i = 0; i < a.length; i += SPECIES.length()) {
2077 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2078 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2079 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
2080 }
2081 }
2082
2083 assertArraysEquals(r, a, b, Double128VectorTests::MAX);
2084 }
2085 static double max(double a, double b) {
2086 return (double)(Math.max(a, b));
2087 }
2088
2089 @Test(dataProvider = "doubleBinaryOpProvider")
2090 static void maxDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2091 double[] a = fa.apply(SPECIES.length());
2092 double[] b = fb.apply(SPECIES.length());
2093 double[] r = fr.apply(SPECIES.length());
2094
2095 for (int i = 0; i < a.length; i += SPECIES.length()) {
2096 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2097 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2098 av.max(bv).intoArray(r, i);
2099 }
2100
2101 assertArraysEquals(r, a, b, Double128VectorTests::max);
2102 }
2103
2104 @Test(dataProvider = "doubleBinaryOpProvider")
2140 av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i);
2141 }
2142
2143 assertBroadcastArraysEquals(r, a, b, Double128VectorTests::MAX);
2144 }
2145
2146 @Test(dataProvider = "doubleBinaryOpProvider")
2147 static void maxDouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2148 double[] a = fa.apply(SPECIES.length());
2149 double[] b = fb.apply(SPECIES.length());
2150 double[] r = fr.apply(SPECIES.length());
2151
2152 for (int i = 0; i < a.length; i += SPECIES.length()) {
2153 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2154 av.max(b[i]).intoArray(r, i);
2155 }
2156
2157 assertBroadcastArraysEquals(r, a, b, Double128VectorTests::max);
2158 }
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171 static double ADDReduce(double[] a, int idx) {
2172 double res = 0;
2173 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2174 res += a[i];
2175 }
2176
2177 return res;
2178 }
2179
2180 static double ADDReduceAll(double[] a) {
2181 double res = 0;
2182 for (int i = 0; i < a.length; i += SPECIES.length()) {
2183 res += ADDReduce(a, i);
2184 }
2185
2186 return res;
2187 }
2188 @Test(dataProvider = "doubleUnaryOpProvider")
2189 static void ADDReduceDouble128VectorTests(IntFunction<double[]> fa) {
2190 double[] a = fa.apply(SPECIES.length());
2191 double[] r = fr.apply(SPECIES.length());
2192 double ra = 0;
2193
2194 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2195 for (int i = 0; i < a.length; i += SPECIES.length()) {
2196 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2197 r[i] = av.reduceLanes(VectorOperators.ADD);
2198 }
2199 }
2200
2201 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2202 ra = 0;
2203 for (int i = 0; i < a.length; i += SPECIES.length()) {
2204 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2205 ra += av.reduceLanes(VectorOperators.ADD);
2206 }
2207 }
2208
2209 assertReductionArraysEquals(r, ra, a,
2210 Double128VectorTests::ADDReduce, Double128VectorTests::ADDReduceAll);
2211 }
2212 static double ADDReduceMasked(double[] a, int idx, boolean[] mask) {
2213 double res = 0;
2214 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2215 if (mask[i % SPECIES.length()])
2216 res += a[i];
2217 }
2218
2219 return res;
2220 }
2221
2222 static double ADDReduceAllMasked(double[] a, boolean[] mask) {
2223 double res = 0;
2224 for (int i = 0; i < a.length; i += SPECIES.length()) {
2225 res += ADDReduceMasked(a, i, mask);
2226 }
2227
2228 return res;
2229 }
2230 @Test(dataProvider = "doubleUnaryOpMaskProvider")
2231 static void ADDReduceDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2232 double[] a = fa.apply(SPECIES.length());
2233 double[] r = fr.apply(SPECIES.length());
2234 boolean[] mask = fm.apply(SPECIES.length());
2235 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2236 double ra = 0;
2237
2238 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2239 for (int i = 0; i < a.length; i += SPECIES.length()) {
2240 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2241 r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
2242 }
2243 }
2244
2245 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2246 ra = 0;
2247 for (int i = 0; i < a.length; i += SPECIES.length()) {
2248 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2249 ra += av.reduceLanes(VectorOperators.ADD, vmask);
2250 }
2251 }
2252
2253 assertReductionArraysEqualsMasked(r, ra, a, mask,
2254 Double128VectorTests::ADDReduceMasked, Double128VectorTests::ADDReduceAllMasked);
2255 }
2256 static double MULReduce(double[] a, int idx) {
2257 double res = 1;
2258 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2259 res *= a[i];
2260 }
2261
2262 return res;
2263 }
2264
2265 static double MULReduceAll(double[] a) {
2266 double res = 1;
2267 for (int i = 0; i < a.length; i += SPECIES.length()) {
2268 res *= MULReduce(a, i);
2269 }
2270
2271 return res;
2272 }
2273 @Test(dataProvider = "doubleUnaryOpProvider")
2274 static void MULReduceDouble128VectorTests(IntFunction<double[]> fa) {
2275 double[] a = fa.apply(SPECIES.length());
2276 double[] r = fr.apply(SPECIES.length());
2277 double ra = 1;
2278
2279 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2280 for (int i = 0; i < a.length; i += SPECIES.length()) {
2281 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2282 r[i] = av.reduceLanes(VectorOperators.MUL);
2283 }
2284 }
2285
2286 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2287 ra = 1;
2288 for (int i = 0; i < a.length; i += SPECIES.length()) {
2289 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2290 ra *= av.reduceLanes(VectorOperators.MUL);
2291 }
2292 }
2293
2294 assertReductionArraysEquals(r, ra, a,
2295 Double128VectorTests::MULReduce, Double128VectorTests::MULReduceAll);
2296 }
2297 static double MULReduceMasked(double[] a, int idx, boolean[] mask) {
2298 double res = 1;
2299 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2300 if (mask[i % SPECIES.length()])
2301 res *= a[i];
2302 }
2303
2304 return res;
2305 }
2306
2307 static double MULReduceAllMasked(double[] a, boolean[] mask) {
2308 double res = 1;
2309 for (int i = 0; i < a.length; i += SPECIES.length()) {
2310 res *= MULReduceMasked(a, i, mask);
2311 }
2312
2313 return res;
2314 }
2315 @Test(dataProvider = "doubleUnaryOpMaskProvider")
2316 static void MULReduceDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2317 double[] a = fa.apply(SPECIES.length());
2318 double[] r = fr.apply(SPECIES.length());
2319 boolean[] mask = fm.apply(SPECIES.length());
2320 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2321 double ra = 1;
2322
2323 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2324 for (int i = 0; i < a.length; i += SPECIES.length()) {
2325 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2326 r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
2327 }
2328 }
2329
2330 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2331 ra = 1;
2332 for (int i = 0; i < a.length; i += SPECIES.length()) {
2333 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2334 ra *= av.reduceLanes(VectorOperators.MUL, vmask);
2335 }
2336 }
2337
2338 assertReductionArraysEqualsMasked(r, ra, a, mask,
2339 Double128VectorTests::MULReduceMasked, Double128VectorTests::MULReduceAllMasked);
2340 }
2341 static double MINReduce(double[] a, int idx) {
2342 double res = Double.POSITIVE_INFINITY;
2343 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2344 res = (double) Math.min(res, a[i]);
2345 }
2346
2347 return res;
2348 }
2349
2350 static double MINReduceAll(double[] a) {
2351 double res = Double.POSITIVE_INFINITY;
2352 for (int i = 0; i < a.length; i += SPECIES.length()) {
2353 res = (double) Math.min(res, MINReduce(a, i));
2354 }
2355
2356 return res;
2357 }
2358 @Test(dataProvider = "doubleUnaryOpProvider")
2359 static void MINReduceDouble128VectorTests(IntFunction<double[]> fa) {
2360 double[] a = fa.apply(SPECIES.length());
2361 double[] r = fr.apply(SPECIES.length());
2362 double ra = Double.POSITIVE_INFINITY;
2363
2364 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2365 for (int i = 0; i < a.length; i += SPECIES.length()) {
2366 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2367 r[i] = av.reduceLanes(VectorOperators.MIN);
2368 }
2369 }
2370
2371 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2372 ra = Double.POSITIVE_INFINITY;
2373 for (int i = 0; i < a.length; i += SPECIES.length()) {
2374 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2375 ra = (double) Math.min(ra, av.reduceLanes(VectorOperators.MIN));
2376 }
2377 }
2378
2379 assertReductionArraysEquals(r, ra, a,
2380 Double128VectorTests::MINReduce, Double128VectorTests::MINReduceAll);
2381 }
2382 static double MINReduceMasked(double[] a, int idx, boolean[] mask) {
2383 double res = Double.POSITIVE_INFINITY;
2384 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2385 if (mask[i % SPECIES.length()])
2386 res = (double) Math.min(res, a[i]);
2387 }
2388
2389 return res;
2390 }
2391
2392 static double MINReduceAllMasked(double[] a, boolean[] mask) {
2393 double res = Double.POSITIVE_INFINITY;
2394 for (int i = 0; i < a.length; i += SPECIES.length()) {
2395 res = (double) Math.min(res, MINReduceMasked(a, i, mask));
2396 }
2397
2398 return res;
2399 }
2400 @Test(dataProvider = "doubleUnaryOpMaskProvider")
2401 static void MINReduceDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2402 double[] a = fa.apply(SPECIES.length());
2403 double[] r = fr.apply(SPECIES.length());
2404 boolean[] mask = fm.apply(SPECIES.length());
2405 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2406 double ra = Double.POSITIVE_INFINITY;
2407
2408 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2409 for (int i = 0; i < a.length; i += SPECIES.length()) {
2410 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2411 r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
2412 }
2413 }
2414
2415 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2416 ra = Double.POSITIVE_INFINITY;
2417 for (int i = 0; i < a.length; i += SPECIES.length()) {
2418 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2419 ra = (double) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
2420 }
2421 }
2422
2423 assertReductionArraysEqualsMasked(r, ra, a, mask,
2424 Double128VectorTests::MINReduceMasked, Double128VectorTests::MINReduceAllMasked);
2425 }
2426 static double MAXReduce(double[] a, int idx) {
2427 double res = Double.NEGATIVE_INFINITY;
2428 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2429 res = (double) Math.max(res, a[i]);
2430 }
2431
2432 return res;
2433 }
2434
2435 static double MAXReduceAll(double[] a) {
2436 double res = Double.NEGATIVE_INFINITY;
2437 for (int i = 0; i < a.length; i += SPECIES.length()) {
2438 res = (double) Math.max(res, MAXReduce(a, i));
2439 }
2440
2441 return res;
2442 }
2443 @Test(dataProvider = "doubleUnaryOpProvider")
2444 static void MAXReduceDouble128VectorTests(IntFunction<double[]> fa) {
2445 double[] a = fa.apply(SPECIES.length());
2446 double[] r = fr.apply(SPECIES.length());
2447 double ra = Double.NEGATIVE_INFINITY;
2448
2449 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2450 for (int i = 0; i < a.length; i += SPECIES.length()) {
2451 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2452 r[i] = av.reduceLanes(VectorOperators.MAX);
2453 }
2454 }
2455
2456 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2457 ra = Double.NEGATIVE_INFINITY;
2458 for (int i = 0; i < a.length; i += SPECIES.length()) {
2459 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2460 ra = (double) Math.max(ra, av.reduceLanes(VectorOperators.MAX));
2461 }
2462 }
2463
2464 assertReductionArraysEquals(r, ra, a,
2465 Double128VectorTests::MAXReduce, Double128VectorTests::MAXReduceAll);
2466 }
2467 static double MAXReduceMasked(double[] a, int idx, boolean[] mask) {
2468 double res = Double.NEGATIVE_INFINITY;
2469 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2470 if (mask[i % SPECIES.length()])
2471 res = (double) Math.max(res, a[i]);
2472 }
2473
2474 return res;
2475 }
2476
2477 static double MAXReduceAllMasked(double[] a, boolean[] mask) {
2478 double res = Double.NEGATIVE_INFINITY;
2479 for (int i = 0; i < a.length; i += SPECIES.length()) {
2480 res = (double) Math.max(res, MAXReduceMasked(a, i, mask));
2481 }
2482
2483 return res;
2484 }
2485 @Test(dataProvider = "doubleUnaryOpMaskProvider")
2486 static void MAXReduceDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2487 double[] a = fa.apply(SPECIES.length());
2488 double[] r = fr.apply(SPECIES.length());
2489 boolean[] mask = fm.apply(SPECIES.length());
2490 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2491 double ra = Double.NEGATIVE_INFINITY;
2492
2493 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2494 for (int i = 0; i < a.length; i += SPECIES.length()) {
2495 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2496 r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
2497 }
2498 }
2499
2500 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2501 ra = Double.NEGATIVE_INFINITY;
2502 for (int i = 0; i < a.length; i += SPECIES.length()) {
2503 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2504 ra = (double) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
2505 }
2506 }
2507
2508 assertReductionArraysEqualsMasked(r, ra, a, mask,
2509 Double128VectorTests::MAXReduceMasked, Double128VectorTests::MAXReduceAllMasked);
2510 }
2511 static double FIRST_NONZEROReduce(double[] a, int idx) {
2512 double res = (double) 0;
2513 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2514 res = firstNonZero(res, a[i]);
2515 }
2516
2517 return res;
2518 }
2519
2520 static double FIRST_NONZEROReduceAll(double[] a) {
2521 double res = (double) 0;
2522 for (int i = 0; i < a.length; i += SPECIES.length()) {
2523 res = firstNonZero(res, FIRST_NONZEROReduce(a, i));
2524 }
2525
2526 return res;
2527 }
2528 @Test(dataProvider = "doubleUnaryOpProvider")
2529 static void FIRST_NONZEROReduceDouble128VectorTests(IntFunction<double[]> fa) {
2530 double[] a = fa.apply(SPECIES.length());
2531 double[] r = fr.apply(SPECIES.length());
2532 double ra = (double) 0;
2533
2534 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2535 for (int i = 0; i < a.length; i += SPECIES.length()) {
2536 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2537 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO);
2538 }
2539 }
2540
2541 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2542 ra = (double) 0;
2543 for (int i = 0; i < a.length; i += SPECIES.length()) {
2544 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2545 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO));
2546 }
2547 }
2548
2549 assertReductionArraysEquals(r, ra, a,
2550 Double128VectorTests::FIRST_NONZEROReduce, Double128VectorTests::FIRST_NONZEROReduceAll);
2551 }
2552 static double FIRST_NONZEROReduceMasked(double[] a, int idx, boolean[] mask) {
2553 double res = (double) 0;
2554 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2555 if (mask[i % SPECIES.length()])
2556 res = firstNonZero(res, a[i]);
2557 }
2558
2559 return res;
2560 }
2561
2562 static double FIRST_NONZEROReduceAllMasked(double[] a, boolean[] mask) {
2563 double res = (double) 0;
2564 for (int i = 0; i < a.length; i += SPECIES.length()) {
2565 res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask));
2566 }
2567
2568 return res;
2569 }
2570 @Test(dataProvider = "doubleUnaryOpMaskProvider")
2571 static void FIRST_NONZEROReduceDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2572 double[] a = fa.apply(SPECIES.length());
2573 double[] r = fr.apply(SPECIES.length());
2574 boolean[] mask = fm.apply(SPECIES.length());
2575 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2576 double ra = (double) 0;
2577
2578 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2579 for (int i = 0; i < a.length; i += SPECIES.length()) {
2580 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2581 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask);
2582 }
2583 }
2584
2585 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2586 ra = (double) 0;
2587 for (int i = 0; i < a.length; i += SPECIES.length()) {
2588 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2589 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask));
2590 }
2591 }
2592
2593 assertReductionArraysEqualsMasked(r, ra, a, mask,
2594 Double128VectorTests::FIRST_NONZEROReduceMasked, Double128VectorTests::FIRST_NONZEROReduceAllMasked);
2595 }
2596
2597
2598
2599
2600
2601 @Test(dataProvider = "doubleUnaryOpProvider")
2602 static void withDouble128VectorTests(IntFunction<double []> fa) {
2603 double[] a = fa.apply(SPECIES.length());
2604 double[] r = fr.apply(SPECIES.length());
2605
2606 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2607 for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
2608 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2609 av.withLane((j++ & (SPECIES.length()-1)), (double)(65535+i)).intoArray(r, i);
2610 }
2611 }
2612
2613
2614 for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
2615 assertInsertArraysEquals(r, a, (double)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
2616 }
2617 }
2618 static boolean testIS_DEFAULT(double a) {
2619 return bits(a)==0;
2620 }
2621
2622 @Test(dataProvider = "doubleTestOpProvider")
2623 static void IS_DEFAULTDouble128VectorTests(IntFunction<double[]> fa) {
2624 double[] a = fa.apply(SPECIES.length());
2625
2626 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2627 for (int i = 0; i < a.length; i += SPECIES.length()) {
2628 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2629 VectorMask<Double> mv = av.test(VectorOperators.IS_DEFAULT);
2630
2631 // Check results as part of computation.
2632 for (int j = 0; j < SPECIES.length(); j++) {
2633 Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
2634 }
2635 }
2636 }
2637 }
2638
2639 @Test(dataProvider = "doubleTestOpMaskProvider")
2640 static void IS_DEFAULTMaskedDouble128VectorTests(IntFunction<double[]> fa,
2641 IntFunction<boolean[]> fm) {
2642 double[] a = fa.apply(SPECIES.length());
2643 boolean[] mask = fm.apply(SPECIES.length());
2644 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2645
2646 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2647 for (int i = 0; i < a.length; i += SPECIES.length()) {
2648 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2649 VectorMask<Double> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
2650
2651 // Check results as part of computation.
2652 for (int j = 0; j < SPECIES.length(); j++) {
2653 Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
2654 }
2655 }
2656 }
2657 }
2658 static boolean testIS_NEGATIVE(double a) {
2659 return bits(a)<0;
2660 }
2661
2662 @Test(dataProvider = "doubleTestOpProvider")
2663 static void IS_NEGATIVEDouble128VectorTests(IntFunction<double[]> fa) {
2664 double[] a = fa.apply(SPECIES.length());
2665
2666 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2667 for (int i = 0; i < a.length; i += SPECIES.length()) {
2668 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2669 VectorMask<Double> mv = av.test(VectorOperators.IS_NEGATIVE);
2670
2671 // Check results as part of computation.
2672 for (int j = 0; j < SPECIES.length(); j++) {
2673 Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
2674 }
2675 }
2676 }
2677 }
2720 @Test(dataProvider = "doubleTestOpMaskProvider")
2721 static void IS_FINITEMaskedDouble128VectorTests(IntFunction<double[]> fa,
2722 IntFunction<boolean[]> fm) {
2723 double[] a = fa.apply(SPECIES.length());
2724 boolean[] mask = fm.apply(SPECIES.length());
2725 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2726
2727 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2728 for (int i = 0; i < a.length; i += SPECIES.length()) {
2729 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2730 VectorMask<Double> mv = av.test(VectorOperators.IS_FINITE, vmask);
2731
2732 // Check results as part of computation.
2733 for (int j = 0; j < SPECIES.length(); j++) {
2734 Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j]));
2735 }
2736 }
2737 }
2738 }
2739
2740
2741 static boolean testIS_NAN(double a) {
2742 return Double.isNaN(a);
2743 }
2744
2745 @Test(dataProvider = "doubleTestOpProvider")
2746 static void IS_NANDouble128VectorTests(IntFunction<double[]> fa) {
2747 double[] a = fa.apply(SPECIES.length());
2748
2749 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2750 for (int i = 0; i < a.length; i += SPECIES.length()) {
2751 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2752 VectorMask<Double> mv = av.test(VectorOperators.IS_NAN);
2753
2754 // Check results as part of computation.
2755 for (int j = 0; j < SPECIES.length(); j++) {
2756 Assert.assertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j]));
2757 }
2758 }
2759 }
2760 }
2762 @Test(dataProvider = "doubleTestOpMaskProvider")
2763 static void IS_NANMaskedDouble128VectorTests(IntFunction<double[]> fa,
2764 IntFunction<boolean[]> fm) {
2765 double[] a = fa.apply(SPECIES.length());
2766 boolean[] mask = fm.apply(SPECIES.length());
2767 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2768
2769 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2770 for (int i = 0; i < a.length; i += SPECIES.length()) {
2771 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2772 VectorMask<Double> mv = av.test(VectorOperators.IS_NAN, vmask);
2773
2774 // Check results as part of computation.
2775 for (int j = 0; j < SPECIES.length(); j++) {
2776 Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j]));
2777 }
2778 }
2779 }
2780 }
2781
2782
2783 static boolean testIS_INFINITE(double a) {
2784 return Double.isInfinite(a);
2785 }
2786
2787 @Test(dataProvider = "doubleTestOpProvider")
2788 static void IS_INFINITEDouble128VectorTests(IntFunction<double[]> fa) {
2789 double[] a = fa.apply(SPECIES.length());
2790
2791 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2792 for (int i = 0; i < a.length; i += SPECIES.length()) {
2793 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2794 VectorMask<Double> mv = av.test(VectorOperators.IS_INFINITE);
2795
2796 // Check results as part of computation.
2797 for (int j = 0; j < SPECIES.length(); j++) {
2798 Assert.assertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j]));
2799 }
2800 }
2801 }
2802 }
2804 @Test(dataProvider = "doubleTestOpMaskProvider")
2805 static void IS_INFINITEMaskedDouble128VectorTests(IntFunction<double[]> fa,
2806 IntFunction<boolean[]> fm) {
2807 double[] a = fa.apply(SPECIES.length());
2808 boolean[] mask = fm.apply(SPECIES.length());
2809 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2810
2811 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2812 for (int i = 0; i < a.length; i += SPECIES.length()) {
2813 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2814 VectorMask<Double> mv = av.test(VectorOperators.IS_INFINITE, vmask);
2815
2816 // Check results as part of computation.
2817 for (int j = 0; j < SPECIES.length(); j++) {
2818 Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j]));
2819 }
2820 }
2821 }
2822 }
2823
2824
2825 @Test(dataProvider = "doubleCompareOpProvider")
2826 static void LTDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2827 double[] a = fa.apply(SPECIES.length());
2828 double[] b = fb.apply(SPECIES.length());
2829
2830 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2831 for (int i = 0; i < a.length; i += SPECIES.length()) {
2832 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2833 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2834 VectorMask<Double> mv = av.compare(VectorOperators.LT, bv);
2835
2836 // Check results as part of computation.
2837 for (int j = 0; j < SPECIES.length(); j++) {
2838 Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
2839 }
2840 }
2841 }
2842 }
2843
2844
2845 @Test(dataProvider = "doubleCompareOpProvider")
2846 static void ltDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2847 double[] a = fa.apply(SPECIES.length());
2848 double[] b = fb.apply(SPECIES.length());
2849
2850 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2851 for (int i = 0; i < a.length; i += SPECIES.length()) {
2852 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2853 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2854 VectorMask<Double> mv = av.lt(bv);
2855
2856 // Check results as part of computation.
2857 for (int j = 0; j < SPECIES.length(); j++) {
2858 Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
2859 }
2860 }
2861 }
2862 }
2863
2864 @Test(dataProvider = "doubleCompareOpMaskProvider")
2867 double[] a = fa.apply(SPECIES.length());
2868 double[] b = fb.apply(SPECIES.length());
2869 boolean[] mask = fm.apply(SPECIES.length());
2870
2871 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2872
2873 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2874 for (int i = 0; i < a.length; i += SPECIES.length()) {
2875 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2876 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2877 VectorMask<Double> mv = av.compare(VectorOperators.LT, bv, vmask);
2878
2879 // Check results as part of computation.
2880 for (int j = 0; j < SPECIES.length(); j++) {
2881 Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
2882 }
2883 }
2884 }
2885 }
2886
2887
2888 @Test(dataProvider = "doubleCompareOpProvider")
2889 static void GTDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2890 double[] a = fa.apply(SPECIES.length());
2891 double[] b = fb.apply(SPECIES.length());
2892
2893 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2894 for (int i = 0; i < a.length; i += SPECIES.length()) {
2895 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2896 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2897 VectorMask<Double> mv = av.compare(VectorOperators.GT, bv);
2898
2899 // Check results as part of computation.
2900 for (int j = 0; j < SPECIES.length(); j++) {
2901 Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
2902 }
2903 }
2904 }
2905 }
2906
2907 @Test(dataProvider = "doubleCompareOpMaskProvider")
2910 double[] a = fa.apply(SPECIES.length());
2911 double[] b = fb.apply(SPECIES.length());
2912 boolean[] mask = fm.apply(SPECIES.length());
2913
2914 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2915
2916 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2917 for (int i = 0; i < a.length; i += SPECIES.length()) {
2918 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2919 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2920 VectorMask<Double> mv = av.compare(VectorOperators.GT, bv, vmask);
2921
2922 // Check results as part of computation.
2923 for (int j = 0; j < SPECIES.length(); j++) {
2924 Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
2925 }
2926 }
2927 }
2928 }
2929
2930
2931 @Test(dataProvider = "doubleCompareOpProvider")
2932 static void EQDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2933 double[] a = fa.apply(SPECIES.length());
2934 double[] b = fb.apply(SPECIES.length());
2935
2936 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2937 for (int i = 0; i < a.length; i += SPECIES.length()) {
2938 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2939 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2940 VectorMask<Double> mv = av.compare(VectorOperators.EQ, bv);
2941
2942 // Check results as part of computation.
2943 for (int j = 0; j < SPECIES.length(); j++) {
2944 Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
2945 }
2946 }
2947 }
2948 }
2949
2950
2951 @Test(dataProvider = "doubleCompareOpProvider")
2952 static void eqDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2953 double[] a = fa.apply(SPECIES.length());
2954 double[] b = fb.apply(SPECIES.length());
2955
2956 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2957 for (int i = 0; i < a.length; i += SPECIES.length()) {
2958 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2959 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2960 VectorMask<Double> mv = av.eq(bv);
2961
2962 // Check results as part of computation.
2963 for (int j = 0; j < SPECIES.length(); j++) {
2964 Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
2965 }
2966 }
2967 }
2968 }
2969
2970 @Test(dataProvider = "doubleCompareOpMaskProvider")
2973 double[] a = fa.apply(SPECIES.length());
2974 double[] b = fb.apply(SPECIES.length());
2975 boolean[] mask = fm.apply(SPECIES.length());
2976
2977 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2978
2979 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2980 for (int i = 0; i < a.length; i += SPECIES.length()) {
2981 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2982 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2983 VectorMask<Double> mv = av.compare(VectorOperators.EQ, bv, vmask);
2984
2985 // Check results as part of computation.
2986 for (int j = 0; j < SPECIES.length(); j++) {
2987 Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
2988 }
2989 }
2990 }
2991 }
2992
2993
2994 @Test(dataProvider = "doubleCompareOpProvider")
2995 static void NEDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2996 double[] a = fa.apply(SPECIES.length());
2997 double[] b = fb.apply(SPECIES.length());
2998
2999 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3000 for (int i = 0; i < a.length; i += SPECIES.length()) {
3001 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3002 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3003 VectorMask<Double> mv = av.compare(VectorOperators.NE, bv);
3004
3005 // Check results as part of computation.
3006 for (int j = 0; j < SPECIES.length(); j++) {
3007 Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
3008 }
3009 }
3010 }
3011 }
3012
3013 @Test(dataProvider = "doubleCompareOpMaskProvider")
3016 double[] a = fa.apply(SPECIES.length());
3017 double[] b = fb.apply(SPECIES.length());
3018 boolean[] mask = fm.apply(SPECIES.length());
3019
3020 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3021
3022 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3023 for (int i = 0; i < a.length; i += SPECIES.length()) {
3024 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3025 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3026 VectorMask<Double> mv = av.compare(VectorOperators.NE, bv, vmask);
3027
3028 // Check results as part of computation.
3029 for (int j = 0; j < SPECIES.length(); j++) {
3030 Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
3031 }
3032 }
3033 }
3034 }
3035
3036
3037 @Test(dataProvider = "doubleCompareOpProvider")
3038 static void LEDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3039 double[] a = fa.apply(SPECIES.length());
3040 double[] b = fb.apply(SPECIES.length());
3041
3042 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3043 for (int i = 0; i < a.length; i += SPECIES.length()) {
3044 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3045 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3046 VectorMask<Double> mv = av.compare(VectorOperators.LE, bv);
3047
3048 // Check results as part of computation.
3049 for (int j = 0; j < SPECIES.length(); j++) {
3050 Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
3051 }
3052 }
3053 }
3054 }
3055
3056 @Test(dataProvider = "doubleCompareOpMaskProvider")
3059 double[] a = fa.apply(SPECIES.length());
3060 double[] b = fb.apply(SPECIES.length());
3061 boolean[] mask = fm.apply(SPECIES.length());
3062
3063 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3064
3065 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3066 for (int i = 0; i < a.length; i += SPECIES.length()) {
3067 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3068 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3069 VectorMask<Double> mv = av.compare(VectorOperators.LE, bv, vmask);
3070
3071 // Check results as part of computation.
3072 for (int j = 0; j < SPECIES.length(); j++) {
3073 Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
3074 }
3075 }
3076 }
3077 }
3078
3079
3080 @Test(dataProvider = "doubleCompareOpProvider")
3081 static void GEDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3082 double[] a = fa.apply(SPECIES.length());
3083 double[] b = fb.apply(SPECIES.length());
3084
3085 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3086 for (int i = 0; i < a.length; i += SPECIES.length()) {
3087 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3088 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3089 VectorMask<Double> mv = av.compare(VectorOperators.GE, bv);
3090
3091 // Check results as part of computation.
3092 for (int j = 0; j < SPECIES.length(); j++) {
3093 Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
3094 }
3095 }
3096 }
3097 }
3098
3099 @Test(dataProvider = "doubleCompareOpMaskProvider")
3102 double[] a = fa.apply(SPECIES.length());
3103 double[] b = fb.apply(SPECIES.length());
3104 boolean[] mask = fm.apply(SPECIES.length());
3105
3106 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3107
3108 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3109 for (int i = 0; i < a.length; i += SPECIES.length()) {
3110 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3111 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3112 VectorMask<Double> mv = av.compare(VectorOperators.GE, bv, vmask);
3113
3114 // Check results as part of computation.
3115 for (int j = 0; j < SPECIES.length(); j++) {
3116 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
3117 }
3118 }
3119 }
3120 }
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131 @Test(dataProvider = "doubleCompareOpProvider")
3132 static void LTDouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3133 double[] a = fa.apply(SPECIES.length());
3134 double[] b = fb.apply(SPECIES.length());
3135
3136 for (int i = 0; i < a.length; i += SPECIES.length()) {
3137 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3138 VectorMask<Double> mv = av.compare(VectorOperators.LT, b[i]);
3139
3140 // Check results as part of computation.
3141 for (int j = 0; j < SPECIES.length(); j++) {
3142 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
3143 }
3144 }
3145 }
3146
3147
3148 @Test(dataProvider = "doubleCompareOpMaskProvider")
3149 static void LTDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa,
3150 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3151 double[] a = fa.apply(SPECIES.length());
3152 double[] b = fb.apply(SPECIES.length());
3153 boolean[] mask = fm.apply(SPECIES.length());
3154
3155 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3156
3157 for (int i = 0; i < a.length; i += SPECIES.length()) {
3158 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3159 VectorMask<Double> mv = av.compare(VectorOperators.LT, b[i], vmask);
3160
3161 // Check results as part of computation.
3162 for (int j = 0; j < SPECIES.length(); j++) {
3163 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
3164 }
3165 }
3166 }
3167
3168 @Test(dataProvider = "doubleCompareOpProvider")
3169 static void LTDouble128VectorTestsBroadcastLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3170 double[] a = fa.apply(SPECIES.length());
3171 double[] b = fb.apply(SPECIES.length());
3172
3173 for (int i = 0; i < a.length; i += SPECIES.length()) {
3174 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3175 VectorMask<Double> mv = av.compare(VectorOperators.LT, (long)b[i]);
3176
3177 // Check results as part of computation.
3178 for (int j = 0; j < SPECIES.length(); j++) {
3179 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (double)((long)b[i]));
3180 }
3181 }
3182 }
3183
3184
3185 @Test(dataProvider = "doubleCompareOpMaskProvider")
3186 static void LTDouble128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<double[]> fa,
3187 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3188 double[] a = fa.apply(SPECIES.length());
3189 double[] b = fb.apply(SPECIES.length());
3190 boolean[] mask = fm.apply(SPECIES.length());
3191
3192 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3193
3194 for (int i = 0; i < a.length; i += SPECIES.length()) {
3195 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3196 VectorMask<Double> mv = av.compare(VectorOperators.LT, (long)b[i], vmask);
3197
3198 // Check results as part of computation.
3199 for (int j = 0; j < SPECIES.length(); j++) {
3200 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (double)((long)b[i])));
3201 }
3202 }
3203 }
3204
3205 @Test(dataProvider = "doubleCompareOpProvider")
3206 static void EQDouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3207 double[] a = fa.apply(SPECIES.length());
3208 double[] b = fb.apply(SPECIES.length());
3209
3210 for (int i = 0; i < a.length; i += SPECIES.length()) {
3211 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3212 VectorMask<Double> mv = av.compare(VectorOperators.EQ, b[i]);
3213
3214 // Check results as part of computation.
3215 for (int j = 0; j < SPECIES.length(); j++) {
3216 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
3217 }
3218 }
3219 }
3220
3221
3222 @Test(dataProvider = "doubleCompareOpMaskProvider")
3223 static void EQDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa,
3224 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3225 double[] a = fa.apply(SPECIES.length());
3226 double[] b = fb.apply(SPECIES.length());
3227 boolean[] mask = fm.apply(SPECIES.length());
3228
3229 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3230
3231 for (int i = 0; i < a.length; i += SPECIES.length()) {
3232 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3233 VectorMask<Double> mv = av.compare(VectorOperators.EQ, b[i], vmask);
3234
3235 // Check results as part of computation.
3236 for (int j = 0; j < SPECIES.length(); j++) {
3237 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
3238 }
3239 }
3240 }
3241
3242 @Test(dataProvider = "doubleCompareOpProvider")
3243 static void EQDouble128VectorTestsBroadcastLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3244 double[] a = fa.apply(SPECIES.length());
3245 double[] b = fb.apply(SPECIES.length());
3246
3247 for (int i = 0; i < a.length; i += SPECIES.length()) {
3248 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3249 VectorMask<Double> mv = av.compare(VectorOperators.EQ, (long)b[i]);
3250
3251 // Check results as part of computation.
3252 for (int j = 0; j < SPECIES.length(); j++) {
3253 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (double)((long)b[i]));
3254 }
3255 }
3256 }
3257
3258
3259 @Test(dataProvider = "doubleCompareOpMaskProvider")
3260 static void EQDouble128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<double[]> fa,
3261 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3262 double[] a = fa.apply(SPECIES.length());
3263 double[] b = fb.apply(SPECIES.length());
3264 boolean[] mask = fm.apply(SPECIES.length());
3265
3266 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3267
3268 for (int i = 0; i < a.length; i += SPECIES.length()) {
3269 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3270 VectorMask<Double> mv = av.compare(VectorOperators.EQ, (long)b[i], vmask);
3271
3272 // Check results as part of computation.
3273 for (int j = 0; j < SPECIES.length(); j++) {
3274 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (double)((long)b[i])));
3275 }
3276 }
3277 }
3278
3317 assertRearrangeArraysEquals(r, a, order, SPECIES.length());
3318 }
3319
3320 @Test(dataProvider = "doubleUnaryOpShuffleMaskProvider")
3321 static void RearrangeDouble128VectorTestsMaskedSmokeTest(IntFunction<double[]> fa,
3322 BiFunction<Integer,Integer,int[]> fs,
3323 IntFunction<boolean[]> fm) {
3324 double[] a = fa.apply(SPECIES.length());
3325 int[] order = fs.apply(a.length, SPECIES.length());
3326 double[] r = fr.apply(SPECIES.length());
3327 boolean[] mask = fm.apply(SPECIES.length());
3328 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3329
3330 for (int i = 0; i < a.length; i += SPECIES.length()) {
3331 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3332 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
3333 }
3334
3335 assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
3336 }
3337 @Test(dataProvider = "doubleUnaryOpProvider")
3338 static void getDouble128VectorTests(IntFunction<double[]> fa) {
3339 double[] a = fa.apply(SPECIES.length());
3340 double[] r = fr.apply(SPECIES.length());
3341
3342 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3343 for (int i = 0; i < a.length; i += SPECIES.length()) {
3344 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3345 int num_lanes = SPECIES.length();
3346 // Manually unroll because full unroll happens after intrinsification.
3347 // Unroll is needed because get intrinsic requires for index to be a known constant.
3348 if (num_lanes == 1) {
3349 r[i]=av.lane(0);
3350 } else if (num_lanes == 2) {
3351 r[i]=av.lane(0);
3352 r[i+1]=av.lane(1);
3353 } else if (num_lanes == 4) {
3354 r[i]=av.lane(0);
3355 r[i+1]=av.lane(1);
3356 r[i+2]=av.lane(2);
3487 }
3488 }
3489
3490 assertArraysEquals(r, a, Double128VectorTests::get);
3491 }
3492
3493 @Test(dataProvider = "doubleUnaryOpProvider")
3494 static void BroadcastDouble128VectorTests(IntFunction<double[]> fa) {
3495 double[] a = fa.apply(SPECIES.length());
3496 double[] r = new double[a.length];
3497
3498 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3499 for (int i = 0; i < a.length; i += SPECIES.length()) {
3500 DoubleVector.broadcast(SPECIES, a[i]).intoArray(r, i);
3501 }
3502 }
3503
3504 assertBroadcastArraysEquals(r, a);
3505 }
3506
3507
3508
3509
3510
3511 @Test(dataProvider = "doubleUnaryOpProvider")
3512 static void ZeroDouble128VectorTests(IntFunction<double[]> fa) {
3513 double[] a = fa.apply(SPECIES.length());
3514 double[] r = new double[a.length];
3515
3516 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3517 for (int i = 0; i < a.length; i += SPECIES.length()) {
3518 DoubleVector.zero(SPECIES).intoArray(a, i);
3519 }
3520 }
3521
3522 Assert.assertEquals(a, r);
3523 }
3524
3525
3526
3527
3528 static double[] sliceUnary(double[] a, int origin, int idx) {
3529 double[] res = new double[SPECIES.length()];
3530 for (int i = 0; i < SPECIES.length(); i++){
3531 if(i+origin < SPECIES.length())
3532 res[i] = a[idx+i+origin];
3533 else
3534 res[i] = (double)0;
3535 }
3536 return res;
3537 }
3538
3539 @Test(dataProvider = "doubleUnaryOpProvider")
3540 static void sliceUnaryDouble128VectorTests(IntFunction<double[]> fa) {
3541 double[] a = fa.apply(SPECIES.length());
3542 double[] r = new double[a.length];
3543 int origin = (new java.util.Random()).nextInt(SPECIES.length());
3544 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3545 for (int i = 0; i < a.length; i += SPECIES.length()) {
3546 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3547 av.slice(origin).intoArray(r, i);
3548 }
3549 }
3550
3551 assertArraysEquals(r, a, origin, Double128VectorTests::sliceUnary);
3552 }
3553 static double[] sliceBinary(double[] a, double[] b, int origin, int idx) {
3554 double[] res = new double[SPECIES.length()];
3555 for (int i = 0, j = 0; i < SPECIES.length(); i++){
3556 if(i+origin < SPECIES.length())
3557 res[i] = a[idx+i+origin];
3558 else {
3559 res[i] = b[idx+j];
3560 j++;
3561 }
3562 }
3563 return res;
3564 }
3565
3566 @Test(dataProvider = "doubleBinaryOpProvider")
3567 static void sliceBinaryDouble128VectorTestsBinary(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3568 double[] a = fa.apply(SPECIES.length());
3569 double[] b = fb.apply(SPECIES.length());
3570 double[] r = new double[a.length];
3571 int origin = (new java.util.Random()).nextInt(SPECIES.length());
3572 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3573 for (int i = 0; i < a.length; i += SPECIES.length()) {
3574 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3575 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3576 av.slice(origin, bv).intoArray(r, i);
3577 }
3578 }
3579
3580 assertArraysEquals(r, a, b, origin, Double128VectorTests::sliceBinary);
3581 }
3582 static double[] slice(double[] a, double[] b, int origin, boolean[] mask, int idx) {
3583 double[] res = new double[SPECIES.length()];
3584 for (int i = 0, j = 0; i < SPECIES.length(); i++){
3585 if(i+origin < SPECIES.length())
3586 res[i] = mask[i] ? a[idx+i+origin] : (double)0;
3587 else {
3588 res[i] = mask[i] ? b[idx+j] : (double)0;
3589 j++;
3590 }
3591 }
3592 return res;
3593 }
3594
3595 @Test(dataProvider = "doubleBinaryOpMaskProvider")
3596 static void sliceDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
3597 IntFunction<boolean[]> fm) {
3598 double[] a = fa.apply(SPECIES.length());
3599 double[] b = fb.apply(SPECIES.length());
3600 boolean[] mask = fm.apply(SPECIES.length());
3601 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3602
3603 double[] r = new double[a.length];
3604 int origin = (new java.util.Random()).nextInt(SPECIES.length());
3605 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3606 for (int i = 0; i < a.length; i += SPECIES.length()) {
3607 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3608 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3609 av.slice(origin, bv, vmask).intoArray(r, i);
3610 }
3611 }
3612
3613 assertArraysEquals(r, a, b, origin, mask, Double128VectorTests::slice);
3614 }
3615 static double[] unsliceUnary(double[] a, int origin, int idx) {
3616 double[] res = new double[SPECIES.length()];
3617 for (int i = 0, j = 0; i < SPECIES.length(); i++){
3618 if(i < origin)
3619 res[i] = (double)0;
3620 else {
3621 res[i] = a[idx+j];
3622 j++;
3623 }
3624 }
3625 return res;
3626 }
3627
3628 @Test(dataProvider = "doubleUnaryOpProvider")
3629 static void unsliceUnaryDouble128VectorTests(IntFunction<double[]> fa) {
3630 double[] a = fa.apply(SPECIES.length());
3631 double[] r = new double[a.length];
3632 int origin = (new java.util.Random()).nextInt(SPECIES.length());
3633 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3634 for (int i = 0; i < a.length; i += SPECIES.length()) {
3635 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3636 av.unslice(origin).intoArray(r, i);
3637 }
3638 }
3639
3640 assertArraysEquals(r, a, origin, Double128VectorTests::unsliceUnary);
3641 }
3642 static double[] unsliceBinary(double[] a, double[] b, int origin, int part, int idx) {
3643 double[] res = new double[SPECIES.length()];
3644 for (int i = 0, j = 0; i < SPECIES.length(); i++){
3645 if (part == 0) {
3646 if (i < origin)
3647 res[i] = b[idx+i];
3648 else {
3649 res[i] = a[idx+j];
3650 j++;
3651 }
3652 } else if (part == 1) {
3653 if (i < origin)
3654 res[i] = a[idx+SPECIES.length()-origin+i];
3655 else {
3656 res[i] = b[idx+origin+j];
3657 j++;
3658 }
3659 }
3660 }
3661 return res;
3662 }
3663
3664 @Test(dataProvider = "doubleBinaryOpProvider")
3665 static void unsliceBinaryDouble128VectorTestsBinary(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3666 double[] a = fa.apply(SPECIES.length());
3667 double[] b = fb.apply(SPECIES.length());
3668 double[] r = new double[a.length];
3669 int origin = (new java.util.Random()).nextInt(SPECIES.length());
3670 int part = (new java.util.Random()).nextInt(2);
3671 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3672 for (int i = 0; i < a.length; i += SPECIES.length()) {
3673 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3674 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3675 av.unslice(origin, bv, part).intoArray(r, i);
3676 }
3677 }
3678
3679 assertArraysEquals(r, a, b, origin, part, Double128VectorTests::unsliceBinary);
3680 }
3681 static double[] unslice(double[] a, double[] b, int origin, int part, boolean[] mask, int idx) {
3682 double[] res = new double[SPECIES.length()];
3683 for (int i = 0, j = 0; i < SPECIES.length(); i++){
3684 if(i+origin < SPECIES.length())
3685 res[i] = b[idx+i+origin];
3686 else {
3687 res[i] = b[idx+j];
3688 j++;
3689 }
3690 }
3691 for (int i = 0; i < SPECIES.length(); i++){
3692 res[i] = mask[i] ? a[idx+i] : res[i];
3693 }
3694 double[] res1 = new double[SPECIES.length()];
3695 if (part == 0) {
3696 for (int i = 0, j = 0; i < SPECIES.length(); i++){
3697 if (i < origin)
3698 res1[i] = b[idx+i];
3699 else {
3700 res1[i] = res[j];
3741
3742 static double strictSIN(double a) {
3743 return (double)(StrictMath.sin((double)a));
3744 }
3745
3746 @Test(dataProvider = "doubleUnaryOpProvider")
3747 static void SINDouble128VectorTests(IntFunction<double[]> fa) {
3748 double[] a = fa.apply(SPECIES.length());
3749 double[] r = fr.apply(SPECIES.length());
3750
3751 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3752 for (int i = 0; i < a.length; i += SPECIES.length()) {
3753 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3754 av.lanewise(VectorOperators.SIN).intoArray(r, i);
3755 }
3756 }
3757
3758 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::SIN, Double128VectorTests::strictSIN);
3759 }
3760
3761
3762 static double EXP(double a) {
3763 return (double)(Math.exp((double)a));
3764 }
3765
3766 static double strictEXP(double a) {
3767 return (double)(StrictMath.exp((double)a));
3768 }
3769
3770 @Test(dataProvider = "doubleUnaryOpProvider")
3771 static void EXPDouble128VectorTests(IntFunction<double[]> fa) {
3772 double[] a = fa.apply(SPECIES.length());
3773 double[] r = fr.apply(SPECIES.length());
3774
3775 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3776 for (int i = 0; i < a.length; i += SPECIES.length()) {
3777 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3778 av.lanewise(VectorOperators.EXP).intoArray(r, i);
3779 }
3780 }
3781
3782 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::EXP, Double128VectorTests::strictEXP);
3783 }
3784
3785
3786 static double LOG1P(double a) {
3787 return (double)(Math.log1p((double)a));
3788 }
3789
3790 static double strictLOG1P(double a) {
3791 return (double)(StrictMath.log1p((double)a));
3792 }
3793
3794 @Test(dataProvider = "doubleUnaryOpProvider")
3795 static void LOG1PDouble128VectorTests(IntFunction<double[]> fa) {
3796 double[] a = fa.apply(SPECIES.length());
3797 double[] r = fr.apply(SPECIES.length());
3798
3799 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3800 for (int i = 0; i < a.length; i += SPECIES.length()) {
3801 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3802 av.lanewise(VectorOperators.LOG1P).intoArray(r, i);
3803 }
3804 }
3805
3806 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::LOG1P, Double128VectorTests::strictLOG1P);
3807 }
3808
3809
3810 static double LOG(double a) {
3811 return (double)(Math.log((double)a));
3812 }
3813
3814 static double strictLOG(double a) {
3815 return (double)(StrictMath.log((double)a));
3816 }
3817
3818 @Test(dataProvider = "doubleUnaryOpProvider")
3819 static void LOGDouble128VectorTests(IntFunction<double[]> fa) {
3820 double[] a = fa.apply(SPECIES.length());
3821 double[] r = fr.apply(SPECIES.length());
3822
3823 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3824 for (int i = 0; i < a.length; i += SPECIES.length()) {
3825 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3826 av.lanewise(VectorOperators.LOG).intoArray(r, i);
3827 }
3828 }
3829
3830 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::LOG, Double128VectorTests::strictLOG);
3831 }
3832
3833
3834 static double LOG10(double a) {
3835 return (double)(Math.log10((double)a));
3836 }
3837
3838 static double strictLOG10(double a) {
3839 return (double)(StrictMath.log10((double)a));
3840 }
3841
3842 @Test(dataProvider = "doubleUnaryOpProvider")
3843 static void LOG10Double128VectorTests(IntFunction<double[]> fa) {
3844 double[] a = fa.apply(SPECIES.length());
3845 double[] r = fr.apply(SPECIES.length());
3846
3847 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3848 for (int i = 0; i < a.length; i += SPECIES.length()) {
3849 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3850 av.lanewise(VectorOperators.LOG10).intoArray(r, i);
3851 }
3852 }
3853
3854 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::LOG10, Double128VectorTests::strictLOG10);
3855 }
3856
3857
3858 static double EXPM1(double a) {
3859 return (double)(Math.expm1((double)a));
3860 }
3861
3862 static double strictEXPM1(double a) {
3863 return (double)(StrictMath.expm1((double)a));
3864 }
3865
3866 @Test(dataProvider = "doubleUnaryOpProvider")
3867 static void EXPM1Double128VectorTests(IntFunction<double[]> fa) {
3868 double[] a = fa.apply(SPECIES.length());
3869 double[] r = fr.apply(SPECIES.length());
3870
3871 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3872 for (int i = 0; i < a.length; i += SPECIES.length()) {
3873 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3874 av.lanewise(VectorOperators.EXPM1).intoArray(r, i);
3875 }
3876 }
3877
3878 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::EXPM1, Double128VectorTests::strictEXPM1);
3879 }
3880
3881
3882 static double COS(double a) {
3883 return (double)(Math.cos((double)a));
3884 }
3885
3886 static double strictCOS(double a) {
3887 return (double)(StrictMath.cos((double)a));
3888 }
3889
3890 @Test(dataProvider = "doubleUnaryOpProvider")
3891 static void COSDouble128VectorTests(IntFunction<double[]> fa) {
3892 double[] a = fa.apply(SPECIES.length());
3893 double[] r = fr.apply(SPECIES.length());
3894
3895 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3896 for (int i = 0; i < a.length; i += SPECIES.length()) {
3897 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3898 av.lanewise(VectorOperators.COS).intoArray(r, i);
3899 }
3900 }
3901
3902 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::COS, Double128VectorTests::strictCOS);
3903 }
3904
3905
3906 static double TAN(double a) {
3907 return (double)(Math.tan((double)a));
3908 }
3909
3910 static double strictTAN(double a) {
3911 return (double)(StrictMath.tan((double)a));
3912 }
3913
3914 @Test(dataProvider = "doubleUnaryOpProvider")
3915 static void TANDouble128VectorTests(IntFunction<double[]> fa) {
3916 double[] a = fa.apply(SPECIES.length());
3917 double[] r = fr.apply(SPECIES.length());
3918
3919 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3920 for (int i = 0; i < a.length; i += SPECIES.length()) {
3921 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3922 av.lanewise(VectorOperators.TAN).intoArray(r, i);
3923 }
3924 }
3925
3926 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::TAN, Double128VectorTests::strictTAN);
3927 }
3928
3929
3930 static double SINH(double a) {
3931 return (double)(Math.sinh((double)a));
3932 }
3933
3934 static double strictSINH(double a) {
3935 return (double)(StrictMath.sinh((double)a));
3936 }
3937
3938 @Test(dataProvider = "doubleUnaryOpProvider")
3939 static void SINHDouble128VectorTests(IntFunction<double[]> fa) {
3940 double[] a = fa.apply(SPECIES.length());
3941 double[] r = fr.apply(SPECIES.length());
3942
3943 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3944 for (int i = 0; i < a.length; i += SPECIES.length()) {
3945 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3946 av.lanewise(VectorOperators.SINH).intoArray(r, i);
3947 }
3948 }
3949
3950 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::SINH, Double128VectorTests::strictSINH);
3951 }
3952
3953
3954 static double COSH(double a) {
3955 return (double)(Math.cosh((double)a));
3956 }
3957
3958 static double strictCOSH(double a) {
3959 return (double)(StrictMath.cosh((double)a));
3960 }
3961
3962 @Test(dataProvider = "doubleUnaryOpProvider")
3963 static void COSHDouble128VectorTests(IntFunction<double[]> fa) {
3964 double[] a = fa.apply(SPECIES.length());
3965 double[] r = fr.apply(SPECIES.length());
3966
3967 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3968 for (int i = 0; i < a.length; i += SPECIES.length()) {
3969 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3970 av.lanewise(VectorOperators.COSH).intoArray(r, i);
3971 }
3972 }
3973
3974 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::COSH, Double128VectorTests::strictCOSH);
3975 }
3976
3977
3978 static double TANH(double a) {
3979 return (double)(Math.tanh((double)a));
3980 }
3981
3982 static double strictTANH(double a) {
3983 return (double)(StrictMath.tanh((double)a));
3984 }
3985
3986 @Test(dataProvider = "doubleUnaryOpProvider")
3987 static void TANHDouble128VectorTests(IntFunction<double[]> fa) {
3988 double[] a = fa.apply(SPECIES.length());
3989 double[] r = fr.apply(SPECIES.length());
3990
3991 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3992 for (int i = 0; i < a.length; i += SPECIES.length()) {
3993 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3994 av.lanewise(VectorOperators.TANH).intoArray(r, i);
3995 }
3996 }
3997
3998 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::TANH, Double128VectorTests::strictTANH);
3999 }
4000
4001
4002 static double ASIN(double a) {
4003 return (double)(Math.asin((double)a));
4004 }
4005
4006 static double strictASIN(double a) {
4007 return (double)(StrictMath.asin((double)a));
4008 }
4009
4010 @Test(dataProvider = "doubleUnaryOpProvider")
4011 static void ASINDouble128VectorTests(IntFunction<double[]> fa) {
4012 double[] a = fa.apply(SPECIES.length());
4013 double[] r = fr.apply(SPECIES.length());
4014
4015 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4016 for (int i = 0; i < a.length; i += SPECIES.length()) {
4017 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4018 av.lanewise(VectorOperators.ASIN).intoArray(r, i);
4019 }
4020 }
4021
4022 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::ASIN, Double128VectorTests::strictASIN);
4023 }
4024
4025
4026 static double ACOS(double a) {
4027 return (double)(Math.acos((double)a));
4028 }
4029
4030 static double strictACOS(double a) {
4031 return (double)(StrictMath.acos((double)a));
4032 }
4033
4034 @Test(dataProvider = "doubleUnaryOpProvider")
4035 static void ACOSDouble128VectorTests(IntFunction<double[]> fa) {
4036 double[] a = fa.apply(SPECIES.length());
4037 double[] r = fr.apply(SPECIES.length());
4038
4039 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4040 for (int i = 0; i < a.length; i += SPECIES.length()) {
4041 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4042 av.lanewise(VectorOperators.ACOS).intoArray(r, i);
4043 }
4044 }
4045
4046 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::ACOS, Double128VectorTests::strictACOS);
4047 }
4048
4049
4050 static double ATAN(double a) {
4051 return (double)(Math.atan((double)a));
4052 }
4053
4054 static double strictATAN(double a) {
4055 return (double)(StrictMath.atan((double)a));
4056 }
4057
4058 @Test(dataProvider = "doubleUnaryOpProvider")
4059 static void ATANDouble128VectorTests(IntFunction<double[]> fa) {
4060 double[] a = fa.apply(SPECIES.length());
4061 double[] r = fr.apply(SPECIES.length());
4062
4063 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4064 for (int i = 0; i < a.length; i += SPECIES.length()) {
4065 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4066 av.lanewise(VectorOperators.ATAN).intoArray(r, i);
4067 }
4068 }
4069
4070 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::ATAN, Double128VectorTests::strictATAN);
4071 }
4072
4073
4074 static double CBRT(double a) {
4075 return (double)(Math.cbrt((double)a));
4076 }
4077
4078 static double strictCBRT(double a) {
4079 return (double)(StrictMath.cbrt((double)a));
4080 }
4081
4082 @Test(dataProvider = "doubleUnaryOpProvider")
4083 static void CBRTDouble128VectorTests(IntFunction<double[]> fa) {
4084 double[] a = fa.apply(SPECIES.length());
4085 double[] r = fr.apply(SPECIES.length());
4086
4087 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4088 for (int i = 0; i < a.length; i += SPECIES.length()) {
4089 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4090 av.lanewise(VectorOperators.CBRT).intoArray(r, i);
4091 }
4092 }
4093
4094 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::CBRT, Double128VectorTests::strictCBRT);
4095 }
4096
4097
4098 static double HYPOT(double a, double b) {
4099 return (double)(Math.hypot((double)a, (double)b));
4100 }
4101
4102 static double strictHYPOT(double a, double b) {
4103 return (double)(StrictMath.hypot((double)a, (double)b));
4104 }
4105
4106 @Test(dataProvider = "doubleBinaryOpProvider")
4107 static void HYPOTDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4108 double[] a = fa.apply(SPECIES.length());
4109 double[] b = fb.apply(SPECIES.length());
4110 double[] r = fr.apply(SPECIES.length());
4111
4112 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4113 for (int i = 0; i < a.length; i += SPECIES.length()) {
4114 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4115 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4116 av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i);
4117 }
4118 }
4119
4120 assertArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::HYPOT, Double128VectorTests::strictHYPOT);
4121 }
4122
4123
4124
4125 static double POW(double a, double b) {
4126 return (double)(Math.pow((double)a, (double)b));
4127 }
4128
4129 static double strictPOW(double a, double b) {
4130 return (double)(StrictMath.pow((double)a, (double)b));
4131 }
4132
4133 @Test(dataProvider = "doubleBinaryOpProvider")
4134 static void POWDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4135 double[] a = fa.apply(SPECIES.length());
4136 double[] b = fb.apply(SPECIES.length());
4137 double[] r = fr.apply(SPECIES.length());
4138
4139 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4140 for (int i = 0; i < a.length; i += SPECIES.length()) {
4141 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4142 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4143 av.lanewise(VectorOperators.POW, bv).intoArray(r, i);
4144 }
4145 }
4146
4147 assertArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::POW, Double128VectorTests::strictPOW);
4148 }
4149
4150 static double pow(double a, double b) {
4151 return (double)(Math.pow((double)a, (double)b));
4152 }
4153
4154 static double strictpow(double a, double b) {
4155 return (double)(StrictMath.pow((double)a, (double)b));
4156 }
4157
4158 @Test(dataProvider = "doubleBinaryOpProvider")
4159 static void powDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4160 double[] a = fa.apply(SPECIES.length());
4161 double[] b = fb.apply(SPECIES.length());
4162 double[] r = fr.apply(SPECIES.length());
4163
4164 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4165 for (int i = 0; i < a.length; i += SPECIES.length()) {
4166 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4167 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4168 av.pow(bv).intoArray(r, i);
4169 }
4170 }
4171
4172 assertArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::pow, Double128VectorTests::strictpow);
4173 }
4174
4175
4176
4177 static double ATAN2(double a, double b) {
4178 return (double)(Math.atan2((double)a, (double)b));
4179 }
4180
4181 static double strictATAN2(double a, double b) {
4182 return (double)(StrictMath.atan2((double)a, (double)b));
4183 }
4184
4185 @Test(dataProvider = "doubleBinaryOpProvider")
4186 static void ATAN2Double128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4187 double[] a = fa.apply(SPECIES.length());
4188 double[] b = fb.apply(SPECIES.length());
4189 double[] r = fr.apply(SPECIES.length());
4190
4191 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4192 for (int i = 0; i < a.length; i += SPECIES.length()) {
4193 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4194 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4195 av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i);
4196 }
4197 }
4198
4199 assertArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::ATAN2, Double128VectorTests::strictATAN2);
4200 }
4201
4202
4203
4204 @Test(dataProvider = "doubleBinaryOpProvider")
4205 static void POWDouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4206 double[] a = fa.apply(SPECIES.length());
4207 double[] b = fb.apply(SPECIES.length());
4208 double[] r = fr.apply(SPECIES.length());
4209
4210 for (int i = 0; i < a.length; i += SPECIES.length()) {
4211 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4212 av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i);
4213 }
4214
4215 assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::POW, Double128VectorTests::strictPOW);
4216 }
4217
4218 @Test(dataProvider = "doubleBinaryOpProvider")
4219 static void powDouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4220 double[] a = fa.apply(SPECIES.length());
4221 double[] b = fb.apply(SPECIES.length());
4222 double[] r = fr.apply(SPECIES.length());
4223
4224 for (int i = 0; i < a.length; i += SPECIES.length()) {
4225 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4226 av.pow(b[i]).intoArray(r, i);
4227 }
4228
4229 assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::pow, Double128VectorTests::strictpow);
4230 }
4231
4232
4233
4234 static double FMA(double a, double b, double c) {
4235 return (double)(Math.fma(a, b, c));
4236 }
4237 static double fma(double a, double b, double c) {
4238 return (double)(Math.fma(a, b, c));
4239 }
4240
4241
4242 @Test(dataProvider = "doubleTernaryOpProvider")
4243 static void FMADouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4244 int count = INVOC_COUNT;
4245 switch ("FMA") {
4246 case "fma": case "lanewise_FMA":
4247 // Math.fma uses BigDecimal
4248 count = Math.max(5, count/20); break;
4249 }
4250 final int INVOC_COUNT = count;
4251 double[] a = fa.apply(SPECIES.length());
4252 double[] b = fb.apply(SPECIES.length());
4253 double[] c = fc.apply(SPECIES.length());
4254 double[] r = fr.apply(SPECIES.length());
4255
4256 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4257 for (int i = 0; i < a.length; i += SPECIES.length()) {
4258 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4259 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4260 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4261 av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i);
4262 }
4263 }
4264
4265 assertArraysEquals(r, a, b, c, Double128VectorTests::FMA);
4266 }
4267 @Test(dataProvider = "doubleTernaryOpProvider")
4268 static void fmaDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4269 int count = INVOC_COUNT;
4270 switch ("fma") {
4271 case "fma": case "lanewise_FMA":
4272 // Math.fma uses BigDecimal
4273 count = Math.max(5, count/20); break;
4274 }
4275 final int INVOC_COUNT = count;
4276 double[] a = fa.apply(SPECIES.length());
4277 double[] b = fb.apply(SPECIES.length());
4278 double[] c = fc.apply(SPECIES.length());
4279 double[] r = fr.apply(SPECIES.length());
4280
4281 for (int i = 0; i < a.length; i += SPECIES.length()) {
4282 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4283 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4284 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4285 av.fma(bv, cv).intoArray(r, i);
4286 }
4287
4288 assertArraysEquals(r, a, b, c, Double128VectorTests::fma);
4289 }
4290
4291
4292 @Test(dataProvider = "doubleTernaryOpMaskProvider")
4293 static void FMADouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
4294 IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4295 int count = INVOC_COUNT;
4296 switch ("FMA") {
4297 case "fma": case "lanewise_FMA":
4298 // Math.fma uses BigDecimal
4299 count = Math.max(5, count/20); break;
4300 }
4301 final int INVOC_COUNT = count;
4302 double[] a = fa.apply(SPECIES.length());
4303 double[] b = fb.apply(SPECIES.length());
4304 double[] c = fc.apply(SPECIES.length());
4305 double[] r = fr.apply(SPECIES.length());
4306 boolean[] mask = fm.apply(SPECIES.length());
4307 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4308
4309 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4310 for (int i = 0; i < a.length; i += SPECIES.length()) {
4311 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4312 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4313 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4314 av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i);
4315 }
4316 }
4317
4318 assertArraysEquals(r, a, b, c, mask, Double128VectorTests::FMA);
4319 }
4320
4321
4322
4323
4324
4325 @Test(dataProvider = "doubleTernaryOpProvider")
4326 static void FMADouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4327 double[] a = fa.apply(SPECIES.length());
4328 double[] b = fb.apply(SPECIES.length());
4329 double[] c = fc.apply(SPECIES.length());
4330 double[] r = fr.apply(SPECIES.length());
4331
4332 for (int i = 0; i < a.length; i += SPECIES.length()) {
4333 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4334 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4335 av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i);
4336 }
4337 assertBroadcastArraysEquals(r, a, b, c, Double128VectorTests::FMA);
4338 }
4339
4340 @Test(dataProvider = "doubleTernaryOpProvider")
4341 static void FMADouble128VectorTestsAltBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4342 double[] a = fa.apply(SPECIES.length());
4343 double[] b = fb.apply(SPECIES.length());
4344 double[] c = fc.apply(SPECIES.length());
4345 double[] r = fr.apply(SPECIES.length());
4346
4347 for (int i = 0; i < a.length; i += SPECIES.length()) {
4348 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4349 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4350 av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i);
4351 }
4352 assertAltBroadcastArraysEquals(r, a, b, c, Double128VectorTests::FMA);
4353 }
4354
4355
4356 @Test(dataProvider = "doubleTernaryOpMaskProvider")
4357 static void FMADouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
4358 IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4359 double[] a = fa.apply(SPECIES.length());
4360 double[] b = fb.apply(SPECIES.length());
4361 double[] c = fc.apply(SPECIES.length());
4362 double[] r = fr.apply(SPECIES.length());
4363 boolean[] mask = fm.apply(SPECIES.length());
4364 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4365
4366 for (int i = 0; i < a.length; i += SPECIES.length()) {
4367 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4368 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4369 av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i);
4370 }
4371
4372 assertBroadcastArraysEquals(r, a, b, c, mask, Double128VectorTests::FMA);
4373 }
4374
4375 @Test(dataProvider = "doubleTernaryOpMaskProvider")
4376 static void FMADouble128VectorTestsAltBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
4377 IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4378 double[] a = fa.apply(SPECIES.length());
4379 double[] b = fb.apply(SPECIES.length());
4380 double[] c = fc.apply(SPECIES.length());
4381 double[] r = fr.apply(SPECIES.length());
4382 boolean[] mask = fm.apply(SPECIES.length());
4383 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4384
4385 for (int i = 0; i < a.length; i += SPECIES.length()) {
4386 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4387 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4388 av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i);
4389 }
4390
4391 assertAltBroadcastArraysEquals(r, a, b, c, mask, Double128VectorTests::FMA);
4392 }
4393
4394
4395
4396
4397 @Test(dataProvider = "doubleTernaryOpProvider")
4398 static void FMADouble128VectorTestsDoubleBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4399 int count = INVOC_COUNT;
4400 switch ("FMA") {
4401 case "fma": case "lanewise_FMA":
4402 // Math.fma uses BigDecimal
4403 count = Math.max(5, count/20); break;
4404 }
4405 final int INVOC_COUNT = count;
4406 double[] a = fa.apply(SPECIES.length());
4407 double[] b = fb.apply(SPECIES.length());
4408 double[] c = fc.apply(SPECIES.length());
4409 double[] r = fr.apply(SPECIES.length());
4410
4411 for (int i = 0; i < a.length; i += SPECIES.length()) {
4412 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4413 av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i);
4414 }
4415
4416 assertDoubleBroadcastArraysEquals(r, a, b, c, Double128VectorTests::FMA);
4417 }
4418 @Test(dataProvider = "doubleTernaryOpProvider")
4419 static void fmaDouble128VectorTestsDoubleBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4420 int count = INVOC_COUNT;
4421 switch ("fma") {
4422 case "fma": case "lanewise_FMA":
4423 // Math.fma uses BigDecimal
4424 count = Math.max(5, count/20); break;
4425 }
4426 final int INVOC_COUNT = count;
4427 double[] a = fa.apply(SPECIES.length());
4428 double[] b = fb.apply(SPECIES.length());
4429 double[] c = fc.apply(SPECIES.length());
4430 double[] r = fr.apply(SPECIES.length());
4431
4432 for (int i = 0; i < a.length; i += SPECIES.length()) {
4433 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4434 av.fma(b[i], c[i]).intoArray(r, i);
4435 }
4436
4437 assertDoubleBroadcastArraysEquals(r, a, b, c, Double128VectorTests::fma);
4438 }
4439
4440
4441 @Test(dataProvider = "doubleTernaryOpMaskProvider")
4442 static void FMADouble128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
4443 IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4444 int count = INVOC_COUNT;
4445 switch ("FMA") {
4446 case "fma": case "lanewise_FMA":
4447 // Math.fma uses BigDecimal
4448 count = Math.max(5, count/20); break;
4449 }
4450 final int INVOC_COUNT = count;
4451 double[] a = fa.apply(SPECIES.length());
4452 double[] b = fb.apply(SPECIES.length());
4453 double[] c = fc.apply(SPECIES.length());
4454 double[] r = fr.apply(SPECIES.length());
4455 boolean[] mask = fm.apply(SPECIES.length());
4456 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4457
4458 for (int i = 0; i < a.length; i += SPECIES.length()) {
4459 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4460 av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i);
4461 }
4462
4463 assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Double128VectorTests::FMA);
4464 }
4465
4466
4467
4468
4469 static double NEG(double a) {
4470 return (double)(-((double)a));
4471 }
4472
4473 static double neg(double a) {
4474 return (double)(-((double)a));
4475 }
4476
4477 @Test(dataProvider = "doubleUnaryOpProvider")
4478 static void NEGDouble128VectorTests(IntFunction<double[]> fa) {
4479 double[] a = fa.apply(SPECIES.length());
4480 double[] r = fr.apply(SPECIES.length());
4481
4482 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4483 for (int i = 0; i < a.length; i += SPECIES.length()) {
4484 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4485 av.lanewise(VectorOperators.NEG).intoArray(r, i);
4486 }
4487 }
4488
4561 }
4562
4563 @Test(dataProvider = "doubleUnaryOpMaskProvider")
4564 static void ABSMaskedDouble128VectorTests(IntFunction<double[]> fa,
4565 IntFunction<boolean[]> fm) {
4566 double[] a = fa.apply(SPECIES.length());
4567 double[] r = fr.apply(SPECIES.length());
4568 boolean[] mask = fm.apply(SPECIES.length());
4569 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4570
4571 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4572 for (int i = 0; i < a.length; i += SPECIES.length()) {
4573 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4574 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
4575 }
4576 }
4577
4578 assertArraysEquals(r, a, mask, Double128VectorTests::ABS);
4579 }
4580
4581
4582
4583
4584
4585
4586
4587
4588 static double SQRT(double a) {
4589 return (double)(Math.sqrt((double)a));
4590 }
4591
4592 static double sqrt(double a) {
4593 return (double)(Math.sqrt((double)a));
4594 }
4595
4596
4597
4598 @Test(dataProvider = "doubleUnaryOpProvider")
4599 static void SQRTDouble128VectorTests(IntFunction<double[]> fa) {
4600 double[] a = fa.apply(SPECIES.length());
4601 double[] r = fr.apply(SPECIES.length());
4602
4603 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4604 for (int i = 0; i < a.length; i += SPECIES.length()) {
4605 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4606 av.lanewise(VectorOperators.SQRT).intoArray(r, i);
4607 }
4608 }
4609
4610 assertArraysEquals(r, a, Double128VectorTests::SQRT);
4611 }
4612
4613 @Test(dataProvider = "doubleUnaryOpProvider")
4614 static void sqrtDouble128VectorTests(IntFunction<double[]> fa) {
4615 double[] a = fa.apply(SPECIES.length());
4616 double[] r = fr.apply(SPECIES.length());
4617
4618 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4619 for (int i = 0; i < a.length; i += SPECIES.length()) {
4620 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4621 av.sqrt().intoArray(r, i);
4622 }
4623 }
4624
4625 assertArraysEquals(r, a, Double128VectorTests::sqrt);
4626 }
4627
4628
4629
4630 @Test(dataProvider = "doubleUnaryOpMaskProvider")
4631 static void SQRTMaskedDouble128VectorTests(IntFunction<double[]> fa,
4632 IntFunction<boolean[]> fm) {
4633 double[] a = fa.apply(SPECIES.length());
4634 double[] r = fr.apply(SPECIES.length());
4635 boolean[] mask = fm.apply(SPECIES.length());
4636 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4637
4638 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4639 for (int i = 0; i < a.length; i += SPECIES.length()) {
4640 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4641 av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i);
4642 }
4643 }
4644
4645 assertArraysEquals(r, a, mask, Double128VectorTests::SQRT);
4646 }
4647
4648
4649 @Test(dataProvider = "doubleCompareOpProvider")
4650 static void ltDouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4651 double[] a = fa.apply(SPECIES.length());
4652 double[] b = fb.apply(SPECIES.length());
4653
4654 for (int i = 0; i < a.length; i += SPECIES.length()) {
4655 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4656 VectorMask<Double> mv = av.lt(b[i]);
4657
4658 // Check results as part of computation.
4659 for (int j = 0; j < SPECIES.length(); j++) {
4660 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
4661 }
4662 }
4663 }
4664
4665 @Test(dataProvider = "doubleCompareOpProvider")
4666 static void eqDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4667 double[] a = fa.apply(SPECIES.length());
4668 double[] b = fb.apply(SPECIES.length());
5020 }
5021 }
5022 return i - idx;
5023 }
5024
5025 @Test(dataProvider = "maskProvider")
5026 static void maskFirstTrueDouble128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5027 boolean[] a = fa.apply(SPECIES.length());
5028 int[] r = new int[a.length];
5029
5030 for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5031 for (int i = 0; i < a.length; i += SPECIES.length()) {
5032 var vmask = SPECIES.loadMask(a, i);
5033 r[i] = vmask.firstTrue();
5034 }
5035 }
5036
5037 assertMaskReductionArraysEquals(r, a, Double128VectorTests::maskFirstTrue);
5038 }
5039
5040 @DataProvider
5041 public static Object[][] longMaskProvider() {
5042 return new Object[][]{
5043 {0xFFFFFFFFFFFFFFFFL},
5044 {0x0000000000000000L},
5045 {0x5555555555555555L},
5046 {0x0123456789abcdefL},
5047 };
5048 }
5049
5050 @Test(dataProvider = "longMaskProvider")
5051 static void maskFromToLongDouble128VectorTestsSmokeTest(long inputLong) {
5052 var vmask = VectorMask.fromLong(SPECIES, inputLong);
5053 long outputLong = vmask.toLong();
5054 Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
5055 }
5056
5057 @DataProvider
5058 public static Object[][] offsetProvider() {
5059 return new Object[][]{
5062 {+1},
5063 {+2},
5064 {-2},
5065 };
5066 }
5067
5068 @Test(dataProvider = "offsetProvider")
5069 static void indexInRangeDouble128VectorTestsSmokeTest(int offset) {
5070 int limit = SPECIES.length() * BUFFER_REPS;
5071 for (int i = 0; i < limit; i += SPECIES.length()) {
5072 var actualMask = SPECIES.indexInRange(i + offset, limit);
5073 var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
5074 assert(actualMask.equals(expectedMask));
5075 for (int j = 0; j < SPECIES.length(); j++) {
5076 int index = i + j + offset;
5077 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
5078 }
5079 }
5080 }
5081
5082 @DataProvider
5083 public static Object[][] lengthProvider() {
5084 return new Object[][]{
5085 {0},
5086 {1},
5087 {32},
5088 {37},
5089 {1024},
5090 {1024+1},
5091 {1024+5},
5092 };
5093 }
5094
5095 @Test(dataProvider = "lengthProvider")
5096 static void loopBoundDouble128VectorTestsSmokeTest(int length) {
5097 int actualLoopBound = SPECIES.loopBound(length);
5098 int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
5099 Assert.assertEquals(actualLoopBound, expectedLoopBound);
5100 }
5101
5102 @Test
5103 static void ElementSizeDouble128VectorTestsSmokeTest() {
5104 DoubleVector av = DoubleVector.zero(SPECIES);
5105 int elsize = av.elementSize();
5106 Assert.assertEquals(elsize, Double.SIZE);
5107 }
5108
5109 @Test
5110 static void VectorShapeDouble128VectorTestsSmokeTest() {
5111 DoubleVector av = DoubleVector.zero(SPECIES);
5112 VectorShape vsh = av.shape();
5113 assert(vsh.equals(VectorShape.S_128_BIT));
5114 }
5115
5116 @Test
5117 static void ShapeWithLanesDouble128VectorTestsSmokeTest() {
5118 DoubleVector av = DoubleVector.zero(SPECIES);
5119 VectorShape vsh = av.shape();
5120 VectorSpecies species = vsh.withLanes(double.class);
5121 assert(species.equals(SPECIES));
5144 DoubleVector av = DoubleVector.zero(SPECIES);
5145 VectorSpecies species = av.species().withLanes(double.class);
5146 assert(species.equals(SPECIES));
5147 }
5148
5149 @Test
5150 static void WithShapeDouble128VectorTestsSmokeTest() {
5151 DoubleVector av = DoubleVector.zero(SPECIES);
5152 VectorShape vsh = av.shape();
5153 VectorSpecies species = av.species().withShape(vsh);
5154 assert(species.equals(SPECIES));
5155 }
5156
5157 @Test
5158 static void MaskAllTrueDouble128VectorTestsSmokeTest() {
5159 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5160 Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
5161 }
5162 }
5163 }
5164
|
43 import org.testng.annotations.Test;
44
45 import java.lang.Integer;
46 import java.util.List;
47 import java.util.Arrays;
48 import java.util.function.BiFunction;
49 import java.util.function.IntFunction;
50 import java.util.Objects;
51 import java.util.stream.Collectors;
52 import java.util.stream.Stream;
53
54 @Test
55 public class Double128VectorTests extends AbstractVectorTest {
56
57 static final VectorSpecies<Double> SPECIES =
58 DoubleVector.SPECIES_128;
59
60 static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
61
62
63
64 static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
65
66 interface FUnOp {
67 double apply(double a);
68 }
69
70 static void assertArraysEquals(double[] r, double[] a, FUnOp f) {
71 int i = 0;
72 try {
73 for (; i < a.length; i++) {
74 Assert.assertEquals(r[i], f.apply(a[i]));
75 }
76 } catch (AssertionError e) {
77 Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);
78 }
79 }
80
81 interface FUnArrayOp {
82 double[] apply(double a);
243 } else {
244 Assert.assertEquals(r[i], a[i], "at index #" + i);
245 }
246 }
247 }
248
249 static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int vector_len) {
250 int i = 0, j = 0;
251 try {
252 for (; i < a.length; i += vector_len) {
253 for (j = 0; j < vector_len; j++) {
254 Assert.assertEquals(r[i+j], a[i+order[i+j]]);
255 }
256 }
257 } catch (AssertionError e) {
258 int idx = i + j;
259 Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
260 }
261 }
262
263 static void assertcompressArraysEquals(double[] r, double[] a, boolean[] m, int vector_len) {
264 int i = 0, j = 0, k = 0;
265 try {
266 for (; i < a.length; i += vector_len) {
267 k = 0;
268 for (j = 0; j < vector_len; j++) {
269 if (m[(i + j) % SPECIES.length()]) {
270 Assert.assertEquals(r[i + k], a[i + j]);
271 k++;
272 }
273 }
274 for (; k < vector_len; k++) {
275 Assert.assertEquals(r[i + k], (double)0);
276 }
277 }
278 } catch (AssertionError e) {
279 int idx = i + k;
280 if (m[(i + j) % SPECIES.length()]) {
281 Assert.assertEquals(r[idx], a[i + j], "at index #" + idx);
282 } else {
283 Assert.assertEquals(r[idx], (double)0, "at index #" + idx);
284 }
285 }
286 }
287
288 static void assertexpandArraysEquals(double[] r, double[] a, boolean[] m, int vector_len) {
289 int i = 0, j = 0, k = 0;
290 try {
291 for (; i < a.length; i += vector_len) {
292 k = 0;
293 for (j = 0; j < vector_len; j++) {
294 if (m[(i + j) % SPECIES.length()]) {
295 Assert.assertEquals(r[i + j], a[i + k]);
296 k++;
297 } else {
298 Assert.assertEquals(r[i + j], (double)0);
299 }
300 }
301 }
302 } catch (AssertionError e) {
303 int idx = i + j;
304 if (m[idx % SPECIES.length()]) {
305 Assert.assertEquals(r[idx], a[i + k], "at index #" + idx);
306 } else {
307 Assert.assertEquals(r[idx], (double)0, "at index #" + idx);
308 }
309 }
310 }
311
312 static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, int vector_len) {
313 int i = 0, j = 0;
314 try {
315 for (; i < a.length; i += vector_len) {
316 for (j = 0; j < vector_len; j++) {
317 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
318 }
319 }
320 } catch (AssertionError e) {
321 int idx = i + j;
322 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]);
323 }
324 }
325
326 static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boolean[] mask, int vector_len) {
327 int i = 0, j = 0;
328 try {
329 for (; i < a.length; i += vector_len) {
330 for (j = 0; j < vector_len; j++) {
331 if (mask[j % SPECIES.length()])
1044 i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1)));
1045 }),
1046 withToString("double[cornerCaseValue(i)]", (int s) -> {
1047 return fill(s * BUFFER_REPS,
1048 i -> (double)longCornerCaseValue(i));
1049 })
1050 );
1051
1052
1053 static void assertArraysEquals(long[] r, double[] a, int offs) {
1054 int i = 0;
1055 try {
1056 for (; i < r.length; i++) {
1057 Assert.assertEquals(r[i], (long)(a[i+offs]));
1058 }
1059 } catch (AssertionError e) {
1060 Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
1061 }
1062 }
1063
1064 static long bits(double e) {
1065 return Double.doubleToLongBits(e);
1066 }
1067
1068 static final List<IntFunction<double[]>> DOUBLE_GENERATORS = List.of(
1069 withToString("double[-i * 5]", (int s) -> {
1070 return fill(s * BUFFER_REPS,
1071 i -> (double)(-i * 5));
1072 }),
1073 withToString("double[i * 5]", (int s) -> {
1074 return fill(s * BUFFER_REPS,
1075 i -> (double)(i * 5));
1076 }),
1077 withToString("double[i + 1]", (int s) -> {
1078 return fill(s * BUFFER_REPS,
1079 i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1)));
1080 }),
1081 withToString("double[cornerCaseValue(i)]", (int s) -> {
1082 return fill(s * BUFFER_REPS,
1083 i -> cornerCaseValue(i));
1227
1228 @DataProvider
1229 public Object[][] doubleUnaryOpSelectFromProvider() {
1230 return DOUBLE_SHUFFLE_GENERATORS.stream().
1231 flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
1232 return new Object[] {fa, fs};
1233 })).
1234 toArray(Object[][]::new);
1235 }
1236
1237 @DataProvider
1238 public Object[][] doubleUnaryOpSelectFromMaskProvider() {
1239 return BOOLEAN_MASK_GENERATORS.stream().
1240 flatMap(fm -> DOUBLE_SHUFFLE_GENERATORS.stream().
1241 flatMap(fs -> DOUBLE_GENERATORS.stream().map(fa -> {
1242 return new Object[] {fa, fs, fm};
1243 }))).
1244 toArray(Object[][]::new);
1245 }
1246
1247 static final List<IntFunction<double[]>> DOUBLE_COMPARE_GENERATORS = List.of(
1248 withToString("double[i]", (int s) -> {
1249 return fill(s * BUFFER_REPS,
1250 i -> (double)i);
1251 }),
1252 withToString("double[i - length / 2]", (int s) -> {
1253 return fill(s * BUFFER_REPS,
1254 i -> (double)(i - (s * BUFFER_REPS / 2)));
1255 }),
1256 withToString("double[i + 1]", (int s) -> {
1257 return fill(s * BUFFER_REPS,
1258 i -> (double)(i + 1));
1259 }),
1260 withToString("double[i - 2]", (int s) -> {
1261 return fill(s * BUFFER_REPS,
1262 i -> (double)(i - 2));
1263 }),
1264 withToString("double[zigZag(i)]", (int s) -> {
1265 return fill(s * BUFFER_REPS,
1266 i -> i%3 == 0 ? (double)i : (i%3 == 1 ? (double)(i + 1) : (double)(i - 2)));
1347
1348 static double get(double[] a, int i) {
1349 return (double) a[i];
1350 }
1351
1352 static final IntFunction<double[]> fr = (vl) -> {
1353 int length = BUFFER_REPS * vl;
1354 return new double[length];
1355 };
1356
1357 static final IntFunction<boolean[]> fmr = (vl) -> {
1358 int length = BUFFER_REPS * vl;
1359 return new boolean[length];
1360 };
1361
1362 static final IntFunction<long[]> lfr = (vl) -> {
1363 int length = BUFFER_REPS * vl;
1364 return new long[length];
1365 };
1366
1367 static boolean eq(double a, double b) {
1368 return a == b;
1369 }
1370
1371 static boolean neq(double a, double b) {
1372 return a != b;
1373 }
1374
1375 static boolean lt(double a, double b) {
1376 return a < b;
1377 }
1378
1379 static boolean le(double a, double b) {
1380 return a <= b;
1381 }
1382
1383 static boolean gt(double a, double b) {
1384 return a > b;
1385 }
1386
1387 static boolean ge(double a, double b) {
1388 return a >= b;
1389 }
1390
1391 static double firstNonZero(double a, double b) {
1392 return Double.compare(a, (double) 0) != 0 ? a : b;
1393 }
1394
1395 @Test
1396 static void smokeTest1() {
1397 DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3);
1398 DoubleVector three2 = (DoubleVector) SPECIES.broadcast(-3);
1399 assert(three.eq(three2).allTrue());
1400 DoubleVector three3 = three2.broadcast(1).broadcast(-3);
1401 assert(three.eq(three3).allTrue());
1402 int scale = 2;
1403 Class<?> ETYPE = double.class;
1404 if (ETYPE == double.class || ETYPE == long.class)
1405 scale = 1000000;
1406 else if (ETYPE == byte.class && SPECIES.length() >= 64)
1407 scale = 1;
1408 DoubleVector higher = three.addIndex(scale);
1409 VectorMask<Double> m = three.compare(VectorOperators.LE, higher);
1410 assert(m.allTrue());
1487 static double ADD(double a, double b) {
1488 return (double)(a + b);
1489 }
1490
1491 @Test(dataProvider = "doubleBinaryOpProvider")
1492 static void ADDDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1493 double[] a = fa.apply(SPECIES.length());
1494 double[] b = fb.apply(SPECIES.length());
1495 double[] r = fr.apply(SPECIES.length());
1496
1497 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1498 for (int i = 0; i < a.length; i += SPECIES.length()) {
1499 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1500 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1501 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
1502 }
1503 }
1504
1505 assertArraysEquals(r, a, b, Double128VectorTests::ADD);
1506 }
1507
1508 static double add(double a, double b) {
1509 return (double)(a + b);
1510 }
1511
1512 @Test(dataProvider = "doubleBinaryOpProvider")
1513 static void addDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1514 double[] a = fa.apply(SPECIES.length());
1515 double[] b = fb.apply(SPECIES.length());
1516 double[] r = fr.apply(SPECIES.length());
1517
1518 for (int i = 0; i < a.length; i += SPECIES.length()) {
1519 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1520 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1521 av.add(bv).intoArray(r, i);
1522 }
1523
1524 assertArraysEquals(r, a, b, Double128VectorTests::add);
1525 }
1526
1527 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1544 assertArraysEquals(r, a, b, mask, Double128VectorTests::ADD);
1545 }
1546
1547 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1548 static void addDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1549 IntFunction<boolean[]> fm) {
1550 double[] a = fa.apply(SPECIES.length());
1551 double[] b = fb.apply(SPECIES.length());
1552 double[] r = fr.apply(SPECIES.length());
1553 boolean[] mask = fm.apply(SPECIES.length());
1554 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1555
1556 for (int i = 0; i < a.length; i += SPECIES.length()) {
1557 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1558 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1559 av.add(bv, vmask).intoArray(r, i);
1560 }
1561
1562 assertArraysEquals(r, a, b, mask, Double128VectorTests::add);
1563 }
1564
1565 static double SUB(double a, double b) {
1566 return (double)(a - b);
1567 }
1568
1569 @Test(dataProvider = "doubleBinaryOpProvider")
1570 static void SUBDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1571 double[] a = fa.apply(SPECIES.length());
1572 double[] b = fb.apply(SPECIES.length());
1573 double[] r = fr.apply(SPECIES.length());
1574
1575 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1576 for (int i = 0; i < a.length; i += SPECIES.length()) {
1577 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1578 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1579 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
1580 }
1581 }
1582
1583 assertArraysEquals(r, a, b, Double128VectorTests::SUB);
1584 }
1585
1586 static double sub(double a, double b) {
1587 return (double)(a - b);
1588 }
1589
1590 @Test(dataProvider = "doubleBinaryOpProvider")
1591 static void subDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1592 double[] a = fa.apply(SPECIES.length());
1593 double[] b = fb.apply(SPECIES.length());
1594 double[] r = fr.apply(SPECIES.length());
1595
1596 for (int i = 0; i < a.length; i += SPECIES.length()) {
1597 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1598 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1599 av.sub(bv).intoArray(r, i);
1600 }
1601
1602 assertArraysEquals(r, a, b, Double128VectorTests::sub);
1603 }
1604
1605 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1622 assertArraysEquals(r, a, b, mask, Double128VectorTests::SUB);
1623 }
1624
1625 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1626 static void subDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1627 IntFunction<boolean[]> fm) {
1628 double[] a = fa.apply(SPECIES.length());
1629 double[] b = fb.apply(SPECIES.length());
1630 double[] r = fr.apply(SPECIES.length());
1631 boolean[] mask = fm.apply(SPECIES.length());
1632 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1633
1634 for (int i = 0; i < a.length; i += SPECIES.length()) {
1635 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1636 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1637 av.sub(bv, vmask).intoArray(r, i);
1638 }
1639
1640 assertArraysEquals(r, a, b, mask, Double128VectorTests::sub);
1641 }
1642
1643 static double MUL(double a, double b) {
1644 return (double)(a * b);
1645 }
1646
1647 @Test(dataProvider = "doubleBinaryOpProvider")
1648 static void MULDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1649 double[] a = fa.apply(SPECIES.length());
1650 double[] b = fb.apply(SPECIES.length());
1651 double[] r = fr.apply(SPECIES.length());
1652
1653 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1654 for (int i = 0; i < a.length; i += SPECIES.length()) {
1655 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1656 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1657 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
1658 }
1659 }
1660
1661 assertArraysEquals(r, a, b, Double128VectorTests::MUL);
1662 }
1663
1664 static double mul(double a, double b) {
1665 return (double)(a * b);
1666 }
1667
1668 @Test(dataProvider = "doubleBinaryOpProvider")
1669 static void mulDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1670 double[] a = fa.apply(SPECIES.length());
1671 double[] b = fb.apply(SPECIES.length());
1672 double[] r = fr.apply(SPECIES.length());
1673
1674 for (int i = 0; i < a.length; i += SPECIES.length()) {
1675 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1676 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1677 av.mul(bv).intoArray(r, i);
1678 }
1679
1680 assertArraysEquals(r, a, b, Double128VectorTests::mul);
1681 }
1682
1683 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1721 static double DIV(double a, double b) {
1722 return (double)(a / b);
1723 }
1724
1725 @Test(dataProvider = "doubleBinaryOpProvider")
1726 static void DIVDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1727 double[] a = fa.apply(SPECIES.length());
1728 double[] b = fb.apply(SPECIES.length());
1729 double[] r = fr.apply(SPECIES.length());
1730
1731 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1732 for (int i = 0; i < a.length; i += SPECIES.length()) {
1733 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1734 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1735 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
1736 }
1737 }
1738
1739 assertArraysEquals(r, a, b, Double128VectorTests::DIV);
1740 }
1741
1742 static double div(double a, double b) {
1743 return (double)(a / b);
1744 }
1745
1746 @Test(dataProvider = "doubleBinaryOpProvider")
1747 static void divDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1748 double[] a = fa.apply(SPECIES.length());
1749 double[] b = fb.apply(SPECIES.length());
1750 double[] r = fr.apply(SPECIES.length());
1751
1752 for (int i = 0; i < a.length; i += SPECIES.length()) {
1753 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1754 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1755 av.div(bv).intoArray(r, i);
1756 }
1757
1758 assertArraysEquals(r, a, b, Double128VectorTests::div);
1759 }
1760
1761 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1762 static void DIVDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1763 IntFunction<boolean[]> fm) {
1764 double[] a = fa.apply(SPECIES.length());
1765 double[] b = fb.apply(SPECIES.length());
1766 double[] r = fr.apply(SPECIES.length());
1767 boolean[] mask = fm.apply(SPECIES.length());
1768 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1769
1770 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1771 for (int i = 0; i < a.length; i += SPECIES.length()) {
1772 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1773 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1774 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
1775 }
1776 }
1777
1778 assertArraysEquals(r, a, b, mask, Double128VectorTests::DIV);
1779 }
1780
1781 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1782 static void divDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1783 IntFunction<boolean[]> fm) {
1784 double[] a = fa.apply(SPECIES.length());
1785 double[] b = fb.apply(SPECIES.length());
1786 double[] r = fr.apply(SPECIES.length());
1787 boolean[] mask = fm.apply(SPECIES.length());
1788 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1789
1790 for (int i = 0; i < a.length; i += SPECIES.length()) {
1791 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1792 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1793 av.div(bv, vmask).intoArray(r, i);
1794 }
1795
1796 assertArraysEquals(r, a, b, mask, Double128VectorTests::div);
1797 }
1798
1799 static double FIRST_NONZERO(double a, double b) {
1800 return (double)(Double.doubleToLongBits(a)!=0?a:b);
1801 }
1802
1803 @Test(dataProvider = "doubleBinaryOpProvider")
1804 static void FIRST_NONZERODouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1805 double[] a = fa.apply(SPECIES.length());
1806 double[] b = fb.apply(SPECIES.length());
1807 double[] r = fr.apply(SPECIES.length());
1808
1809 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1810 for (int i = 0; i < a.length; i += SPECIES.length()) {
1811 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1812 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1813 av.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i);
1814 }
1815 }
1816
1817 assertArraysEquals(r, a, b, Double128VectorTests::FIRST_NONZERO);
1818 }
1820 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1821 static void FIRST_NONZERODouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
1822 IntFunction<boolean[]> fm) {
1823 double[] a = fa.apply(SPECIES.length());
1824 double[] b = fb.apply(SPECIES.length());
1825 double[] r = fr.apply(SPECIES.length());
1826 boolean[] mask = fm.apply(SPECIES.length());
1827 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1828
1829 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1830 for (int i = 0; i < a.length; i += SPECIES.length()) {
1831 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1832 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
1833 av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i);
1834 }
1835 }
1836
1837 assertArraysEquals(r, a, b, mask, Double128VectorTests::FIRST_NONZERO);
1838 }
1839
1840 @Test(dataProvider = "doubleBinaryOpProvider")
1841 static void addDouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1842 double[] a = fa.apply(SPECIES.length());
1843 double[] b = fb.apply(SPECIES.length());
1844 double[] r = fr.apply(SPECIES.length());
1845
1846 for (int i = 0; i < a.length; i += SPECIES.length()) {
1847 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1848 av.add(b[i]).intoArray(r, i);
1849 }
1850
1851 assertBroadcastArraysEquals(r, a, b, Double128VectorTests::add);
1852 }
1853
1854 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1855 static void addDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1856 IntFunction<boolean[]> fm) {
1857 double[] a = fa.apply(SPECIES.length());
1858 double[] b = fb.apply(SPECIES.length());
1859 double[] r = fr.apply(SPECIES.length());
1913 assertBroadcastArraysEquals(r, a, b, Double128VectorTests::mul);
1914 }
1915
1916 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1917 static void mulDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1918 IntFunction<boolean[]> fm) {
1919 double[] a = fa.apply(SPECIES.length());
1920 double[] b = fb.apply(SPECIES.length());
1921 double[] r = fr.apply(SPECIES.length());
1922 boolean[] mask = fm.apply(SPECIES.length());
1923 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1924
1925 for (int i = 0; i < a.length; i += SPECIES.length()) {
1926 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1927 av.mul(b[i], vmask).intoArray(r, i);
1928 }
1929
1930 assertBroadcastArraysEquals(r, a, b, mask, Double128VectorTests::mul);
1931 }
1932
1933 @Test(dataProvider = "doubleBinaryOpProvider")
1934 static void divDouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1935 double[] a = fa.apply(SPECIES.length());
1936 double[] b = fb.apply(SPECIES.length());
1937 double[] r = fr.apply(SPECIES.length());
1938
1939 for (int i = 0; i < a.length; i += SPECIES.length()) {
1940 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1941 av.div(b[i]).intoArray(r, i);
1942 }
1943
1944 assertBroadcastArraysEquals(r, a, b, Double128VectorTests::div);
1945 }
1946
1947 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1948 static void divDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1949 IntFunction<boolean[]> fm) {
1950 double[] a = fa.apply(SPECIES.length());
1951 double[] b = fb.apply(SPECIES.length());
1952 double[] r = fr.apply(SPECIES.length());
1953 boolean[] mask = fm.apply(SPECIES.length());
1954 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1955
1956 for (int i = 0; i < a.length; i += SPECIES.length()) {
1957 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1958 av.div(b[i], vmask).intoArray(r, i);
1959 }
1960
1961 assertBroadcastArraysEquals(r, a, b, mask, Double128VectorTests::div);
1962 }
1963
1964 @Test(dataProvider = "doubleBinaryOpProvider")
1965 static void ADDDouble128VectorTestsBroadcastLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
1966 double[] a = fa.apply(SPECIES.length());
1967 double[] b = fb.apply(SPECIES.length());
1968 double[] r = fr.apply(SPECIES.length());
1969
1970 for (int i = 0; i < a.length; i += SPECIES.length()) {
1971 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1972 av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);
1973 }
1974
1975 assertBroadcastLongArraysEquals(r, a, b, Double128VectorTests::ADD);
1976 }
1977
1978 @Test(dataProvider = "doubleBinaryOpMaskProvider")
1979 static void ADDDouble128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
1980 IntFunction<boolean[]> fm) {
1981 double[] a = fa.apply(SPECIES.length());
1982 double[] b = fb.apply(SPECIES.length());
1983 double[] r = fr.apply(SPECIES.length());
1984 boolean[] mask = fm.apply(SPECIES.length());
1985 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1986
1987 for (int i = 0; i < a.length; i += SPECIES.length()) {
1988 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
1989 av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i);
1990 }
1991
1992 assertBroadcastLongArraysEquals(r, a, b, mask, Double128VectorTests::ADD);
1993 }
1994
1995 static double MIN(double a, double b) {
1996 return (double)(Math.min(a, b));
1997 }
1998
1999 @Test(dataProvider = "doubleBinaryOpProvider")
2000 static void MINDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2001 double[] a = fa.apply(SPECIES.length());
2002 double[] b = fb.apply(SPECIES.length());
2003 double[] r = fr.apply(SPECIES.length());
2004
2005 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2006 for (int i = 0; i < a.length; i += SPECIES.length()) {
2007 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2008 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2009 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
2010 }
2011 }
2012
2013 assertArraysEquals(r, a, b, Double128VectorTests::MIN);
2014 }
2015
2016 static double min(double a, double b) {
2017 return (double)(Math.min(a, b));
2018 }
2019
2020 @Test(dataProvider = "doubleBinaryOpProvider")
2021 static void minDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2022 double[] a = fa.apply(SPECIES.length());
2023 double[] b = fb.apply(SPECIES.length());
2024 double[] r = fr.apply(SPECIES.length());
2025
2026 for (int i = 0; i < a.length; i += SPECIES.length()) {
2027 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2028 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2029 av.min(bv).intoArray(r, i);
2030 }
2031
2032 assertArraysEquals(r, a, b, Double128VectorTests::min);
2033 }
2034
2035 static double MAX(double a, double b) {
2036 return (double)(Math.max(a, b));
2037 }
2038
2039 @Test(dataProvider = "doubleBinaryOpProvider")
2040 static void MAXDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2041 double[] a = fa.apply(SPECIES.length());
2042 double[] b = fb.apply(SPECIES.length());
2043 double[] r = fr.apply(SPECIES.length());
2044
2045 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2046 for (int i = 0; i < a.length; i += SPECIES.length()) {
2047 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2048 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2049 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
2050 }
2051 }
2052
2053 assertArraysEquals(r, a, b, Double128VectorTests::MAX);
2054 }
2055
2056 static double max(double a, double b) {
2057 return (double)(Math.max(a, b));
2058 }
2059
2060 @Test(dataProvider = "doubleBinaryOpProvider")
2061 static void maxDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2062 double[] a = fa.apply(SPECIES.length());
2063 double[] b = fb.apply(SPECIES.length());
2064 double[] r = fr.apply(SPECIES.length());
2065
2066 for (int i = 0; i < a.length; i += SPECIES.length()) {
2067 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2068 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2069 av.max(bv).intoArray(r, i);
2070 }
2071
2072 assertArraysEquals(r, a, b, Double128VectorTests::max);
2073 }
2074
2075 @Test(dataProvider = "doubleBinaryOpProvider")
2111 av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i);
2112 }
2113
2114 assertBroadcastArraysEquals(r, a, b, Double128VectorTests::MAX);
2115 }
2116
2117 @Test(dataProvider = "doubleBinaryOpProvider")
2118 static void maxDouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2119 double[] a = fa.apply(SPECIES.length());
2120 double[] b = fb.apply(SPECIES.length());
2121 double[] r = fr.apply(SPECIES.length());
2122
2123 for (int i = 0; i < a.length; i += SPECIES.length()) {
2124 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2125 av.max(b[i]).intoArray(r, i);
2126 }
2127
2128 assertBroadcastArraysEquals(r, a, b, Double128VectorTests::max);
2129 }
2130
2131 static double ADDReduce(double[] a, int idx) {
2132 double res = 0;
2133 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2134 res += a[i];
2135 }
2136
2137 return res;
2138 }
2139
2140 static double ADDReduceAll(double[] a) {
2141 double res = 0;
2142 for (int i = 0; i < a.length; i += SPECIES.length()) {
2143 res += ADDReduce(a, i);
2144 }
2145
2146 return res;
2147 }
2148
2149 @Test(dataProvider = "doubleUnaryOpProvider")
2150 static void ADDReduceDouble128VectorTests(IntFunction<double[]> fa) {
2151 double[] a = fa.apply(SPECIES.length());
2152 double[] r = fr.apply(SPECIES.length());
2153 double ra = 0;
2154
2155 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2156 for (int i = 0; i < a.length; i += SPECIES.length()) {
2157 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2158 r[i] = av.reduceLanes(VectorOperators.ADD);
2159 }
2160 }
2161
2162 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2163 ra = 0;
2164 for (int i = 0; i < a.length; i += SPECIES.length()) {
2165 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2166 ra += av.reduceLanes(VectorOperators.ADD);
2167 }
2168 }
2169
2170 assertReductionArraysEquals(r, ra, a,
2171 Double128VectorTests::ADDReduce, Double128VectorTests::ADDReduceAll);
2172 }
2173
2174 static double ADDReduceMasked(double[] a, int idx, boolean[] mask) {
2175 double res = 0;
2176 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2177 if (mask[i % SPECIES.length()])
2178 res += a[i];
2179 }
2180
2181 return res;
2182 }
2183
2184 static double ADDReduceAllMasked(double[] a, boolean[] mask) {
2185 double res = 0;
2186 for (int i = 0; i < a.length; i += SPECIES.length()) {
2187 res += ADDReduceMasked(a, i, mask);
2188 }
2189
2190 return res;
2191 }
2192
2193 @Test(dataProvider = "doubleUnaryOpMaskProvider")
2194 static void ADDReduceDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2195 double[] a = fa.apply(SPECIES.length());
2196 double[] r = fr.apply(SPECIES.length());
2197 boolean[] mask = fm.apply(SPECIES.length());
2198 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2199 double ra = 0;
2200
2201 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2202 for (int i = 0; i < a.length; i += SPECIES.length()) {
2203 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2204 r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
2205 }
2206 }
2207
2208 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2209 ra = 0;
2210 for (int i = 0; i < a.length; i += SPECIES.length()) {
2211 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2212 ra += av.reduceLanes(VectorOperators.ADD, vmask);
2213 }
2214 }
2215
2216 assertReductionArraysEqualsMasked(r, ra, a, mask,
2217 Double128VectorTests::ADDReduceMasked, Double128VectorTests::ADDReduceAllMasked);
2218 }
2219
2220 static double MULReduce(double[] a, int idx) {
2221 double res = 1;
2222 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2223 res *= a[i];
2224 }
2225
2226 return res;
2227 }
2228
2229 static double MULReduceAll(double[] a) {
2230 double res = 1;
2231 for (int i = 0; i < a.length; i += SPECIES.length()) {
2232 res *= MULReduce(a, i);
2233 }
2234
2235 return res;
2236 }
2237
2238 @Test(dataProvider = "doubleUnaryOpProvider")
2239 static void MULReduceDouble128VectorTests(IntFunction<double[]> fa) {
2240 double[] a = fa.apply(SPECIES.length());
2241 double[] r = fr.apply(SPECIES.length());
2242 double ra = 1;
2243
2244 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2245 for (int i = 0; i < a.length; i += SPECIES.length()) {
2246 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2247 r[i] = av.reduceLanes(VectorOperators.MUL);
2248 }
2249 }
2250
2251 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2252 ra = 1;
2253 for (int i = 0; i < a.length; i += SPECIES.length()) {
2254 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2255 ra *= av.reduceLanes(VectorOperators.MUL);
2256 }
2257 }
2258
2259 assertReductionArraysEquals(r, ra, a,
2260 Double128VectorTests::MULReduce, Double128VectorTests::MULReduceAll);
2261 }
2262
2263 static double MULReduceMasked(double[] a, int idx, boolean[] mask) {
2264 double res = 1;
2265 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2266 if (mask[i % SPECIES.length()])
2267 res *= a[i];
2268 }
2269
2270 return res;
2271 }
2272
2273 static double MULReduceAllMasked(double[] a, boolean[] mask) {
2274 double res = 1;
2275 for (int i = 0; i < a.length; i += SPECIES.length()) {
2276 res *= MULReduceMasked(a, i, mask);
2277 }
2278
2279 return res;
2280 }
2281
2282 @Test(dataProvider = "doubleUnaryOpMaskProvider")
2283 static void MULReduceDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2284 double[] a = fa.apply(SPECIES.length());
2285 double[] r = fr.apply(SPECIES.length());
2286 boolean[] mask = fm.apply(SPECIES.length());
2287 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2288 double ra = 1;
2289
2290 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2291 for (int i = 0; i < a.length; i += SPECIES.length()) {
2292 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2293 r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
2294 }
2295 }
2296
2297 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2298 ra = 1;
2299 for (int i = 0; i < a.length; i += SPECIES.length()) {
2300 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2301 ra *= av.reduceLanes(VectorOperators.MUL, vmask);
2302 }
2303 }
2304
2305 assertReductionArraysEqualsMasked(r, ra, a, mask,
2306 Double128VectorTests::MULReduceMasked, Double128VectorTests::MULReduceAllMasked);
2307 }
2308
2309 static double MINReduce(double[] a, int idx) {
2310 double res = Double.POSITIVE_INFINITY;
2311 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2312 res = (double) Math.min(res, a[i]);
2313 }
2314
2315 return res;
2316 }
2317
2318 static double MINReduceAll(double[] a) {
2319 double res = Double.POSITIVE_INFINITY;
2320 for (int i = 0; i < a.length; i += SPECIES.length()) {
2321 res = (double) Math.min(res, MINReduce(a, i));
2322 }
2323
2324 return res;
2325 }
2326
2327 @Test(dataProvider = "doubleUnaryOpProvider")
2328 static void MINReduceDouble128VectorTests(IntFunction<double[]> fa) {
2329 double[] a = fa.apply(SPECIES.length());
2330 double[] r = fr.apply(SPECIES.length());
2331 double ra = Double.POSITIVE_INFINITY;
2332
2333 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2334 for (int i = 0; i < a.length; i += SPECIES.length()) {
2335 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2336 r[i] = av.reduceLanes(VectorOperators.MIN);
2337 }
2338 }
2339
2340 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2341 ra = Double.POSITIVE_INFINITY;
2342 for (int i = 0; i < a.length; i += SPECIES.length()) {
2343 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2344 ra = (double) Math.min(ra, av.reduceLanes(VectorOperators.MIN));
2345 }
2346 }
2347
2348 assertReductionArraysEquals(r, ra, a,
2349 Double128VectorTests::MINReduce, Double128VectorTests::MINReduceAll);
2350 }
2351
2352 static double MINReduceMasked(double[] a, int idx, boolean[] mask) {
2353 double res = Double.POSITIVE_INFINITY;
2354 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2355 if (mask[i % SPECIES.length()])
2356 res = (double) Math.min(res, a[i]);
2357 }
2358
2359 return res;
2360 }
2361
2362 static double MINReduceAllMasked(double[] a, boolean[] mask) {
2363 double res = Double.POSITIVE_INFINITY;
2364 for (int i = 0; i < a.length; i += SPECIES.length()) {
2365 res = (double) Math.min(res, MINReduceMasked(a, i, mask));
2366 }
2367
2368 return res;
2369 }
2370
2371 @Test(dataProvider = "doubleUnaryOpMaskProvider")
2372 static void MINReduceDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2373 double[] a = fa.apply(SPECIES.length());
2374 double[] r = fr.apply(SPECIES.length());
2375 boolean[] mask = fm.apply(SPECIES.length());
2376 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2377 double ra = Double.POSITIVE_INFINITY;
2378
2379 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2380 for (int i = 0; i < a.length; i += SPECIES.length()) {
2381 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2382 r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
2383 }
2384 }
2385
2386 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2387 ra = Double.POSITIVE_INFINITY;
2388 for (int i = 0; i < a.length; i += SPECIES.length()) {
2389 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2390 ra = (double) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
2391 }
2392 }
2393
2394 assertReductionArraysEqualsMasked(r, ra, a, mask,
2395 Double128VectorTests::MINReduceMasked, Double128VectorTests::MINReduceAllMasked);
2396 }
2397
2398 static double MAXReduce(double[] a, int idx) {
2399 double res = Double.NEGATIVE_INFINITY;
2400 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2401 res = (double) Math.max(res, a[i]);
2402 }
2403
2404 return res;
2405 }
2406
2407 static double MAXReduceAll(double[] a) {
2408 double res = Double.NEGATIVE_INFINITY;
2409 for (int i = 0; i < a.length; i += SPECIES.length()) {
2410 res = (double) Math.max(res, MAXReduce(a, i));
2411 }
2412
2413 return res;
2414 }
2415
2416 @Test(dataProvider = "doubleUnaryOpProvider")
2417 static void MAXReduceDouble128VectorTests(IntFunction<double[]> fa) {
2418 double[] a = fa.apply(SPECIES.length());
2419 double[] r = fr.apply(SPECIES.length());
2420 double ra = Double.NEGATIVE_INFINITY;
2421
2422 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2423 for (int i = 0; i < a.length; i += SPECIES.length()) {
2424 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2425 r[i] = av.reduceLanes(VectorOperators.MAX);
2426 }
2427 }
2428
2429 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2430 ra = Double.NEGATIVE_INFINITY;
2431 for (int i = 0; i < a.length; i += SPECIES.length()) {
2432 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2433 ra = (double) Math.max(ra, av.reduceLanes(VectorOperators.MAX));
2434 }
2435 }
2436
2437 assertReductionArraysEquals(r, ra, a,
2438 Double128VectorTests::MAXReduce, Double128VectorTests::MAXReduceAll);
2439 }
2440
2441 static double MAXReduceMasked(double[] a, int idx, boolean[] mask) {
2442 double res = Double.NEGATIVE_INFINITY;
2443 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2444 if (mask[i % SPECIES.length()])
2445 res = (double) Math.max(res, a[i]);
2446 }
2447
2448 return res;
2449 }
2450
2451 static double MAXReduceAllMasked(double[] a, boolean[] mask) {
2452 double res = Double.NEGATIVE_INFINITY;
2453 for (int i = 0; i < a.length; i += SPECIES.length()) {
2454 res = (double) Math.max(res, MAXReduceMasked(a, i, mask));
2455 }
2456
2457 return res;
2458 }
2459
2460 @Test(dataProvider = "doubleUnaryOpMaskProvider")
2461 static void MAXReduceDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2462 double[] a = fa.apply(SPECIES.length());
2463 double[] r = fr.apply(SPECIES.length());
2464 boolean[] mask = fm.apply(SPECIES.length());
2465 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2466 double ra = Double.NEGATIVE_INFINITY;
2467
2468 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2469 for (int i = 0; i < a.length; i += SPECIES.length()) {
2470 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2471 r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
2472 }
2473 }
2474
2475 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2476 ra = Double.NEGATIVE_INFINITY;
2477 for (int i = 0; i < a.length; i += SPECIES.length()) {
2478 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2479 ra = (double) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
2480 }
2481 }
2482
2483 assertReductionArraysEqualsMasked(r, ra, a, mask,
2484 Double128VectorTests::MAXReduceMasked, Double128VectorTests::MAXReduceAllMasked);
2485 }
2486
2487 static double FIRST_NONZEROReduce(double[] a, int idx) {
2488 double res = (double) 0;
2489 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2490 res = firstNonZero(res, a[i]);
2491 }
2492
2493 return res;
2494 }
2495
2496 static double FIRST_NONZEROReduceAll(double[] a) {
2497 double res = (double) 0;
2498 for (int i = 0; i < a.length; i += SPECIES.length()) {
2499 res = firstNonZero(res, FIRST_NONZEROReduce(a, i));
2500 }
2501
2502 return res;
2503 }
2504
2505 @Test(dataProvider = "doubleUnaryOpProvider")
2506 static void FIRST_NONZEROReduceDouble128VectorTests(IntFunction<double[]> fa) {
2507 double[] a = fa.apply(SPECIES.length());
2508 double[] r = fr.apply(SPECIES.length());
2509 double ra = (double) 0;
2510
2511 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2512 for (int i = 0; i < a.length; i += SPECIES.length()) {
2513 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2514 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO);
2515 }
2516 }
2517
2518 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2519 ra = (double) 0;
2520 for (int i = 0; i < a.length; i += SPECIES.length()) {
2521 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2522 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO));
2523 }
2524 }
2525
2526 assertReductionArraysEquals(r, ra, a,
2527 Double128VectorTests::FIRST_NONZEROReduce, Double128VectorTests::FIRST_NONZEROReduceAll);
2528 }
2529
2530 static double FIRST_NONZEROReduceMasked(double[] a, int idx, boolean[] mask) {
2531 double res = (double) 0;
2532 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2533 if (mask[i % SPECIES.length()])
2534 res = firstNonZero(res, a[i]);
2535 }
2536
2537 return res;
2538 }
2539
2540 static double FIRST_NONZEROReduceAllMasked(double[] a, boolean[] mask) {
2541 double res = (double) 0;
2542 for (int i = 0; i < a.length; i += SPECIES.length()) {
2543 res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask));
2544 }
2545
2546 return res;
2547 }
2548
2549 @Test(dataProvider = "doubleUnaryOpMaskProvider")
2550 static void FIRST_NONZEROReduceDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<boolean[]> fm) {
2551 double[] a = fa.apply(SPECIES.length());
2552 double[] r = fr.apply(SPECIES.length());
2553 boolean[] mask = fm.apply(SPECIES.length());
2554 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2555 double ra = (double) 0;
2556
2557 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2558 for (int i = 0; i < a.length; i += SPECIES.length()) {
2559 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2560 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask);
2561 }
2562 }
2563
2564 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2565 ra = (double) 0;
2566 for (int i = 0; i < a.length; i += SPECIES.length()) {
2567 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2568 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask));
2569 }
2570 }
2571
2572 assertReductionArraysEqualsMasked(r, ra, a, mask,
2573 Double128VectorTests::FIRST_NONZEROReduceMasked, Double128VectorTests::FIRST_NONZEROReduceAllMasked);
2574 }
2575
2576 @Test(dataProvider = "doubleUnaryOpProvider")
2577 static void withDouble128VectorTests(IntFunction<double []> fa) {
2578 double[] a = fa.apply(SPECIES.length());
2579 double[] r = fr.apply(SPECIES.length());
2580
2581 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2582 for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
2583 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2584 av.withLane((j++ & (SPECIES.length()-1)), (double)(65535+i)).intoArray(r, i);
2585 }
2586 }
2587
2588
2589 for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
2590 assertInsertArraysEquals(r, a, (double)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
2591 }
2592 }
2593
2594 static boolean testIS_DEFAULT(double a) {
2595 return bits(a)==0;
2596 }
2597
2598 @Test(dataProvider = "doubleTestOpProvider")
2599 static void IS_DEFAULTDouble128VectorTests(IntFunction<double[]> fa) {
2600 double[] a = fa.apply(SPECIES.length());
2601
2602 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2603 for (int i = 0; i < a.length; i += SPECIES.length()) {
2604 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2605 VectorMask<Double> mv = av.test(VectorOperators.IS_DEFAULT);
2606
2607 // Check results as part of computation.
2608 for (int j = 0; j < SPECIES.length(); j++) {
2609 Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
2610 }
2611 }
2612 }
2613 }
2614
2615 @Test(dataProvider = "doubleTestOpMaskProvider")
2616 static void IS_DEFAULTMaskedDouble128VectorTests(IntFunction<double[]> fa,
2617 IntFunction<boolean[]> fm) {
2618 double[] a = fa.apply(SPECIES.length());
2619 boolean[] mask = fm.apply(SPECIES.length());
2620 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2621
2622 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2623 for (int i = 0; i < a.length; i += SPECIES.length()) {
2624 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2625 VectorMask<Double> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
2626
2627 // Check results as part of computation.
2628 for (int j = 0; j < SPECIES.length(); j++) {
2629 Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
2630 }
2631 }
2632 }
2633 }
2634
2635 static boolean testIS_NEGATIVE(double a) {
2636 return bits(a)<0;
2637 }
2638
2639 @Test(dataProvider = "doubleTestOpProvider")
2640 static void IS_NEGATIVEDouble128VectorTests(IntFunction<double[]> fa) {
2641 double[] a = fa.apply(SPECIES.length());
2642
2643 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2644 for (int i = 0; i < a.length; i += SPECIES.length()) {
2645 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2646 VectorMask<Double> mv = av.test(VectorOperators.IS_NEGATIVE);
2647
2648 // Check results as part of computation.
2649 for (int j = 0; j < SPECIES.length(); j++) {
2650 Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
2651 }
2652 }
2653 }
2654 }
2697 @Test(dataProvider = "doubleTestOpMaskProvider")
2698 static void IS_FINITEMaskedDouble128VectorTests(IntFunction<double[]> fa,
2699 IntFunction<boolean[]> fm) {
2700 double[] a = fa.apply(SPECIES.length());
2701 boolean[] mask = fm.apply(SPECIES.length());
2702 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2703
2704 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2705 for (int i = 0; i < a.length; i += SPECIES.length()) {
2706 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2707 VectorMask<Double> mv = av.test(VectorOperators.IS_FINITE, vmask);
2708
2709 // Check results as part of computation.
2710 for (int j = 0; j < SPECIES.length(); j++) {
2711 Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j]));
2712 }
2713 }
2714 }
2715 }
2716
2717 static boolean testIS_NAN(double a) {
2718 return Double.isNaN(a);
2719 }
2720
2721 @Test(dataProvider = "doubleTestOpProvider")
2722 static void IS_NANDouble128VectorTests(IntFunction<double[]> fa) {
2723 double[] a = fa.apply(SPECIES.length());
2724
2725 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2726 for (int i = 0; i < a.length; i += SPECIES.length()) {
2727 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2728 VectorMask<Double> mv = av.test(VectorOperators.IS_NAN);
2729
2730 // Check results as part of computation.
2731 for (int j = 0; j < SPECIES.length(); j++) {
2732 Assert.assertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j]));
2733 }
2734 }
2735 }
2736 }
2738 @Test(dataProvider = "doubleTestOpMaskProvider")
2739 static void IS_NANMaskedDouble128VectorTests(IntFunction<double[]> fa,
2740 IntFunction<boolean[]> fm) {
2741 double[] a = fa.apply(SPECIES.length());
2742 boolean[] mask = fm.apply(SPECIES.length());
2743 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2744
2745 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2746 for (int i = 0; i < a.length; i += SPECIES.length()) {
2747 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2748 VectorMask<Double> mv = av.test(VectorOperators.IS_NAN, vmask);
2749
2750 // Check results as part of computation.
2751 for (int j = 0; j < SPECIES.length(); j++) {
2752 Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j]));
2753 }
2754 }
2755 }
2756 }
2757
2758 static boolean testIS_INFINITE(double a) {
2759 return Double.isInfinite(a);
2760 }
2761
2762 @Test(dataProvider = "doubleTestOpProvider")
2763 static void IS_INFINITEDouble128VectorTests(IntFunction<double[]> fa) {
2764 double[] a = fa.apply(SPECIES.length());
2765
2766 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2767 for (int i = 0; i < a.length; i += SPECIES.length()) {
2768 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2769 VectorMask<Double> mv = av.test(VectorOperators.IS_INFINITE);
2770
2771 // Check results as part of computation.
2772 for (int j = 0; j < SPECIES.length(); j++) {
2773 Assert.assertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j]));
2774 }
2775 }
2776 }
2777 }
2779 @Test(dataProvider = "doubleTestOpMaskProvider")
2780 static void IS_INFINITEMaskedDouble128VectorTests(IntFunction<double[]> fa,
2781 IntFunction<boolean[]> fm) {
2782 double[] a = fa.apply(SPECIES.length());
2783 boolean[] mask = fm.apply(SPECIES.length());
2784 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2785
2786 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2787 for (int i = 0; i < a.length; i += SPECIES.length()) {
2788 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2789 VectorMask<Double> mv = av.test(VectorOperators.IS_INFINITE, vmask);
2790
2791 // Check results as part of computation.
2792 for (int j = 0; j < SPECIES.length(); j++) {
2793 Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j]));
2794 }
2795 }
2796 }
2797 }
2798
2799 @Test(dataProvider = "doubleCompareOpProvider")
2800 static void LTDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2801 double[] a = fa.apply(SPECIES.length());
2802 double[] b = fb.apply(SPECIES.length());
2803
2804 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2805 for (int i = 0; i < a.length; i += SPECIES.length()) {
2806 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2807 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2808 VectorMask<Double> mv = av.compare(VectorOperators.LT, bv);
2809
2810 // Check results as part of computation.
2811 for (int j = 0; j < SPECIES.length(); j++) {
2812 Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
2813 }
2814 }
2815 }
2816 }
2817
2818 @Test(dataProvider = "doubleCompareOpProvider")
2819 static void ltDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2820 double[] a = fa.apply(SPECIES.length());
2821 double[] b = fb.apply(SPECIES.length());
2822
2823 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2824 for (int i = 0; i < a.length; i += SPECIES.length()) {
2825 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2826 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2827 VectorMask<Double> mv = av.lt(bv);
2828
2829 // Check results as part of computation.
2830 for (int j = 0; j < SPECIES.length(); j++) {
2831 Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
2832 }
2833 }
2834 }
2835 }
2836
2837 @Test(dataProvider = "doubleCompareOpMaskProvider")
2840 double[] a = fa.apply(SPECIES.length());
2841 double[] b = fb.apply(SPECIES.length());
2842 boolean[] mask = fm.apply(SPECIES.length());
2843
2844 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2845
2846 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2847 for (int i = 0; i < a.length; i += SPECIES.length()) {
2848 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2849 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2850 VectorMask<Double> mv = av.compare(VectorOperators.LT, bv, vmask);
2851
2852 // Check results as part of computation.
2853 for (int j = 0; j < SPECIES.length(); j++) {
2854 Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
2855 }
2856 }
2857 }
2858 }
2859
2860 @Test(dataProvider = "doubleCompareOpProvider")
2861 static void GTDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2862 double[] a = fa.apply(SPECIES.length());
2863 double[] b = fb.apply(SPECIES.length());
2864
2865 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2866 for (int i = 0; i < a.length; i += SPECIES.length()) {
2867 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2868 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2869 VectorMask<Double> mv = av.compare(VectorOperators.GT, bv);
2870
2871 // Check results as part of computation.
2872 for (int j = 0; j < SPECIES.length(); j++) {
2873 Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
2874 }
2875 }
2876 }
2877 }
2878
2879 @Test(dataProvider = "doubleCompareOpMaskProvider")
2882 double[] a = fa.apply(SPECIES.length());
2883 double[] b = fb.apply(SPECIES.length());
2884 boolean[] mask = fm.apply(SPECIES.length());
2885
2886 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2887
2888 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2889 for (int i = 0; i < a.length; i += SPECIES.length()) {
2890 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2891 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2892 VectorMask<Double> mv = av.compare(VectorOperators.GT, bv, vmask);
2893
2894 // Check results as part of computation.
2895 for (int j = 0; j < SPECIES.length(); j++) {
2896 Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
2897 }
2898 }
2899 }
2900 }
2901
2902 @Test(dataProvider = "doubleCompareOpProvider")
2903 static void EQDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2904 double[] a = fa.apply(SPECIES.length());
2905 double[] b = fb.apply(SPECIES.length());
2906
2907 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2908 for (int i = 0; i < a.length; i += SPECIES.length()) {
2909 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2910 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2911 VectorMask<Double> mv = av.compare(VectorOperators.EQ, bv);
2912
2913 // Check results as part of computation.
2914 for (int j = 0; j < SPECIES.length(); j++) {
2915 Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
2916 }
2917 }
2918 }
2919 }
2920
2921 @Test(dataProvider = "doubleCompareOpProvider")
2922 static void eqDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2923 double[] a = fa.apply(SPECIES.length());
2924 double[] b = fb.apply(SPECIES.length());
2925
2926 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2927 for (int i = 0; i < a.length; i += SPECIES.length()) {
2928 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2929 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2930 VectorMask<Double> mv = av.eq(bv);
2931
2932 // Check results as part of computation.
2933 for (int j = 0; j < SPECIES.length(); j++) {
2934 Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
2935 }
2936 }
2937 }
2938 }
2939
2940 @Test(dataProvider = "doubleCompareOpMaskProvider")
2943 double[] a = fa.apply(SPECIES.length());
2944 double[] b = fb.apply(SPECIES.length());
2945 boolean[] mask = fm.apply(SPECIES.length());
2946
2947 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2948
2949 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2950 for (int i = 0; i < a.length; i += SPECIES.length()) {
2951 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2952 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2953 VectorMask<Double> mv = av.compare(VectorOperators.EQ, bv, vmask);
2954
2955 // Check results as part of computation.
2956 for (int j = 0; j < SPECIES.length(); j++) {
2957 Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
2958 }
2959 }
2960 }
2961 }
2962
2963 @Test(dataProvider = "doubleCompareOpProvider")
2964 static void NEDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
2965 double[] a = fa.apply(SPECIES.length());
2966 double[] b = fb.apply(SPECIES.length());
2967
2968 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2969 for (int i = 0; i < a.length; i += SPECIES.length()) {
2970 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2971 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2972 VectorMask<Double> mv = av.compare(VectorOperators.NE, bv);
2973
2974 // Check results as part of computation.
2975 for (int j = 0; j < SPECIES.length(); j++) {
2976 Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
2977 }
2978 }
2979 }
2980 }
2981
2982 @Test(dataProvider = "doubleCompareOpMaskProvider")
2985 double[] a = fa.apply(SPECIES.length());
2986 double[] b = fb.apply(SPECIES.length());
2987 boolean[] mask = fm.apply(SPECIES.length());
2988
2989 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2990
2991 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2992 for (int i = 0; i < a.length; i += SPECIES.length()) {
2993 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
2994 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
2995 VectorMask<Double> mv = av.compare(VectorOperators.NE, bv, vmask);
2996
2997 // Check results as part of computation.
2998 for (int j = 0; j < SPECIES.length(); j++) {
2999 Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
3000 }
3001 }
3002 }
3003 }
3004
3005 @Test(dataProvider = "doubleCompareOpProvider")
3006 static void LEDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3007 double[] a = fa.apply(SPECIES.length());
3008 double[] b = fb.apply(SPECIES.length());
3009
3010 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3011 for (int i = 0; i < a.length; i += SPECIES.length()) {
3012 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3013 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3014 VectorMask<Double> mv = av.compare(VectorOperators.LE, bv);
3015
3016 // Check results as part of computation.
3017 for (int j = 0; j < SPECIES.length(); j++) {
3018 Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
3019 }
3020 }
3021 }
3022 }
3023
3024 @Test(dataProvider = "doubleCompareOpMaskProvider")
3027 double[] a = fa.apply(SPECIES.length());
3028 double[] b = fb.apply(SPECIES.length());
3029 boolean[] mask = fm.apply(SPECIES.length());
3030
3031 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3032
3033 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3034 for (int i = 0; i < a.length; i += SPECIES.length()) {
3035 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3036 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3037 VectorMask<Double> mv = av.compare(VectorOperators.LE, bv, vmask);
3038
3039 // Check results as part of computation.
3040 for (int j = 0; j < SPECIES.length(); j++) {
3041 Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
3042 }
3043 }
3044 }
3045 }
3046
3047 @Test(dataProvider = "doubleCompareOpProvider")
3048 static void GEDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3049 double[] a = fa.apply(SPECIES.length());
3050 double[] b = fb.apply(SPECIES.length());
3051
3052 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3053 for (int i = 0; i < a.length; i += SPECIES.length()) {
3054 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3055 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3056 VectorMask<Double> mv = av.compare(VectorOperators.GE, bv);
3057
3058 // Check results as part of computation.
3059 for (int j = 0; j < SPECIES.length(); j++) {
3060 Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
3061 }
3062 }
3063 }
3064 }
3065
3066 @Test(dataProvider = "doubleCompareOpMaskProvider")
3069 double[] a = fa.apply(SPECIES.length());
3070 double[] b = fb.apply(SPECIES.length());
3071 boolean[] mask = fm.apply(SPECIES.length());
3072
3073 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3074
3075 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3076 for (int i = 0; i < a.length; i += SPECIES.length()) {
3077 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3078 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3079 VectorMask<Double> mv = av.compare(VectorOperators.GE, bv, vmask);
3080
3081 // Check results as part of computation.
3082 for (int j = 0; j < SPECIES.length(); j++) {
3083 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
3084 }
3085 }
3086 }
3087 }
3088
3089 @Test(dataProvider = "doubleCompareOpProvider")
3090 static void LTDouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3091 double[] a = fa.apply(SPECIES.length());
3092 double[] b = fb.apply(SPECIES.length());
3093
3094 for (int i = 0; i < a.length; i += SPECIES.length()) {
3095 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3096 VectorMask<Double> mv = av.compare(VectorOperators.LT, b[i]);
3097
3098 // Check results as part of computation.
3099 for (int j = 0; j < SPECIES.length(); j++) {
3100 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
3101 }
3102 }
3103 }
3104
3105 @Test(dataProvider = "doubleCompareOpMaskProvider")
3106 static void LTDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa,
3107 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3108 double[] a = fa.apply(SPECIES.length());
3109 double[] b = fb.apply(SPECIES.length());
3110 boolean[] mask = fm.apply(SPECIES.length());
3111
3112 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3113
3114 for (int i = 0; i < a.length; i += SPECIES.length()) {
3115 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3116 VectorMask<Double> mv = av.compare(VectorOperators.LT, b[i], vmask);
3117
3118 // Check results as part of computation.
3119 for (int j = 0; j < SPECIES.length(); j++) {
3120 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
3121 }
3122 }
3123 }
3124
3125 @Test(dataProvider = "doubleCompareOpProvider")
3126 static void LTDouble128VectorTestsBroadcastLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3127 double[] a = fa.apply(SPECIES.length());
3128 double[] b = fb.apply(SPECIES.length());
3129
3130 for (int i = 0; i < a.length; i += SPECIES.length()) {
3131 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3132 VectorMask<Double> mv = av.compare(VectorOperators.LT, (long)b[i]);
3133
3134 // Check results as part of computation.
3135 for (int j = 0; j < SPECIES.length(); j++) {
3136 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (double)((long)b[i]));
3137 }
3138 }
3139 }
3140
3141 @Test(dataProvider = "doubleCompareOpMaskProvider")
3142 static void LTDouble128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<double[]> fa,
3143 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3144 double[] a = fa.apply(SPECIES.length());
3145 double[] b = fb.apply(SPECIES.length());
3146 boolean[] mask = fm.apply(SPECIES.length());
3147
3148 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3149
3150 for (int i = 0; i < a.length; i += SPECIES.length()) {
3151 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3152 VectorMask<Double> mv = av.compare(VectorOperators.LT, (long)b[i], vmask);
3153
3154 // Check results as part of computation.
3155 for (int j = 0; j < SPECIES.length(); j++) {
3156 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (double)((long)b[i])));
3157 }
3158 }
3159 }
3160
3161 @Test(dataProvider = "doubleCompareOpProvider")
3162 static void EQDouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3163 double[] a = fa.apply(SPECIES.length());
3164 double[] b = fb.apply(SPECIES.length());
3165
3166 for (int i = 0; i < a.length; i += SPECIES.length()) {
3167 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3168 VectorMask<Double> mv = av.compare(VectorOperators.EQ, b[i]);
3169
3170 // Check results as part of computation.
3171 for (int j = 0; j < SPECIES.length(); j++) {
3172 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
3173 }
3174 }
3175 }
3176
3177 @Test(dataProvider = "doubleCompareOpMaskProvider")
3178 static void EQDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa,
3179 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3180 double[] a = fa.apply(SPECIES.length());
3181 double[] b = fb.apply(SPECIES.length());
3182 boolean[] mask = fm.apply(SPECIES.length());
3183
3184 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3185
3186 for (int i = 0; i < a.length; i += SPECIES.length()) {
3187 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3188 VectorMask<Double> mv = av.compare(VectorOperators.EQ, b[i], vmask);
3189
3190 // Check results as part of computation.
3191 for (int j = 0; j < SPECIES.length(); j++) {
3192 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
3193 }
3194 }
3195 }
3196
3197 @Test(dataProvider = "doubleCompareOpProvider")
3198 static void EQDouble128VectorTestsBroadcastLongSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3199 double[] a = fa.apply(SPECIES.length());
3200 double[] b = fb.apply(SPECIES.length());
3201
3202 for (int i = 0; i < a.length; i += SPECIES.length()) {
3203 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3204 VectorMask<Double> mv = av.compare(VectorOperators.EQ, (long)b[i]);
3205
3206 // Check results as part of computation.
3207 for (int j = 0; j < SPECIES.length(); j++) {
3208 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (double)((long)b[i]));
3209 }
3210 }
3211 }
3212
3213 @Test(dataProvider = "doubleCompareOpMaskProvider")
3214 static void EQDouble128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<double[]> fa,
3215 IntFunction<double[]> fb, IntFunction<boolean[]> fm) {
3216 double[] a = fa.apply(SPECIES.length());
3217 double[] b = fb.apply(SPECIES.length());
3218 boolean[] mask = fm.apply(SPECIES.length());
3219
3220 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3221
3222 for (int i = 0; i < a.length; i += SPECIES.length()) {
3223 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3224 VectorMask<Double> mv = av.compare(VectorOperators.EQ, (long)b[i], vmask);
3225
3226 // Check results as part of computation.
3227 for (int j = 0; j < SPECIES.length(); j++) {
3228 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (double)((long)b[i])));
3229 }
3230 }
3231 }
3232
3271 assertRearrangeArraysEquals(r, a, order, SPECIES.length());
3272 }
3273
3274 @Test(dataProvider = "doubleUnaryOpShuffleMaskProvider")
3275 static void RearrangeDouble128VectorTestsMaskedSmokeTest(IntFunction<double[]> fa,
3276 BiFunction<Integer,Integer,int[]> fs,
3277 IntFunction<boolean[]> fm) {
3278 double[] a = fa.apply(SPECIES.length());
3279 int[] order = fs.apply(a.length, SPECIES.length());
3280 double[] r = fr.apply(SPECIES.length());
3281 boolean[] mask = fm.apply(SPECIES.length());
3282 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3283
3284 for (int i = 0; i < a.length; i += SPECIES.length()) {
3285 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3286 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
3287 }
3288
3289 assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
3290 }
3291
3292 @Test(dataProvider = "doubleUnaryOpMaskProvider")
3293 static void compressDouble128VectorTests(IntFunction<double[]> fa,
3294 IntFunction<boolean[]> fm) {
3295 double[] a = fa.apply(SPECIES.length());
3296 double[] r = fr.apply(SPECIES.length());
3297 boolean[] mask = fm.apply(SPECIES.length());
3298 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3299
3300 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3301 for (int i = 0; i < a.length; i += SPECIES.length()) {
3302 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3303 av.compress(vmask).intoArray(r, i);
3304 }
3305 }
3306
3307 assertcompressArraysEquals(r, a, mask, SPECIES.length());
3308 }
3309
3310 @Test(dataProvider = "doubleUnaryOpMaskProvider")
3311 static void expandDouble128VectorTests(IntFunction<double[]> fa,
3312 IntFunction<boolean[]> fm) {
3313 double[] a = fa.apply(SPECIES.length());
3314 double[] r = fr.apply(SPECIES.length());
3315 boolean[] mask = fm.apply(SPECIES.length());
3316 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3317
3318 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3319 for (int i = 0; i < a.length; i += SPECIES.length()) {
3320 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3321 av.expand(vmask).intoArray(r, i);
3322 }
3323 }
3324
3325 assertexpandArraysEquals(r, a, mask, SPECIES.length());
3326 }
3327
3328 @Test(dataProvider = "doubleUnaryOpProvider")
3329 static void getDouble128VectorTests(IntFunction<double[]> fa) {
3330 double[] a = fa.apply(SPECIES.length());
3331 double[] r = fr.apply(SPECIES.length());
3332
3333 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3334 for (int i = 0; i < a.length; i += SPECIES.length()) {
3335 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3336 int num_lanes = SPECIES.length();
3337 // Manually unroll because full unroll happens after intrinsification.
3338 // Unroll is needed because get intrinsic requires for index to be a known constant.
3339 if (num_lanes == 1) {
3340 r[i]=av.lane(0);
3341 } else if (num_lanes == 2) {
3342 r[i]=av.lane(0);
3343 r[i+1]=av.lane(1);
3344 } else if (num_lanes == 4) {
3345 r[i]=av.lane(0);
3346 r[i+1]=av.lane(1);
3347 r[i+2]=av.lane(2);
3478 }
3479 }
3480
3481 assertArraysEquals(r, a, Double128VectorTests::get);
3482 }
3483
3484 @Test(dataProvider = "doubleUnaryOpProvider")
3485 static void BroadcastDouble128VectorTests(IntFunction<double[]> fa) {
3486 double[] a = fa.apply(SPECIES.length());
3487 double[] r = new double[a.length];
3488
3489 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3490 for (int i = 0; i < a.length; i += SPECIES.length()) {
3491 DoubleVector.broadcast(SPECIES, a[i]).intoArray(r, i);
3492 }
3493 }
3494
3495 assertBroadcastArraysEquals(r, a);
3496 }
3497
3498 @Test(dataProvider = "doubleUnaryOpProvider")
3499 static void ZeroDouble128VectorTests(IntFunction<double[]> fa) {
3500 double[] a = fa.apply(SPECIES.length());
3501 double[] r = new double[a.length];
3502
3503 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3504 for (int i = 0; i < a.length; i += SPECIES.length()) {
3505 DoubleVector.zero(SPECIES).intoArray(a, i);
3506 }
3507 }
3508
3509 Assert.assertEquals(a, r);
3510 }
3511
3512 static double[] sliceUnary(double[] a, int origin, int idx) {
3513 double[] res = new double[SPECIES.length()];
3514 for (int i = 0; i < SPECIES.length(); i++){
3515 if(i+origin < SPECIES.length())
3516 res[i] = a[idx+i+origin];
3517 else
3518 res[i] = (double)0;
3519 }
3520 return res;
3521 }
3522
3523 @Test(dataProvider = "doubleUnaryOpProvider")
3524 static void sliceUnaryDouble128VectorTests(IntFunction<double[]> fa) {
3525 double[] a = fa.apply(SPECIES.length());
3526 double[] r = new double[a.length];
3527 int origin = (new java.util.Random()).nextInt(SPECIES.length());
3528 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3529 for (int i = 0; i < a.length; i += SPECIES.length()) {
3530 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3531 av.slice(origin).intoArray(r, i);
3532 }
3533 }
3534
3535 assertArraysEquals(r, a, origin, Double128VectorTests::sliceUnary);
3536 }
3537
3538 static double[] sliceBinary(double[] a, double[] b, int origin, int idx) {
3539 double[] res = new double[SPECIES.length()];
3540 for (int i = 0, j = 0; i < SPECIES.length(); i++){
3541 if(i+origin < SPECIES.length())
3542 res[i] = a[idx+i+origin];
3543 else {
3544 res[i] = b[idx+j];
3545 j++;
3546 }
3547 }
3548 return res;
3549 }
3550
3551 @Test(dataProvider = "doubleBinaryOpProvider")
3552 static void sliceBinaryDouble128VectorTestsBinary(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3553 double[] a = fa.apply(SPECIES.length());
3554 double[] b = fb.apply(SPECIES.length());
3555 double[] r = new double[a.length];
3556 int origin = (new java.util.Random()).nextInt(SPECIES.length());
3557 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3558 for (int i = 0; i < a.length; i += SPECIES.length()) {
3559 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3560 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3561 av.slice(origin, bv).intoArray(r, i);
3562 }
3563 }
3564
3565 assertArraysEquals(r, a, b, origin, Double128VectorTests::sliceBinary);
3566 }
3567
3568 static double[] slice(double[] a, double[] b, int origin, boolean[] mask, int idx) {
3569 double[] res = new double[SPECIES.length()];
3570 for (int i = 0, j = 0; i < SPECIES.length(); i++){
3571 if(i+origin < SPECIES.length())
3572 res[i] = mask[i] ? a[idx+i+origin] : (double)0;
3573 else {
3574 res[i] = mask[i] ? b[idx+j] : (double)0;
3575 j++;
3576 }
3577 }
3578 return res;
3579 }
3580
3581 @Test(dataProvider = "doubleBinaryOpMaskProvider")
3582 static void sliceDouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
3583 IntFunction<boolean[]> fm) {
3584 double[] a = fa.apply(SPECIES.length());
3585 double[] b = fb.apply(SPECIES.length());
3586 boolean[] mask = fm.apply(SPECIES.length());
3587 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3588
3589 double[] r = new double[a.length];
3590 int origin = (new java.util.Random()).nextInt(SPECIES.length());
3591 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3592 for (int i = 0; i < a.length; i += SPECIES.length()) {
3593 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3594 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3595 av.slice(origin, bv, vmask).intoArray(r, i);
3596 }
3597 }
3598
3599 assertArraysEquals(r, a, b, origin, mask, Double128VectorTests::slice);
3600 }
3601
3602 static double[] unsliceUnary(double[] a, int origin, int idx) {
3603 double[] res = new double[SPECIES.length()];
3604 for (int i = 0, j = 0; i < SPECIES.length(); i++){
3605 if(i < origin)
3606 res[i] = (double)0;
3607 else {
3608 res[i] = a[idx+j];
3609 j++;
3610 }
3611 }
3612 return res;
3613 }
3614
3615 @Test(dataProvider = "doubleUnaryOpProvider")
3616 static void unsliceUnaryDouble128VectorTests(IntFunction<double[]> fa) {
3617 double[] a = fa.apply(SPECIES.length());
3618 double[] r = new double[a.length];
3619 int origin = (new java.util.Random()).nextInt(SPECIES.length());
3620 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3621 for (int i = 0; i < a.length; i += SPECIES.length()) {
3622 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3623 av.unslice(origin).intoArray(r, i);
3624 }
3625 }
3626
3627 assertArraysEquals(r, a, origin, Double128VectorTests::unsliceUnary);
3628 }
3629
3630 static double[] unsliceBinary(double[] a, double[] b, int origin, int part, int idx) {
3631 double[] res = new double[SPECIES.length()];
3632 for (int i = 0, j = 0; i < SPECIES.length(); i++){
3633 if (part == 0) {
3634 if (i < origin)
3635 res[i] = b[idx+i];
3636 else {
3637 res[i] = a[idx+j];
3638 j++;
3639 }
3640 } else if (part == 1) {
3641 if (i < origin)
3642 res[i] = a[idx+SPECIES.length()-origin+i];
3643 else {
3644 res[i] = b[idx+origin+j];
3645 j++;
3646 }
3647 }
3648 }
3649 return res;
3650 }
3651
3652 @Test(dataProvider = "doubleBinaryOpProvider")
3653 static void unsliceBinaryDouble128VectorTestsBinary(IntFunction<double[]> fa, IntFunction<double[]> fb) {
3654 double[] a = fa.apply(SPECIES.length());
3655 double[] b = fb.apply(SPECIES.length());
3656 double[] r = new double[a.length];
3657 int origin = (new java.util.Random()).nextInt(SPECIES.length());
3658 int part = (new java.util.Random()).nextInt(2);
3659 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3660 for (int i = 0; i < a.length; i += SPECIES.length()) {
3661 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3662 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
3663 av.unslice(origin, bv, part).intoArray(r, i);
3664 }
3665 }
3666
3667 assertArraysEquals(r, a, b, origin, part, Double128VectorTests::unsliceBinary);
3668 }
3669
3670 static double[] unslice(double[] a, double[] b, int origin, int part, boolean[] mask, int idx) {
3671 double[] res = new double[SPECIES.length()];
3672 for (int i = 0, j = 0; i < SPECIES.length(); i++){
3673 if(i+origin < SPECIES.length())
3674 res[i] = b[idx+i+origin];
3675 else {
3676 res[i] = b[idx+j];
3677 j++;
3678 }
3679 }
3680 for (int i = 0; i < SPECIES.length(); i++){
3681 res[i] = mask[i] ? a[idx+i] : res[i];
3682 }
3683 double[] res1 = new double[SPECIES.length()];
3684 if (part == 0) {
3685 for (int i = 0, j = 0; i < SPECIES.length(); i++){
3686 if (i < origin)
3687 res1[i] = b[idx+i];
3688 else {
3689 res1[i] = res[j];
3730
3731 static double strictSIN(double a) {
3732 return (double)(StrictMath.sin((double)a));
3733 }
3734
3735 @Test(dataProvider = "doubleUnaryOpProvider")
3736 static void SINDouble128VectorTests(IntFunction<double[]> fa) {
3737 double[] a = fa.apply(SPECIES.length());
3738 double[] r = fr.apply(SPECIES.length());
3739
3740 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3741 for (int i = 0; i < a.length; i += SPECIES.length()) {
3742 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3743 av.lanewise(VectorOperators.SIN).intoArray(r, i);
3744 }
3745 }
3746
3747 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::SIN, Double128VectorTests::strictSIN);
3748 }
3749
3750 static double EXP(double a) {
3751 return (double)(Math.exp((double)a));
3752 }
3753
3754 static double strictEXP(double a) {
3755 return (double)(StrictMath.exp((double)a));
3756 }
3757
3758 @Test(dataProvider = "doubleUnaryOpProvider")
3759 static void EXPDouble128VectorTests(IntFunction<double[]> fa) {
3760 double[] a = fa.apply(SPECIES.length());
3761 double[] r = fr.apply(SPECIES.length());
3762
3763 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3764 for (int i = 0; i < a.length; i += SPECIES.length()) {
3765 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3766 av.lanewise(VectorOperators.EXP).intoArray(r, i);
3767 }
3768 }
3769
3770 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::EXP, Double128VectorTests::strictEXP);
3771 }
3772
3773 static double LOG1P(double a) {
3774 return (double)(Math.log1p((double)a));
3775 }
3776
3777 static double strictLOG1P(double a) {
3778 return (double)(StrictMath.log1p((double)a));
3779 }
3780
3781 @Test(dataProvider = "doubleUnaryOpProvider")
3782 static void LOG1PDouble128VectorTests(IntFunction<double[]> fa) {
3783 double[] a = fa.apply(SPECIES.length());
3784 double[] r = fr.apply(SPECIES.length());
3785
3786 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3787 for (int i = 0; i < a.length; i += SPECIES.length()) {
3788 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3789 av.lanewise(VectorOperators.LOG1P).intoArray(r, i);
3790 }
3791 }
3792
3793 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::LOG1P, Double128VectorTests::strictLOG1P);
3794 }
3795
3796 static double LOG(double a) {
3797 return (double)(Math.log((double)a));
3798 }
3799
3800 static double strictLOG(double a) {
3801 return (double)(StrictMath.log((double)a));
3802 }
3803
3804 @Test(dataProvider = "doubleUnaryOpProvider")
3805 static void LOGDouble128VectorTests(IntFunction<double[]> fa) {
3806 double[] a = fa.apply(SPECIES.length());
3807 double[] r = fr.apply(SPECIES.length());
3808
3809 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3810 for (int i = 0; i < a.length; i += SPECIES.length()) {
3811 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3812 av.lanewise(VectorOperators.LOG).intoArray(r, i);
3813 }
3814 }
3815
3816 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::LOG, Double128VectorTests::strictLOG);
3817 }
3818
3819 static double LOG10(double a) {
3820 return (double)(Math.log10((double)a));
3821 }
3822
3823 static double strictLOG10(double a) {
3824 return (double)(StrictMath.log10((double)a));
3825 }
3826
3827 @Test(dataProvider = "doubleUnaryOpProvider")
3828 static void LOG10Double128VectorTests(IntFunction<double[]> fa) {
3829 double[] a = fa.apply(SPECIES.length());
3830 double[] r = fr.apply(SPECIES.length());
3831
3832 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3833 for (int i = 0; i < a.length; i += SPECIES.length()) {
3834 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3835 av.lanewise(VectorOperators.LOG10).intoArray(r, i);
3836 }
3837 }
3838
3839 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::LOG10, Double128VectorTests::strictLOG10);
3840 }
3841
3842 static double EXPM1(double a) {
3843 return (double)(Math.expm1((double)a));
3844 }
3845
3846 static double strictEXPM1(double a) {
3847 return (double)(StrictMath.expm1((double)a));
3848 }
3849
3850 @Test(dataProvider = "doubleUnaryOpProvider")
3851 static void EXPM1Double128VectorTests(IntFunction<double[]> fa) {
3852 double[] a = fa.apply(SPECIES.length());
3853 double[] r = fr.apply(SPECIES.length());
3854
3855 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3856 for (int i = 0; i < a.length; i += SPECIES.length()) {
3857 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3858 av.lanewise(VectorOperators.EXPM1).intoArray(r, i);
3859 }
3860 }
3861
3862 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::EXPM1, Double128VectorTests::strictEXPM1);
3863 }
3864
3865 static double COS(double a) {
3866 return (double)(Math.cos((double)a));
3867 }
3868
3869 static double strictCOS(double a) {
3870 return (double)(StrictMath.cos((double)a));
3871 }
3872
3873 @Test(dataProvider = "doubleUnaryOpProvider")
3874 static void COSDouble128VectorTests(IntFunction<double[]> fa) {
3875 double[] a = fa.apply(SPECIES.length());
3876 double[] r = fr.apply(SPECIES.length());
3877
3878 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3879 for (int i = 0; i < a.length; i += SPECIES.length()) {
3880 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3881 av.lanewise(VectorOperators.COS).intoArray(r, i);
3882 }
3883 }
3884
3885 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::COS, Double128VectorTests::strictCOS);
3886 }
3887
3888 static double TAN(double a) {
3889 return (double)(Math.tan((double)a));
3890 }
3891
3892 static double strictTAN(double a) {
3893 return (double)(StrictMath.tan((double)a));
3894 }
3895
3896 @Test(dataProvider = "doubleUnaryOpProvider")
3897 static void TANDouble128VectorTests(IntFunction<double[]> fa) {
3898 double[] a = fa.apply(SPECIES.length());
3899 double[] r = fr.apply(SPECIES.length());
3900
3901 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3902 for (int i = 0; i < a.length; i += SPECIES.length()) {
3903 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3904 av.lanewise(VectorOperators.TAN).intoArray(r, i);
3905 }
3906 }
3907
3908 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::TAN, Double128VectorTests::strictTAN);
3909 }
3910
3911 static double SINH(double a) {
3912 return (double)(Math.sinh((double)a));
3913 }
3914
3915 static double strictSINH(double a) {
3916 return (double)(StrictMath.sinh((double)a));
3917 }
3918
3919 @Test(dataProvider = "doubleUnaryOpProvider")
3920 static void SINHDouble128VectorTests(IntFunction<double[]> fa) {
3921 double[] a = fa.apply(SPECIES.length());
3922 double[] r = fr.apply(SPECIES.length());
3923
3924 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3925 for (int i = 0; i < a.length; i += SPECIES.length()) {
3926 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3927 av.lanewise(VectorOperators.SINH).intoArray(r, i);
3928 }
3929 }
3930
3931 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::SINH, Double128VectorTests::strictSINH);
3932 }
3933
3934 static double COSH(double a) {
3935 return (double)(Math.cosh((double)a));
3936 }
3937
3938 static double strictCOSH(double a) {
3939 return (double)(StrictMath.cosh((double)a));
3940 }
3941
3942 @Test(dataProvider = "doubleUnaryOpProvider")
3943 static void COSHDouble128VectorTests(IntFunction<double[]> fa) {
3944 double[] a = fa.apply(SPECIES.length());
3945 double[] r = fr.apply(SPECIES.length());
3946
3947 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3948 for (int i = 0; i < a.length; i += SPECIES.length()) {
3949 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3950 av.lanewise(VectorOperators.COSH).intoArray(r, i);
3951 }
3952 }
3953
3954 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::COSH, Double128VectorTests::strictCOSH);
3955 }
3956
3957 static double TANH(double a) {
3958 return (double)(Math.tanh((double)a));
3959 }
3960
3961 static double strictTANH(double a) {
3962 return (double)(StrictMath.tanh((double)a));
3963 }
3964
3965 @Test(dataProvider = "doubleUnaryOpProvider")
3966 static void TANHDouble128VectorTests(IntFunction<double[]> fa) {
3967 double[] a = fa.apply(SPECIES.length());
3968 double[] r = fr.apply(SPECIES.length());
3969
3970 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3971 for (int i = 0; i < a.length; i += SPECIES.length()) {
3972 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3973 av.lanewise(VectorOperators.TANH).intoArray(r, i);
3974 }
3975 }
3976
3977 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::TANH, Double128VectorTests::strictTANH);
3978 }
3979
3980 static double ASIN(double a) {
3981 return (double)(Math.asin((double)a));
3982 }
3983
3984 static double strictASIN(double a) {
3985 return (double)(StrictMath.asin((double)a));
3986 }
3987
3988 @Test(dataProvider = "doubleUnaryOpProvider")
3989 static void ASINDouble128VectorTests(IntFunction<double[]> fa) {
3990 double[] a = fa.apply(SPECIES.length());
3991 double[] r = fr.apply(SPECIES.length());
3992
3993 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3994 for (int i = 0; i < a.length; i += SPECIES.length()) {
3995 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
3996 av.lanewise(VectorOperators.ASIN).intoArray(r, i);
3997 }
3998 }
3999
4000 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::ASIN, Double128VectorTests::strictASIN);
4001 }
4002
4003 static double ACOS(double a) {
4004 return (double)(Math.acos((double)a));
4005 }
4006
4007 static double strictACOS(double a) {
4008 return (double)(StrictMath.acos((double)a));
4009 }
4010
4011 @Test(dataProvider = "doubleUnaryOpProvider")
4012 static void ACOSDouble128VectorTests(IntFunction<double[]> fa) {
4013 double[] a = fa.apply(SPECIES.length());
4014 double[] r = fr.apply(SPECIES.length());
4015
4016 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4017 for (int i = 0; i < a.length; i += SPECIES.length()) {
4018 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4019 av.lanewise(VectorOperators.ACOS).intoArray(r, i);
4020 }
4021 }
4022
4023 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::ACOS, Double128VectorTests::strictACOS);
4024 }
4025
4026 static double ATAN(double a) {
4027 return (double)(Math.atan((double)a));
4028 }
4029
4030 static double strictATAN(double a) {
4031 return (double)(StrictMath.atan((double)a));
4032 }
4033
4034 @Test(dataProvider = "doubleUnaryOpProvider")
4035 static void ATANDouble128VectorTests(IntFunction<double[]> fa) {
4036 double[] a = fa.apply(SPECIES.length());
4037 double[] r = fr.apply(SPECIES.length());
4038
4039 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4040 for (int i = 0; i < a.length; i += SPECIES.length()) {
4041 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4042 av.lanewise(VectorOperators.ATAN).intoArray(r, i);
4043 }
4044 }
4045
4046 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::ATAN, Double128VectorTests::strictATAN);
4047 }
4048
4049 static double CBRT(double a) {
4050 return (double)(Math.cbrt((double)a));
4051 }
4052
4053 static double strictCBRT(double a) {
4054 return (double)(StrictMath.cbrt((double)a));
4055 }
4056
4057 @Test(dataProvider = "doubleUnaryOpProvider")
4058 static void CBRTDouble128VectorTests(IntFunction<double[]> fa) {
4059 double[] a = fa.apply(SPECIES.length());
4060 double[] r = fr.apply(SPECIES.length());
4061
4062 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4063 for (int i = 0; i < a.length; i += SPECIES.length()) {
4064 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4065 av.lanewise(VectorOperators.CBRT).intoArray(r, i);
4066 }
4067 }
4068
4069 assertArraysEqualsWithinOneUlp(r, a, Double128VectorTests::CBRT, Double128VectorTests::strictCBRT);
4070 }
4071
4072 static double HYPOT(double a, double b) {
4073 return (double)(Math.hypot((double)a, (double)b));
4074 }
4075
4076 static double strictHYPOT(double a, double b) {
4077 return (double)(StrictMath.hypot((double)a, (double)b));
4078 }
4079
4080 @Test(dataProvider = "doubleBinaryOpProvider")
4081 static void HYPOTDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4082 double[] a = fa.apply(SPECIES.length());
4083 double[] b = fb.apply(SPECIES.length());
4084 double[] r = fr.apply(SPECIES.length());
4085
4086 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4087 for (int i = 0; i < a.length; i += SPECIES.length()) {
4088 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4089 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4090 av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i);
4091 }
4092 }
4093
4094 assertArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::HYPOT, Double128VectorTests::strictHYPOT);
4095 }
4096
4097
4098 static double POW(double a, double b) {
4099 return (double)(Math.pow((double)a, (double)b));
4100 }
4101
4102 static double strictPOW(double a, double b) {
4103 return (double)(StrictMath.pow((double)a, (double)b));
4104 }
4105
4106 @Test(dataProvider = "doubleBinaryOpProvider")
4107 static void POWDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4108 double[] a = fa.apply(SPECIES.length());
4109 double[] b = fb.apply(SPECIES.length());
4110 double[] r = fr.apply(SPECIES.length());
4111
4112 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4113 for (int i = 0; i < a.length; i += SPECIES.length()) {
4114 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4115 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4116 av.lanewise(VectorOperators.POW, bv).intoArray(r, i);
4117 }
4118 }
4119
4120 assertArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::POW, Double128VectorTests::strictPOW);
4121 }
4122
4123
4124 static double pow(double a, double b) {
4125 return (double)(Math.pow((double)a, (double)b));
4126 }
4127
4128 static double strictpow(double a, double b) {
4129 return (double)(StrictMath.pow((double)a, (double)b));
4130 }
4131
4132 @Test(dataProvider = "doubleBinaryOpProvider")
4133 static void powDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4134 double[] a = fa.apply(SPECIES.length());
4135 double[] b = fb.apply(SPECIES.length());
4136 double[] r = fr.apply(SPECIES.length());
4137
4138 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4139 for (int i = 0; i < a.length; i += SPECIES.length()) {
4140 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4141 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4142 av.pow(bv).intoArray(r, i);
4143 }
4144 }
4145
4146 assertArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::pow, Double128VectorTests::strictpow);
4147 }
4148
4149
4150 static double ATAN2(double a, double b) {
4151 return (double)(Math.atan2((double)a, (double)b));
4152 }
4153
4154 static double strictATAN2(double a, double b) {
4155 return (double)(StrictMath.atan2((double)a, (double)b));
4156 }
4157
4158 @Test(dataProvider = "doubleBinaryOpProvider")
4159 static void ATAN2Double128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4160 double[] a = fa.apply(SPECIES.length());
4161 double[] b = fb.apply(SPECIES.length());
4162 double[] r = fr.apply(SPECIES.length());
4163
4164 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4165 for (int i = 0; i < a.length; i += SPECIES.length()) {
4166 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4167 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4168 av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i);
4169 }
4170 }
4171
4172 assertArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::ATAN2, Double128VectorTests::strictATAN2);
4173 }
4174
4175
4176 @Test(dataProvider = "doubleBinaryOpProvider")
4177 static void POWDouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4178 double[] a = fa.apply(SPECIES.length());
4179 double[] b = fb.apply(SPECIES.length());
4180 double[] r = fr.apply(SPECIES.length());
4181
4182 for (int i = 0; i < a.length; i += SPECIES.length()) {
4183 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4184 av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i);
4185 }
4186
4187 assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::POW, Double128VectorTests::strictPOW);
4188 }
4189
4190
4191 @Test(dataProvider = "doubleBinaryOpProvider")
4192 static void powDouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4193 double[] a = fa.apply(SPECIES.length());
4194 double[] b = fb.apply(SPECIES.length());
4195 double[] r = fr.apply(SPECIES.length());
4196
4197 for (int i = 0; i < a.length; i += SPECIES.length()) {
4198 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4199 av.pow(b[i]).intoArray(r, i);
4200 }
4201
4202 assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Double128VectorTests::pow, Double128VectorTests::strictpow);
4203 }
4204
4205
4206 static double FMA(double a, double b, double c) {
4207 return (double)(Math.fma(a, b, c));
4208 }
4209
4210 static double fma(double a, double b, double c) {
4211 return (double)(Math.fma(a, b, c));
4212 }
4213
4214 @Test(dataProvider = "doubleTernaryOpProvider")
4215 static void FMADouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4216 int count = INVOC_COUNT;
4217 switch ("FMA") {
4218 case "fma": case "lanewise_FMA":
4219 // Math.fma uses BigDecimal
4220 count = Math.max(5, count/20); break;
4221 }
4222 final int INVOC_COUNT = count;
4223 double[] a = fa.apply(SPECIES.length());
4224 double[] b = fb.apply(SPECIES.length());
4225 double[] c = fc.apply(SPECIES.length());
4226 double[] r = fr.apply(SPECIES.length());
4227
4228 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4229 for (int i = 0; i < a.length; i += SPECIES.length()) {
4230 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4231 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4232 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4233 av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i);
4234 }
4235 }
4236
4237 assertArraysEquals(r, a, b, c, Double128VectorTests::FMA);
4238 }
4239
4240 @Test(dataProvider = "doubleTernaryOpProvider")
4241 static void fmaDouble128VectorTests(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4242 int count = INVOC_COUNT;
4243 switch ("fma") {
4244 case "fma": case "lanewise_FMA":
4245 // Math.fma uses BigDecimal
4246 count = Math.max(5, count/20); break;
4247 }
4248 final int INVOC_COUNT = count;
4249 double[] a = fa.apply(SPECIES.length());
4250 double[] b = fb.apply(SPECIES.length());
4251 double[] c = fc.apply(SPECIES.length());
4252 double[] r = fr.apply(SPECIES.length());
4253
4254 for (int i = 0; i < a.length; i += SPECIES.length()) {
4255 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4256 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4257 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4258 av.fma(bv, cv).intoArray(r, i);
4259 }
4260
4261 assertArraysEquals(r, a, b, c, Double128VectorTests::fma);
4262 }
4263
4264 @Test(dataProvider = "doubleTernaryOpMaskProvider")
4265 static void FMADouble128VectorTestsMasked(IntFunction<double[]> fa, IntFunction<double[]> fb,
4266 IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4267 int count = INVOC_COUNT;
4268 switch ("FMA") {
4269 case "fma": case "lanewise_FMA":
4270 // Math.fma uses BigDecimal
4271 count = Math.max(5, count/20); break;
4272 }
4273 final int INVOC_COUNT = count;
4274 double[] a = fa.apply(SPECIES.length());
4275 double[] b = fb.apply(SPECIES.length());
4276 double[] c = fc.apply(SPECIES.length());
4277 double[] r = fr.apply(SPECIES.length());
4278 boolean[] mask = fm.apply(SPECIES.length());
4279 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4280
4281 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4282 for (int i = 0; i < a.length; i += SPECIES.length()) {
4283 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4284 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4285 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4286 av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i);
4287 }
4288 }
4289
4290 assertArraysEquals(r, a, b, c, mask, Double128VectorTests::FMA);
4291 }
4292
4293 @Test(dataProvider = "doubleTernaryOpProvider")
4294 static void FMADouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4295 double[] a = fa.apply(SPECIES.length());
4296 double[] b = fb.apply(SPECIES.length());
4297 double[] c = fc.apply(SPECIES.length());
4298 double[] r = fr.apply(SPECIES.length());
4299
4300 for (int i = 0; i < a.length; i += SPECIES.length()) {
4301 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4302 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4303 av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i);
4304 }
4305 assertBroadcastArraysEquals(r, a, b, c, Double128VectorTests::FMA);
4306 }
4307
4308 @Test(dataProvider = "doubleTernaryOpProvider")
4309 static void FMADouble128VectorTestsAltBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4310 double[] a = fa.apply(SPECIES.length());
4311 double[] b = fb.apply(SPECIES.length());
4312 double[] c = fc.apply(SPECIES.length());
4313 double[] r = fr.apply(SPECIES.length());
4314
4315 for (int i = 0; i < a.length; i += SPECIES.length()) {
4316 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4317 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4318 av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i);
4319 }
4320 assertAltBroadcastArraysEquals(r, a, b, c, Double128VectorTests::FMA);
4321 }
4322
4323 @Test(dataProvider = "doubleTernaryOpMaskProvider")
4324 static void FMADouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
4325 IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4326 double[] a = fa.apply(SPECIES.length());
4327 double[] b = fb.apply(SPECIES.length());
4328 double[] c = fc.apply(SPECIES.length());
4329 double[] r = fr.apply(SPECIES.length());
4330 boolean[] mask = fm.apply(SPECIES.length());
4331 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4332
4333 for (int i = 0; i < a.length; i += SPECIES.length()) {
4334 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4335 DoubleVector bv = DoubleVector.fromArray(SPECIES, b, i);
4336 av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i);
4337 }
4338
4339 assertBroadcastArraysEquals(r, a, b, c, mask, Double128VectorTests::FMA);
4340 }
4341
4342 @Test(dataProvider = "doubleTernaryOpMaskProvider")
4343 static void FMADouble128VectorTestsAltBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
4344 IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4345 double[] a = fa.apply(SPECIES.length());
4346 double[] b = fb.apply(SPECIES.length());
4347 double[] c = fc.apply(SPECIES.length());
4348 double[] r = fr.apply(SPECIES.length());
4349 boolean[] mask = fm.apply(SPECIES.length());
4350 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4351
4352 for (int i = 0; i < a.length; i += SPECIES.length()) {
4353 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4354 DoubleVector cv = DoubleVector.fromArray(SPECIES, c, i);
4355 av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i);
4356 }
4357
4358 assertAltBroadcastArraysEquals(r, a, b, c, mask, Double128VectorTests::FMA);
4359 }
4360
4361 @Test(dataProvider = "doubleTernaryOpProvider")
4362 static void FMADouble128VectorTestsDoubleBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4363 int count = INVOC_COUNT;
4364 switch ("FMA") {
4365 case "fma": case "lanewise_FMA":
4366 // Math.fma uses BigDecimal
4367 count = Math.max(5, count/20); break;
4368 }
4369 final int INVOC_COUNT = count;
4370 double[] a = fa.apply(SPECIES.length());
4371 double[] b = fb.apply(SPECIES.length());
4372 double[] c = fc.apply(SPECIES.length());
4373 double[] r = fr.apply(SPECIES.length());
4374
4375 for (int i = 0; i < a.length; i += SPECIES.length()) {
4376 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4377 av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i);
4378 }
4379
4380 assertDoubleBroadcastArraysEquals(r, a, b, c, Double128VectorTests::FMA);
4381 }
4382
4383 @Test(dataProvider = "doubleTernaryOpProvider")
4384 static void fmaDouble128VectorTestsDoubleBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb, IntFunction<double[]> fc) {
4385 int count = INVOC_COUNT;
4386 switch ("fma") {
4387 case "fma": case "lanewise_FMA":
4388 // Math.fma uses BigDecimal
4389 count = Math.max(5, count/20); break;
4390 }
4391 final int INVOC_COUNT = count;
4392 double[] a = fa.apply(SPECIES.length());
4393 double[] b = fb.apply(SPECIES.length());
4394 double[] c = fc.apply(SPECIES.length());
4395 double[] r = fr.apply(SPECIES.length());
4396
4397 for (int i = 0; i < a.length; i += SPECIES.length()) {
4398 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4399 av.fma(b[i], c[i]).intoArray(r, i);
4400 }
4401
4402 assertDoubleBroadcastArraysEquals(r, a, b, c, Double128VectorTests::fma);
4403 }
4404
4405 @Test(dataProvider = "doubleTernaryOpMaskProvider")
4406 static void FMADouble128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb,
4407 IntFunction<double[]> fc, IntFunction<boolean[]> fm) {
4408 int count = INVOC_COUNT;
4409 switch ("FMA") {
4410 case "fma": case "lanewise_FMA":
4411 // Math.fma uses BigDecimal
4412 count = Math.max(5, count/20); break;
4413 }
4414 final int INVOC_COUNT = count;
4415 double[] a = fa.apply(SPECIES.length());
4416 double[] b = fb.apply(SPECIES.length());
4417 double[] c = fc.apply(SPECIES.length());
4418 double[] r = fr.apply(SPECIES.length());
4419 boolean[] mask = fm.apply(SPECIES.length());
4420 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4421
4422 for (int i = 0; i < a.length; i += SPECIES.length()) {
4423 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4424 av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i);
4425 }
4426
4427 assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Double128VectorTests::FMA);
4428 }
4429
4430 static double NEG(double a) {
4431 return (double)(-((double)a));
4432 }
4433
4434 static double neg(double a) {
4435 return (double)(-((double)a));
4436 }
4437
4438 @Test(dataProvider = "doubleUnaryOpProvider")
4439 static void NEGDouble128VectorTests(IntFunction<double[]> fa) {
4440 double[] a = fa.apply(SPECIES.length());
4441 double[] r = fr.apply(SPECIES.length());
4442
4443 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4444 for (int i = 0; i < a.length; i += SPECIES.length()) {
4445 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4446 av.lanewise(VectorOperators.NEG).intoArray(r, i);
4447 }
4448 }
4449
4522 }
4523
4524 @Test(dataProvider = "doubleUnaryOpMaskProvider")
4525 static void ABSMaskedDouble128VectorTests(IntFunction<double[]> fa,
4526 IntFunction<boolean[]> fm) {
4527 double[] a = fa.apply(SPECIES.length());
4528 double[] r = fr.apply(SPECIES.length());
4529 boolean[] mask = fm.apply(SPECIES.length());
4530 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4531
4532 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4533 for (int i = 0; i < a.length; i += SPECIES.length()) {
4534 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4535 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
4536 }
4537 }
4538
4539 assertArraysEquals(r, a, mask, Double128VectorTests::ABS);
4540 }
4541
4542 static double SQRT(double a) {
4543 return (double)(Math.sqrt((double)a));
4544 }
4545
4546 static double sqrt(double a) {
4547 return (double)(Math.sqrt((double)a));
4548 }
4549
4550 @Test(dataProvider = "doubleUnaryOpProvider")
4551 static void SQRTDouble128VectorTests(IntFunction<double[]> fa) {
4552 double[] a = fa.apply(SPECIES.length());
4553 double[] r = fr.apply(SPECIES.length());
4554
4555 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4556 for (int i = 0; i < a.length; i += SPECIES.length()) {
4557 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4558 av.lanewise(VectorOperators.SQRT).intoArray(r, i);
4559 }
4560 }
4561
4562 assertArraysEquals(r, a, Double128VectorTests::SQRT);
4563 }
4564
4565 @Test(dataProvider = "doubleUnaryOpProvider")
4566 static void sqrtDouble128VectorTests(IntFunction<double[]> fa) {
4567 double[] a = fa.apply(SPECIES.length());
4568 double[] r = fr.apply(SPECIES.length());
4569
4570 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4571 for (int i = 0; i < a.length; i += SPECIES.length()) {
4572 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4573 av.sqrt().intoArray(r, i);
4574 }
4575 }
4576
4577 assertArraysEquals(r, a, Double128VectorTests::sqrt);
4578 }
4579
4580 @Test(dataProvider = "doubleUnaryOpMaskProvider")
4581 static void SQRTMaskedDouble128VectorTests(IntFunction<double[]> fa,
4582 IntFunction<boolean[]> fm) {
4583 double[] a = fa.apply(SPECIES.length());
4584 double[] r = fr.apply(SPECIES.length());
4585 boolean[] mask = fm.apply(SPECIES.length());
4586 VectorMask<Double> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4587
4588 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4589 for (int i = 0; i < a.length; i += SPECIES.length()) {
4590 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4591 av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i);
4592 }
4593 }
4594
4595 assertArraysEquals(r, a, mask, Double128VectorTests::SQRT);
4596 }
4597
4598 @Test(dataProvider = "doubleCompareOpProvider")
4599 static void ltDouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4600 double[] a = fa.apply(SPECIES.length());
4601 double[] b = fb.apply(SPECIES.length());
4602
4603 for (int i = 0; i < a.length; i += SPECIES.length()) {
4604 DoubleVector av = DoubleVector.fromArray(SPECIES, a, i);
4605 VectorMask<Double> mv = av.lt(b[i]);
4606
4607 // Check results as part of computation.
4608 for (int j = 0; j < SPECIES.length(); j++) {
4609 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
4610 }
4611 }
4612 }
4613
4614 @Test(dataProvider = "doubleCompareOpProvider")
4615 static void eqDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
4616 double[] a = fa.apply(SPECIES.length());
4617 double[] b = fb.apply(SPECIES.length());
4969 }
4970 }
4971 return i - idx;
4972 }
4973
4974 @Test(dataProvider = "maskProvider")
4975 static void maskFirstTrueDouble128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
4976 boolean[] a = fa.apply(SPECIES.length());
4977 int[] r = new int[a.length];
4978
4979 for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
4980 for (int i = 0; i < a.length; i += SPECIES.length()) {
4981 var vmask = SPECIES.loadMask(a, i);
4982 r[i] = vmask.firstTrue();
4983 }
4984 }
4985
4986 assertMaskReductionArraysEquals(r, a, Double128VectorTests::maskFirstTrue);
4987 }
4988
4989 @Test(dataProvider = "maskProvider")
4990 static void maskCompressDouble128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
4991 int trueCount = 0;
4992 boolean[] a = fa.apply(SPECIES.length());
4993
4994 for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
4995 for (int i = 0; i < a.length; i += SPECIES.length()) {
4996 var vmask = SPECIES.loadMask(a, i);
4997 trueCount = vmask.trueCount();
4998 var rmask = vmask.compress();
4999 for (int j = 0; j < SPECIES.length(); j++) {
5000 Assert.assertEquals(rmask.laneIsSet(j), j < trueCount);
5001 }
5002 }
5003 }
5004 }
5005
5006 @DataProvider
5007 public static Object[][] longMaskProvider() {
5008 return new Object[][]{
5009 {0xFFFFFFFFFFFFFFFFL},
5010 {0x0000000000000000L},
5011 {0x5555555555555555L},
5012 {0x0123456789abcdefL},
5013 };
5014 }
5015
5016 @Test(dataProvider = "longMaskProvider")
5017 static void maskFromToLongDouble128VectorTestsSmokeTest(long inputLong) {
5018 var vmask = VectorMask.fromLong(SPECIES, inputLong);
5019 long outputLong = vmask.toLong();
5020 Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
5021 }
5022
5023 @DataProvider
5024 public static Object[][] offsetProvider() {
5025 return new Object[][]{
5028 {+1},
5029 {+2},
5030 {-2},
5031 };
5032 }
5033
5034 @Test(dataProvider = "offsetProvider")
5035 static void indexInRangeDouble128VectorTestsSmokeTest(int offset) {
5036 int limit = SPECIES.length() * BUFFER_REPS;
5037 for (int i = 0; i < limit; i += SPECIES.length()) {
5038 var actualMask = SPECIES.indexInRange(i + offset, limit);
5039 var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
5040 assert(actualMask.equals(expectedMask));
5041 for (int j = 0; j < SPECIES.length(); j++) {
5042 int index = i + j + offset;
5043 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
5044 }
5045 }
5046 }
5047
5048 @Test(dataProvider = "offsetProvider")
5049 static void indexInRangeLongDouble128VectorTestsSmokeTest(int offset) {
5050 long limit = SPECIES.length() * BUFFER_REPS;
5051 for (long i = 0; i < limit; i += SPECIES.length()) {
5052 var actualMask = SPECIES.indexInRange(i + offset, limit);
5053 var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
5054 assert(actualMask.equals(expectedMask));
5055 for (int j = 0; j < SPECIES.length(); j++) {
5056 long index = i + j + offset;
5057 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
5058 }
5059 }
5060 }
5061
5062 @DataProvider
5063 public static Object[][] lengthProvider() {
5064 return new Object[][]{
5065 {0},
5066 {1},
5067 {32},
5068 {37},
5069 {1024},
5070 {1024+1},
5071 {1024+5},
5072 };
5073 }
5074
5075 @Test(dataProvider = "lengthProvider")
5076 static void loopBoundDouble128VectorTestsSmokeTest(int length) {
5077 int actualLoopBound = SPECIES.loopBound(length);
5078 int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
5079 Assert.assertEquals(actualLoopBound, expectedLoopBound);
5080 }
5081
5082 @Test(dataProvider = "lengthProvider")
5083 static void loopBoundLongDouble128VectorTestsSmokeTest(int _length) {
5084 long length = _length;
5085 long actualLoopBound = SPECIES.loopBound(length);
5086 long expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
5087 Assert.assertEquals(actualLoopBound, expectedLoopBound);
5088 }
5089
5090 @Test
5091 static void ElementSizeDouble128VectorTestsSmokeTest() {
5092 DoubleVector av = DoubleVector.zero(SPECIES);
5093 int elsize = av.elementSize();
5094 Assert.assertEquals(elsize, Double.SIZE);
5095 }
5096
5097 @Test
5098 static void VectorShapeDouble128VectorTestsSmokeTest() {
5099 DoubleVector av = DoubleVector.zero(SPECIES);
5100 VectorShape vsh = av.shape();
5101 assert(vsh.equals(VectorShape.S_128_BIT));
5102 }
5103
5104 @Test
5105 static void ShapeWithLanesDouble128VectorTestsSmokeTest() {
5106 DoubleVector av = DoubleVector.zero(SPECIES);
5107 VectorShape vsh = av.shape();
5108 VectorSpecies species = vsh.withLanes(double.class);
5109 assert(species.equals(SPECIES));
5132 DoubleVector av = DoubleVector.zero(SPECIES);
5133 VectorSpecies species = av.species().withLanes(double.class);
5134 assert(species.equals(SPECIES));
5135 }
5136
5137 @Test
5138 static void WithShapeDouble128VectorTestsSmokeTest() {
5139 DoubleVector av = DoubleVector.zero(SPECIES);
5140 VectorShape vsh = av.shape();
5141 VectorSpecies species = av.species().withShape(vsh);
5142 assert(species.equals(SPECIES));
5143 }
5144
5145 @Test
5146 static void MaskAllTrueDouble128VectorTestsSmokeTest() {
5147 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5148 Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
5149 }
5150 }
5151 }
|