< prev index next >

test/jdk/jdk/incubator/vector/Short64VectorTests.java

Print this page




 224 
 225     interface FBinMaskOp {
 226         short apply(short a, short b, boolean m);
 227 
 228         static FBinMaskOp lift(FBinOp f) {
 229             return (a, b, m) -> m ? f.apply(a, b) : a;
 230         }
 231     }
 232 
 233     static void assertArraysEquals(short[] a, short[] b, short[] r, FBinOp f) {
 234         int i = 0;
 235         try {
 236             for (; i < a.length; i++) {
 237                 Assert.assertEquals(r[i], f.apply(a[i], b[i]));
 238             }
 239         } catch (AssertionError e) {
 240             Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i);
 241         }
 242     }
 243 












 244     static void assertArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) {
 245         assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
 246     }
 247 
 248     static void assertArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) {
 249         int i = 0;
 250         try {
 251             for (; i < a.length; i++) {
 252                 Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]));
 253             }
 254         } catch (AssertionError err) {
 255             Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]);
 256         }
 257     }
 258 


















 259     static void assertShiftArraysEquals(short[] a, short[] b, short[] r, FBinOp f) {
 260         int i = 0;
 261         int j = 0;
 262         try {
 263             for (; j < a.length; j += SPECIES.length()) {
 264                 for (i = 0; i < SPECIES.length(); i++) {
 265                     Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]));
 266                 }
 267             }
 268         } catch (AssertionError e) {
 269             Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j);
 270         }
 271     }
 272 
 273     static void assertShiftArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) {
 274         assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
 275     }
 276 
 277     static void assertShiftArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) {
 278         int i = 0;


1352     static short OR(short a, short b) {
1353         return (short)(a | b);
1354     }
1355 
1356     @Test(dataProvider = "shortBinaryOpProvider")
1357     static void ORShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1358         short[] a = fa.apply(SPECIES.length());
1359         short[] b = fb.apply(SPECIES.length());
1360         short[] r = fr.apply(SPECIES.length());
1361 
1362         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1363             for (int i = 0; i < a.length; i += SPECIES.length()) {
1364                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1365                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1366                 av.lanewise(VectorOperators.OR, bv).intoArray(r, i);
1367             }
1368         }
1369 
1370         assertArraysEquals(a, b, r, Short64VectorTests::OR);
1371     }




















1372 
1373 
1374 
1375     @Test(dataProvider = "shortBinaryOpMaskProvider")
1376     static void ORShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1377                                           IntFunction<boolean[]> fm) {
1378         short[] a = fa.apply(SPECIES.length());
1379         short[] b = fb.apply(SPECIES.length());
1380         short[] r = fr.apply(SPECIES.length());
1381         boolean[] mask = fm.apply(SPECIES.length());
1382         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1383 
1384         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1385             for (int i = 0; i < a.length; i += SPECIES.length()) {
1386                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1387                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1388                 av.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i);
1389             }
1390         }
1391 


1420     static void XORShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1421                                           IntFunction<boolean[]> fm) {
1422         short[] a = fa.apply(SPECIES.length());
1423         short[] b = fb.apply(SPECIES.length());
1424         short[] r = fr.apply(SPECIES.length());
1425         boolean[] mask = fm.apply(SPECIES.length());
1426         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1427 
1428         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1429             for (int i = 0; i < a.length; i += SPECIES.length()) {
1430                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1431                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1432                 av.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i);
1433             }
1434         }
1435 
1436         assertArraysEquals(a, b, r, mask, Short64VectorTests::XOR);
1437     }
1438 
1439 























































































































































































1440 
1441 
1442 
1443 
1444     static short LSHL(short a, short b) {
1445         return (short)((a << (b & 0xF)));
1446     }
1447 
1448     @Test(dataProvider = "shortBinaryOpProvider")
1449     static void LSHLShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1450         short[] a = fa.apply(SPECIES.length());
1451         short[] b = fb.apply(SPECIES.length());
1452         short[] 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                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1457                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1458                 av.lanewise(VectorOperators.LSHL, bv).intoArray(r, i);
1459             }


