1 2 @Test(dataProvider = "$type$CompareOpProvider") 3 static void lt$vectorteststype$BroadcastSmokeTest(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb) { 4 $type$[] a = fa.apply(SPECIES.length()); 5 $type$[] b = fb.apply(SPECIES.length()); 6 7 for (int i = 0; i < a.length; i += SPECIES.length()) { 8 $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); 9 VectorMask<$Wideboxtype$> mv = av.lt(b[i]); 10 11 // Check results as part of computation. 12 for (int j = 0; j < SPECIES.length(); j++) { 13 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); 14 } 15 } 16 } 17 18 @Test(dataProvider = "$type$CompareOpProvider") 19 static void eq$vectorteststype$BroadcastMaskedSmokeTest(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb) { 20 $type$[] a = fa.apply(SPECIES.length()); 21 $type$[] b = fb.apply(SPECIES.length()); 22 23 for (int i = 0; i < a.length; i += SPECIES.length()) { 24 $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); 25 VectorMask<$Wideboxtype$> mv = av.eq(b[i]); 26 27 // Check results as part of computation. 28 for (int j = 0; j < SPECIES.length(); j++) { 29 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); 30 } 31 } 32 } 33 34 #if[byteOrShort] 35 @Test(dataProvider = "$type$UnaryOpProvider") 36 #else[byteOrShort] 37 #if[Int] 38 @Test(dataProvider = "$type$UnaryOpProvider") 39 #else[Int] 40 @Test(dataProvider = "$type$toIntUnaryOpProvider") 41 #end[Int] 42 #end[byteOrShort] 43 static void toIntArray$vectorteststype$SmokeTest(IntFunction<$type$[]> fa) { 44 $type$[] a = fa.apply(SPECIES.length()); 45 46 for (int i = 0; i < a.length; i += SPECIES.length()) { 47 $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); 48 int[] r = av.toIntArray(); 49 assertArraysEquals(r, a, i); 50 } 51 } 52 53 #if[FP] 54 @Test(dataProvider = "$type$toLongUnaryOpProvider") 55 #else[FP] 56 @Test(dataProvider = "$type$UnaryOpProvider") 57 #end[FP] 58 static void toLongArray$vectorteststype$SmokeTest(IntFunction<$type$[]> fa) { 59 $type$[] a = fa.apply(SPECIES.length()); 60 61 for (int i = 0; i < a.length; i += SPECIES.length()) { 62 $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); 63 long[] r = av.toLongArray(); 64 assertArraysEquals(r, a, i); 65 } 66 } 67 68 #if[!Double] 69 @Test(dataProvider = "$type$UnaryOpProvider") 70 static void toDoubleArray$vectorteststype$SmokeTest(IntFunction<$type$[]> fa) { 71 $type$[] a = fa.apply(SPECIES.length()); 72 73 for (int i = 0; i < a.length; i += SPECIES.length()) { 74 $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); 75 double[] r = av.toDoubleArray(); 76 assertArraysEquals(r, a, i); 77 } 78 } 79 #end[!Double] 80 81 @Test(dataProvider = "$type$UnaryOpProvider") 82 static void toString$vectorteststype$SmokeTest(IntFunction<$type$[]> fa) { 83 $type$[] a = fa.apply(SPECIES.length()); 84 85 for (int i = 0; i < a.length; i += SPECIES.length()) { 86 $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); 87 String str = av.toString(); 88 89 $type$ subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); 90 Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str); 91 } 92 } 93 94 @Test(dataProvider = "$type$UnaryOpProvider") 95 static void hashCode$vectorteststype$SmokeTest(IntFunction<$type$[]> fa) { 96 $type$[] a = fa.apply(SPECIES.length()); 97 98 for (int i = 0; i < a.length; i += SPECIES.length()) { 99 $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); 100 int hash = av.hashCode(); 101 102 $type$ subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); 103 int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); 104 Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); 105 } 106 } 107 108 #if[byte] 109 @Test(dataProvider = "$type$UnaryOpProvider") 110 static void reinterpretAsBytes$vectorteststype$SmokeTest(IntFunction<$type$[]> fa) { 111 $type$[] a = fa.apply(SPECIES.length()); 112 $type$[] r = new $type$[a.length]; 113 114 for (int i = 0; i < a.length; i += SPECIES.length()) { 115 $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); 116 av.reinterpretAsBytes().intoArray(r, i); 117 } 118 assertArraysEquals(r, a, 0); 119 } 120 #end[byte] 121 122 #if[!Long] 123 static long ADDReduceLong($type$[] a, int idx) { 124 $type$ res = 0; 125 for (int i = idx; i < (idx + SPECIES.length()); i++) { 126 res += a[i]; 127 } 128 129 return (long)res; 130 } 131 132 static long ADDReduceAllLong($type$[] a) { 133 long res = 0; 134 for (int i = 0; i < a.length; i += SPECIES.length()) { 135 res += ADDReduceLong(a, i); 136 } 137 138 return res; 139 } 140 141 @Test(dataProvider = "$type$UnaryOpProvider") 142 static void ADDReduceLong$vectorteststype$(IntFunction<$type$[]> fa) { 143 $type$[] a = fa.apply(SPECIES.length()); 144 long[] r = lfr.apply(SPECIES.length()); 145 long ra = 0; 146 147 for (int i = 0; i < a.length; i += SPECIES.length()) { 148 $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); 149 r[i] = av.reduceLanesToLong(VectorOperators.ADD); 150 } 151 152 ra = 0; 153 for (int i = 0; i < a.length; i ++) { 154 ra += r[i]; 155 } 156 157 assertReductionLongArraysEquals(r, ra, a, 158 $vectorteststype$::ADDReduceLong, $vectorteststype$::ADDReduceAllLong); 159 } 160 161 static long ADDReduceLongMasked($type$[] a, int idx, boolean[] mask) { 162 $type$ res = 0; 163 for (int i = idx; i < (idx + SPECIES.length()); i++) { 164 if(mask[i % SPECIES.length()]) 165 res += a[i]; 166 } 167 168 return (long)res; 169 } 170 171 static long ADDReduceAllLongMasked($type$[] a, boolean[] mask) { 172 long res = 0; 173 for (int i = 0; i < a.length; i += SPECIES.length()) { 174 res += ADDReduceLongMasked(a, i, mask); 175 } 176 177 return res; 178 } 179 180 @Test(dataProvider = "$type$UnaryOpMaskProvider") 181 static void ADDReduceLong$vectorteststype$Masked(IntFunction<$type$[]> fa, IntFunction<boolean[]> fm) { 182 $type$[] a = fa.apply(SPECIES.length()); 183 long[] r = lfr.apply(SPECIES.length()); 184 boolean[] mask = fm.apply(SPECIES.length()); 185 VectorMask<$Wideboxtype$> vmask = VectorMask.fromArray(SPECIES, mask, 0); 186 long ra = 0; 187 188 for (int i = 0; i < a.length; i += SPECIES.length()) { 189 $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); 190 r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask); 191 } 192 193 ra = 0; 194 for (int i = 0; i < a.length; i ++) { 195 ra += r[i]; 196 } 197 198 assertReductionLongArraysEqualsMasked(r, ra, a, mask, 199 $vectorteststype$::ADDReduceLongMasked, $vectorteststype$::ADDReduceAllLongMasked); 200 } 201 202 #if[FP] 203 @Test(dataProvider = "$type$toLongUnaryOpProvider") 204 #else[FP] 205 @Test(dataProvider = "$type$UnaryOpProvider") 206 #end[FP] 207 static void BroadcastLong$vectorteststype$SmokeTest(IntFunction<$type$[]> fa) { 208 $type$[] a = fa.apply(SPECIES.length()); 209 $type$[] r = new $type$[a.length]; 210 211 for (int i = 0; i < a.length; i += SPECIES.length()) { 212 $abstractvectortype$.broadcast(SPECIES, (long)a[i]).intoArray(r, i); 213 } 214 assertBroadcastArraysEquals(r, a); 215 } 216 217 @Test(dataProvider = "$type$BinaryOpMaskProvider") 218 static void blend$vectorteststype$BroadcastLongSmokeTest(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb, 219 IntFunction<boolean[]> fm) { 220 $type$[] a = fa.apply(SPECIES.length()); 221 $type$[] b = fb.apply(SPECIES.length()); 222 $type$[] r = fr.apply(SPECIES.length()); 223 boolean[] mask = fm.apply(SPECIES.length()); 224 VectorMask<$Wideboxtype$> vmask = VectorMask.fromArray(SPECIES, mask, 0); 225 226 for (int ic = 0; ic < INVOC_COUNT; ic++) { 227 for (int i = 0; i < a.length; i += SPECIES.length()) { 228 $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); 229 av.blend((long)b[i], vmask).intoArray(r, i); 230 } 231 } 232 assertBroadcastLongArraysEquals(r, a, b, mask, $vectorteststype$::blend); 233 } 234 #end[!Long] 235 236 #if[Long] 237 @Test(dataProvider = "$type$UnaryOpProvider") 238 static void ADDReduceLong$vectorteststype$(IntFunction<$type$[]> fa) { 239 $type$[] a = fa.apply(SPECIES.length()); 240 $type$[] r = fr.apply(SPECIES.length()); 241 $type$ ra = 0; 242 243 for (int i = 0; i < a.length; i += SPECIES.length()) { 244 $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); 245 r[i] = av.reduceLanesToLong(VectorOperators.ADD); 246 } 247 248 ra = 0; 249 for (int i = 0; i < a.length; i ++) { 250 ra += r[i]; 251 } 252 253 assertReductionArraysEquals(r, ra, a, 254 $vectorteststype$::ADDReduce, $vectorteststype$::ADDReduceAll); 255 } 256 257 @Test(dataProvider = "$type$UnaryOpMaskProvider") 258 static void ADDReduceLong$vectorteststype$Masked(IntFunction<$type$[]> fa, IntFunction<boolean[]> fm) { 259 $type$[] a = fa.apply(SPECIES.length()); 260 $type$[] r = fr.apply(SPECIES.length()); 261 boolean[] mask = fm.apply(SPECIES.length()); 262 VectorMask<$Wideboxtype$> vmask = VectorMask.fromArray(SPECIES, mask, 0); 263 $type$ ra = 0; 264 265 for (int i = 0; i < a.length; i += SPECIES.length()) { 266 $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); 267 r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask); 268 } 269 270 ra = 0; 271 for (int i = 0; i < a.length; i ++) { 272 ra += r[i]; 273 } 274 275 assertReductionArraysEqualsMasked(r, ra, a, mask, 276 $vectorteststype$::ADDReduceMasked, $vectorteststype$::ADDReduceAllMasked); 277 } 278 #end[Long] 279 280 #if[Int] 281 @Test(dataProvider = "$type$UnaryOpShuffleProvider") 282 #else[Int] 283 @Test(dataProvider = "$type$UnaryOpSelectFromProvider") 284 #end[Int] 285 static void SelectFrom$vectorteststype$(IntFunction<$type$[]> fa, 286 BiFunction<Integer,Integer,$type$[]> fs) { 287 $type$[] a = fa.apply(SPECIES.length()); 288 $type$[] order = fs.apply(a.length, SPECIES.length()); 289 $type$[] r = fr.apply(SPECIES.length()); 290 291 for (int i = 0; i < a.length; i += SPECIES.length()) { 292 $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); 293 $abstractvectortype$ bv = $abstractvectortype$.fromArray(SPECIES, order, i); 294 bv.selectFrom(av).intoArray(r, i); 295 } 296 297 assertSelectFromArraysEquals(r, a, order, SPECIES.length()); 298 } 299 300 #if[Int] 301 @Test(dataProvider = "$type$UnaryOpShuffleMaskProvider") 302 #else[Int] 303 @Test(dataProvider = "$type$UnaryOpSelectFromMaskProvider") 304 #end[Int] 305 static void SelectFrom$vectorteststype$MaskedSmokeTest(IntFunction<$type$[]> fa, 306 BiFunction<Integer,Integer,$type$[]> fs, 307 IntFunction<boolean[]> fm) { 308 $type$[] a = fa.apply(SPECIES.length()); 309 $type$[] order = fs.apply(a.length, SPECIES.length()); 310 $type$[] r = fr.apply(SPECIES.length()); 311 boolean[] mask = fm.apply(SPECIES.length()); 312 VectorMask<$Wideboxtype$> vmask = VectorMask.fromArray(SPECIES, mask, 0); 313 314 for (int i = 0; i < a.length; i += SPECIES.length()) { 315 $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); 316 $abstractvectortype$ bv = $abstractvectortype$.fromArray(SPECIES, order, i); 317 bv.selectFrom(av, vmask).intoArray(r, i); 318 } 319 320 assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); 321 } 322 323 @Test(dataProvider = "shuffleProvider") 324 static void shuffleMiscellaneous$vectorteststype$SmokeTest(BiFunction<Integer,Integer,int[]> fs) { 325 int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); 326 327 for (int i = 0; i < a.length; i += SPECIES.length()) { 328 var shuffle = VectorShuffle.fromArray(SPECIES, a, i); 329 int hash = shuffle.hashCode(); 330 int length = shuffle.length(); 331 332 int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); 333 int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); 334 Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); 335 Assert.assertEquals(length, SPECIES.length()); 336 } 337 } 338 339 @Test(dataProvider = "shuffleProvider") 340 static void shuffleToString$vectorteststype$SmokeTest(BiFunction<Integer,Integer,int[]> fs) { 341 int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); 342 343 for (int i = 0; i < a.length; i += SPECIES.length()) { 344 var shuffle = VectorShuffle.fromArray(SPECIES, a, i); 345 String str = shuffle.toString(); 346 347 int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); 348 Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " + 349 i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str); 350 } 351 } 352 353 @Test(dataProvider = "shuffleCompareOpProvider") 354 static void shuffleEquals$vectorteststype$SmokeTest(BiFunction<Integer,Integer,int[]> fa, BiFunction<Integer,Integer,int[]> fb) { 355 int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); 356 int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); 357 358 for (int i = 0; i < a.length; i += SPECIES.length()) { 359 var av = VectorShuffle.fromArray(SPECIES, a, i); 360 var bv = VectorShuffle.fromArray(SPECIES, b, i); 361 boolean eq = av.equals(bv); 362 int to = i + SPECIES.length(); 363 Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to)); 364 } 365 } 366 367 @Test(dataProvider = "maskCompareOpProvider") 368 static void maskEquals$vectorteststype$SmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) { 369 boolean[] a = fa.apply(SPECIES.length()); 370 boolean[] b = fb.apply(SPECIES.length()); 371 372 for (int i = 0; i < a.length; i += SPECIES.length()) { 373 var av = SPECIES.loadMask(a, i); 374 var bv = SPECIES.loadMask(b, i); 375 boolean equals = av.equals(bv); 376 int to = i + SPECIES.length(); 377 Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to)); 378 } 379 } 380 381 static boolean beq(boolean a, boolean b) { 382 return (a == b); 383 } 384 385 @Test(dataProvider = "maskCompareOpProvider") 386 static void maskEq$vectorteststype$SmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) { 387 boolean[] a = fa.apply(SPECIES.length()); 388 boolean[] b = fb.apply(SPECIES.length()); 389 boolean[] r = new boolean[a.length]; 390 391 for (int i = 0; i < a.length; i += SPECIES.length()) { 392 var av = SPECIES.loadMask(a, i); 393 var bv = SPECIES.loadMask(b, i); 394 var cv = av.eq(bv); 395 cv.intoArray(r, i); 396 } 397 assertArraysEquals(r, a, b, $vectorteststype$::beq); 398 } 399 400 @Test(dataProvider = "maskProvider") 401 static void maskHashCode$vectorteststype$SmokeTest(IntFunction<boolean[]> fa) { 402 boolean[] a = fa.apply(SPECIES.length()); 403 404 for (int i = 0; i < a.length; i += SPECIES.length()) { 405 var vmask = SPECIES.loadMask(a, i); 406 int hash = vmask.hashCode(); 407 408 boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); 409 int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); 410 Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); 411 } 412 } 413 414 static int maskTrueCount(boolean[] a, int idx) { 415 int trueCount = 0; 416 for (int i = idx; i < idx + SPECIES.length(); i++) { 417 trueCount += a[i] ? 1 : 0; 418 } 419 return trueCount; 420 } 421 422 @Test(dataProvider = "maskProvider") 423 static void maskTrueCount$vectorteststype$SmokeTest(IntFunction<boolean[]> fa) { 424 boolean[] a = fa.apply(SPECIES.length()); 425 int[] r = new int[a.length]; 426 427 for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { 428 for (int i = 0; i < a.length; i += SPECIES.length()) { 429 var vmask = SPECIES.loadMask(a, i); 430 r[i] = vmask.trueCount(); 431 } 432 } 433 434 assertMaskReductionArraysEquals(r, a, $vectorteststype$::maskTrueCount); 435 } 436 437 static int maskLastTrue(boolean[] a, int idx) { 438 int i = idx + SPECIES.length() - 1; 439 for (; i >= idx; i--) { 440 if (a[i]) { 441 break; 442 } 443 } 444 return i - idx; 445 } 446 447 @Test(dataProvider = "maskProvider") 448 static void maskLastTrue$vectorteststype$SmokeTest(IntFunction<boolean[]> fa) { 449 boolean[] a = fa.apply(SPECIES.length()); 450 int[] r = new int[a.length]; 451 452 for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { 453 for (int i = 0; i < a.length; i += SPECIES.length()) { 454 var vmask = SPECIES.loadMask(a, i); 455 r[i] = vmask.lastTrue(); 456 } 457 } 458 459 assertMaskReductionArraysEquals(r, a, $vectorteststype$::maskLastTrue); 460 } 461 462 static int maskFirstTrue(boolean[] a, int idx) { 463 int i = idx; 464 for (; i < idx + SPECIES.length(); i++) { 465 if (a[i]) { 466 break; 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 524 public static Object[][] offsetProvider() { 525 return new Object[][]{ 526 {0}, 527 {-1}, 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)); 610 } 611 612 @Test 613 static void ElementType$vectorteststype$SmokeTest() { 614 $abstractvectortype$ av = $abstractvectortype$.zero(SPECIES); 615 assert(av.species().elementType() == $type$.class); 616 } 617 618 @Test 619 static void SpeciesElementSize$vectorteststype$SmokeTest() { 620 $abstractvectortype$ av = $abstractvectortype$.zero(SPECIES); 621 assert(av.species().elementSize() == $Wideboxtype$.SIZE); 622 } 623 624 @Test 625 static void VectorType$vectorteststype$SmokeTest() { 626 $abstractvectortype$ av = $abstractvectortype$.zero(SPECIES); 627 assert(av.species().vectorType() == av.getClass()); 628 } 629 630 @Test 631 static void WithLanes$vectorteststype$SmokeTest() { 632 $abstractvectortype$ av = $abstractvectortype$.zero(SPECIES); 633 VectorSpecies species = av.species().withLanes($type$.class); 634 assert(species.equals(SPECIES)); 635 } 636 637 @Test 638 static void WithShape$vectorteststype$SmokeTest() { 639 $abstractvectortype$ av = $abstractvectortype$.zero(SPECIES); 640 VectorShape vsh = av.shape(); 641 VectorSpecies species = av.species().withShape(vsh); 642 assert(species.equals(SPECIES)); 643 } 644 645 @Test 646 static void MaskAllTrue$vectorteststype$SmokeTest() { 647 for (int ic = 0; ic < INVOC_COUNT; ic++) { 648 Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); 649 } 650 }