< prev index next >

test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template

Print this page

467             }
468         }
469         return i - idx;
470     }
471 
472     @Test(dataProvider = "maskProvider")
473     static void maskFirstTrue$vectorteststype$SmokeTest(IntFunction<boolean[]> fa) {
474         boolean[] a = fa.apply(SPECIES.length());
475         int[] r = new int[a.length];
476 
477         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
478             for (int i = 0; i < a.length; i += SPECIES.length()) {
479                 var vmask = SPECIES.loadMask(a, i);
480                 r[i] = vmask.firstTrue();
481             }
482         }
483 
484         assertMaskReductionArraysEquals(r, a, $vectorteststype$::maskFirstTrue);
485     }
486 

















487 #if[!MaxBit]
488     @DataProvider
489     public static Object[][] longMaskProvider() {
490         return new Object[][]{
491                 {0xFFFFFFFFFFFFFFFFL},
492                 {0x0000000000000000L},
493                 {0x5555555555555555L},
494                 {0x0123456789abcdefL},
495         };
496     }
497 
498     @Test(dataProvider = "longMaskProvider")
499     static void maskFromToLong$vectorteststype$SmokeTest(long inputLong) {
500         var vmask = VectorMask.fromLong(SPECIES, inputLong);
501         long outputLong = vmask.toLong();
502         Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
503     }
504 #end[!MaxBit]
505 
506     @DataProvider

511                 {+1},
512                 {+2},
513                 {-2},
514         };
515     }
516 
517     @Test(dataProvider = "offsetProvider")
518     static void indexInRange$vectorteststype$SmokeTest(int offset) {
519         int limit = SPECIES.length() * BUFFER_REPS;
520         for (int i = 0; i < limit; i += SPECIES.length()) {
521             var actualMask = SPECIES.indexInRange(i + offset, limit);
522             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
523             assert(actualMask.equals(expectedMask));
524             for (int j = 0; j < SPECIES.length(); j++)  {
525                 int index = i + j + offset;
526                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
527             }
528         }
529     }
530 














531     @DataProvider
532     public static Object[][] lengthProvider() {
533         return new Object[][]{
534                 {0},
535                 {1},
536                 {32},
537                 {37},
538                 {1024},
539                 {1024+1},
540                 {1024+5},
541         };
542     }
543 
544     @Test(dataProvider = "lengthProvider")
545     static void loopBound$vectorteststype$SmokeTest(int length) {
546         int actualLoopBound = SPECIES.loopBound(length);
547         int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
548         Assert.assertEquals(actualLoopBound, expectedLoopBound);
549     }
550 








551     @Test
552     static void ElementSize$vectorteststype$SmokeTest() {
553         $abstractvectortype$ av = $abstractvectortype$.zero(SPECIES);
554         int elsize = av.elementSize();
555         Assert.assertEquals(elsize, $Wideboxtype$.SIZE);
556     }
557 
558     @Test
559     static void VectorShape$vectorteststype$SmokeTest() {
560         $abstractvectortype$ av = $abstractvectortype$.zero(SPECIES);
561         VectorShape vsh = av.shape();
562         assert(vsh.equals(VectorShape.$Shape$));
563     }
564 
565     @Test
566     static void ShapeWithLanes$vectorteststype$SmokeTest() {
567         $abstractvectortype$ av = $abstractvectortype$.zero(SPECIES);
568         VectorShape vsh = av.shape();
569         VectorSpecies species = vsh.withLanes($type$.class);
570         assert(species.equals(SPECIES));

467             }
468         }
469         return i - idx;
470     }
471 
472     @Test(dataProvider = "maskProvider")
473     static void maskFirstTrue$vectorteststype$SmokeTest(IntFunction<boolean[]> fa) {
474         boolean[] a = fa.apply(SPECIES.length());
475         int[] r = new int[a.length];
476 
477         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
478             for (int i = 0; i < a.length; i += SPECIES.length()) {
479                 var vmask = SPECIES.loadMask(a, i);
480                 r[i] = vmask.firstTrue();
481             }
482         }
483 
484         assertMaskReductionArraysEquals(r, a, $vectorteststype$::maskFirstTrue);
485     }
486 
487     @Test(dataProvider = "maskProvider")
488     static void maskCompress$vectorteststype$SmokeTest(IntFunction<boolean[]> fa) {
489         int trueCount = 0;
490         boolean[] a = fa.apply(SPECIES.length());
491 
492         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
493             for (int i = 0; i < a.length; i += SPECIES.length()) {
494                 var vmask = SPECIES.loadMask(a, i);
495                 trueCount = vmask.trueCount();
496                 var rmask = vmask.compress();
497                 for (int j = 0; j < SPECIES.length(); j++)  {
498                     Assert.assertEquals(rmask.laneIsSet(j), j < trueCount);
499                 }
500             }
501         }
502     }
503 
504 #if[!MaxBit]
505     @DataProvider
506     public static Object[][] longMaskProvider() {
507         return new Object[][]{
508                 {0xFFFFFFFFFFFFFFFFL},
509                 {0x0000000000000000L},
510                 {0x5555555555555555L},
511                 {0x0123456789abcdefL},
512         };
513     }
514 
515     @Test(dataProvider = "longMaskProvider")
516     static void maskFromToLong$vectorteststype$SmokeTest(long inputLong) {
517         var vmask = VectorMask.fromLong(SPECIES, inputLong);
518         long outputLong = vmask.toLong();
519         Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
520     }
521 #end[!MaxBit]
522 
523     @DataProvider