1782         return (short)(Math.max(a, b));
1783     }
1784 
1785     @Test(dataProvider = "shortBinaryOpProvider")
1786     static void maxShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1787         short[] a = fa.apply(SPECIES.length());
1788         short[] b = fb.apply(SPECIES.length());
1789         short[] r = fr.apply(SPECIES.length());
1790 
1791         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1792             for (int i = 0; i < a.length; i += SPECIES.length()) {
1793                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1794                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1795                 av.max(bv).intoArray(r, i);
1796             }
1797         }
1798 
1799         assertArraysEquals(a, b, r, Short64VectorTests::max);
1800     }
1801 
























































1802     static short AND(short[] a, int idx) {
1803         short res = -1;
1804         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1805             res &= a[i];
1806         }
1807 
1808         return res;
1809     }
1810 
1811     static short AND(short[] a) {
1812         short res = -1;
1813         for (int i = 0; i < a.length; i += SPECIES.length()) {
1814             short tmp = -1;
1815             for (int j = 0; j < SPECIES.length(); j++) {
1816                 tmp &= a[i + j];
1817             }
1818             res &= tmp;
1819         }
1820 
1821         return res;


3226         boolean[] mask = fm.apply(SPECIES.length());
3227         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3228 
3229         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3230             for (int i = 0; i < a.length; i += SPECIES.length()) {
3231                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3232                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3233                 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
3234                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i);
3235             }
3236         }
3237 
3238         assertArraysEquals(a, b, c, r, mask, Short64VectorTests::BITWISE_BLEND);
3239     }
3240 
3241 
3242     static short NEG(short a) {
3243         return (short)(-((short)a));
3244     }
3245 




3246     @Test(dataProvider = "shortUnaryOpProvider")
3247     static void NEGShort64VectorTests(IntFunction<short[]> fa) {
3248         short[] a = fa.apply(SPECIES.length());
3249         short[] r = fr.apply(SPECIES.length());
3250 
3251         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3252             for (int i = 0; i < a.length; i += SPECIES.length()) {
3253                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3254                 av.lanewise(VectorOperators.NEG).intoArray(r, i);
3255             }
3256         }
3257 
3258         assertArraysEquals(a, r, Short64VectorTests::NEG);
3259     }
3260 















3261     @Test(dataProvider = "shortUnaryOpMaskProvider")
3262     static void NEGMaskedShort64VectorTests(IntFunction<short[]> fa,
3263                                                 IntFunction<boolean[]> fm) {
3264         short[] a = fa.apply(SPECIES.length());
3265         short[] r = fr.apply(SPECIES.length());
3266         boolean[] mask = fm.apply(SPECIES.length());
3267         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3268 
3269         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3270             for (int i = 0; i < a.length; i += SPECIES.length()) {
3271                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3272                 av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i);
3273             }
3274         }
3275 
3276         assertArraysEquals(a, r, mask, Short64VectorTests::NEG);
3277     }
3278 
3279     static short ABS(short a) {
3280         return (short)(Math.abs((short)a));


3320         short[] a = fa.apply(SPECIES.length());
3321         short[] r = fr.apply(SPECIES.length());
3322         boolean[] mask = fm.apply(SPECIES.length());
3323         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3324 
3325         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3326             for (int i = 0; i < a.length; i += SPECIES.length()) {
3327                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3328                 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
3329             }
3330         }
3331 
3332         assertArraysEquals(a, r, mask, Short64VectorTests::ABS);
3333     }
3334 
3335 
3336     static short NOT(short a) {
3337         return (short)(~((short)a));
3338     }
3339 




3340 
3341 
3342     @Test(dataProvider = "shortUnaryOpProvider")
3343     static void NOTShort64VectorTests(IntFunction<short[]> fa) {
3344         short[] a = fa.apply(SPECIES.length());
3345         short[] r = fr.apply(SPECIES.length());
3346 
3347         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3348             for (int i = 0; i < a.length; i += SPECIES.length()) {
3349                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3350                 av.lanewise(VectorOperators.NOT).intoArray(r, i);
3351             }
3352         }
3353 
3354         assertArraysEquals(a, r, Short64VectorTests::NOT);















3355     }
3356 
3357 
3358 
3359     @Test(dataProvider = "shortUnaryOpMaskProvider")
3360     static void NOTMaskedShort64VectorTests(IntFunction<short[]> fa,
3361                                                 IntFunction<boolean[]> fm) {
3362         short[] a = fa.apply(SPECIES.length());
3363         short[] r = fr.apply(SPECIES.length());
3364         boolean[] mask = fm.apply(SPECIES.length());
3365         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3366 
3367         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3368             for (int i = 0; i < a.length; i += SPECIES.length()) {
3369                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3370                 av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i);
3371             }
3372         }
3373 
3374         assertArraysEquals(a, r, mask, Short64VectorTests::NOT);




 224 
 225     interface FBinMaskOp {
 226         short apply(short a, short b, boolean m);
 227 
 228         static FBinMaskOp lift(FBinOp f) {
 229             return (a, b, m) -> m ? f.apply(a, b) : a;
 230         }
 231     }
 232 
 233     static void assertArraysEquals(short[] a, short[] b, short[] r, FBinOp f) {
 234         int i = 0;
 235         try {
 236             for (; i < a.length; i++) {
 237                 Assert.assertEquals(r[i], f.apply(a[i], b[i]));
 238             }
 239         } catch (AssertionError e) {
 240             Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i);
 241         }
 242     }
 243 
 244     static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, FBinOp f) {
 245         int i = 0;
 246         try {
 247             for (; i < a.length; i++) {
 248                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]));
 249             }
 250         } catch (AssertionError e) {
 251             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]),
 252                                 "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);
 253         }
 254     }
 255 
 256     static void assertArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) {
 257         assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
 258     }
 259 
 260     static void assertArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) {
 261         int i = 0;
 262         try {
 263             for (; i < a.length; i++) {
 264                 Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]));
 265             }
 266         } catch (AssertionError err) {
 267             Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]);
 268         }
 269     }
 270 
 271     static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) {
 272         assertBroadcastArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
 273     }
 274 
 275     static void assertBroadcastArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) {
 276         int i = 0;
 277         try {
 278             for (; i < a.length; i++) {
 279                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));
 280             }
 281         } catch (AssertionError err) {
 282             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], 
 283                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + 
 284                                 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 285                                 mask[i % SPECIES.length()]);
 286         }
 287     }
 288 
 289     static void assertShiftArraysEquals(short[] a, short[] b, short[] r, FBinOp f) {
 290         int i = 0;
 291         int j = 0;
 292         try {
 293             for (; j < a.length; j += SPECIES.length()) {
 294                 for (i = 0; i < SPECIES.length(); i++) {
 295                     Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]));
 296                 }
 297             }
 298         } catch (AssertionError e) {
 299             Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j);
 300         }
 301     }
 302 
 303     static void assertShiftArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinOp f) {
 304         assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
 305     }
 306 
 307     static void assertShiftArraysEquals(short[] a, short[] b, short[] r, boolean[] mask, FBinMaskOp f) {
 308         int i = 0;


1382     static short OR(short a, short b) {
1383         return (short)(a | b);
1384     }
1385 
1386     @Test(dataProvider = "shortBinaryOpProvider")
1387     static void ORShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1388         short[] a = fa.apply(SPECIES.length());
1389         short[] b = fb.apply(SPECIES.length());
1390         short[] r = fr.apply(SPECIES.length());
1391 
1392         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1393             for (int i = 0; i < a.length; i += SPECIES.length()) {
1394                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1395                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1396                 av.lanewise(VectorOperators.OR, bv).intoArray(r, i);
1397             }
1398         }
1399 
1400         assertArraysEquals(a, b, r, Short64VectorTests::OR);
1401     }
1402     static short or(short a, short b) {
1403         return (short)(a | b);
1404     }
1405 
1406     @Test(dataProvider = "shortBinaryOpProvider")
1407     static void orShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1408         short[] a = fa.apply(SPECIES.length());
1409         short[] b = fb.apply(SPECIES.length());
1410         short[] r = fr.apply(SPECIES.length());
1411 
1412         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1413             for (int i = 0; i < a.length; i += SPECIES.length()) {
1414                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1415                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1416                 av.or(bv).intoArray(r, i);
1417             }
1418         }
1419 
1420         assertArraysEquals(a, b, r, Short64VectorTests::or);
1421     }
1422 
1423 
1424 
1425     @Test(dataProvider = "shortBinaryOpMaskProvider")
1426     static void ORShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1427                                           IntFunction<boolean[]> fm) {
1428         short[] a = fa.apply(SPECIES.length());
1429         short[] b = fb.apply(SPECIES.length());
1430         short[] r = fr.apply(SPECIES.length());
1431         boolean[] mask = fm.apply(SPECIES.length());
1432         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1433 
1434         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1435             for (int i = 0; i < a.length; i += SPECIES.length()) {
1436                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1437                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1438                 av.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i);
1439             }
1440         }
1441 