528                 {+1},
529                 {+2},
530                 {-2},
531         };
532     }
533 
534     @Test(dataProvider = "offsetProvider")
535     static void indexInRange$vectorteststype$SmokeTest(int offset) {
536         int limit = SPECIES.length() * BUFFER_REPS;
537         for (int i = 0; i < limit; i += SPECIES.length()) {
538             var actualMask = SPECIES.indexInRange(i + offset, limit);
539             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
540             assert(actualMask.equals(expectedMask));
541             for (int j = 0; j < SPECIES.length(); j++)  {
542                 int index = i + j + offset;
543                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
544             }
545         }
546     }
547 
548     @Test(dataProvider = "offsetProvider")
549     static void indexInRangeLong$vectorteststype$SmokeTest(int offset) {
550         long limit = SPECIES.length() * BUFFER_REPS;
551         for (long i = 0; i < limit; i += SPECIES.length()) {
552             var actualMask = SPECIES.indexInRange(i + offset, limit);
553             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
554             assert(actualMask.equals(expectedMask));
555             for (int j = 0; j < SPECIES.length(); j++)  {
556                 long index = i + j + offset;
557                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
558             }
559         }
560     }
561 
562     @DataProvider
563     public static Object[][] lengthProvider() {
564         return new Object[][]{
565                 {0},
566                 {1},
567                 {32},
568                 {37},
569                 {1024},
570                 {1024+1},
571                 {1024+5},
572         };
573     }
574 
575     @Test(dataProvider = "lengthProvider")
576     static void loopBound$vectorteststype$SmokeTest(int length) {
577         int actualLoopBound = SPECIES.loopBound(length);
578         int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
579         Assert.assertEquals(actualLoopBound, expectedLoopBound);
580     }
581 
582     @Test(dataProvider = "lengthProvider")
583     static void loopBoundLong$vectorteststype$SmokeTest(int _length) {
584         long length = _length;
585         long actualLoopBound = SPECIES.loopBound(length);
586         long expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
587         Assert.assertEquals(actualLoopBound, expectedLoopBound);
588     }
589 
590     @Test
591     static void ElementSize$vectorteststype$SmokeTest() {
592         $abstractvectortype$ av = $abstractvectortype$.zero(SPECIES);
593         int elsize = av.elementSize();
594         Assert.assertEquals(elsize, $Wideboxtype$.SIZE);
595     }
596 
597     @Test
598     static void VectorShape$vectorteststype$SmokeTest() {
599         $abstractvectortype$ av = $abstractvectortype$.zero(SPECIES);
600         VectorShape vsh = av.shape();
601         assert(vsh.equals(VectorShape.$Shape$));
602     }
603 
604     @Test
605     static void ShapeWithLanes$vectorteststype$SmokeTest() {
606         $abstractvectortype$ av = $abstractvectortype$.zero(SPECIES);
607         VectorShape vsh = av.shape();
608         VectorSpecies species = vsh.withLanes($type$.class);
609         assert(species.equals(SPECIES));
< prev index next >