1470     static void XORShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1471                                           IntFunction<boolean[]> fm) {
1472         short[] a = fa.apply(SPECIES.length());
1473         short[] b = fb.apply(SPECIES.length());
1474         short[] r = fr.apply(SPECIES.length());
1475         boolean[] mask = fm.apply(SPECIES.length());
1476         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1477 
1478         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1479             for (int i = 0; i < a.length; i += SPECIES.length()) {
1480                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1481                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1482                 av.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i);
1483             }
1484         }
1485 
1486         assertArraysEquals(a, b, r, mask, Short64VectorTests::XOR);
1487     }
1488 
1489 
1490     @Test(dataProvider = "shortBinaryOpProvider")
1491     static void addShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1492         short[] a = fa.apply(SPECIES.length());
1493         short[] b = fb.apply(SPECIES.length());
1494         short[] r = fr.apply(SPECIES.length());
1495 
1496         for (int i = 0; i < a.length; i += SPECIES.length()) {
1497             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1498             av.add(b[i]).intoArray(r, i);
1499         }
1500 
1501         assertBroadcastArraysEquals(a, b, r, Short64VectorTests::add);
1502     }
1503 
1504     @Test(dataProvider = "shortBinaryOpMaskProvider")
1505     static void addShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
1506                                           IntFunction<boolean[]> fm) {
1507         short[] a = fa.apply(SPECIES.length());
1508         short[] b = fb.apply(SPECIES.length());
1509         short[] r = fr.apply(SPECIES.length());
1510         boolean[] mask = fm.apply(SPECIES.length());
1511         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1512 
1513         for (int i = 0; i < a.length; i += SPECIES.length()) {
1514             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1515             av.add(b[i], vmask).intoArray(r, i);
1516         }
1517 
1518         assertBroadcastArraysEquals(a, b, r, mask, Short64VectorTests::add);
1519     }
1520 
1521     @Test(dataProvider = "shortBinaryOpProvider")
1522     static void subShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1523         short[] a = fa.apply(SPECIES.length());
1524         short[] b = fb.apply(SPECIES.length());
1525         short[] r = fr.apply(SPECIES.length());
1526 
1527         for (int i = 0; i < a.length; i += SPECIES.length()) {
1528             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1529             av.sub(b[i]).intoArray(r, i);
1530         }
1531 
1532         assertBroadcastArraysEquals(a, b, r, Short64VectorTests::sub);
1533     }
1534 
1535     @Test(dataProvider = "shortBinaryOpMaskProvider")
1536     static void subShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
1537                                           IntFunction<boolean[]> fm) {
1538         short[] a = fa.apply(SPECIES.length());
1539         short[] b = fb.apply(SPECIES.length());
1540         short[] r = fr.apply(SPECIES.length());
1541         boolean[] mask = fm.apply(SPECIES.length());
1542         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1543 
1544         for (int i = 0; i < a.length; i += SPECIES.length()) {
1545             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1546             av.sub(b[i], vmask).intoArray(r, i);
1547         }
1548 
1549         assertBroadcastArraysEquals(a, b, r, mask, Short64VectorTests::sub);
1550     }
1551 
1552     @Test(dataProvider = "shortBinaryOpProvider")
1553     static void mulShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1554         short[] a = fa.apply(SPECIES.length());
1555         short[] b = fb.apply(SPECIES.length());
1556         short[] r = fr.apply(SPECIES.length());
1557 
1558         for (int i = 0; i < a.length; i += SPECIES.length()) {
1559             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1560             av.mul(b[i]).intoArray(r, i);
1561         }
1562 
1563         assertBroadcastArraysEquals(a, b, r, Short64VectorTests::mul);
1564     }
1565 
1566     @Test(dataProvider = "shortBinaryOpMaskProvider")
1567     static void mulShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
1568                                           IntFunction<boolean[]> fm) {
1569         short[] a = fa.apply(SPECIES.length());
1570         short[] b = fb.apply(SPECIES.length());
1571         short[] r = fr.apply(SPECIES.length());
1572         boolean[] mask = fm.apply(SPECIES.length());
1573         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1574 
1575         for (int i = 0; i < a.length; i += SPECIES.length()) {
1576             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1577             av.mul(b[i], vmask).intoArray(r, i);
1578         }
1579 
1580         assertBroadcastArraysEquals(a, b, r, mask, Short64VectorTests::mul);
1581     }
1582 
1583 
1584 
1585 
1586     @Test(dataProvider = "shortBinaryOpProvider")
1587     static void divShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1588         short[] a = fa.apply(SPECIES.length());
1589         short[] b = fb.apply(SPECIES.length());
1590         short[] r = fr.apply(SPECIES.length());
1591 
1592         replaceZero(b, (short) 1);
1593 
1594         for (int i = 0; i < a.length; i += SPECIES.length()) {
1595             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1596             av.div(b[i]).intoArray(r, i);
1597         }
1598 
1599         assertBroadcastArraysEquals(a, b, r, Short64VectorTests::div);
1600     }
1601 
1602 
1603 
1604     @Test(dataProvider = "shortBinaryOpMaskProvider")
1605     static void divShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
1606                                           IntFunction<boolean[]> fm) {
1607         short[] a = fa.apply(SPECIES.length());
1608         short[] b = fb.apply(SPECIES.length());
1609         short[] r = fr.apply(SPECIES.length());
1610         boolean[] mask = fm.apply(SPECIES.length());
1611         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1612 
1613         replaceZero(b, (short) 1);
1614 
1615         for (int i = 0; i < a.length; i += SPECIES.length()) {
1616             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1617             av.div(b[i], vmask).intoArray(r, i);
1618         }
1619 
1620         assertBroadcastArraysEquals(a, b, r, mask, Short64VectorTests::div);
1621     }
1622 
1623 
1624 
1625     @Test(dataProvider = "shortBinaryOpProvider")
1626     static void ORShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1627         short[] a = fa.apply(SPECIES.length());
1628         short[] b = fb.apply(SPECIES.length());
1629         short[] r = fr.apply(SPECIES.length());
1630 
1631         for (int i = 0; i < a.length; i += SPECIES.length()) {
1632             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1633             av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i);
1634         }
1635 
1636         assertBroadcastArraysEquals(a, b, r, Short64VectorTests::OR);
1637     }
1638 
1639     @Test(dataProvider = "shortBinaryOpProvider")
1640     static void orShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1641         short[] a = fa.apply(SPECIES.length());
1642         short[] b = fb.apply(SPECIES.length());
1643         short[] r = fr.apply(SPECIES.length());
1644 
1645         for (int i = 0; i < a.length; i += SPECIES.length()) {
1646             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1647             av.or(b[i]).intoArray(r, i);
1648         }
1649 
1650         assertBroadcastArraysEquals(a, b, r, Short64VectorTests::or);
1651     }
1652 
1653 
1654 
1655     @Test(dataProvider = "shortBinaryOpMaskProvider")
1656     static void ORShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
1657                                           IntFunction<boolean[]> fm) {
1658         short[] a = fa.apply(SPECIES.length());
1659         short[] b = fb.apply(SPECIES.length());
1660         short[] r = fr.apply(SPECIES.length());
1661         boolean[] mask = fm.apply(SPECIES.length());
1662         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1663 
1664         for (int i = 0; i < a.length; i += SPECIES.length()) {
1665             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1666             av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i);
1667         }
1668 
1669         assertBroadcastArraysEquals(a, b, r, mask, Short64VectorTests::OR);
1670     }
1671 
1672 
1673 
1674 
1675 
1676 
1677     static short LSHL(short a, short b) {
1678         return (short)((a << (b & 0xF)));
1679     }
1680 
1681     @Test(dataProvider = "shortBinaryOpProvider")
1682     static void LSHLShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1683         short[] a = fa.apply(SPECIES.length());
1684         short[] b = fb.apply(SPECIES.length());
1685         short[] r = fr.apply(SPECIES.length());
1686 
1687         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1688             for (int i = 0; i < a.length; i += SPECIES.length()) {
1689                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1690                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1691                 av.lanewise(VectorOperators.LSHL, bv).intoArray(r, i);
1692             }


2015         return (short)(Math.max(a, b));
2016     }
2017 
2018     @Test(dataProvider = "shortBinaryOpProvider")
2019     static void maxShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2020         short[] a = fa.apply(SPECIES.length());
2021         short[] b = fb.apply(SPECIES.length());
2022         short[] r = fr.apply(SPECIES.length());
2023 
2024         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2025             for (int i = 0; i < a.length; i += SPECIES.length()) {
2026                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2027                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2028                 av.max(bv).intoArray(r, i);
2029             }
2030         }
2031 
2032         assertArraysEquals(a, b, r, Short64VectorTests::max);
2033     }
2034 
2035     @Test(dataProvider = "shortBinaryOpProvider")
2036     static void MINShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2037         short[] a = fa.apply(SPECIES.length());
2038         short[] b = fb.apply(SPECIES.length());
2039         short[] r = fr.apply(SPECIES.length());
2040 
2041         for (int i = 0; i < a.length; i += SPECIES.length()) {
2042             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2043             av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i);
2044         }
2045 
2046         assertBroadcastArraysEquals(a, b, r, Short64VectorTests::MIN);
2047     }
2048 
2049     @Test(dataProvider = "shortBinaryOpProvider")
2050     static void minShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2051         short[] a = fa.apply(SPECIES.length());
2052         short[] b = fb.apply(SPECIES.length());
2053         short[] r = fr.apply(SPECIES.length());
2054 
2055         for (int i = 0; i < a.length; i += SPECIES.length()) {
2056             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2057             av.min(b[i]).intoArray(r, i);
2058         }
2059 
2060         assertBroadcastArraysEquals(a, b, r, Short64VectorTests::min);
2061     }
2062 
2063     @Test(dataProvider = "shortBinaryOpProvider")
2064     static void MAXShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2065         short[] a = fa.apply(SPECIES.length());
2066         short[] b = fb.apply(SPECIES.length());
2067         short[] r = fr.apply(SPECIES.length());
2068 
2069         for (int i = 0; i < a.length; i += SPECIES.length()) {
2070             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2071             av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i);
2072         }
2073 
2074         assertBroadcastArraysEquals(a, b, r, Short64VectorTests::MAX);
2075     }
2076 
2077     @Test(dataProvider = "shortBinaryOpProvider")
2078     static void maxShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2079         short[] a = fa.apply(SPECIES.length());
2080         short[] b = fb.apply(SPECIES.length());
2081         short[] r = fr.apply(SPECIES.length());
2082 
2083         for (int i = 0; i < a.length; i += SPECIES.length()) {
2084             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2085             av.max(b[i]).intoArray(r, i);
2086         }
2087 
2088         assertBroadcastArraysEquals(a, b, r, Short64VectorTests::max);
2089     }
2090 
2091     static short AND(short[] a, int idx) {
2092         short res = -1;
2093         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2094             res &= a[i];
2095         }
2096 
2097         return res;
2098     }
2099 
2100     static short AND(short[] a) {
2101         short res = -1;
2102         for (int i = 0; i < a.length; i += SPECIES.length()) {
2103             short tmp = -1;
2104             for (int j = 0; j < SPECIES.length(); j++) {
2105                 tmp &= a[i + j];
2106             }
2107             res &= tmp;
2108         }
2109 
2110         return res;


3515         boolean[] mask = fm.apply(SPECIES.length());
3516         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3517 
3518         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3519             for (int i = 0; i < a.length; i += SPECIES.length()) {
3520                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3521                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3522                 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
3523                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i);
3524             }
3525         }
3526 
3527         assertArraysEquals(a, b, c, r, mask, Short64VectorTests::BITWISE_BLEND);
3528     }
3529 
3530 
3531     static short NEG(short a) {
3532         return (short)(-((short)a));
3533     }
3534 
3535     static short neg(short a) {
3536         return (short)(-((short)a));
3537     }
3538 
3539     @Test(dataProvider = "shortUnaryOpProvider")
3540     static void NEGShort64VectorTests(IntFunction<short[]> fa) {
3541         short[] a = fa.apply(SPECIES.length());
3542         short[] r = fr.apply(SPECIES.length());
3543 
3544         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3545             for (int i = 0; i < a.length; i += SPECIES.length()) {
3546                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3547                 av.lanewise(VectorOperators.NEG).intoArray(r, i);
3548             }
3549         }
3550 
3551         assertArraysEquals(a, r, Short64VectorTests::NEG);
3552     }
3553 
3554     @Test(dataProvider = "shortUnaryOpProvider")
3555     static void negShort64VectorTests(IntFunction<short[]> fa) {
3556         short[] a = fa.apply(SPECIES.length());
3557         short[] r = fr.apply(SPECIES.length());
3558 
3559         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3560             for (int i = 0; i < a.length; i += SPECIES.length()) {
3561                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3562                 av.neg().intoArray(r, i);
3563             }
3564         }
3565 
3566         assertArraysEquals(a, r, Short64VectorTests::neg);
3567     }
3568 
3569     @Test(dataProvider = "shortUnaryOpMaskProvider")
3570     static void NEGMaskedShort64VectorTests(IntFunction<short[]> fa,
3571                                                 IntFunction<boolean[]> fm) {
3572         short[] a = fa.apply(SPECIES.length());
3573         short[] r = fr.apply(SPECIES.length());
3574         boolean[] mask = fm.apply(SPECIES.length());
3575         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3576 
3577         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3578             for (int i = 0; i < a.length; i += SPECIES.length()) {
3579                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3580                 av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i);
3581             }
3582         }
3583 
3584         assertArraysEquals(a, r, mask, Short64VectorTests::NEG);
3585     }
3586 
3587     static short ABS(short a) {
3588         return (short)(Math.abs((short)a));


3628         short[] a = fa.apply(SPECIES.length());
3629         short[] r = fr.apply(SPECIES.length());
3630         boolean[] mask = fm.apply(SPECIES.length());
3631         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3632 
3633         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3634             for (int i = 0; i < a.length; i += SPECIES.length()) {
3635                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3636                 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
3637             }
3638         }
3639 
3640         assertArraysEquals(a, r, mask, Short64VectorTests::ABS);
3641     }
3642 
3643 
3644     static short NOT(short a) {
3645         return (short)(~((short)a));
3646     }
3647 
3648     static short not(short a) {
3649         return (short)(~((short)a));
3650     }
3651 
3652 
3653 
3654     @Test(dataProvider = "shortUnaryOpProvider")
3655     static void NOTShort64VectorTests(IntFunction<short[]> fa) {
3656         short[] a = fa.apply(SPECIES.length());
3657         short[] r = fr.apply(SPECIES.length());
3658 
3659         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3660             for (int i = 0; i < a.length; i += SPECIES.length()) {
3661                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3662                 av.lanewise(VectorOperators.NOT).intoArray(r, i);
3663             }
3664         }
3665 
3666         assertArraysEquals(a, r, Short64VectorTests::NOT);
3667     }
3668 
3669     @Test(dataProvider = "shortUnaryOpProvider")
3670     static void notShort64VectorTests(IntFunction<short[]> fa) {
3671         short[] a = fa.apply(SPECIES.length());
3672         short[] r = fr.apply(SPECIES.length());
3673 
3674         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3675             for (int i = 0; i < a.length; i += SPECIES.length()) {
3676                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3677                 av.not().intoArray(r, i);
3678             }
3679         }
3680 
3681         assertArraysEquals(a, r, Short64VectorTests::not);
3682     }
3683 
3684 
3685 
3686     @Test(dataProvider = "shortUnaryOpMaskProvider")
3687     static void NOTMaskedShort64VectorTests(IntFunction<short[]> fa,
3688                                                 IntFunction<boolean[]> fm) {
3689         short[] a = fa.apply(SPECIES.length());
3690         short[] r = fr.apply(SPECIES.length());
3691         boolean[] mask = fm.apply(SPECIES.length());
3692         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3693 
3694         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3695             for (int i = 0; i < a.length; i += SPECIES.length()) {
3696                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3697                 av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i);
3698             }
3699         }
3700 
3701         assertArraysEquals(a, r, mask, Short64VectorTests::NOT);


< prev index next >