1 /* 2 * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @modules jdk.incubator.vector 27 * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation ShortMaxVectorTests 28 */ 29 30 // -- This file was mechanically generated: Do not edit! -- // 31 32 import jdk.incubator.vector.VectorShape; 33 import jdk.incubator.vector.VectorSpecies; 34 import jdk.incubator.vector.VectorShuffle; 35 import jdk.incubator.vector.VectorMask; 36 import jdk.incubator.vector.VectorOperators; 37 import jdk.incubator.vector.Vector; 38 39 import jdk.incubator.vector.ShortVector; 40 41 import org.testng.Assert; 42 import org.testng.annotations.DataProvider; 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 ShortMaxVectorTests extends AbstractVectorTest { 56 57 static final VectorSpecies<Short> SPECIES = 58 ShortVector.SPECIES_MAX; 59 60 static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); 61 62 static VectorShape getMaxBit() { 63 return VectorShape.S_Max_BIT; 64 } 65 66 private static final int Max = 256; // juts so we can do N/Max 67 68 private static final short CONST_SHIFT = Short.SIZE / 2; 69 70 static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max); 71 72 interface FUnOp { 73 short apply(short a); 74 } 75 76 static void assertArraysEquals(short[] r, short[] a, FUnOp f) { 77 int i = 0; 78 try { 79 for (; i < a.length; i++) { 80 Assert.assertEquals(r[i], f.apply(a[i])); 81 } 82 } catch (AssertionError e) { 83 Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); 84 } 85 } 86 87 interface FUnArrayOp { 88 short[] apply(short a); 89 } 90 91 static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { 92 int i = 0; 93 try { 94 for (; i < a.length; i += SPECIES.length()) { 95 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), 96 f.apply(a[i])); 97 } 98 } catch (AssertionError e) { 99 short[] ref = f.apply(a[i]); 100 short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); 101 Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) 102 + ", res: " + Arrays.toString(res) 103 + "), at index #" + i); 104 } 105 } 106 107 static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { 108 int i = 0; 109 try { 110 for (; i < a.length; i++) { 111 Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); 112 } 113 } catch (AssertionError e) { 114 Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); 115 } 116 } 117 118 interface FReductionOp { 119 short apply(short[] a, int idx); 120 } 121 122 interface FReductionAllOp { 123 short apply(short[] a); 124 } 125 126 static void assertReductionArraysEquals(short[] r, short rc, short[] a, 127 FReductionOp f, FReductionAllOp fa) { 128 int i = 0; 129 try { 130 Assert.assertEquals(rc, fa.apply(a)); 131 for (; i < a.length; i += SPECIES.length()) { 132 Assert.assertEquals(r[i], f.apply(a, i)); 133 } 134 } catch (AssertionError e) { 135 Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); 136 Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); 137 } 138 } 139 140 interface FReductionMaskedOp { 141 short apply(short[] a, int idx, boolean[] mask); 142 } 143 144 interface FReductionAllMaskedOp { 145 short apply(short[] a, boolean[] mask); 146 } 147 148 static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, boolean[] mask, 149 FReductionMaskedOp f, FReductionAllMaskedOp fa) { 150 int i = 0; 151 try { 152 Assert.assertEquals(rc, fa.apply(a, mask)); 153 for (; i < a.length; i += SPECIES.length()) { 154 Assert.assertEquals(r[i], f.apply(a, i, mask)); 155 } 156 } catch (AssertionError e) { 157 Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); 158 Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); 159 } 160 } 161 162 interface FReductionOpLong { 163 long apply(short[] a, int idx); 164 } 165 166 interface FReductionAllOpLong { 167 long apply(short[] a); 168 } 169 170 static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, 171 FReductionOpLong f, FReductionAllOpLong fa) { 172 int i = 0; 173 try { 174 Assert.assertEquals(rc, fa.apply(a)); 175 for (; i < a.length; i += SPECIES.length()) { 176 Assert.assertEquals(r[i], f.apply(a, i)); 177 } 178 } catch (AssertionError e) { 179 Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); 180 Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); 181 } 182 } 183 184 interface FReductionMaskedOpLong { 185 long apply(short[] a, int idx, boolean[] mask); 186 } 187 188 interface FReductionAllMaskedOpLong { 189 long apply(short[] a, boolean[] mask); 190 } 191 192 static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, boolean[] mask, 193 FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { 194 int i = 0; 195 try { 196 Assert.assertEquals(rc, fa.apply(a, mask)); 197 for (; i < a.length; i += SPECIES.length()) { 198 Assert.assertEquals(r[i], f.apply(a, i, mask)); 199 } 200 } catch (AssertionError e) { 201 Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); 202 Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); 203 } 204 } 205 206 interface FBoolReductionOp { 207 boolean apply(boolean[] a, int idx); 208 } 209 210 static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { 211 int i = 0; 212 try { 213 for (; i < a.length; i += SPECIES.length()) { 214 Assert.assertEquals(r[i], f.apply(a, i)); 215 } 216 } catch (AssertionError e) { 217 Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); 218 } 219 } 220 221 interface FMaskReductionOp { 222 int apply(boolean[] a, int idx); 223 } 224 225 static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReductionOp f) { 226 int i = 0; 227 try { 228 for (; i < a.length; i += SPECIES.length()) { 229 Assert.assertEquals(r[i], f.apply(a, i)); 230 } 231 } catch (AssertionError e) { 232 Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); 233 } 234 } 235 236 static void assertInsertArraysEquals(short[] r, short[] a, short element, int index, int start, int end) { 237 int i = start; 238 try { 239 for (; i < end; i += 1) { 240 if(i%SPECIES.length() == index) { 241 Assert.assertEquals(r[i], element); 242 } else { 243 Assert.assertEquals(r[i], a[i]); 244 } 245 } 246 } catch (AssertionError e) { 247 if (i%SPECIES.length() == index) { 248 Assert.assertEquals(r[i], element, "at index #" + i); 249 } else { 250 Assert.assertEquals(r[i], a[i], "at index #" + i); 251 } 252 } 253 } 254 255 static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) { 256 int i = 0, j = 0; 257 try { 258 for (; i < a.length; i += vector_len) { 259 for (j = 0; j < vector_len; j++) { 260 Assert.assertEquals(r[i+j], a[i+order[i+j]]); 261 } 262 } 263 } catch (AssertionError e) { 264 int idx = i + j; 265 Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); 266 } 267 } 268 269 static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) { 270 int i = 0, j = 0; 271 try { 272 for (; i < a.length; i += vector_len) { 273 for (j = 0; j < vector_len; j++) { 274 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); 275 } 276 } 277 } catch (AssertionError e) { 278 int idx = i + j; 279 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); 280 } 281 } 282 283 static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boolean[] mask, int vector_len) { 284 int i = 0, j = 0; 285 try { 286 for (; i < a.length; i += vector_len) { 287 for (j = 0; j < vector_len; j++) { 288 if (mask[j % SPECIES.length()]) 289 Assert.assertEquals(r[i+j], a[i+order[i+j]]); 290 else 291 Assert.assertEquals(r[i+j], (short)0); 292 } 293 } 294 } catch (AssertionError e) { 295 int idx = i + j; 296 if (mask[j % SPECIES.length()]) 297 Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); 298 else 299 Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); 300 } 301 } 302 303 static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, boolean[] mask, int vector_len) { 304 int i = 0, j = 0; 305 try { 306 for (; i < a.length; i += vector_len) { 307 for (j = 0; j < vector_len; j++) { 308 if (mask[j % SPECIES.length()]) 309 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); 310 else 311 Assert.assertEquals(r[i+j], (short)0); 312 } 313 } 314 } catch (AssertionError e) { 315 int idx = i + j; 316 if (mask[j % SPECIES.length()]) 317 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); 318 else 319 Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); 320 } 321 } 322 323 static void assertBroadcastArraysEquals(short[] r, short[] a) { 324 int i = 0; 325 for (; i < a.length; i += SPECIES.length()) { 326 int idx = i; 327 for (int j = idx; j < (idx + SPECIES.length()); j++) 328 a[j]=a[idx]; 329 } 330 331 try { 332 for (i = 0; i < a.length; i++) { 333 Assert.assertEquals(r[i], a[i]); 334 } 335 } catch (AssertionError e) { 336 Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); 337 } 338 } 339 340 interface FBinOp { 341 short apply(short a, short b); 342 } 343 344 interface FBinMaskOp { 345 short apply(short a, short b, boolean m); 346 347 static FBinMaskOp lift(FBinOp f) { 348 return (a, b, m) -> m ? f.apply(a, b) : a; 349 } 350 } 351 352 static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { 353 int i = 0; 354 try { 355 for (; i < a.length; i++) { 356 Assert.assertEquals(r[i], f.apply(a[i], b[i])); 357 } 358 } catch (AssertionError e) { 359 Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); 360 } 361 } 362 363 static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { 364 int i = 0; 365 try { 366 for (; i < a.length; i++) { 367 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); 368 } 369 } catch (AssertionError e) { 370 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), 371 "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); 372 } 373 } 374 375 static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { 376 int i = 0; 377 try { 378 for (; i < a.length; i++) { 379 Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); 380 } 381 } catch (AssertionError e) { 382 Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), 383 "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); 384 } 385 } 386 387 static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { 388 assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); 389 } 390 391 static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { 392 int i = 0; 393 try { 394 for (; i < a.length; i++) { 395 Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); 396 } 397 } catch (AssertionError err) { 398 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()]); 399 } 400 } 401 402 static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { 403 assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); 404 } 405 406 static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { 407 int i = 0; 408 try { 409 for (; i < a.length; i++) { 410 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); 411 } 412 } catch (AssertionError err) { 413 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], 414 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + 415 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + 416 mask[i % SPECIES.length()]); 417 } 418 } 419 420 static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { 421 assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); 422 } 423 424 static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { 425 int i = 0; 426 try { 427 for (; i < a.length; i++) { 428 Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); 429 } 430 } catch (AssertionError err) { 431 Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), 432 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + 433 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + 434 mask[i % SPECIES.length()]); 435 } 436 } 437 438 static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { 439 int i = 0; 440 int j = 0; 441 try { 442 for (; j < a.length; j += SPECIES.length()) { 443 for (i = 0; i < SPECIES.length(); i++) { 444 Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); 445 } 446 } 447 } catch (AssertionError e) { 448 Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); 449 } 450 } 451 452 static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { 453 assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); 454 } 455 456 static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { 457 int i = 0; 458 int j = 0; 459 try { 460 for (; j < a.length; j += SPECIES.length()) { 461 for (i = 0; i < SPECIES.length(); i++) { 462 Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); 463 } 464 } 465 } catch (AssertionError err) { 466 Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); 467 } 468 } 469 470 interface FBinConstOp { 471 short apply(short a); 472 } 473 474 interface FBinConstMaskOp { 475 short apply(short a, boolean m); 476 477 static FBinConstMaskOp lift(FBinConstOp f) { 478 return (a, m) -> m ? f.apply(a) : a; 479 } 480 } 481 482 static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) { 483 int i = 0; 484 int j = 0; 485 try { 486 for (; j < a.length; j += SPECIES.length()) { 487 for (i = 0; i < SPECIES.length(); i++) { 488 Assert.assertEquals(r[i+j], f.apply(a[i+j])); 489 } 490 } 491 } catch (AssertionError e) { 492 Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); 493 } 494 } 495 496 static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstOp f) { 497 assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f)); 498 } 499 500 static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstMaskOp f) { 501 int i = 0; 502 int j = 0; 503 try { 504 for (; j < a.length; j += SPECIES.length()) { 505 for (i = 0; i < SPECIES.length(); i++) { 506 Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); 507 } 508 } 509 } catch (AssertionError err) { 510 Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); 511 } 512 } 513 514 interface FTernOp { 515 short apply(short a, short b, short c); 516 } 517 518 interface FTernMaskOp { 519 short apply(short a, short b, short c, boolean m); 520 521 static FTernMaskOp lift(FTernOp f) { 522 return (a, b, c, m) -> m ? f.apply(a, b, c) : a; 523 } 524 } 525 526 static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { 527 int i = 0; 528 try { 529 for (; i < a.length; i++) { 530 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); 531 } 532 } catch (AssertionError e) { 533 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); 534 } 535 } 536 537 static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { 538 assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); 539 } 540 541 static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { 542 int i = 0; 543 try { 544 for (; i < a.length; i++) { 545 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); 546 } 547 } catch (AssertionError err) { 548 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " 549 + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); 550 } 551 } 552 553 static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { 554 int i = 0; 555 try { 556 for (; i < a.length; i++) { 557 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); 558 } 559 } catch (AssertionError e) { 560 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + 561 i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + 562 c[(i / SPECIES.length()) * SPECIES.length()]); 563 } 564 } 565 566 static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { 567 int i = 0; 568 try { 569 for (; i < a.length; i++) { 570 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); 571 } 572 } catch (AssertionError e) { 573 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + 574 i + ", input1 = " + a[i] + ", input2 = " + 575 b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); 576 } 577 } 578 579 static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, 580 FTernOp f) { 581 assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); 582 } 583 584 static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, 585 FTernMaskOp f) { 586 int i = 0; 587 try { 588 for (; i < a.length; i++) { 589 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], 590 mask[i % SPECIES.length()])); 591 } 592 } catch (AssertionError err) { 593 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], 594 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + 595 b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + 596 mask[i % SPECIES.length()]); 597 } 598 } 599 600 static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, 601 FTernOp f) { 602 assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); 603 } 604 605 static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, 606 FTernMaskOp f) { 607 int i = 0; 608 try { 609 for (; i < a.length; i++) { 610 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], 611 mask[i % SPECIES.length()])); 612 } 613 } catch (AssertionError err) { 614 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], 615 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + 616 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + 617 ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); 618 } 619 } 620 621 static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { 622 int i = 0; 623 try { 624 for (; i < a.length; i++) { 625 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], 626 c[(i / SPECIES.length()) * SPECIES.length()])); 627 } 628 } catch (AssertionError e) { 629 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], 630 c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] 631 + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + 632 c[(i / SPECIES.length()) * SPECIES.length()]); 633 } 634 } 635 636 static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, 637 FTernOp f) { 638 assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); 639 } 640 641 static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, 642 FTernMaskOp f) { 643 int i = 0; 644 try { 645 for (; i < a.length; i++) { 646 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], 647 c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); 648 } 649 } catch (AssertionError err) { 650 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], 651 c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" 652 + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + 653 ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + 654 mask[i % SPECIES.length()]); 655 } 656 } 657 658 659 660 interface FBinArrayOp { 661 short apply(short[] a, int b); 662 } 663 664 static void assertArraysEquals(short[] r, short[] a, FBinArrayOp f) { 665 int i = 0; 666 try { 667 for (; i < a.length; i++) { 668 Assert.assertEquals(r[i], f.apply(a, i)); 669 } 670 } catch (AssertionError e) { 671 Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); 672 } 673 } 674 675 interface FGatherScatterOp { 676 short[] apply(short[] a, int ix, int[] b, int iy); 677 } 678 679 static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f) { 680 int i = 0; 681 try { 682 for (; i < a.length; i += SPECIES.length()) { 683 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), 684 f.apply(a, i, b, i)); 685 } 686 } catch (AssertionError e) { 687 short[] ref = f.apply(a, i, b, i); 688 short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); 689 Assert.assertEquals(res, ref, 690 "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " 691 + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) 692 + ", b: " 693 + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) 694 + " at index #" + i); 695 } 696 } 697 698 interface FGatherMaskedOp { 699 short[] apply(short[] a, int ix, boolean[] mask, int[] b, int iy); 700 } 701 702 interface FScatterMaskedOp { 703 short[] apply(short[] r, short[] a, int ix, boolean[] mask, int[] b, int iy); 704 } 705 706 static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { 707 int i = 0; 708 try { 709 for (; i < a.length; i += SPECIES.length()) { 710 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), 711 f.apply(a, i, mask, b, i)); 712 } 713 } catch (AssertionError e) { 714 short[] ref = f.apply(a, i, mask, b, i); 715 short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); 716 Assert.assertEquals(res, ref, 717 "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " 718 + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) 719 + ", b: " 720 + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) 721 + ", mask: " 722 + Arrays.toString(mask) 723 + " at index #" + i); 724 } 725 } 726 727 static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { 728 int i = 0; 729 try { 730 for (; i < a.length; i += SPECIES.length()) { 731 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), 732 f.apply(r, a, i, mask, b, i)); 733 } 734 } catch (AssertionError e) { 735 short[] ref = f.apply(r, a, i, mask, b, i); 736 short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); 737 Assert.assertEquals(res, ref, 738 "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " 739 + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) 740 + ", b: " 741 + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) 742 + ", r: " 743 + Arrays.toString(Arrays.copyOfRange(r, i, i+SPECIES.length())) 744 + ", mask: " 745 + Arrays.toString(mask) 746 + " at index #" + i); 747 } 748 } 749 750 interface FLaneOp { 751 short[] apply(short[] a, int origin, int idx); 752 } 753 754 static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { 755 int i = 0; 756 try { 757 for (; i < a.length; i += SPECIES.length()) { 758 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), 759 f.apply(a, origin, i)); 760 } 761 } catch (AssertionError e) { 762 short[] ref = f.apply(a, origin, i); 763 short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); 764 Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) 765 + ", res: " + Arrays.toString(res) 766 + "), at index #" + i); 767 } 768 } 769 770 interface FLaneBop { 771 short[] apply(short[] a, short[] b, int origin, int idx); 772 } 773 774 static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLaneBop f) { 775 int i = 0; 776 try { 777 for (; i < a.length; i += SPECIES.length()) { 778 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), 779 f.apply(a, b, origin, i)); 780 } 781 } catch (AssertionError e) { 782 short[] ref = f.apply(a, b, origin, i); 783 short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); 784 Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) 785 + ", res: " + Arrays.toString(res) 786 + "), at index #" + i 787 + ", at origin #" + origin); 788 } 789 } 790 791 interface FLaneMaskedBop { 792 short[] apply(short[] a, short[] b, int origin, boolean[] mask, int idx); 793 } 794 795 static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, boolean[] mask, FLaneMaskedBop f) { 796 int i = 0; 797 try { 798 for (; i < a.length; i += SPECIES.length()) { 799 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), 800 f.apply(a, b, origin, mask, i)); 801 } 802 } catch (AssertionError e) { 803 short[] ref = f.apply(a, b, origin, mask, i); 804 short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); 805 Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) 806 + ", res: " + Arrays.toString(res) 807 + "), at index #" + i 808 + ", at origin #" + origin); 809 } 810 } 811 812 interface FLanePartBop { 813 short[] apply(short[] a, short[] b, int origin, int part, int idx); 814 } 815 816 static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, FLanePartBop f) { 817 int i = 0; 818 try { 819 for (; i < a.length; i += SPECIES.length()) { 820 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), 821 f.apply(a, b, origin, part, i)); 822 } 823 } catch (AssertionError e) { 824 short[] ref = f.apply(a, b, origin, part, i); 825 short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); 826 Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) 827 + ", res: " + Arrays.toString(res) 828 + "), at index #" + i 829 + ", at origin #" + origin 830 + ", with part #" + part); 831 } 832 } 833 834 interface FLanePartMaskedBop { 835 short[] apply(short[] a, short[] b, int origin, int part, boolean[] mask, int idx); 836 } 837 838 static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { 839 int i = 0; 840 try { 841 for (; i < a.length; i += SPECIES.length()) { 842 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), 843 f.apply(a, b, origin, part, mask, i)); 844 } 845 } catch (AssertionError e) { 846 short[] ref = f.apply(a, b, origin, part, mask, i); 847 short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); 848 Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) 849 + ", res: " + Arrays.toString(res) 850 + "), at index #" + i 851 + ", at origin #" + origin 852 + ", with part #" + part); 853 } 854 } 855 856 857 static void assertArraysEquals(int[] r, short[] a, int offs) { 858 int i = 0; 859 try { 860 for (; i < r.length; i++) { 861 Assert.assertEquals(r[i], (int)(a[i+offs])); 862 } 863 } catch (AssertionError e) { 864 Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); 865 } 866 } 867 868 869 870 static void assertArraysEquals(long[] r, short[] a, int offs) { 871 int i = 0; 872 try { 873 for (; i < r.length; i++) { 874 Assert.assertEquals(r[i], (long)(a[i+offs])); 875 } 876 } catch (AssertionError e) { 877 Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); 878 } 879 } 880 881 static void assertArraysEquals(double[] r, short[] a, int offs) { 882 int i = 0; 883 try { 884 for (; i < r.length; i++) { 885 Assert.assertEquals(r[i], (double)(a[i+offs])); 886 } 887 } catch (AssertionError e) { 888 Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); 889 } 890 } 891 892 893 static short bits(short e) { 894 return e; 895 } 896 897 static final List<IntFunction<short[]>> SHORT_GENERATORS = List.of( 898 withToString("short[-i * 5]", (int s) -> { 899 return fill(s * BUFFER_REPS, 900 i -> (short)(-i * 5)); 901 }), 902 withToString("short[i * 5]", (int s) -> { 903 return fill(s * BUFFER_REPS, 904 i -> (short)(i * 5)); 905 }), 906 withToString("short[i + 1]", (int s) -> { 907 return fill(s * BUFFER_REPS, 908 i -> (((short)(i + 1) == 0) ? 1 : (short)(i + 1))); 909 }), 910 withToString("short[cornerCaseValue(i)]", (int s) -> { 911 return fill(s * BUFFER_REPS, 912 i -> cornerCaseValue(i)); 913 }) 914 ); 915 916 // Create combinations of pairs 917 // @@@ Might be sensitive to order e.g. div by 0 918 static final List<List<IntFunction<short[]>>> SHORT_GENERATOR_PAIRS = 919 Stream.of(SHORT_GENERATORS.get(0)). 920 flatMap(fa -> SHORT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). 921 collect(Collectors.toList()); 922 923 @DataProvider 924 public Object[][] boolUnaryOpProvider() { 925 return BOOL_ARRAY_GENERATORS.stream(). 926 map(f -> new Object[]{f}). 927 toArray(Object[][]::new); 928 } 929 930 static final List<List<IntFunction<short[]>>> SHORT_GENERATOR_TRIPLES = 931 SHORT_GENERATOR_PAIRS.stream(). 932 flatMap(pair -> SHORT_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))). 933 collect(Collectors.toList()); 934 935 @DataProvider 936 public Object[][] shortBinaryOpProvider() { 937 return SHORT_GENERATOR_PAIRS.stream().map(List::toArray). 938 toArray(Object[][]::new); 939 } 940 941 @DataProvider 942 public Object[][] shortIndexedOpProvider() { 943 return SHORT_GENERATOR_PAIRS.stream().map(List::toArray). 944 toArray(Object[][]::new); 945 } 946 947 @DataProvider 948 public Object[][] shortBinaryOpMaskProvider() { 949 return BOOLEAN_MASK_GENERATORS.stream(). 950 flatMap(fm -> SHORT_GENERATOR_PAIRS.stream().map(lfa -> { 951 return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); 952 })). 953 toArray(Object[][]::new); 954 } 955 956 @DataProvider 957 public Object[][] shortTernaryOpProvider() { 958 return SHORT_GENERATOR_TRIPLES.stream().map(List::toArray). 959 toArray(Object[][]::new); 960 } 961 962 @DataProvider 963 public Object[][] shortTernaryOpMaskProvider() { 964 return BOOLEAN_MASK_GENERATORS.stream(). 965 flatMap(fm -> SHORT_GENERATOR_TRIPLES.stream().map(lfa -> { 966 return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); 967 })). 968 toArray(Object[][]::new); 969 } 970 971 @DataProvider 972 public Object[][] shortUnaryOpProvider() { 973 return SHORT_GENERATORS.stream(). 974 map(f -> new Object[]{f}). 975 toArray(Object[][]::new); 976 } 977 978 @DataProvider 979 public Object[][] shortUnaryOpMaskProvider() { 980 return BOOLEAN_MASK_GENERATORS.stream(). 981 flatMap(fm -> SHORT_GENERATORS.stream().map(fa -> { 982 return new Object[] {fa, fm}; 983 })). 984 toArray(Object[][]::new); 985 } 986 987 988 989 @DataProvider 990 public Object[][] maskProvider() { 991 return BOOLEAN_MASK_GENERATORS.stream(). 992 map(f -> new Object[]{f}). 993 toArray(Object[][]::new); 994 } 995 996 @DataProvider 997 public Object[][] maskCompareOpProvider() { 998 return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). 999 toArray(Object[][]::new); 1000 } 1001 1002 @DataProvider 1003 public Object[][] shuffleProvider() { 1004 return INT_SHUFFLE_GENERATORS.stream(). 1005 map(f -> new Object[]{f}). 1006 toArray(Object[][]::new); 1007 } 1008 1009 @DataProvider 1010 public Object[][] shuffleCompareOpProvider() { 1011 return INT_SHUFFLE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). 1012 toArray(Object[][]::new); 1013 } 1014 1015 @DataProvider 1016 public Object[][] shortUnaryOpShuffleProvider() { 1017 return INT_SHUFFLE_GENERATORS.stream(). 1018 flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> { 1019 return new Object[] {fa, fs}; 1020 })). 1021 toArray(Object[][]::new); 1022 } 1023 1024 @DataProvider 1025 public Object[][] shortUnaryOpShuffleMaskProvider() { 1026 return BOOLEAN_MASK_GENERATORS.stream(). 1027 flatMap(fm -> INT_SHUFFLE_GENERATORS.stream(). 1028 flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> { 1029 return new Object[] {fa, fs, fm}; 1030 }))). 1031 toArray(Object[][]::new); 1032 } 1033 1034 static final List<BiFunction<Integer,Integer,short[]>> SHORT_SHUFFLE_GENERATORS = List.of( 1035 withToStringBi("shuffle[random]", (Integer l, Integer m) -> { 1036 short[] a = new short[l]; 1037 int upper = m; 1038 for (int i = 0; i < 1; i++) { 1039 a[i] = (short)RAND.nextInt(upper); 1040 } 1041 return a; 1042 }) 1043 ); 1044 1045 @DataProvider 1046 public Object[][] shortUnaryOpSelectFromProvider() { 1047 return SHORT_SHUFFLE_GENERATORS.stream(). 1048 flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> { 1049 return new Object[] {fa, fs}; 1050 })). 1051 toArray(Object[][]::new); 1052 } 1053 1054 @DataProvider 1055 public Object[][] shortUnaryOpSelectFromMaskProvider() { 1056 return BOOLEAN_MASK_GENERATORS.stream(). 1057 flatMap(fm -> SHORT_SHUFFLE_GENERATORS.stream(). 1058 flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> { 1059 return new Object[] {fa, fs, fm}; 1060 }))). 1061 toArray(Object[][]::new); 1062 } 1063 1064 1065 static final List<IntFunction<short[]>> SHORT_COMPARE_GENERATORS = List.of( 1066 withToString("short[i]", (int s) -> { 1067 return fill(s * BUFFER_REPS, 1068 i -> (short)i); 1069 }), 1070 withToString("short[i - length / 2]", (int s) -> { 1071 return fill(s * BUFFER_REPS, 1072 i -> (short)(i - (s * BUFFER_REPS / 2))); 1073 }), 1074 withToString("short[i + 1]", (int s) -> { 1075 return fill(s * BUFFER_REPS, 1076 i -> (short)(i + 1)); 1077 }), 1078 withToString("short[i - 2]", (int s) -> { 1079 return fill(s * BUFFER_REPS, 1080 i -> (short)(i - 2)); 1081 }), 1082 withToString("short[zigZag(i)]", (int s) -> { 1083 return fill(s * BUFFER_REPS, 1084 i -> i%3 == 0 ? (short)i : (i%3 == 1 ? (short)(i + 1) : (short)(i - 2))); 1085 }), 1086 withToString("short[cornerCaseValue(i)]", (int s) -> { 1087 return fill(s * BUFFER_REPS, 1088 i -> cornerCaseValue(i)); 1089 }) 1090 ); 1091 1092 static final List<List<IntFunction<short[]>>> SHORT_TEST_GENERATOR_ARGS = 1093 SHORT_COMPARE_GENERATORS.stream(). 1094 map(fa -> List.of(fa)). 1095 collect(Collectors.toList()); 1096 1097 @DataProvider 1098 public Object[][] shortTestOpProvider() { 1099 return SHORT_TEST_GENERATOR_ARGS.stream().map(List::toArray). 1100 toArray(Object[][]::new); 1101 } 1102 1103 @DataProvider 1104 public Object[][] shortTestOpMaskProvider() { 1105 return BOOLEAN_MASK_GENERATORS.stream(). 1106 flatMap(fm -> SHORT_TEST_GENERATOR_ARGS.stream().map(lfa -> { 1107 return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); 1108 })). 1109 toArray(Object[][]::new); 1110 } 1111 1112 static final List<List<IntFunction<short[]>>> SHORT_COMPARE_GENERATOR_PAIRS = 1113 SHORT_COMPARE_GENERATORS.stream(). 1114 flatMap(fa -> SHORT_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))). 1115 collect(Collectors.toList()); 1116 1117 @DataProvider 1118 public Object[][] shortCompareOpProvider() { 1119 return SHORT_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). 1120 toArray(Object[][]::new); 1121 } 1122 1123 @DataProvider 1124 public Object[][] shortCompareOpMaskProvider() { 1125 return BOOLEAN_MASK_GENERATORS.stream(). 1126 flatMap(fm -> SHORT_COMPARE_GENERATOR_PAIRS.stream().map(lfa -> { 1127 return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); 1128 })). 1129 toArray(Object[][]::new); 1130 } 1131 1132 interface ToShortF { 1133 short apply(int i); 1134 } 1135 1136 static short[] fill(int s , ToShortF f) { 1137 return fill(new short[s], f); 1138 } 1139 1140 static short[] fill(short[] a, ToShortF f) { 1141 for (int i = 0; i < a.length; i++) { 1142 a[i] = f.apply(i); 1143 } 1144 return a; 1145 } 1146 1147 static short cornerCaseValue(int i) { 1148 switch(i % 5) { 1149 case 0: 1150 return Short.MAX_VALUE; 1151 case 1: 1152 return Short.MIN_VALUE; 1153 case 2: 1154 return Short.MIN_VALUE; 1155 case 3: 1156 return Short.MAX_VALUE; 1157 default: 1158 return (short)0; 1159 } 1160 } 1161 1162 static short get(short[] a, int i) { 1163 return (short) a[i]; 1164 } 1165 1166 static final IntFunction<short[]> fr = (vl) -> { 1167 int length = BUFFER_REPS * vl; 1168 return new short[length]; 1169 }; 1170 1171 static final IntFunction<boolean[]> fmr = (vl) -> { 1172 int length = BUFFER_REPS * vl; 1173 return new boolean[length]; 1174 }; 1175 1176 static final IntFunction<long[]> lfr = (vl) -> { 1177 int length = BUFFER_REPS * vl; 1178 return new long[length]; 1179 }; 1180 1181 static void replaceZero(short[] a, short v) { 1182 for (int i = 0; i < a.length; i++) { 1183 if (a[i] == 0) { 1184 a[i] = v; 1185 } 1186 } 1187 } 1188 1189 static void replaceZero(short[] a, boolean[] mask, short v) { 1190 for (int i = 0; i < a.length; i++) { 1191 if (mask[i % mask.length] && a[i] == 0) { 1192 a[i] = v; 1193 } 1194 } 1195 } 1196 1197 static short ROL_scalar(short a, short b) { 1198 return (short)(((((short)a) & 0xFFFF) << (b & 15)) | ((((short)a) & 0xFFFF) >>> (16 - (b & 15)))); 1199 } 1200 1201 static short ROR_scalar(short a, short b) { 1202 return (short)(((((short)a) & 0xFFFF) >>> (b & 15)) | ((((short)a) & 0xFFFF) << (16 - (b & 15)))); 1203 } 1204 1205 static boolean eq(short a, short b) { 1206 return a == b; 1207 } 1208 1209 static boolean neq(short a, short b) { 1210 return a != b; 1211 } 1212 1213 static boolean lt(short a, short b) { 1214 return a < b; 1215 } 1216 1217 static boolean le(short a, short b) { 1218 return a <= b; 1219 } 1220 1221 static boolean gt(short a, short b) { 1222 return a > b; 1223 } 1224 1225 static boolean ge(short a, short b) { 1226 return a >= b; 1227 } 1228 1229 static boolean ult(short a, short b) { 1230 return Short.compareUnsigned(a, b) < 0; 1231 } 1232 1233 static boolean ule(short a, short b) { 1234 return Short.compareUnsigned(a, b) <= 0; 1235 } 1236 1237 static boolean ugt(short a, short b) { 1238 return Short.compareUnsigned(a, b) > 0; 1239 } 1240 1241 static boolean uge(short a, short b) { 1242 return Short.compareUnsigned(a, b) >= 0; 1243 } 1244 1245 static short firstNonZero(short a, short b) { 1246 return Short.compare(a, (short) 0) != 0 ? a : b; 1247 } 1248 1249 @Test 1250 static void smokeTest1() { 1251 ShortVector three = ShortVector.broadcast(SPECIES, (byte)-3); 1252 ShortVector three2 = (ShortVector) SPECIES.broadcast(-3); 1253 assert(three.eq(three2).allTrue()); 1254 ShortVector three3 = three2.broadcast(1).broadcast(-3); 1255 assert(three.eq(three3).allTrue()); 1256 int scale = 2; 1257 Class<?> ETYPE = short.class; 1258 if (ETYPE == double.class || ETYPE == long.class) 1259 scale = 1000000; 1260 else if (ETYPE == byte.class && SPECIES.length() >= 64) 1261 scale = 1; 1262 ShortVector higher = three.addIndex(scale); 1263 VectorMask<Short> m = three.compare(VectorOperators.LE, higher); 1264 assert(m.allTrue()); 1265 m = higher.min((short)-1).test(VectorOperators.IS_NEGATIVE); 1266 assert(m.allTrue()); 1267 short max = higher.reduceLanes(VectorOperators.MAX); 1268 assert(max == -3 + scale * (SPECIES.length()-1)); 1269 } 1270 1271 private static short[] 1272 bothToArray(ShortVector a, ShortVector b) { 1273 short[] r = new short[a.length() + b.length()]; 1274 a.intoArray(r, 0); 1275 b.intoArray(r, a.length()); 1276 return r; 1277 } 1278 1279 @Test 1280 static void smokeTest2() { 1281 // Do some zipping and shuffling. 1282 ShortVector io = (ShortVector) SPECIES.broadcast(0).addIndex(1); 1283 ShortVector io2 = (ShortVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); 1284 Assert.assertEquals(io, io2); 1285 ShortVector a = io.add((short)1); //[1,2] 1286 ShortVector b = a.neg(); //[-1,-2] 1287 short[] abValues = bothToArray(a,b); //[1,2,-1,-2] 1288 VectorShuffle<Short> zip0 = VectorShuffle.makeZip(SPECIES, 0); 1289 VectorShuffle<Short> zip1 = VectorShuffle.makeZip(SPECIES, 1); 1290 ShortVector zab0 = a.rearrange(zip0,b); //[1,-1] 1291 ShortVector zab1 = a.rearrange(zip1,b); //[2,-2] 1292 short[] zabValues = bothToArray(zab0, zab1); //[1,-1,2,-2] 1293 // manually zip 1294 short[] manual = new short[zabValues.length]; 1295 for (int i = 0; i < manual.length; i += 2) { 1296 manual[i+0] = abValues[i/2]; 1297 manual[i+1] = abValues[a.length() + i/2]; 1298 } 1299 Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); 1300 VectorShuffle<Short> unz0 = VectorShuffle.makeUnzip(SPECIES, 0); 1301 VectorShuffle<Short> unz1 = VectorShuffle.makeUnzip(SPECIES, 1); 1302 ShortVector uab0 = zab0.rearrange(unz0,zab1); 1303 ShortVector uab1 = zab0.rearrange(unz1,zab1); 1304 short[] abValues1 = bothToArray(uab0, uab1); 1305 Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); 1306 } 1307 1308 static void iotaShuffle() { 1309 ShortVector io = (ShortVector) SPECIES.broadcast(0).addIndex(1); 1310 ShortVector io2 = (ShortVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); 1311 Assert.assertEquals(io, io2); 1312 } 1313 1314 @Test 1315 // Test all shuffle related operations. 1316 static void shuffleTest() { 1317 // To test backend instructions, make sure that C2 is used. 1318 for (int loop = 0; loop < INVOC_COUNT * INVOC_COUNT; loop++) { 1319 iotaShuffle(); 1320 } 1321 } 1322 1323 @Test 1324 void viewAsIntegeralLanesTest() { 1325 Vector<?> asIntegral = SPECIES.zero().viewAsIntegralLanes(); 1326 Assert.assertEquals(asIntegral.species(), SPECIES); 1327 } 1328 1329 @Test(expectedExceptions = UnsupportedOperationException.class) 1330 void viewAsFloatingLanesTest() { 1331 SPECIES.zero().viewAsFloatingLanes(); 1332 } 1333 1334 @Test 1335 // Test div by 0. 1336 static void bitwiseDivByZeroSmokeTest() { 1337 try { 1338 ShortVector a = (ShortVector) SPECIES.broadcast(0).addIndex(1); 1339 ShortVector b = (ShortVector) SPECIES.broadcast(0); 1340 a.div(b); 1341 Assert.fail(); 1342 } catch (ArithmeticException e) { 1343 } 1344 1345 try { 1346 ShortVector a = (ShortVector) SPECIES.broadcast(0).addIndex(1); 1347 ShortVector b = (ShortVector) SPECIES.broadcast(0); 1348 VectorMask<Short> m = a.lt((short) 1); 1349 a.div(b, m); 1350 Assert.fail(); 1351 } catch (ArithmeticException e) { 1352 } 1353 } 1354 static short ADD(short a, short b) { 1355 return (short)(a + b); 1356 } 1357 1358 @Test(dataProvider = "shortBinaryOpProvider") 1359 static void ADDShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 1360 short[] a = fa.apply(SPECIES.length()); 1361 short[] b = fb.apply(SPECIES.length()); 1362 short[] r = fr.apply(SPECIES.length()); 1363 1364 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1365 for (int i = 0; i < a.length; i += SPECIES.length()) { 1366 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1367 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1368 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i); 1369 } 1370 } 1371 1372 assertArraysEquals(r, a, b, ShortMaxVectorTests::ADD); 1373 } 1374 static short add(short a, short b) { 1375 return (short)(a + b); 1376 } 1377 1378 @Test(dataProvider = "shortBinaryOpProvider") 1379 static void addShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 1380 short[] a = fa.apply(SPECIES.length()); 1381 short[] b = fb.apply(SPECIES.length()); 1382 short[] r = fr.apply(SPECIES.length()); 1383 1384 for (int i = 0; i < a.length; i += SPECIES.length()) { 1385 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1386 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1387 av.add(bv).intoArray(r, i); 1388 } 1389 1390 assertArraysEquals(r, a, b, ShortMaxVectorTests::add); 1391 } 1392 1393 @Test(dataProvider = "shortBinaryOpMaskProvider") 1394 static void ADDShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 1395 IntFunction<boolean[]> fm) { 1396 short[] a = fa.apply(SPECIES.length()); 1397 short[] b = fb.apply(SPECIES.length()); 1398 short[] r = fr.apply(SPECIES.length()); 1399 boolean[] mask = fm.apply(SPECIES.length()); 1400 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1401 1402 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1403 for (int i = 0; i < a.length; i += SPECIES.length()) { 1404 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1405 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1406 av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i); 1407 } 1408 } 1409 1410 assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::ADD); 1411 } 1412 1413 @Test(dataProvider = "shortBinaryOpMaskProvider") 1414 static void addShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 1415 IntFunction<boolean[]> fm) { 1416 short[] a = fa.apply(SPECIES.length()); 1417 short[] b = fb.apply(SPECIES.length()); 1418 short[] r = fr.apply(SPECIES.length()); 1419 boolean[] mask = fm.apply(SPECIES.length()); 1420 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1421 1422 for (int i = 0; i < a.length; i += SPECIES.length()) { 1423 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1424 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1425 av.add(bv, vmask).intoArray(r, i); 1426 } 1427 1428 assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::add); 1429 } 1430 static short SUB(short a, short b) { 1431 return (short)(a - b); 1432 } 1433 1434 @Test(dataProvider = "shortBinaryOpProvider") 1435 static void SUBShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 1436 short[] a = fa.apply(SPECIES.length()); 1437 short[] b = fb.apply(SPECIES.length()); 1438 short[] r = fr.apply(SPECIES.length()); 1439 1440 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1441 for (int i = 0; i < a.length; i += SPECIES.length()) { 1442 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1443 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1444 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i); 1445 } 1446 } 1447 1448 assertArraysEquals(r, a, b, ShortMaxVectorTests::SUB); 1449 } 1450 static short sub(short a, short b) { 1451 return (short)(a - b); 1452 } 1453 1454 @Test(dataProvider = "shortBinaryOpProvider") 1455 static void subShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 1456 short[] a = fa.apply(SPECIES.length()); 1457 short[] b = fb.apply(SPECIES.length()); 1458 short[] r = fr.apply(SPECIES.length()); 1459 1460 for (int i = 0; i < a.length; i += SPECIES.length()) { 1461 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1462 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1463 av.sub(bv).intoArray(r, i); 1464 } 1465 1466 assertArraysEquals(r, a, b, ShortMaxVectorTests::sub); 1467 } 1468 1469 @Test(dataProvider = "shortBinaryOpMaskProvider") 1470 static void SUBShortMaxVectorTestsMasked(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.SUB, bv, vmask).intoArray(r, i); 1483 } 1484 } 1485 1486 assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::SUB); 1487 } 1488 1489 @Test(dataProvider = "shortBinaryOpMaskProvider") 1490 static void subShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 1491 IntFunction<boolean[]> fm) { 1492 short[] a = fa.apply(SPECIES.length()); 1493 short[] b = fb.apply(SPECIES.length()); 1494 short[] r = fr.apply(SPECIES.length()); 1495 boolean[] mask = fm.apply(SPECIES.length()); 1496 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1497 1498 for (int i = 0; i < a.length; i += SPECIES.length()) { 1499 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1500 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1501 av.sub(bv, vmask).intoArray(r, i); 1502 } 1503 1504 assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::sub); 1505 } 1506 static short MUL(short a, short b) { 1507 return (short)(a * b); 1508 } 1509 1510 @Test(dataProvider = "shortBinaryOpProvider") 1511 static void MULShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 1512 short[] a = fa.apply(SPECIES.length()); 1513 short[] b = fb.apply(SPECIES.length()); 1514 short[] r = fr.apply(SPECIES.length()); 1515 1516 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1517 for (int i = 0; i < a.length; i += SPECIES.length()) { 1518 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1519 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1520 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i); 1521 } 1522 } 1523 1524 assertArraysEquals(r, a, b, ShortMaxVectorTests::MUL); 1525 } 1526 static short mul(short a, short b) { 1527 return (short)(a * b); 1528 } 1529 1530 @Test(dataProvider = "shortBinaryOpProvider") 1531 static void mulShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 1532 short[] a = fa.apply(SPECIES.length()); 1533 short[] b = fb.apply(SPECIES.length()); 1534 short[] r = fr.apply(SPECIES.length()); 1535 1536 for (int i = 0; i < a.length; i += SPECIES.length()) { 1537 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1538 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1539 av.mul(bv).intoArray(r, i); 1540 } 1541 1542 assertArraysEquals(r, a, b, ShortMaxVectorTests::mul); 1543 } 1544 1545 @Test(dataProvider = "shortBinaryOpMaskProvider") 1546 static void MULShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 1547 IntFunction<boolean[]> fm) { 1548 short[] a = fa.apply(SPECIES.length()); 1549 short[] b = fb.apply(SPECIES.length()); 1550 short[] r = fr.apply(SPECIES.length()); 1551 boolean[] mask = fm.apply(SPECIES.length()); 1552 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1553 1554 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1555 for (int i = 0; i < a.length; i += SPECIES.length()) { 1556 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1557 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1558 av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i); 1559 } 1560 } 1561 1562 assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::MUL); 1563 } 1564 1565 @Test(dataProvider = "shortBinaryOpMaskProvider") 1566 static void mulShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 1567 IntFunction<boolean[]> fm) { 1568 short[] a = fa.apply(SPECIES.length()); 1569 short[] b = fb.apply(SPECIES.length()); 1570 short[] r = fr.apply(SPECIES.length()); 1571 boolean[] mask = fm.apply(SPECIES.length()); 1572 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1573 1574 for (int i = 0; i < a.length; i += SPECIES.length()) { 1575 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1576 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1577 av.mul(bv, vmask).intoArray(r, i); 1578 } 1579 1580 assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::mul); 1581 } 1582 1583 1584 1585 static short DIV(short a, short b) { 1586 return (short)(a / b); 1587 } 1588 1589 @Test(dataProvider = "shortBinaryOpProvider") 1590 static void DIVShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 1591 short[] a = fa.apply(SPECIES.length()); 1592 short[] b = fb.apply(SPECIES.length()); 1593 short[] r = fr.apply(SPECIES.length()); 1594 1595 replaceZero(b, (short) 1); 1596 1597 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1598 for (int i = 0; i < a.length; i += SPECIES.length()) { 1599 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1600 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1601 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i); 1602 } 1603 } 1604 1605 assertArraysEquals(r, a, b, ShortMaxVectorTests::DIV); 1606 } 1607 static short div(short a, short b) { 1608 return (short)(a / b); 1609 } 1610 1611 @Test(dataProvider = "shortBinaryOpProvider") 1612 static void divShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 1613 short[] a = fa.apply(SPECIES.length()); 1614 short[] b = fb.apply(SPECIES.length()); 1615 short[] r = fr.apply(SPECIES.length()); 1616 1617 replaceZero(b, (short) 1); 1618 1619 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1620 for (int i = 0; i < a.length; i += SPECIES.length()) { 1621 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1622 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1623 av.div(bv).intoArray(r, i); 1624 } 1625 } 1626 1627 assertArraysEquals(r, a, b, ShortMaxVectorTests::div); 1628 } 1629 1630 1631 1632 @Test(dataProvider = "shortBinaryOpMaskProvider") 1633 static void DIVShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 1634 IntFunction<boolean[]> fm) { 1635 short[] a = fa.apply(SPECIES.length()); 1636 short[] b = fb.apply(SPECIES.length()); 1637 short[] r = fr.apply(SPECIES.length()); 1638 boolean[] mask = fm.apply(SPECIES.length()); 1639 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1640 1641 replaceZero(b, mask, (short) 1); 1642 1643 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1644 for (int i = 0; i < a.length; i += SPECIES.length()) { 1645 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1646 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1647 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i); 1648 } 1649 } 1650 1651 assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::DIV); 1652 } 1653 1654 @Test(dataProvider = "shortBinaryOpMaskProvider") 1655 static void divShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 1656 IntFunction<boolean[]> fm) { 1657 short[] a = fa.apply(SPECIES.length()); 1658 short[] b = fb.apply(SPECIES.length()); 1659 short[] r = fr.apply(SPECIES.length()); 1660 boolean[] mask = fm.apply(SPECIES.length()); 1661 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1662 1663 replaceZero(b, mask, (short) 1); 1664 1665 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1666 for (int i = 0; i < a.length; i += SPECIES.length()) { 1667 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1668 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1669 av.div(bv, vmask).intoArray(r, i); 1670 } 1671 } 1672 1673 assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::div); 1674 } 1675 1676 static short FIRST_NONZERO(short a, short b) { 1677 return (short)((a)!=0?a:b); 1678 } 1679 1680 @Test(dataProvider = "shortBinaryOpProvider") 1681 static void FIRST_NONZEROShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 1682 short[] a = fa.apply(SPECIES.length()); 1683 short[] b = fb.apply(SPECIES.length()); 1684 short[] r = fr.apply(SPECIES.length()); 1685 1686 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1687 for (int i = 0; i < a.length; i += SPECIES.length()) { 1688 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1689 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1690 av.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i); 1691 } 1692 } 1693 1694 assertArraysEquals(r, a, b, ShortMaxVectorTests::FIRST_NONZERO); 1695 } 1696 1697 @Test(dataProvider = "shortBinaryOpMaskProvider") 1698 static void FIRST_NONZEROShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 1699 IntFunction<boolean[]> fm) { 1700 short[] a = fa.apply(SPECIES.length()); 1701 short[] b = fb.apply(SPECIES.length()); 1702 short[] r = fr.apply(SPECIES.length()); 1703 boolean[] mask = fm.apply(SPECIES.length()); 1704 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1705 1706 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1707 for (int i = 0; i < a.length; i += SPECIES.length()) { 1708 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1709 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1710 av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i); 1711 } 1712 } 1713 1714 assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::FIRST_NONZERO); 1715 } 1716 1717 static short AND(short a, short b) { 1718 return (short)(a & b); 1719 } 1720 1721 @Test(dataProvider = "shortBinaryOpProvider") 1722 static void ANDShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 1723 short[] a = fa.apply(SPECIES.length()); 1724 short[] b = fb.apply(SPECIES.length()); 1725 short[] r = fr.apply(SPECIES.length()); 1726 1727 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1728 for (int i = 0; i < a.length; i += SPECIES.length()) { 1729 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1730 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1731 av.lanewise(VectorOperators.AND, bv).intoArray(r, i); 1732 } 1733 } 1734 1735 assertArraysEquals(r, a, b, ShortMaxVectorTests::AND); 1736 } 1737 static short and(short a, short b) { 1738 return (short)(a & b); 1739 } 1740 1741 @Test(dataProvider = "shortBinaryOpProvider") 1742 static void andShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 1743 short[] a = fa.apply(SPECIES.length()); 1744 short[] b = fb.apply(SPECIES.length()); 1745 short[] r = fr.apply(SPECIES.length()); 1746 1747 for (int i = 0; i < a.length; i += SPECIES.length()) { 1748 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1749 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1750 av.and(bv).intoArray(r, i); 1751 } 1752 1753 assertArraysEquals(r, a, b, ShortMaxVectorTests::and); 1754 } 1755 1756 1757 1758 @Test(dataProvider = "shortBinaryOpMaskProvider") 1759 static void ANDShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 1760 IntFunction<boolean[]> fm) { 1761 short[] a = fa.apply(SPECIES.length()); 1762 short[] b = fb.apply(SPECIES.length()); 1763 short[] r = fr.apply(SPECIES.length()); 1764 boolean[] mask = fm.apply(SPECIES.length()); 1765 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1766 1767 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1768 for (int i = 0; i < a.length; i += SPECIES.length()) { 1769 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1770 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1771 av.lanewise(VectorOperators.AND, bv, vmask).intoArray(r, i); 1772 } 1773 } 1774 1775 assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::AND); 1776 } 1777 1778 1779 static short AND_NOT(short a, short b) { 1780 return (short)(a & ~b); 1781 } 1782 1783 @Test(dataProvider = "shortBinaryOpProvider") 1784 static void AND_NOTShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 1785 short[] a = fa.apply(SPECIES.length()); 1786 short[] b = fb.apply(SPECIES.length()); 1787 short[] r = fr.apply(SPECIES.length()); 1788 1789 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1790 for (int i = 0; i < a.length; i += SPECIES.length()) { 1791 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1792 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1793 av.lanewise(VectorOperators.AND_NOT, bv).intoArray(r, i); 1794 } 1795 } 1796 1797 assertArraysEquals(r, a, b, ShortMaxVectorTests::AND_NOT); 1798 } 1799 1800 1801 1802 @Test(dataProvider = "shortBinaryOpMaskProvider") 1803 static void AND_NOTShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 1804 IntFunction<boolean[]> fm) { 1805 short[] a = fa.apply(SPECIES.length()); 1806 short[] b = fb.apply(SPECIES.length()); 1807 short[] r = fr.apply(SPECIES.length()); 1808 boolean[] mask = fm.apply(SPECIES.length()); 1809 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1810 1811 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1812 for (int i = 0; i < a.length; i += SPECIES.length()) { 1813 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1814 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1815 av.lanewise(VectorOperators.AND_NOT, bv, vmask).intoArray(r, i); 1816 } 1817 } 1818 1819 assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::AND_NOT); 1820 } 1821 1822 1823 static short OR(short a, short b) { 1824 return (short)(a | b); 1825 } 1826 1827 @Test(dataProvider = "shortBinaryOpProvider") 1828 static void ORShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 1829 short[] a = fa.apply(SPECIES.length()); 1830 short[] b = fb.apply(SPECIES.length()); 1831 short[] r = fr.apply(SPECIES.length()); 1832 1833 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1834 for (int i = 0; i < a.length; i += SPECIES.length()) { 1835 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1836 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1837 av.lanewise(VectorOperators.OR, bv).intoArray(r, i); 1838 } 1839 } 1840 1841 assertArraysEquals(r, a, b, ShortMaxVectorTests::OR); 1842 } 1843 static short or(short a, short b) { 1844 return (short)(a | b); 1845 } 1846 1847 @Test(dataProvider = "shortBinaryOpProvider") 1848 static void orShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 1849 short[] a = fa.apply(SPECIES.length()); 1850 short[] b = fb.apply(SPECIES.length()); 1851 short[] r = fr.apply(SPECIES.length()); 1852 1853 for (int i = 0; i < a.length; i += SPECIES.length()) { 1854 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1855 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1856 av.or(bv).intoArray(r, i); 1857 } 1858 1859 assertArraysEquals(r, a, b, ShortMaxVectorTests::or); 1860 } 1861 1862 1863 1864 @Test(dataProvider = "shortBinaryOpMaskProvider") 1865 static void ORShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 1866 IntFunction<boolean[]> fm) { 1867 short[] a = fa.apply(SPECIES.length()); 1868 short[] b = fb.apply(SPECIES.length()); 1869 short[] r = fr.apply(SPECIES.length()); 1870 boolean[] mask = fm.apply(SPECIES.length()); 1871 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1872 1873 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1874 for (int i = 0; i < a.length; i += SPECIES.length()) { 1875 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1876 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1877 av.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i); 1878 } 1879 } 1880 1881 assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::OR); 1882 } 1883 1884 1885 static short XOR(short a, short b) { 1886 return (short)(a ^ b); 1887 } 1888 1889 @Test(dataProvider = "shortBinaryOpProvider") 1890 static void XORShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 1891 short[] a = fa.apply(SPECIES.length()); 1892 short[] b = fb.apply(SPECIES.length()); 1893 short[] r = fr.apply(SPECIES.length()); 1894 1895 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1896 for (int i = 0; i < a.length; i += SPECIES.length()) { 1897 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1898 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1899 av.lanewise(VectorOperators.XOR, bv).intoArray(r, i); 1900 } 1901 } 1902 1903 assertArraysEquals(r, a, b, ShortMaxVectorTests::XOR); 1904 } 1905 1906 1907 1908 @Test(dataProvider = "shortBinaryOpMaskProvider") 1909 static void XORShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 1910 IntFunction<boolean[]> fm) { 1911 short[] a = fa.apply(SPECIES.length()); 1912 short[] b = fb.apply(SPECIES.length()); 1913 short[] r = fr.apply(SPECIES.length()); 1914 boolean[] mask = fm.apply(SPECIES.length()); 1915 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1916 1917 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1918 for (int i = 0; i < a.length; i += SPECIES.length()) { 1919 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1920 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 1921 av.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i); 1922 } 1923 } 1924 1925 assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::XOR); 1926 } 1927 1928 1929 @Test(dataProvider = "shortBinaryOpProvider") 1930 static void addShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 1931 short[] a = fa.apply(SPECIES.length()); 1932 short[] b = fb.apply(SPECIES.length()); 1933 short[] r = fr.apply(SPECIES.length()); 1934 1935 for (int i = 0; i < a.length; i += SPECIES.length()) { 1936 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1937 av.add(b[i]).intoArray(r, i); 1938 } 1939 1940 assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::add); 1941 } 1942 1943 @Test(dataProvider = "shortBinaryOpMaskProvider") 1944 static void addShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, 1945 IntFunction<boolean[]> fm) { 1946 short[] a = fa.apply(SPECIES.length()); 1947 short[] b = fb.apply(SPECIES.length()); 1948 short[] r = fr.apply(SPECIES.length()); 1949 boolean[] mask = fm.apply(SPECIES.length()); 1950 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1951 1952 for (int i = 0; i < a.length; i += SPECIES.length()) { 1953 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1954 av.add(b[i], vmask).intoArray(r, i); 1955 } 1956 1957 assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::add); 1958 } 1959 1960 @Test(dataProvider = "shortBinaryOpProvider") 1961 static void subShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 1962 short[] a = fa.apply(SPECIES.length()); 1963 short[] b = fb.apply(SPECIES.length()); 1964 short[] r = fr.apply(SPECIES.length()); 1965 1966 for (int i = 0; i < a.length; i += SPECIES.length()) { 1967 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1968 av.sub(b[i]).intoArray(r, i); 1969 } 1970 1971 assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::sub); 1972 } 1973 1974 @Test(dataProvider = "shortBinaryOpMaskProvider") 1975 static void subShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, 1976 IntFunction<boolean[]> fm) { 1977 short[] a = fa.apply(SPECIES.length()); 1978 short[] b = fb.apply(SPECIES.length()); 1979 short[] r = fr.apply(SPECIES.length()); 1980 boolean[] mask = fm.apply(SPECIES.length()); 1981 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1982 1983 for (int i = 0; i < a.length; i += SPECIES.length()) { 1984 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1985 av.sub(b[i], vmask).intoArray(r, i); 1986 } 1987 1988 assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::sub); 1989 } 1990 1991 @Test(dataProvider = "shortBinaryOpProvider") 1992 static void mulShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 1993 short[] a = fa.apply(SPECIES.length()); 1994 short[] b = fb.apply(SPECIES.length()); 1995 short[] r = fr.apply(SPECIES.length()); 1996 1997 for (int i = 0; i < a.length; i += SPECIES.length()) { 1998 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 1999 av.mul(b[i]).intoArray(r, i); 2000 } 2001 2002 assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::mul); 2003 } 2004 2005 @Test(dataProvider = "shortBinaryOpMaskProvider") 2006 static void mulShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, 2007 IntFunction<boolean[]> fm) { 2008 short[] a = fa.apply(SPECIES.length()); 2009 short[] b = fb.apply(SPECIES.length()); 2010 short[] r = fr.apply(SPECIES.length()); 2011 boolean[] mask = fm.apply(SPECIES.length()); 2012 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2013 2014 for (int i = 0; i < a.length; i += SPECIES.length()) { 2015 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2016 av.mul(b[i], vmask).intoArray(r, i); 2017 } 2018 2019 assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::mul); 2020 } 2021 2022 2023 2024 2025 @Test(dataProvider = "shortBinaryOpProvider") 2026 static void divShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2027 short[] a = fa.apply(SPECIES.length()); 2028 short[] b = fb.apply(SPECIES.length()); 2029 short[] r = fr.apply(SPECIES.length()); 2030 2031 replaceZero(b, (short) 1); 2032 2033 for (int i = 0; i < a.length; i += SPECIES.length()) { 2034 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2035 av.div(b[i]).intoArray(r, i); 2036 } 2037 2038 assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::div); 2039 } 2040 2041 2042 2043 @Test(dataProvider = "shortBinaryOpMaskProvider") 2044 static void divShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, 2045 IntFunction<boolean[]> fm) { 2046 short[] a = fa.apply(SPECIES.length()); 2047 short[] b = fb.apply(SPECIES.length()); 2048 short[] r = fr.apply(SPECIES.length()); 2049 boolean[] mask = fm.apply(SPECIES.length()); 2050 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2051 2052 replaceZero(b, (short) 1); 2053 2054 for (int i = 0; i < a.length; i += SPECIES.length()) { 2055 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2056 av.div(b[i], vmask).intoArray(r, i); 2057 } 2058 2059 assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::div); 2060 } 2061 2062 2063 2064 @Test(dataProvider = "shortBinaryOpProvider") 2065 static void ORShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2066 short[] a = fa.apply(SPECIES.length()); 2067 short[] b = fb.apply(SPECIES.length()); 2068 short[] r = fr.apply(SPECIES.length()); 2069 2070 for (int i = 0; i < a.length; i += SPECIES.length()) { 2071 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2072 av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); 2073 } 2074 2075 assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::OR); 2076 } 2077 2078 @Test(dataProvider = "shortBinaryOpProvider") 2079 static void orShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2080 short[] a = fa.apply(SPECIES.length()); 2081 short[] b = fb.apply(SPECIES.length()); 2082 short[] r = fr.apply(SPECIES.length()); 2083 2084 for (int i = 0; i < a.length; i += SPECIES.length()) { 2085 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2086 av.or(b[i]).intoArray(r, i); 2087 } 2088 2089 assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::or); 2090 } 2091 2092 2093 2094 @Test(dataProvider = "shortBinaryOpMaskProvider") 2095 static void ORShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, 2096 IntFunction<boolean[]> fm) { 2097 short[] a = fa.apply(SPECIES.length()); 2098 short[] b = fb.apply(SPECIES.length()); 2099 short[] r = fr.apply(SPECIES.length()); 2100 boolean[] mask = fm.apply(SPECIES.length()); 2101 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2102 2103 for (int i = 0; i < a.length; i += SPECIES.length()) { 2104 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2105 av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); 2106 } 2107 2108 assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::OR); 2109 } 2110 2111 2112 2113 @Test(dataProvider = "shortBinaryOpProvider") 2114 static void ANDShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2115 short[] a = fa.apply(SPECIES.length()); 2116 short[] b = fb.apply(SPECIES.length()); 2117 short[] r = fr.apply(SPECIES.length()); 2118 2119 for (int i = 0; i < a.length; i += SPECIES.length()) { 2120 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2121 av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); 2122 } 2123 2124 assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::AND); 2125 } 2126 2127 @Test(dataProvider = "shortBinaryOpProvider") 2128 static void andShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2129 short[] a = fa.apply(SPECIES.length()); 2130 short[] b = fb.apply(SPECIES.length()); 2131 short[] r = fr.apply(SPECIES.length()); 2132 2133 for (int i = 0; i < a.length; i += SPECIES.length()) { 2134 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2135 av.and(b[i]).intoArray(r, i); 2136 } 2137 2138 assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::and); 2139 } 2140 2141 2142 2143 @Test(dataProvider = "shortBinaryOpMaskProvider") 2144 static void ANDShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, 2145 IntFunction<boolean[]> fm) { 2146 short[] a = fa.apply(SPECIES.length()); 2147 short[] b = fb.apply(SPECIES.length()); 2148 short[] r = fr.apply(SPECIES.length()); 2149 boolean[] mask = fm.apply(SPECIES.length()); 2150 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2151 2152 for (int i = 0; i < a.length; i += SPECIES.length()) { 2153 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2154 av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); 2155 } 2156 2157 assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::AND); 2158 } 2159 2160 2161 2162 @Test(dataProvider = "shortBinaryOpProvider") 2163 static void ORShortMaxVectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2164 short[] a = fa.apply(SPECIES.length()); 2165 short[] b = fb.apply(SPECIES.length()); 2166 short[] r = fr.apply(SPECIES.length()); 2167 2168 for (int i = 0; i < a.length; i += SPECIES.length()) { 2169 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2170 av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); 2171 } 2172 2173 assertBroadcastLongArraysEquals(r, a, b, ShortMaxVectorTests::OR); 2174 } 2175 2176 2177 2178 @Test(dataProvider = "shortBinaryOpMaskProvider") 2179 static void ORShortMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, 2180 IntFunction<boolean[]> fm) { 2181 short[] a = fa.apply(SPECIES.length()); 2182 short[] b = fb.apply(SPECIES.length()); 2183 short[] r = fr.apply(SPECIES.length()); 2184 boolean[] mask = fm.apply(SPECIES.length()); 2185 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2186 2187 for (int i = 0; i < a.length; i += SPECIES.length()) { 2188 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2189 av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); 2190 } 2191 2192 assertBroadcastLongArraysEquals(r, a, b, mask, ShortMaxVectorTests::OR); 2193 } 2194 2195 2196 @Test(dataProvider = "shortBinaryOpProvider") 2197 static void ADDShortMaxVectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2198 short[] a = fa.apply(SPECIES.length()); 2199 short[] b = fb.apply(SPECIES.length()); 2200 short[] r = fr.apply(SPECIES.length()); 2201 2202 for (int i = 0; i < a.length; i += SPECIES.length()) { 2203 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2204 av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); 2205 } 2206 2207 assertBroadcastLongArraysEquals(r, a, b, ShortMaxVectorTests::ADD); 2208 } 2209 2210 @Test(dataProvider = "shortBinaryOpMaskProvider") 2211 static void ADDShortMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, 2212 IntFunction<boolean[]> fm) { 2213 short[] a = fa.apply(SPECIES.length()); 2214 short[] b = fb.apply(SPECIES.length()); 2215 short[] r = fr.apply(SPECIES.length()); 2216 boolean[] mask = fm.apply(SPECIES.length()); 2217 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2218 2219 for (int i = 0; i < a.length; i += SPECIES.length()) { 2220 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2221 av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); 2222 } 2223 2224 assertBroadcastLongArraysEquals(r, a, b, mask, ShortMaxVectorTests::ADD); 2225 } 2226 2227 2228 2229 2230 2231 static short LSHL(short a, short b) { 2232 return (short)((a << (b & 0xF))); 2233 } 2234 2235 @Test(dataProvider = "shortBinaryOpProvider") 2236 static void LSHLShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2237 short[] a = fa.apply(SPECIES.length()); 2238 short[] b = fb.apply(SPECIES.length()); 2239 short[] r = fr.apply(SPECIES.length()); 2240 2241 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2242 for (int i = 0; i < a.length; i += SPECIES.length()) { 2243 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2244 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 2245 av.lanewise(VectorOperators.LSHL, bv).intoArray(r, i); 2246 } 2247 } 2248 2249 assertArraysEquals(r, a, b, ShortMaxVectorTests::LSHL); 2250 } 2251 2252 2253 2254 @Test(dataProvider = "shortBinaryOpMaskProvider") 2255 static void LSHLShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 2256 IntFunction<boolean[]> fm) { 2257 short[] a = fa.apply(SPECIES.length()); 2258 short[] b = fb.apply(SPECIES.length()); 2259 short[] r = fr.apply(SPECIES.length()); 2260 boolean[] mask = fm.apply(SPECIES.length()); 2261 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2262 2263 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2264 for (int i = 0; i < a.length; i += SPECIES.length()) { 2265 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2266 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 2267 av.lanewise(VectorOperators.LSHL, bv, vmask).intoArray(r, i); 2268 } 2269 } 2270 2271 assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::LSHL); 2272 } 2273 2274 2275 2276 2277 2278 2279 static short ASHR(short a, short b) { 2280 return (short)((a >> (b & 0xF))); 2281 } 2282 2283 @Test(dataProvider = "shortBinaryOpProvider") 2284 static void ASHRShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2285 short[] a = fa.apply(SPECIES.length()); 2286 short[] b = fb.apply(SPECIES.length()); 2287 short[] r = fr.apply(SPECIES.length()); 2288 2289 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2290 for (int i = 0; i < a.length; i += SPECIES.length()) { 2291 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2292 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 2293 av.lanewise(VectorOperators.ASHR, bv).intoArray(r, i); 2294 } 2295 } 2296 2297 assertArraysEquals(r, a, b, ShortMaxVectorTests::ASHR); 2298 } 2299 2300 2301 2302 @Test(dataProvider = "shortBinaryOpMaskProvider") 2303 static void ASHRShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 2304 IntFunction<boolean[]> fm) { 2305 short[] a = fa.apply(SPECIES.length()); 2306 short[] b = fb.apply(SPECIES.length()); 2307 short[] r = fr.apply(SPECIES.length()); 2308 boolean[] mask = fm.apply(SPECIES.length()); 2309 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2310 2311 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2312 for (int i = 0; i < a.length; i += SPECIES.length()) { 2313 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2314 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 2315 av.lanewise(VectorOperators.ASHR, bv, vmask).intoArray(r, i); 2316 } 2317 } 2318 2319 assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::ASHR); 2320 } 2321 2322 2323 2324 2325 2326 2327 static short LSHR(short a, short b) { 2328 return (short)(((a & 0xFFFF) >>> (b & 0xF))); 2329 } 2330 2331 @Test(dataProvider = "shortBinaryOpProvider") 2332 static void LSHRShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2333 short[] a = fa.apply(SPECIES.length()); 2334 short[] b = fb.apply(SPECIES.length()); 2335 short[] r = fr.apply(SPECIES.length()); 2336 2337 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2338 for (int i = 0; i < a.length; i += SPECIES.length()) { 2339 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2340 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 2341 av.lanewise(VectorOperators.LSHR, bv).intoArray(r, i); 2342 } 2343 } 2344 2345 assertArraysEquals(r, a, b, ShortMaxVectorTests::LSHR); 2346 } 2347 2348 2349 2350 @Test(dataProvider = "shortBinaryOpMaskProvider") 2351 static void LSHRShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 2352 IntFunction<boolean[]> fm) { 2353 short[] a = fa.apply(SPECIES.length()); 2354 short[] b = fb.apply(SPECIES.length()); 2355 short[] r = fr.apply(SPECIES.length()); 2356 boolean[] mask = fm.apply(SPECIES.length()); 2357 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2358 2359 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2360 for (int i = 0; i < a.length; i += SPECIES.length()) { 2361 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2362 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 2363 av.lanewise(VectorOperators.LSHR, bv, vmask).intoArray(r, i); 2364 } 2365 } 2366 2367 assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::LSHR); 2368 } 2369 2370 2371 2372 2373 2374 2375 static short LSHL_unary(short a, short b) { 2376 return (short)((a << (b & 15))); 2377 } 2378 2379 @Test(dataProvider = "shortBinaryOpProvider") 2380 static void LSHLShortMaxVectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2381 short[] a = fa.apply(SPECIES.length()); 2382 short[] b = fb.apply(SPECIES.length()); 2383 short[] r = fr.apply(SPECIES.length()); 2384 2385 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2386 for (int i = 0; i < a.length; i += SPECIES.length()) { 2387 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2388 av.lanewise(VectorOperators.LSHL, (int)b[i]).intoArray(r, i); 2389 } 2390 } 2391 2392 assertShiftArraysEquals(r, a, b, ShortMaxVectorTests::LSHL_unary); 2393 } 2394 2395 2396 2397 @Test(dataProvider = "shortBinaryOpMaskProvider") 2398 static void LSHLShortMaxVectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 2399 IntFunction<boolean[]> fm) { 2400 short[] a = fa.apply(SPECIES.length()); 2401 short[] b = fb.apply(SPECIES.length()); 2402 short[] r = fr.apply(SPECIES.length()); 2403 boolean[] mask = fm.apply(SPECIES.length()); 2404 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2405 2406 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2407 for (int i = 0; i < a.length; i += SPECIES.length()) { 2408 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2409 av.lanewise(VectorOperators.LSHL, (int)b[i], vmask).intoArray(r, i); 2410 } 2411 } 2412 2413 assertShiftArraysEquals(r, a, b, mask, ShortMaxVectorTests::LSHL_unary); 2414 } 2415 2416 2417 2418 2419 2420 2421 static short LSHR_unary(short a, short b) { 2422 return (short)(((a & 0xFFFF) >>> (b & 15))); 2423 } 2424 2425 @Test(dataProvider = "shortBinaryOpProvider") 2426 static void LSHRShortMaxVectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2427 short[] a = fa.apply(SPECIES.length()); 2428 short[] b = fb.apply(SPECIES.length()); 2429 short[] r = fr.apply(SPECIES.length()); 2430 2431 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2432 for (int i = 0; i < a.length; i += SPECIES.length()) { 2433 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2434 av.lanewise(VectorOperators.LSHR, (int)b[i]).intoArray(r, i); 2435 } 2436 } 2437 2438 assertShiftArraysEquals(r, a, b, ShortMaxVectorTests::LSHR_unary); 2439 } 2440 2441 2442 2443 @Test(dataProvider = "shortBinaryOpMaskProvider") 2444 static void LSHRShortMaxVectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 2445 IntFunction<boolean[]> fm) { 2446 short[] a = fa.apply(SPECIES.length()); 2447 short[] b = fb.apply(SPECIES.length()); 2448 short[] r = fr.apply(SPECIES.length()); 2449 boolean[] mask = fm.apply(SPECIES.length()); 2450 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2451 2452 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2453 for (int i = 0; i < a.length; i += SPECIES.length()) { 2454 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2455 av.lanewise(VectorOperators.LSHR, (int)b[i], vmask).intoArray(r, i); 2456 } 2457 } 2458 2459 assertShiftArraysEquals(r, a, b, mask, ShortMaxVectorTests::LSHR_unary); 2460 } 2461 2462 2463 2464 2465 2466 2467 static short ASHR_unary(short a, short b) { 2468 return (short)((a >> (b & 15))); 2469 } 2470 2471 @Test(dataProvider = "shortBinaryOpProvider") 2472 static void ASHRShortMaxVectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2473 short[] a = fa.apply(SPECIES.length()); 2474 short[] b = fb.apply(SPECIES.length()); 2475 short[] r = fr.apply(SPECIES.length()); 2476 2477 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2478 for (int i = 0; i < a.length; i += SPECIES.length()) { 2479 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2480 av.lanewise(VectorOperators.ASHR, (int)b[i]).intoArray(r, i); 2481 } 2482 } 2483 2484 assertShiftArraysEquals(r, a, b, ShortMaxVectorTests::ASHR_unary); 2485 } 2486 2487 2488 2489 @Test(dataProvider = "shortBinaryOpMaskProvider") 2490 static void ASHRShortMaxVectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 2491 IntFunction<boolean[]> fm) { 2492 short[] a = fa.apply(SPECIES.length()); 2493 short[] b = fb.apply(SPECIES.length()); 2494 short[] r = fr.apply(SPECIES.length()); 2495 boolean[] mask = fm.apply(SPECIES.length()); 2496 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2497 2498 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2499 for (int i = 0; i < a.length; i += SPECIES.length()) { 2500 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2501 av.lanewise(VectorOperators.ASHR, (int)b[i], vmask).intoArray(r, i); 2502 } 2503 } 2504 2505 assertShiftArraysEquals(r, a, b, mask, ShortMaxVectorTests::ASHR_unary); 2506 } 2507 2508 2509 static short ROR(short a, short b) { 2510 return (short)(ROR_scalar(a,b)); 2511 } 2512 2513 @Test(dataProvider = "shortBinaryOpProvider") 2514 static void RORShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2515 short[] a = fa.apply(SPECIES.length()); 2516 short[] b = fb.apply(SPECIES.length()); 2517 short[] r = fr.apply(SPECIES.length()); 2518 2519 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2520 for (int i = 0; i < a.length; i += SPECIES.length()) { 2521 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2522 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 2523 av.lanewise(VectorOperators.ROR, bv).intoArray(r, i); 2524 } 2525 } 2526 2527 assertArraysEquals(r, a, b, ShortMaxVectorTests::ROR); 2528 } 2529 2530 2531 2532 @Test(dataProvider = "shortBinaryOpMaskProvider") 2533 static void RORShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 2534 IntFunction<boolean[]> fm) { 2535 short[] a = fa.apply(SPECIES.length()); 2536 short[] b = fb.apply(SPECIES.length()); 2537 short[] r = fr.apply(SPECIES.length()); 2538 boolean[] mask = fm.apply(SPECIES.length()); 2539 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2540 2541 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2542 for (int i = 0; i < a.length; i += SPECIES.length()) { 2543 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2544 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 2545 av.lanewise(VectorOperators.ROR, bv, vmask).intoArray(r, i); 2546 } 2547 } 2548 2549 assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::ROR); 2550 } 2551 2552 2553 static short ROL(short a, short b) { 2554 return (short)(ROL_scalar(a,b)); 2555 } 2556 2557 @Test(dataProvider = "shortBinaryOpProvider") 2558 static void ROLShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2559 short[] a = fa.apply(SPECIES.length()); 2560 short[] b = fb.apply(SPECIES.length()); 2561 short[] r = fr.apply(SPECIES.length()); 2562 2563 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2564 for (int i = 0; i < a.length; i += SPECIES.length()) { 2565 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2566 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 2567 av.lanewise(VectorOperators.ROL, bv).intoArray(r, i); 2568 } 2569 } 2570 2571 assertArraysEquals(r, a, b, ShortMaxVectorTests::ROL); 2572 } 2573 2574 2575 2576 @Test(dataProvider = "shortBinaryOpMaskProvider") 2577 static void ROLShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 2578 IntFunction<boolean[]> fm) { 2579 short[] a = fa.apply(SPECIES.length()); 2580 short[] b = fb.apply(SPECIES.length()); 2581 short[] r = fr.apply(SPECIES.length()); 2582 boolean[] mask = fm.apply(SPECIES.length()); 2583 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2584 2585 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2586 for (int i = 0; i < a.length; i += SPECIES.length()) { 2587 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2588 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 2589 av.lanewise(VectorOperators.ROL, bv, vmask).intoArray(r, i); 2590 } 2591 } 2592 2593 assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::ROL); 2594 } 2595 2596 2597 static short ROR_unary(short a, short b) { 2598 return (short)(ROR_scalar(a, b)); 2599 } 2600 2601 @Test(dataProvider = "shortBinaryOpProvider") 2602 static void RORShortMaxVectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2603 short[] a = fa.apply(SPECIES.length()); 2604 short[] b = fb.apply(SPECIES.length()); 2605 short[] r = fr.apply(SPECIES.length()); 2606 2607 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2608 for (int i = 0; i < a.length; i += SPECIES.length()) { 2609 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2610 av.lanewise(VectorOperators.ROR, (int)b[i]).intoArray(r, i); 2611 } 2612 } 2613 2614 assertShiftArraysEquals(r, a, b, ShortMaxVectorTests::ROR_unary); 2615 } 2616 2617 2618 2619 @Test(dataProvider = "shortBinaryOpMaskProvider") 2620 static void RORShortMaxVectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 2621 IntFunction<boolean[]> fm) { 2622 short[] a = fa.apply(SPECIES.length()); 2623 short[] b = fb.apply(SPECIES.length()); 2624 short[] r = fr.apply(SPECIES.length()); 2625 boolean[] mask = fm.apply(SPECIES.length()); 2626 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2627 2628 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2629 for (int i = 0; i < a.length; i += SPECIES.length()) { 2630 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2631 av.lanewise(VectorOperators.ROR, (int)b[i], vmask).intoArray(r, i); 2632 } 2633 } 2634 2635 assertShiftArraysEquals(r, a, b, mask, ShortMaxVectorTests::ROR_unary); 2636 } 2637 2638 2639 static short ROL_unary(short a, short b) { 2640 return (short)(ROL_scalar(a, b)); 2641 } 2642 2643 @Test(dataProvider = "shortBinaryOpProvider") 2644 static void ROLShortMaxVectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2645 short[] a = fa.apply(SPECIES.length()); 2646 short[] b = fb.apply(SPECIES.length()); 2647 short[] r = fr.apply(SPECIES.length()); 2648 2649 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2650 for (int i = 0; i < a.length; i += SPECIES.length()) { 2651 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2652 av.lanewise(VectorOperators.ROL, (int)b[i]).intoArray(r, i); 2653 } 2654 } 2655 2656 assertShiftArraysEquals(r, a, b, ShortMaxVectorTests::ROL_unary); 2657 } 2658 2659 2660 2661 @Test(dataProvider = "shortBinaryOpMaskProvider") 2662 static void ROLShortMaxVectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 2663 IntFunction<boolean[]> fm) { 2664 short[] a = fa.apply(SPECIES.length()); 2665 short[] b = fb.apply(SPECIES.length()); 2666 short[] r = fr.apply(SPECIES.length()); 2667 boolean[] mask = fm.apply(SPECIES.length()); 2668 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2669 2670 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2671 for (int i = 0; i < a.length; i += SPECIES.length()) { 2672 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2673 av.lanewise(VectorOperators.ROL, (int)b[i], vmask).intoArray(r, i); 2674 } 2675 } 2676 2677 assertShiftArraysEquals(r, a, b, mask, ShortMaxVectorTests::ROL_unary); 2678 } 2679 2680 2681 2682 2683 2684 2685 static short LSHR_binary_const(short a) { 2686 return (short)(((a & 0xFFFF) >>> CONST_SHIFT)); 2687 } 2688 2689 @Test(dataProvider = "shortUnaryOpProvider") 2690 static void LSHRShortMaxVectorTestsScalarShiftConst(IntFunction<short[]> fa) { 2691 short[] a = fa.apply(SPECIES.length()); 2692 short[] r = fr.apply(SPECIES.length()); 2693 2694 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2695 for (int i = 0; i < a.length; i += SPECIES.length()) { 2696 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2697 av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i); 2698 } 2699 } 2700 2701 assertShiftConstEquals(r, a, ShortMaxVectorTests::LSHR_binary_const); 2702 } 2703 2704 2705 2706 @Test(dataProvider = "shortUnaryOpMaskProvider") 2707 static void LSHRShortMaxVectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa, 2708 IntFunction<boolean[]> fm) { 2709 short[] a = fa.apply(SPECIES.length()); 2710 short[] r = fr.apply(SPECIES.length()); 2711 boolean[] mask = fm.apply(SPECIES.length()); 2712 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2713 2714 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2715 for (int i = 0; i < a.length; i += SPECIES.length()) { 2716 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2717 av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i); 2718 } 2719 } 2720 2721 assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::LSHR_binary_const); 2722 } 2723 2724 2725 2726 static short LSHL_binary_const(short a) { 2727 return (short)((a << CONST_SHIFT)); 2728 } 2729 2730 @Test(dataProvider = "shortUnaryOpProvider") 2731 static void LSHLShortMaxVectorTestsScalarShiftConst(IntFunction<short[]> fa) { 2732 short[] a = fa.apply(SPECIES.length()); 2733 short[] r = fr.apply(SPECIES.length()); 2734 2735 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2736 for (int i = 0; i < a.length; i += SPECIES.length()) { 2737 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2738 av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i); 2739 } 2740 } 2741 2742 assertShiftConstEquals(r, a, ShortMaxVectorTests::LSHL_binary_const); 2743 } 2744 2745 2746 2747 @Test(dataProvider = "shortUnaryOpMaskProvider") 2748 static void LSHLShortMaxVectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa, 2749 IntFunction<boolean[]> fm) { 2750 short[] a = fa.apply(SPECIES.length()); 2751 short[] r = fr.apply(SPECIES.length()); 2752 boolean[] mask = fm.apply(SPECIES.length()); 2753 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2754 2755 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2756 for (int i = 0; i < a.length; i += SPECIES.length()) { 2757 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2758 av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i); 2759 } 2760 } 2761 2762 assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::LSHL_binary_const); 2763 } 2764 2765 2766 2767 static short ASHR_binary_const(short a) { 2768 return (short)((a >> CONST_SHIFT)); 2769 } 2770 2771 @Test(dataProvider = "shortUnaryOpProvider") 2772 static void ASHRShortMaxVectorTestsScalarShiftConst(IntFunction<short[]> fa) { 2773 short[] a = fa.apply(SPECIES.length()); 2774 short[] r = fr.apply(SPECIES.length()); 2775 2776 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2777 for (int i = 0; i < a.length; i += SPECIES.length()) { 2778 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2779 av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i); 2780 } 2781 } 2782 2783 assertShiftConstEquals(r, a, ShortMaxVectorTests::ASHR_binary_const); 2784 } 2785 2786 2787 2788 @Test(dataProvider = "shortUnaryOpMaskProvider") 2789 static void ASHRShortMaxVectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa, 2790 IntFunction<boolean[]> fm) { 2791 short[] a = fa.apply(SPECIES.length()); 2792 short[] r = fr.apply(SPECIES.length()); 2793 boolean[] mask = fm.apply(SPECIES.length()); 2794 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2795 2796 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2797 for (int i = 0; i < a.length; i += SPECIES.length()) { 2798 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2799 av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i); 2800 } 2801 } 2802 2803 assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::ASHR_binary_const); 2804 } 2805 2806 2807 2808 static short ROR_binary_const(short a) { 2809 return (short)(ROR_scalar(a, CONST_SHIFT)); 2810 } 2811 2812 @Test(dataProvider = "shortUnaryOpProvider") 2813 static void RORShortMaxVectorTestsScalarShiftConst(IntFunction<short[]> fa) { 2814 short[] a = fa.apply(SPECIES.length()); 2815 short[] r = fr.apply(SPECIES.length()); 2816 2817 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2818 for (int i = 0; i < a.length; i += SPECIES.length()) { 2819 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2820 av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i); 2821 } 2822 } 2823 2824 assertShiftConstEquals(r, a, ShortMaxVectorTests::ROR_binary_const); 2825 } 2826 2827 2828 2829 @Test(dataProvider = "shortUnaryOpMaskProvider") 2830 static void RORShortMaxVectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa, 2831 IntFunction<boolean[]> fm) { 2832 short[] a = fa.apply(SPECIES.length()); 2833 short[] r = fr.apply(SPECIES.length()); 2834 boolean[] mask = fm.apply(SPECIES.length()); 2835 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2836 2837 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2838 for (int i = 0; i < a.length; i += SPECIES.length()) { 2839 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2840 av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i); 2841 } 2842 } 2843 2844 assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::ROR_binary_const); 2845 } 2846 2847 2848 2849 static short ROL_binary_const(short a) { 2850 return (short)(ROL_scalar(a, CONST_SHIFT)); 2851 } 2852 2853 @Test(dataProvider = "shortUnaryOpProvider") 2854 static void ROLShortMaxVectorTestsScalarShiftConst(IntFunction<short[]> fa) { 2855 short[] a = fa.apply(SPECIES.length()); 2856 short[] r = fr.apply(SPECIES.length()); 2857 2858 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2859 for (int i = 0; i < a.length; i += SPECIES.length()) { 2860 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2861 av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i); 2862 } 2863 } 2864 2865 assertShiftConstEquals(r, a, ShortMaxVectorTests::ROL_binary_const); 2866 } 2867 2868 2869 2870 @Test(dataProvider = "shortUnaryOpMaskProvider") 2871 static void ROLShortMaxVectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa, 2872 IntFunction<boolean[]> fm) { 2873 short[] a = fa.apply(SPECIES.length()); 2874 short[] r = fr.apply(SPECIES.length()); 2875 boolean[] mask = fm.apply(SPECIES.length()); 2876 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2877 2878 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2879 for (int i = 0; i < a.length; i += SPECIES.length()) { 2880 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2881 av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i); 2882 } 2883 } 2884 2885 assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::ROL_binary_const); 2886 } 2887 2888 2889 static short MIN(short a, short b) { 2890 return (short)(Math.min(a, b)); 2891 } 2892 2893 @Test(dataProvider = "shortBinaryOpProvider") 2894 static void MINShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2895 short[] a = fa.apply(SPECIES.length()); 2896 short[] b = fb.apply(SPECIES.length()); 2897 short[] r = fr.apply(SPECIES.length()); 2898 2899 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2900 for (int i = 0; i < a.length; i += SPECIES.length()) { 2901 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2902 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 2903 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i); 2904 } 2905 } 2906 2907 assertArraysEquals(r, a, b, ShortMaxVectorTests::MIN); 2908 } 2909 static short min(short a, short b) { 2910 return (short)(Math.min(a, b)); 2911 } 2912 2913 @Test(dataProvider = "shortBinaryOpProvider") 2914 static void minShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2915 short[] a = fa.apply(SPECIES.length()); 2916 short[] b = fb.apply(SPECIES.length()); 2917 short[] r = fr.apply(SPECIES.length()); 2918 2919 for (int i = 0; i < a.length; i += SPECIES.length()) { 2920 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2921 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 2922 av.min(bv).intoArray(r, i); 2923 } 2924 2925 assertArraysEquals(r, a, b, ShortMaxVectorTests::min); 2926 } 2927 static short MAX(short a, short b) { 2928 return (short)(Math.max(a, b)); 2929 } 2930 2931 @Test(dataProvider = "shortBinaryOpProvider") 2932 static void MAXShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2933 short[] a = fa.apply(SPECIES.length()); 2934 short[] b = fb.apply(SPECIES.length()); 2935 short[] r = fr.apply(SPECIES.length()); 2936 2937 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2938 for (int i = 0; i < a.length; i += SPECIES.length()) { 2939 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2940 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 2941 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i); 2942 } 2943 } 2944 2945 assertArraysEquals(r, a, b, ShortMaxVectorTests::MAX); 2946 } 2947 static short max(short a, short b) { 2948 return (short)(Math.max(a, b)); 2949 } 2950 2951 @Test(dataProvider = "shortBinaryOpProvider") 2952 static void maxShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2953 short[] a = fa.apply(SPECIES.length()); 2954 short[] b = fb.apply(SPECIES.length()); 2955 short[] r = fr.apply(SPECIES.length()); 2956 2957 for (int i = 0; i < a.length; i += SPECIES.length()) { 2958 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2959 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 2960 av.max(bv).intoArray(r, i); 2961 } 2962 2963 assertArraysEquals(r, a, b, ShortMaxVectorTests::max); 2964 } 2965 2966 @Test(dataProvider = "shortBinaryOpProvider") 2967 static void MINShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2968 short[] a = fa.apply(SPECIES.length()); 2969 short[] b = fb.apply(SPECIES.length()); 2970 short[] r = fr.apply(SPECIES.length()); 2971 2972 for (int i = 0; i < a.length; i += SPECIES.length()) { 2973 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2974 av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); 2975 } 2976 2977 assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::MIN); 2978 } 2979 2980 @Test(dataProvider = "shortBinaryOpProvider") 2981 static void minShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2982 short[] a = fa.apply(SPECIES.length()); 2983 short[] b = fb.apply(SPECIES.length()); 2984 short[] r = fr.apply(SPECIES.length()); 2985 2986 for (int i = 0; i < a.length; i += SPECIES.length()) { 2987 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 2988 av.min(b[i]).intoArray(r, i); 2989 } 2990 2991 assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::min); 2992 } 2993 2994 @Test(dataProvider = "shortBinaryOpProvider") 2995 static void MAXShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 2996 short[] a = fa.apply(SPECIES.length()); 2997 short[] b = fb.apply(SPECIES.length()); 2998 short[] r = fr.apply(SPECIES.length()); 2999 3000 for (int i = 0; i < a.length; i += SPECIES.length()) { 3001 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3002 av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); 3003 } 3004 3005 assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::MAX); 3006 } 3007 3008 @Test(dataProvider = "shortBinaryOpProvider") 3009 static void maxShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 3010 short[] a = fa.apply(SPECIES.length()); 3011 short[] b = fb.apply(SPECIES.length()); 3012 short[] r = fr.apply(SPECIES.length()); 3013 3014 for (int i = 0; i < a.length; i += SPECIES.length()) { 3015 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3016 av.max(b[i]).intoArray(r, i); 3017 } 3018 3019 assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::max); 3020 } 3021 3022 static short ANDReduce(short[] a, int idx) { 3023 short res = -1; 3024 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3025 res &= a[i]; 3026 } 3027 3028 return res; 3029 } 3030 3031 static short ANDReduceAll(short[] a) { 3032 short res = -1; 3033 for (int i = 0; i < a.length; i += SPECIES.length()) { 3034 res &= ANDReduce(a, i); 3035 } 3036 3037 return res; 3038 } 3039 3040 3041 @Test(dataProvider = "shortUnaryOpProvider") 3042 static void ANDReduceShortMaxVectorTests(IntFunction<short[]> fa) { 3043 short[] a = fa.apply(SPECIES.length()); 3044 short[] r = fr.apply(SPECIES.length()); 3045 short ra = -1; 3046 3047 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3048 for (int i = 0; i < a.length; i += SPECIES.length()) { 3049 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3050 r[i] = av.reduceLanes(VectorOperators.AND); 3051 } 3052 } 3053 3054 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3055 ra = -1; 3056 for (int i = 0; i < a.length; i += SPECIES.length()) { 3057 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3058 ra &= av.reduceLanes(VectorOperators.AND); 3059 } 3060 } 3061 3062 assertReductionArraysEquals(r, ra, a, 3063 ShortMaxVectorTests::ANDReduce, ShortMaxVectorTests::ANDReduceAll); 3064 } 3065 3066 3067 static short ANDReduceMasked(short[] a, int idx, boolean[] mask) { 3068 short res = -1; 3069 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3070 if (mask[i % SPECIES.length()]) 3071 res &= a[i]; 3072 } 3073 3074 return res; 3075 } 3076 3077 static short ANDReduceAllMasked(short[] a, boolean[] mask) { 3078 short res = -1; 3079 for (int i = 0; i < a.length; i += SPECIES.length()) { 3080 res &= ANDReduceMasked(a, i, mask); 3081 } 3082 3083 return res; 3084 } 3085 3086 3087 @Test(dataProvider = "shortUnaryOpMaskProvider") 3088 static void ANDReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) { 3089 short[] a = fa.apply(SPECIES.length()); 3090 short[] r = fr.apply(SPECIES.length()); 3091 boolean[] mask = fm.apply(SPECIES.length()); 3092 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3093 short ra = -1; 3094 3095 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3096 for (int i = 0; i < a.length; i += SPECIES.length()) { 3097 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3098 r[i] = av.reduceLanes(VectorOperators.AND, vmask); 3099 } 3100 } 3101 3102 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3103 ra = -1; 3104 for (int i = 0; i < a.length; i += SPECIES.length()) { 3105 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3106 ra &= av.reduceLanes(VectorOperators.AND, vmask); 3107 } 3108 } 3109 3110 assertReductionArraysEqualsMasked(r, ra, a, mask, 3111 ShortMaxVectorTests::ANDReduceMasked, ShortMaxVectorTests::ANDReduceAllMasked); 3112 } 3113 3114 3115 static short ORReduce(short[] a, int idx) { 3116 short res = 0; 3117 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3118 res |= a[i]; 3119 } 3120 3121 return res; 3122 } 3123 3124 static short ORReduceAll(short[] a) { 3125 short res = 0; 3126 for (int i = 0; i < a.length; i += SPECIES.length()) { 3127 res |= ORReduce(a, i); 3128 } 3129 3130 return res; 3131 } 3132 3133 3134 @Test(dataProvider = "shortUnaryOpProvider") 3135 static void ORReduceShortMaxVectorTests(IntFunction<short[]> fa) { 3136 short[] a = fa.apply(SPECIES.length()); 3137 short[] r = fr.apply(SPECIES.length()); 3138 short ra = 0; 3139 3140 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3141 for (int i = 0; i < a.length; i += SPECIES.length()) { 3142 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3143 r[i] = av.reduceLanes(VectorOperators.OR); 3144 } 3145 } 3146 3147 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3148 ra = 0; 3149 for (int i = 0; i < a.length; i += SPECIES.length()) { 3150 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3151 ra |= av.reduceLanes(VectorOperators.OR); 3152 } 3153 } 3154 3155 assertReductionArraysEquals(r, ra, a, 3156 ShortMaxVectorTests::ORReduce, ShortMaxVectorTests::ORReduceAll); 3157 } 3158 3159 3160 static short ORReduceMasked(short[] a, int idx, boolean[] mask) { 3161 short res = 0; 3162 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3163 if (mask[i % SPECIES.length()]) 3164 res |= a[i]; 3165 } 3166 3167 return res; 3168 } 3169 3170 static short ORReduceAllMasked(short[] a, boolean[] mask) { 3171 short res = 0; 3172 for (int i = 0; i < a.length; i += SPECIES.length()) { 3173 res |= ORReduceMasked(a, i, mask); 3174 } 3175 3176 return res; 3177 } 3178 3179 3180 @Test(dataProvider = "shortUnaryOpMaskProvider") 3181 static void ORReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) { 3182 short[] a = fa.apply(SPECIES.length()); 3183 short[] r = fr.apply(SPECIES.length()); 3184 boolean[] mask = fm.apply(SPECIES.length()); 3185 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3186 short ra = 0; 3187 3188 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3189 for (int i = 0; i < a.length; i += SPECIES.length()) { 3190 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3191 r[i] = av.reduceLanes(VectorOperators.OR, vmask); 3192 } 3193 } 3194 3195 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3196 ra = 0; 3197 for (int i = 0; i < a.length; i += SPECIES.length()) { 3198 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3199 ra |= av.reduceLanes(VectorOperators.OR, vmask); 3200 } 3201 } 3202 3203 assertReductionArraysEqualsMasked(r, ra, a, mask, 3204 ShortMaxVectorTests::ORReduceMasked, ShortMaxVectorTests::ORReduceAllMasked); 3205 } 3206 3207 3208 static short XORReduce(short[] a, int idx) { 3209 short res = 0; 3210 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3211 res ^= a[i]; 3212 } 3213 3214 return res; 3215 } 3216 3217 static short XORReduceAll(short[] a) { 3218 short res = 0; 3219 for (int i = 0; i < a.length; i += SPECIES.length()) { 3220 res ^= XORReduce(a, i); 3221 } 3222 3223 return res; 3224 } 3225 3226 3227 @Test(dataProvider = "shortUnaryOpProvider") 3228 static void XORReduceShortMaxVectorTests(IntFunction<short[]> fa) { 3229 short[] a = fa.apply(SPECIES.length()); 3230 short[] r = fr.apply(SPECIES.length()); 3231 short ra = 0; 3232 3233 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3234 for (int i = 0; i < a.length; i += SPECIES.length()) { 3235 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3236 r[i] = av.reduceLanes(VectorOperators.XOR); 3237 } 3238 } 3239 3240 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3241 ra = 0; 3242 for (int i = 0; i < a.length; i += SPECIES.length()) { 3243 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3244 ra ^= av.reduceLanes(VectorOperators.XOR); 3245 } 3246 } 3247 3248 assertReductionArraysEquals(r, ra, a, 3249 ShortMaxVectorTests::XORReduce, ShortMaxVectorTests::XORReduceAll); 3250 } 3251 3252 3253 static short XORReduceMasked(short[] a, int idx, boolean[] mask) { 3254 short res = 0; 3255 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3256 if (mask[i % SPECIES.length()]) 3257 res ^= a[i]; 3258 } 3259 3260 return res; 3261 } 3262 3263 static short XORReduceAllMasked(short[] a, boolean[] mask) { 3264 short res = 0; 3265 for (int i = 0; i < a.length; i += SPECIES.length()) { 3266 res ^= XORReduceMasked(a, i, mask); 3267 } 3268 3269 return res; 3270 } 3271 3272 3273 @Test(dataProvider = "shortUnaryOpMaskProvider") 3274 static void XORReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) { 3275 short[] a = fa.apply(SPECIES.length()); 3276 short[] r = fr.apply(SPECIES.length()); 3277 boolean[] mask = fm.apply(SPECIES.length()); 3278 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3279 short ra = 0; 3280 3281 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3282 for (int i = 0; i < a.length; i += SPECIES.length()) { 3283 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3284 r[i] = av.reduceLanes(VectorOperators.XOR, vmask); 3285 } 3286 } 3287 3288 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3289 ra = 0; 3290 for (int i = 0; i < a.length; i += SPECIES.length()) { 3291 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3292 ra ^= av.reduceLanes(VectorOperators.XOR, vmask); 3293 } 3294 } 3295 3296 assertReductionArraysEqualsMasked(r, ra, a, mask, 3297 ShortMaxVectorTests::XORReduceMasked, ShortMaxVectorTests::XORReduceAllMasked); 3298 } 3299 3300 static short ADDReduce(short[] a, int idx) { 3301 short res = 0; 3302 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3303 res += a[i]; 3304 } 3305 3306 return res; 3307 } 3308 3309 static short ADDReduceAll(short[] a) { 3310 short res = 0; 3311 for (int i = 0; i < a.length; i += SPECIES.length()) { 3312 res += ADDReduce(a, i); 3313 } 3314 3315 return res; 3316 } 3317 @Test(dataProvider = "shortUnaryOpProvider") 3318 static void ADDReduceShortMaxVectorTests(IntFunction<short[]> fa) { 3319 short[] a = fa.apply(SPECIES.length()); 3320 short[] r = fr.apply(SPECIES.length()); 3321 short ra = 0; 3322 3323 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3324 for (int i = 0; i < a.length; i += SPECIES.length()) { 3325 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3326 r[i] = av.reduceLanes(VectorOperators.ADD); 3327 } 3328 } 3329 3330 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3331 ra = 0; 3332 for (int i = 0; i < a.length; i += SPECIES.length()) { 3333 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3334 ra += av.reduceLanes(VectorOperators.ADD); 3335 } 3336 } 3337 3338 assertReductionArraysEquals(r, ra, a, 3339 ShortMaxVectorTests::ADDReduce, ShortMaxVectorTests::ADDReduceAll); 3340 } 3341 static short ADDReduceMasked(short[] a, int idx, boolean[] mask) { 3342 short res = 0; 3343 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3344 if (mask[i % SPECIES.length()]) 3345 res += a[i]; 3346 } 3347 3348 return res; 3349 } 3350 3351 static short ADDReduceAllMasked(short[] a, boolean[] mask) { 3352 short res = 0; 3353 for (int i = 0; i < a.length; i += SPECIES.length()) { 3354 res += ADDReduceMasked(a, i, mask); 3355 } 3356 3357 return res; 3358 } 3359 @Test(dataProvider = "shortUnaryOpMaskProvider") 3360 static void ADDReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) { 3361 short[] a = fa.apply(SPECIES.length()); 3362 short[] r = fr.apply(SPECIES.length()); 3363 boolean[] mask = fm.apply(SPECIES.length()); 3364 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3365 short ra = 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 r[i] = av.reduceLanes(VectorOperators.ADD, vmask); 3371 } 3372 } 3373 3374 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3375 ra = 0; 3376 for (int i = 0; i < a.length; i += SPECIES.length()) { 3377 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3378 ra += av.reduceLanes(VectorOperators.ADD, vmask); 3379 } 3380 } 3381 3382 assertReductionArraysEqualsMasked(r, ra, a, mask, 3383 ShortMaxVectorTests::ADDReduceMasked, ShortMaxVectorTests::ADDReduceAllMasked); 3384 } 3385 static short MULReduce(short[] a, int idx) { 3386 short res = 1; 3387 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3388 res *= a[i]; 3389 } 3390 3391 return res; 3392 } 3393 3394 static short MULReduceAll(short[] a) { 3395 short res = 1; 3396 for (int i = 0; i < a.length; i += SPECIES.length()) { 3397 res *= MULReduce(a, i); 3398 } 3399 3400 return res; 3401 } 3402 @Test(dataProvider = "shortUnaryOpProvider") 3403 static void MULReduceShortMaxVectorTests(IntFunction<short[]> fa) { 3404 short[] a = fa.apply(SPECIES.length()); 3405 short[] r = fr.apply(SPECIES.length()); 3406 short ra = 1; 3407 3408 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3409 for (int i = 0; i < a.length; i += SPECIES.length()) { 3410 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3411 r[i] = av.reduceLanes(VectorOperators.MUL); 3412 } 3413 } 3414 3415 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3416 ra = 1; 3417 for (int i = 0; i < a.length; i += SPECIES.length()) { 3418 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3419 ra *= av.reduceLanes(VectorOperators.MUL); 3420 } 3421 } 3422 3423 assertReductionArraysEquals(r, ra, a, 3424 ShortMaxVectorTests::MULReduce, ShortMaxVectorTests::MULReduceAll); 3425 } 3426 static short MULReduceMasked(short[] a, int idx, boolean[] mask) { 3427 short res = 1; 3428 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3429 if (mask[i % SPECIES.length()]) 3430 res *= a[i]; 3431 } 3432 3433 return res; 3434 } 3435 3436 static short MULReduceAllMasked(short[] a, boolean[] mask) { 3437 short res = 1; 3438 for (int i = 0; i < a.length; i += SPECIES.length()) { 3439 res *= MULReduceMasked(a, i, mask); 3440 } 3441 3442 return res; 3443 } 3444 @Test(dataProvider = "shortUnaryOpMaskProvider") 3445 static void MULReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) { 3446 short[] a = fa.apply(SPECIES.length()); 3447 short[] r = fr.apply(SPECIES.length()); 3448 boolean[] mask = fm.apply(SPECIES.length()); 3449 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3450 short ra = 1; 3451 3452 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3453 for (int i = 0; i < a.length; i += SPECIES.length()) { 3454 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3455 r[i] = av.reduceLanes(VectorOperators.MUL, vmask); 3456 } 3457 } 3458 3459 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3460 ra = 1; 3461 for (int i = 0; i < a.length; i += SPECIES.length()) { 3462 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3463 ra *= av.reduceLanes(VectorOperators.MUL, vmask); 3464 } 3465 } 3466 3467 assertReductionArraysEqualsMasked(r, ra, a, mask, 3468 ShortMaxVectorTests::MULReduceMasked, ShortMaxVectorTests::MULReduceAllMasked); 3469 } 3470 static short MINReduce(short[] a, int idx) { 3471 short res = Short.MAX_VALUE; 3472 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3473 res = (short) Math.min(res, a[i]); 3474 } 3475 3476 return res; 3477 } 3478 3479 static short MINReduceAll(short[] a) { 3480 short res = Short.MAX_VALUE; 3481 for (int i = 0; i < a.length; i += SPECIES.length()) { 3482 res = (short) Math.min(res, MINReduce(a, i)); 3483 } 3484 3485 return res; 3486 } 3487 @Test(dataProvider = "shortUnaryOpProvider") 3488 static void MINReduceShortMaxVectorTests(IntFunction<short[]> fa) { 3489 short[] a = fa.apply(SPECIES.length()); 3490 short[] r = fr.apply(SPECIES.length()); 3491 short ra = Short.MAX_VALUE; 3492 3493 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3494 for (int i = 0; i < a.length; i += SPECIES.length()) { 3495 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3496 r[i] = av.reduceLanes(VectorOperators.MIN); 3497 } 3498 } 3499 3500 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3501 ra = Short.MAX_VALUE; 3502 for (int i = 0; i < a.length; i += SPECIES.length()) { 3503 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3504 ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); 3505 } 3506 } 3507 3508 assertReductionArraysEquals(r, ra, a, 3509 ShortMaxVectorTests::MINReduce, ShortMaxVectorTests::MINReduceAll); 3510 } 3511 static short MINReduceMasked(short[] a, int idx, boolean[] mask) { 3512 short res = Short.MAX_VALUE; 3513 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3514 if (mask[i % SPECIES.length()]) 3515 res = (short) Math.min(res, a[i]); 3516 } 3517 3518 return res; 3519 } 3520 3521 static short MINReduceAllMasked(short[] a, boolean[] mask) { 3522 short res = Short.MAX_VALUE; 3523 for (int i = 0; i < a.length; i += SPECIES.length()) { 3524 res = (short) Math.min(res, MINReduceMasked(a, i, mask)); 3525 } 3526 3527 return res; 3528 } 3529 @Test(dataProvider = "shortUnaryOpMaskProvider") 3530 static void MINReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) { 3531 short[] a = fa.apply(SPECIES.length()); 3532 short[] r = fr.apply(SPECIES.length()); 3533 boolean[] mask = fm.apply(SPECIES.length()); 3534 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3535 short ra = Short.MAX_VALUE; 3536 3537 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3538 for (int i = 0; i < a.length; i += SPECIES.length()) { 3539 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3540 r[i] = av.reduceLanes(VectorOperators.MIN, vmask); 3541 } 3542 } 3543 3544 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3545 ra = Short.MAX_VALUE; 3546 for (int i = 0; i < a.length; i += SPECIES.length()) { 3547 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3548 ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); 3549 } 3550 } 3551 3552 assertReductionArraysEqualsMasked(r, ra, a, mask, 3553 ShortMaxVectorTests::MINReduceMasked, ShortMaxVectorTests::MINReduceAllMasked); 3554 } 3555 static short MAXReduce(short[] a, int idx) { 3556 short res = Short.MIN_VALUE; 3557 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3558 res = (short) Math.max(res, a[i]); 3559 } 3560 3561 return res; 3562 } 3563 3564 static short MAXReduceAll(short[] a) { 3565 short res = Short.MIN_VALUE; 3566 for (int i = 0; i < a.length; i += SPECIES.length()) { 3567 res = (short) Math.max(res, MAXReduce(a, i)); 3568 } 3569 3570 return res; 3571 } 3572 @Test(dataProvider = "shortUnaryOpProvider") 3573 static void MAXReduceShortMaxVectorTests(IntFunction<short[]> fa) { 3574 short[] a = fa.apply(SPECIES.length()); 3575 short[] r = fr.apply(SPECIES.length()); 3576 short ra = Short.MIN_VALUE; 3577 3578 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3579 for (int i = 0; i < a.length; i += SPECIES.length()) { 3580 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3581 r[i] = av.reduceLanes(VectorOperators.MAX); 3582 } 3583 } 3584 3585 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3586 ra = Short.MIN_VALUE; 3587 for (int i = 0; i < a.length; i += SPECIES.length()) { 3588 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3589 ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); 3590 } 3591 } 3592 3593 assertReductionArraysEquals(r, ra, a, 3594 ShortMaxVectorTests::MAXReduce, ShortMaxVectorTests::MAXReduceAll); 3595 } 3596 static short MAXReduceMasked(short[] a, int idx, boolean[] mask) { 3597 short res = Short.MIN_VALUE; 3598 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3599 if (mask[i % SPECIES.length()]) 3600 res = (short) Math.max(res, a[i]); 3601 } 3602 3603 return res; 3604 } 3605 3606 static short MAXReduceAllMasked(short[] a, boolean[] mask) { 3607 short res = Short.MIN_VALUE; 3608 for (int i = 0; i < a.length; i += SPECIES.length()) { 3609 res = (short) Math.max(res, MAXReduceMasked(a, i, mask)); 3610 } 3611 3612 return res; 3613 } 3614 @Test(dataProvider = "shortUnaryOpMaskProvider") 3615 static void MAXReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) { 3616 short[] a = fa.apply(SPECIES.length()); 3617 short[] r = fr.apply(SPECIES.length()); 3618 boolean[] mask = fm.apply(SPECIES.length()); 3619 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3620 short ra = Short.MIN_VALUE; 3621 3622 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3623 for (int i = 0; i < a.length; i += SPECIES.length()) { 3624 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3625 r[i] = av.reduceLanes(VectorOperators.MAX, vmask); 3626 } 3627 } 3628 3629 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3630 ra = Short.MIN_VALUE; 3631 for (int i = 0; i < a.length; i += SPECIES.length()) { 3632 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3633 ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); 3634 } 3635 } 3636 3637 assertReductionArraysEqualsMasked(r, ra, a, mask, 3638 ShortMaxVectorTests::MAXReduceMasked, ShortMaxVectorTests::MAXReduceAllMasked); 3639 } 3640 static short FIRST_NONZEROReduce(short[] a, int idx) { 3641 short res = (short) 0; 3642 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3643 res = firstNonZero(res, a[i]); 3644 } 3645 3646 return res; 3647 } 3648 3649 static short FIRST_NONZEROReduceAll(short[] a) { 3650 short res = (short) 0; 3651 for (int i = 0; i < a.length; i += SPECIES.length()) { 3652 res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); 3653 } 3654 3655 return res; 3656 } 3657 @Test(dataProvider = "shortUnaryOpProvider") 3658 static void FIRST_NONZEROReduceShortMaxVectorTests(IntFunction<short[]> fa) { 3659 short[] a = fa.apply(SPECIES.length()); 3660 short[] r = fr.apply(SPECIES.length()); 3661 short ra = (short) 0; 3662 3663 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3664 for (int i = 0; i < a.length; i += SPECIES.length()) { 3665 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3666 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO); 3667 } 3668 } 3669 3670 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3671 ra = (short) 0; 3672 for (int i = 0; i < a.length; i += SPECIES.length()) { 3673 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3674 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); 3675 } 3676 } 3677 3678 assertReductionArraysEquals(r, ra, a, 3679 ShortMaxVectorTests::FIRST_NONZEROReduce, ShortMaxVectorTests::FIRST_NONZEROReduceAll); 3680 } 3681 static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) { 3682 short res = (short) 0; 3683 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3684 if (mask[i % SPECIES.length()]) 3685 res = firstNonZero(res, a[i]); 3686 } 3687 3688 return res; 3689 } 3690 3691 static short FIRST_NONZEROReduceAllMasked(short[] a, boolean[] mask) { 3692 short res = (short) 0; 3693 for (int i = 0; i < a.length; i += SPECIES.length()) { 3694 res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); 3695 } 3696 3697 return res; 3698 } 3699 @Test(dataProvider = "shortUnaryOpMaskProvider") 3700 static void FIRST_NONZEROReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) { 3701 short[] a = fa.apply(SPECIES.length()); 3702 short[] r = fr.apply(SPECIES.length()); 3703 boolean[] mask = fm.apply(SPECIES.length()); 3704 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3705 short ra = (short) 0; 3706 3707 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3708 for (int i = 0; i < a.length; i += SPECIES.length()) { 3709 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3710 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask); 3711 } 3712 } 3713 3714 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3715 ra = (short) 0; 3716 for (int i = 0; i < a.length; i += SPECIES.length()) { 3717 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3718 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); 3719 } 3720 } 3721 3722 assertReductionArraysEqualsMasked(r, ra, a, mask, 3723 ShortMaxVectorTests::FIRST_NONZEROReduceMasked, ShortMaxVectorTests::FIRST_NONZEROReduceAllMasked); 3724 } 3725 3726 static boolean anyTrue(boolean[] a, int idx) { 3727 boolean res = false; 3728 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3729 res |= a[i]; 3730 } 3731 3732 return res; 3733 } 3734 3735 3736 @Test(dataProvider = "boolUnaryOpProvider") 3737 static void anyTrueShortMaxVectorTests(IntFunction<boolean[]> fm) { 3738 boolean[] mask = fm.apply(SPECIES.length()); 3739 boolean[] r = fmr.apply(SPECIES.length()); 3740 3741 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3742 for (int i = 0; i < mask.length; i += SPECIES.length()) { 3743 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, i); 3744 r[i] = vmask.anyTrue(); 3745 } 3746 } 3747 3748 assertReductionBoolArraysEquals(r, mask, ShortMaxVectorTests::anyTrue); 3749 } 3750 3751 3752 static boolean allTrue(boolean[] a, int idx) { 3753 boolean res = true; 3754 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3755 res &= a[i]; 3756 } 3757 3758 return res; 3759 } 3760 3761 3762 @Test(dataProvider = "boolUnaryOpProvider") 3763 static void allTrueShortMaxVectorTests(IntFunction<boolean[]> fm) { 3764 boolean[] mask = fm.apply(SPECIES.length()); 3765 boolean[] r = fmr.apply(SPECIES.length()); 3766 3767 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3768 for (int i = 0; i < mask.length; i += SPECIES.length()) { 3769 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, i); 3770 r[i] = vmask.allTrue(); 3771 } 3772 } 3773 3774 assertReductionBoolArraysEquals(r, mask, ShortMaxVectorTests::allTrue); 3775 } 3776 3777 3778 @Test(dataProvider = "shortUnaryOpProvider") 3779 static void withShortMaxVectorTests(IntFunction<short []> fa) { 3780 short[] a = fa.apply(SPECIES.length()); 3781 short[] r = fr.apply(SPECIES.length()); 3782 3783 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3784 for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { 3785 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3786 av.withLane((j++ & (SPECIES.length()-1)), (short)(65535+i)).intoArray(r, i); 3787 } 3788 } 3789 3790 3791 for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { 3792 assertInsertArraysEquals(r, a, (short)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); 3793 } 3794 } 3795 static boolean testIS_DEFAULT(short a) { 3796 return bits(a)==0; 3797 } 3798 3799 @Test(dataProvider = "shortTestOpProvider") 3800 static void IS_DEFAULTShortMaxVectorTests(IntFunction<short[]> fa) { 3801 short[] a = fa.apply(SPECIES.length()); 3802 3803 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3804 for (int i = 0; i < a.length; i += SPECIES.length()) { 3805 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3806 VectorMask<Short> mv = av.test(VectorOperators.IS_DEFAULT); 3807 3808 // Check results as part of computation. 3809 for (int j = 0; j < SPECIES.length(); j++) { 3810 Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); 3811 } 3812 } 3813 } 3814 } 3815 3816 @Test(dataProvider = "shortTestOpMaskProvider") 3817 static void IS_DEFAULTMaskedShortMaxVectorTests(IntFunction<short[]> fa, 3818 IntFunction<boolean[]> fm) { 3819 short[] a = fa.apply(SPECIES.length()); 3820 boolean[] mask = fm.apply(SPECIES.length()); 3821 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3822 3823 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3824 for (int i = 0; i < a.length; i += SPECIES.length()) { 3825 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3826 VectorMask<Short> mv = av.test(VectorOperators.IS_DEFAULT, vmask); 3827 3828 // Check results as part of computation. 3829 for (int j = 0; j < SPECIES.length(); j++) { 3830 Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); 3831 } 3832 } 3833 } 3834 } 3835 static boolean testIS_NEGATIVE(short a) { 3836 return bits(a)<0; 3837 } 3838 3839 @Test(dataProvider = "shortTestOpProvider") 3840 static void IS_NEGATIVEShortMaxVectorTests(IntFunction<short[]> fa) { 3841 short[] a = fa.apply(SPECIES.length()); 3842 3843 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3844 for (int i = 0; i < a.length; i += SPECIES.length()) { 3845 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3846 VectorMask<Short> mv = av.test(VectorOperators.IS_NEGATIVE); 3847 3848 // Check results as part of computation. 3849 for (int j = 0; j < SPECIES.length(); j++) { 3850 Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); 3851 } 3852 } 3853 } 3854 } 3855 3856 @Test(dataProvider = "shortTestOpMaskProvider") 3857 static void IS_NEGATIVEMaskedShortMaxVectorTests(IntFunction<short[]> fa, 3858 IntFunction<boolean[]> fm) { 3859 short[] a = fa.apply(SPECIES.length()); 3860 boolean[] mask = fm.apply(SPECIES.length()); 3861 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3862 3863 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3864 for (int i = 0; i < a.length; i += SPECIES.length()) { 3865 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3866 VectorMask<Short> mv = av.test(VectorOperators.IS_NEGATIVE, vmask); 3867 3868 // Check results as part of computation. 3869 for (int j = 0; j < SPECIES.length(); j++) { 3870 Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); 3871 } 3872 } 3873 } 3874 } 3875 3876 3877 3878 3879 @Test(dataProvider = "shortCompareOpProvider") 3880 static void LTShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 3881 short[] a = fa.apply(SPECIES.length()); 3882 short[] b = fb.apply(SPECIES.length()); 3883 3884 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3885 for (int i = 0; i < a.length; i += SPECIES.length()) { 3886 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3887 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 3888 VectorMask<Short> mv = av.compare(VectorOperators.LT, bv); 3889 3890 // Check results as part of computation. 3891 for (int j = 0; j < SPECIES.length(); j++) { 3892 Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); 3893 } 3894 } 3895 } 3896 } 3897 3898 3899 @Test(dataProvider = "shortCompareOpProvider") 3900 static void ltShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 3901 short[] a = fa.apply(SPECIES.length()); 3902 short[] b = fb.apply(SPECIES.length()); 3903 3904 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3905 for (int i = 0; i < a.length; i += SPECIES.length()) { 3906 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3907 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 3908 VectorMask<Short> mv = av.lt(bv); 3909 3910 // Check results as part of computation. 3911 for (int j = 0; j < SPECIES.length(); j++) { 3912 Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); 3913 } 3914 } 3915 } 3916 } 3917 3918 @Test(dataProvider = "shortCompareOpMaskProvider") 3919 static void LTShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 3920 IntFunction<boolean[]> fm) { 3921 short[] a = fa.apply(SPECIES.length()); 3922 short[] b = fb.apply(SPECIES.length()); 3923 boolean[] mask = fm.apply(SPECIES.length()); 3924 3925 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3926 3927 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3928 for (int i = 0; i < a.length; i += SPECIES.length()) { 3929 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3930 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 3931 VectorMask<Short> mv = av.compare(VectorOperators.LT, bv, vmask); 3932 3933 // Check results as part of computation. 3934 for (int j = 0; j < SPECIES.length(); j++) { 3935 Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j])); 3936 } 3937 } 3938 } 3939 } 3940 3941 3942 @Test(dataProvider = "shortCompareOpProvider") 3943 static void GTShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 3944 short[] a = fa.apply(SPECIES.length()); 3945 short[] b = fb.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 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3950 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 3951 VectorMask<Short> mv = av.compare(VectorOperators.GT, bv); 3952 3953 // Check results as part of computation. 3954 for (int j = 0; j < SPECIES.length(); j++) { 3955 Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); 3956 } 3957 } 3958 } 3959 } 3960 3961 @Test(dataProvider = "shortCompareOpMaskProvider") 3962 static void GTShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 3963 IntFunction<boolean[]> fm) { 3964 short[] a = fa.apply(SPECIES.length()); 3965 short[] b = fb.apply(SPECIES.length()); 3966 boolean[] mask = fm.apply(SPECIES.length()); 3967 3968 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3969 3970 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3971 for (int i = 0; i < a.length; i += SPECIES.length()) { 3972 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3973 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 3974 VectorMask<Short> mv = av.compare(VectorOperators.GT, bv, vmask); 3975 3976 // Check results as part of computation. 3977 for (int j = 0; j < SPECIES.length(); j++) { 3978 Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j])); 3979 } 3980 } 3981 } 3982 } 3983 3984 3985 @Test(dataProvider = "shortCompareOpProvider") 3986 static void EQShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 3987 short[] a = fa.apply(SPECIES.length()); 3988 short[] b = fb.apply(SPECIES.length()); 3989 3990 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3991 for (int i = 0; i < a.length; i += SPECIES.length()) { 3992 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 3993 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 3994 VectorMask<Short> mv = av.compare(VectorOperators.EQ, bv); 3995 3996 // Check results as part of computation. 3997 for (int j = 0; j < SPECIES.length(); j++) { 3998 Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); 3999 } 4000 } 4001 } 4002 } 4003 4004 4005 @Test(dataProvider = "shortCompareOpProvider") 4006 static void eqShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 4007 short[] a = fa.apply(SPECIES.length()); 4008 short[] b = fb.apply(SPECIES.length()); 4009 4010 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4011 for (int i = 0; i < a.length; i += SPECIES.length()) { 4012 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4013 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4014 VectorMask<Short> mv = av.eq(bv); 4015 4016 // Check results as part of computation. 4017 for (int j = 0; j < SPECIES.length(); j++) { 4018 Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); 4019 } 4020 } 4021 } 4022 } 4023 4024 @Test(dataProvider = "shortCompareOpMaskProvider") 4025 static void EQShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 4026 IntFunction<boolean[]> fm) { 4027 short[] a = fa.apply(SPECIES.length()); 4028 short[] b = fb.apply(SPECIES.length()); 4029 boolean[] mask = fm.apply(SPECIES.length()); 4030 4031 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4032 4033 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4034 for (int i = 0; i < a.length; i += SPECIES.length()) { 4035 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4036 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4037 VectorMask<Short> mv = av.compare(VectorOperators.EQ, bv, vmask); 4038 4039 // Check results as part of computation. 4040 for (int j = 0; j < SPECIES.length(); j++) { 4041 Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j])); 4042 } 4043 } 4044 } 4045 } 4046 4047 4048 @Test(dataProvider = "shortCompareOpProvider") 4049 static void NEShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 4050 short[] a = fa.apply(SPECIES.length()); 4051 short[] b = fb.apply(SPECIES.length()); 4052 4053 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4054 for (int i = 0; i < a.length; i += SPECIES.length()) { 4055 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4056 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4057 VectorMask<Short> mv = av.compare(VectorOperators.NE, bv); 4058 4059 // Check results as part of computation. 4060 for (int j = 0; j < SPECIES.length(); j++) { 4061 Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); 4062 } 4063 } 4064 } 4065 } 4066 4067 @Test(dataProvider = "shortCompareOpMaskProvider") 4068 static void NEShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 4069 IntFunction<boolean[]> fm) { 4070 short[] a = fa.apply(SPECIES.length()); 4071 short[] b = fb.apply(SPECIES.length()); 4072 boolean[] mask = fm.apply(SPECIES.length()); 4073 4074 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4075 4076 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4077 for (int i = 0; i < a.length; i += SPECIES.length()) { 4078 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4079 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4080 VectorMask<Short> mv = av.compare(VectorOperators.NE, bv, vmask); 4081 4082 // Check results as part of computation. 4083 for (int j = 0; j < SPECIES.length(); j++) { 4084 Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j])); 4085 } 4086 } 4087 } 4088 } 4089 4090 4091 @Test(dataProvider = "shortCompareOpProvider") 4092 static void LEShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 4093 short[] a = fa.apply(SPECIES.length()); 4094 short[] b = fb.apply(SPECIES.length()); 4095 4096 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4097 for (int i = 0; i < a.length; i += SPECIES.length()) { 4098 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4099 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4100 VectorMask<Short> mv = av.compare(VectorOperators.LE, bv); 4101 4102 // Check results as part of computation. 4103 for (int j = 0; j < SPECIES.length(); j++) { 4104 Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); 4105 } 4106 } 4107 } 4108 } 4109 4110 @Test(dataProvider = "shortCompareOpMaskProvider") 4111 static void LEShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 4112 IntFunction<boolean[]> fm) { 4113 short[] a = fa.apply(SPECIES.length()); 4114 short[] b = fb.apply(SPECIES.length()); 4115 boolean[] mask = fm.apply(SPECIES.length()); 4116 4117 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4118 4119 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4120 for (int i = 0; i < a.length; i += SPECIES.length()) { 4121 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4122 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4123 VectorMask<Short> mv = av.compare(VectorOperators.LE, bv, vmask); 4124 4125 // Check results as part of computation. 4126 for (int j = 0; j < SPECIES.length(); j++) { 4127 Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j])); 4128 } 4129 } 4130 } 4131 } 4132 4133 4134 @Test(dataProvider = "shortCompareOpProvider") 4135 static void GEShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 4136 short[] a = fa.apply(SPECIES.length()); 4137 short[] b = fb.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 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4142 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4143 VectorMask<Short> mv = av.compare(VectorOperators.GE, bv); 4144 4145 // Check results as part of computation. 4146 for (int j = 0; j < SPECIES.length(); j++) { 4147 Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); 4148 } 4149 } 4150 } 4151 } 4152 4153 @Test(dataProvider = "shortCompareOpMaskProvider") 4154 static void GEShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 4155 IntFunction<boolean[]> fm) { 4156 short[] a = fa.apply(SPECIES.length()); 4157 short[] b = fb.apply(SPECIES.length()); 4158 boolean[] mask = fm.apply(SPECIES.length()); 4159 4160 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4161 4162 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4163 for (int i = 0; i < a.length; i += SPECIES.length()) { 4164 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4165 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4166 VectorMask<Short> mv = av.compare(VectorOperators.GE, bv, vmask); 4167 4168 // Check results as part of computation. 4169 for (int j = 0; j < SPECIES.length(); j++) { 4170 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j])); 4171 } 4172 } 4173 } 4174 } 4175 4176 4177 4178 @Test(dataProvider = "shortCompareOpProvider") 4179 static void UNSIGNED_LTShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 4180 short[] a = fa.apply(SPECIES.length()); 4181 short[] b = fb.apply(SPECIES.length()); 4182 4183 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4184 for (int i = 0; i < a.length; i += SPECIES.length()) { 4185 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4186 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4187 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_LT, bv); 4188 4189 // Check results as part of computation. 4190 for (int j = 0; j < SPECIES.length(); j++) { 4191 Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); 4192 } 4193 } 4194 } 4195 } 4196 4197 4198 4199 @Test(dataProvider = "shortCompareOpMaskProvider") 4200 static void UNSIGNED_LTShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 4201 IntFunction<boolean[]> fm) { 4202 short[] a = fa.apply(SPECIES.length()); 4203 short[] b = fb.apply(SPECIES.length()); 4204 boolean[] mask = fm.apply(SPECIES.length()); 4205 4206 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4207 4208 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4209 for (int i = 0; i < a.length; i += SPECIES.length()) { 4210 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4211 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4212 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); 4213 4214 // Check results as part of computation. 4215 for (int j = 0; j < SPECIES.length(); j++) { 4216 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j])); 4217 } 4218 } 4219 } 4220 } 4221 4222 4223 4224 4225 @Test(dataProvider = "shortCompareOpProvider") 4226 static void UNSIGNED_GTShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 4227 short[] a = fa.apply(SPECIES.length()); 4228 short[] b = fb.apply(SPECIES.length()); 4229 4230 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4231 for (int i = 0; i < a.length; i += SPECIES.length()) { 4232 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4233 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4234 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_GT, bv); 4235 4236 // Check results as part of computation. 4237 for (int j = 0; j < SPECIES.length(); j++) { 4238 Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); 4239 } 4240 } 4241 } 4242 } 4243 4244 4245 4246 @Test(dataProvider = "shortCompareOpMaskProvider") 4247 static void UNSIGNED_GTShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 4248 IntFunction<boolean[]> fm) { 4249 short[] a = fa.apply(SPECIES.length()); 4250 short[] b = fb.apply(SPECIES.length()); 4251 boolean[] mask = fm.apply(SPECIES.length()); 4252 4253 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4254 4255 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4256 for (int i = 0; i < a.length; i += SPECIES.length()) { 4257 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4258 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4259 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); 4260 4261 // Check results as part of computation. 4262 for (int j = 0; j < SPECIES.length(); j++) { 4263 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j])); 4264 } 4265 } 4266 } 4267 } 4268 4269 4270 4271 4272 @Test(dataProvider = "shortCompareOpProvider") 4273 static void UNSIGNED_LEShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 4274 short[] a = fa.apply(SPECIES.length()); 4275 short[] b = fb.apply(SPECIES.length()); 4276 4277 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4278 for (int i = 0; i < a.length; i += SPECIES.length()) { 4279 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4280 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4281 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_LE, bv); 4282 4283 // Check results as part of computation. 4284 for (int j = 0; j < SPECIES.length(); j++) { 4285 Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); 4286 } 4287 } 4288 } 4289 } 4290 4291 4292 4293 @Test(dataProvider = "shortCompareOpMaskProvider") 4294 static void UNSIGNED_LEShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 4295 IntFunction<boolean[]> fm) { 4296 short[] a = fa.apply(SPECIES.length()); 4297 short[] b = fb.apply(SPECIES.length()); 4298 boolean[] mask = fm.apply(SPECIES.length()); 4299 4300 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4301 4302 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4303 for (int i = 0; i < a.length; i += SPECIES.length()) { 4304 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4305 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4306 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); 4307 4308 // Check results as part of computation. 4309 for (int j = 0; j < SPECIES.length(); j++) { 4310 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j])); 4311 } 4312 } 4313 } 4314 } 4315 4316 4317 4318 4319 @Test(dataProvider = "shortCompareOpProvider") 4320 static void UNSIGNED_GEShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) { 4321 short[] a = fa.apply(SPECIES.length()); 4322 short[] b = fb.apply(SPECIES.length()); 4323 4324 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4325 for (int i = 0; i < a.length; i += SPECIES.length()) { 4326 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4327 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4328 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_GE, bv); 4329 4330 // Check results as part of computation. 4331 for (int j = 0; j < SPECIES.length(); j++) { 4332 Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); 4333 } 4334 } 4335 } 4336 } 4337 4338 4339 4340 @Test(dataProvider = "shortCompareOpMaskProvider") 4341 static void UNSIGNED_GEShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 4342 IntFunction<boolean[]> fm) { 4343 short[] a = fa.apply(SPECIES.length()); 4344 short[] b = fb.apply(SPECIES.length()); 4345 boolean[] mask = fm.apply(SPECIES.length()); 4346 4347 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4348 4349 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4350 for (int i = 0; i < a.length; i += SPECIES.length()) { 4351 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4352 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4353 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); 4354 4355 // Check results as part of computation. 4356 for (int j = 0; j < SPECIES.length(); j++) { 4357 Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j])); 4358 } 4359 } 4360 } 4361 } 4362 4363 4364 4365 @Test(dataProvider = "shortCompareOpProvider") 4366 static void LTShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 4367 short[] a = fa.apply(SPECIES.length()); 4368 short[] b = fb.apply(SPECIES.length()); 4369 4370 for (int i = 0; i < a.length; i += SPECIES.length()) { 4371 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4372 VectorMask<Short> mv = av.compare(VectorOperators.LT, b[i]); 4373 4374 // Check results as part of computation. 4375 for (int j = 0; j < SPECIES.length(); j++) { 4376 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); 4377 } 4378 } 4379 } 4380 4381 4382 @Test(dataProvider = "shortCompareOpMaskProvider") 4383 static void LTShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, 4384 IntFunction<short[]> fb, IntFunction<boolean[]> fm) { 4385 short[] a = fa.apply(SPECIES.length()); 4386 short[] b = fb.apply(SPECIES.length()); 4387 boolean[] mask = fm.apply(SPECIES.length()); 4388 4389 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4390 4391 for (int i = 0; i < a.length; i += SPECIES.length()) { 4392 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4393 VectorMask<Short> mv = av.compare(VectorOperators.LT, b[i], vmask); 4394 4395 // Check results as part of computation. 4396 for (int j = 0; j < SPECIES.length(); j++) { 4397 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); 4398 } 4399 } 4400 } 4401 4402 @Test(dataProvider = "shortCompareOpProvider") 4403 static void LTShortMaxVectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 4404 short[] a = fa.apply(SPECIES.length()); 4405 short[] b = fb.apply(SPECIES.length()); 4406 4407 for (int i = 0; i < a.length; i += SPECIES.length()) { 4408 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4409 VectorMask<Short> mv = av.compare(VectorOperators.LT, (long)b[i]); 4410 4411 // Check results as part of computation. 4412 for (int j = 0; j < SPECIES.length(); j++) { 4413 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (short)((long)b[i])); 4414 } 4415 } 4416 } 4417 4418 4419 @Test(dataProvider = "shortCompareOpMaskProvider") 4420 static void LTShortMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction<short[]> fa, 4421 IntFunction<short[]> fb, IntFunction<boolean[]> fm) { 4422 short[] a = fa.apply(SPECIES.length()); 4423 short[] b = fb.apply(SPECIES.length()); 4424 boolean[] mask = fm.apply(SPECIES.length()); 4425 4426 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4427 4428 for (int i = 0; i < a.length; i += SPECIES.length()) { 4429 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4430 VectorMask<Short> mv = av.compare(VectorOperators.LT, (long)b[i], vmask); 4431 4432 // Check results as part of computation. 4433 for (int j = 0; j < SPECIES.length(); j++) { 4434 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (short)((long)b[i]))); 4435 } 4436 } 4437 } 4438 4439 @Test(dataProvider = "shortCompareOpProvider") 4440 static void EQShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 4441 short[] a = fa.apply(SPECIES.length()); 4442 short[] b = fb.apply(SPECIES.length()); 4443 4444 for (int i = 0; i < a.length; i += SPECIES.length()) { 4445 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4446 VectorMask<Short> mv = av.compare(VectorOperators.EQ, b[i]); 4447 4448 // Check results as part of computation. 4449 for (int j = 0; j < SPECIES.length(); j++) { 4450 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); 4451 } 4452 } 4453 } 4454 4455 4456 @Test(dataProvider = "shortCompareOpMaskProvider") 4457 static void EQShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, 4458 IntFunction<short[]> fb, IntFunction<boolean[]> fm) { 4459 short[] a = fa.apply(SPECIES.length()); 4460 short[] b = fb.apply(SPECIES.length()); 4461 boolean[] mask = fm.apply(SPECIES.length()); 4462 4463 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4464 4465 for (int i = 0; i < a.length; i += SPECIES.length()) { 4466 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4467 VectorMask<Short> mv = av.compare(VectorOperators.EQ, b[i], vmask); 4468 4469 // Check results as part of computation. 4470 for (int j = 0; j < SPECIES.length(); j++) { 4471 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); 4472 } 4473 } 4474 } 4475 4476 @Test(dataProvider = "shortCompareOpProvider") 4477 static void EQShortMaxVectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 4478 short[] a = fa.apply(SPECIES.length()); 4479 short[] b = fb.apply(SPECIES.length()); 4480 4481 for (int i = 0; i < a.length; i += SPECIES.length()) { 4482 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4483 VectorMask<Short> mv = av.compare(VectorOperators.EQ, (long)b[i]); 4484 4485 // Check results as part of computation. 4486 for (int j = 0; j < SPECIES.length(); j++) { 4487 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (short)((long)b[i])); 4488 } 4489 } 4490 } 4491 4492 4493 @Test(dataProvider = "shortCompareOpMaskProvider") 4494 static void EQShortMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction<short[]> fa, 4495 IntFunction<short[]> fb, IntFunction<boolean[]> fm) { 4496 short[] a = fa.apply(SPECIES.length()); 4497 short[] b = fb.apply(SPECIES.length()); 4498 boolean[] mask = fm.apply(SPECIES.length()); 4499 4500 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4501 4502 for (int i = 0; i < a.length; i += SPECIES.length()) { 4503 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4504 VectorMask<Short> mv = av.compare(VectorOperators.EQ, (long)b[i], vmask); 4505 4506 // Check results as part of computation. 4507 for (int j = 0; j < SPECIES.length(); j++) { 4508 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (short)((long)b[i]))); 4509 } 4510 } 4511 } 4512 4513 static short blend(short a, short b, boolean mask) { 4514 return mask ? b : a; 4515 } 4516 4517 @Test(dataProvider = "shortBinaryOpMaskProvider") 4518 static void blendShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, 4519 IntFunction<boolean[]> fm) { 4520 short[] a = fa.apply(SPECIES.length()); 4521 short[] b = fb.apply(SPECIES.length()); 4522 short[] r = fr.apply(SPECIES.length()); 4523 boolean[] mask = fm.apply(SPECIES.length()); 4524 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4525 4526 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4527 for (int i = 0; i < a.length; i += SPECIES.length()) { 4528 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4529 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4530 av.blend(bv, vmask).intoArray(r, i); 4531 } 4532 } 4533 4534 assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::blend); 4535 } 4536 4537 @Test(dataProvider = "shortUnaryOpShuffleProvider") 4538 static void RearrangeShortMaxVectorTests(IntFunction<short[]> fa, 4539 BiFunction<Integer,Integer,int[]> fs) { 4540 short[] a = fa.apply(SPECIES.length()); 4541 int[] order = fs.apply(a.length, SPECIES.length()); 4542 short[] r = fr.apply(SPECIES.length()); 4543 4544 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4545 for (int i = 0; i < a.length; i += SPECIES.length()) { 4546 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4547 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i); 4548 } 4549 } 4550 4551 assertRearrangeArraysEquals(r, a, order, SPECIES.length()); 4552 } 4553 4554 @Test(dataProvider = "shortUnaryOpShuffleMaskProvider") 4555 static void RearrangeShortMaxVectorTestsMaskedSmokeTest(IntFunction<short[]> fa, 4556 BiFunction<Integer,Integer,int[]> fs, 4557 IntFunction<boolean[]> fm) { 4558 short[] a = fa.apply(SPECIES.length()); 4559 int[] order = fs.apply(a.length, SPECIES.length()); 4560 short[] r = fr.apply(SPECIES.length()); 4561 boolean[] mask = fm.apply(SPECIES.length()); 4562 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4563 4564 for (int i = 0; i < a.length; i += SPECIES.length()) { 4565 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4566 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); 4567 } 4568 4569 assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); 4570 } 4571 @Test(dataProvider = "shortUnaryOpProvider") 4572 static void getShortMaxVectorTests(IntFunction<short[]> fa) { 4573 short[] a = fa.apply(SPECIES.length()); 4574 short[] r = fr.apply(SPECIES.length()); 4575 4576 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4577 for (int i = 0; i < a.length; i += SPECIES.length()) { 4578 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4579 int num_lanes = SPECIES.length(); 4580 // Manually unroll because full unroll happens after intrinsification. 4581 // Unroll is needed because get intrinsic requires for index to be a known constant. 4582 if (num_lanes == 1) { 4583 r[i]=av.lane(0); 4584 } else if (num_lanes == 2) { 4585 r[i]=av.lane(0); 4586 r[i+1]=av.lane(1); 4587 } else if (num_lanes == 4) { 4588 r[i]=av.lane(0); 4589 r[i+1]=av.lane(1); 4590 r[i+2]=av.lane(2); 4591 r[i+3]=av.lane(3); 4592 } else if (num_lanes == 8) { 4593 r[i]=av.lane(0); 4594 r[i+1]=av.lane(1); 4595 r[i+2]=av.lane(2); 4596 r[i+3]=av.lane(3); 4597 r[i+4]=av.lane(4); 4598 r[i+5]=av.lane(5); 4599 r[i+6]=av.lane(6); 4600 r[i+7]=av.lane(7); 4601 } else if (num_lanes == 16) { 4602 r[i]=av.lane(0); 4603 r[i+1]=av.lane(1); 4604 r[i+2]=av.lane(2); 4605 r[i+3]=av.lane(3); 4606 r[i+4]=av.lane(4); 4607 r[i+5]=av.lane(5); 4608 r[i+6]=av.lane(6); 4609 r[i+7]=av.lane(7); 4610 r[i+8]=av.lane(8); 4611 r[i+9]=av.lane(9); 4612 r[i+10]=av.lane(10); 4613 r[i+11]=av.lane(11); 4614 r[i+12]=av.lane(12); 4615 r[i+13]=av.lane(13); 4616 r[i+14]=av.lane(14); 4617 r[i+15]=av.lane(15); 4618 } else if (num_lanes == 32) { 4619 r[i]=av.lane(0); 4620 r[i+1]=av.lane(1); 4621 r[i+2]=av.lane(2); 4622 r[i+3]=av.lane(3); 4623 r[i+4]=av.lane(4); 4624 r[i+5]=av.lane(5); 4625 r[i+6]=av.lane(6); 4626 r[i+7]=av.lane(7); 4627 r[i+8]=av.lane(8); 4628 r[i+9]=av.lane(9); 4629 r[i+10]=av.lane(10); 4630 r[i+11]=av.lane(11); 4631 r[i+12]=av.lane(12); 4632 r[i+13]=av.lane(13); 4633 r[i+14]=av.lane(14); 4634 r[i+15]=av.lane(15); 4635 r[i+16]=av.lane(16); 4636 r[i+17]=av.lane(17); 4637 r[i+18]=av.lane(18); 4638 r[i+19]=av.lane(19); 4639 r[i+20]=av.lane(20); 4640 r[i+21]=av.lane(21); 4641 r[i+22]=av.lane(22); 4642 r[i+23]=av.lane(23); 4643 r[i+24]=av.lane(24); 4644 r[i+25]=av.lane(25); 4645 r[i+26]=av.lane(26); 4646 r[i+27]=av.lane(27); 4647 r[i+28]=av.lane(28); 4648 r[i+29]=av.lane(29); 4649 r[i+30]=av.lane(30); 4650 r[i+31]=av.lane(31); 4651 } else if (num_lanes == 64) { 4652 r[i]=av.lane(0); 4653 r[i+1]=av.lane(1); 4654 r[i+2]=av.lane(2); 4655 r[i+3]=av.lane(3); 4656 r[i+4]=av.lane(4); 4657 r[i+5]=av.lane(5); 4658 r[i+6]=av.lane(6); 4659 r[i+7]=av.lane(7); 4660 r[i+8]=av.lane(8); 4661 r[i+9]=av.lane(9); 4662 r[i+10]=av.lane(10); 4663 r[i+11]=av.lane(11); 4664 r[i+12]=av.lane(12); 4665 r[i+13]=av.lane(13); 4666 r[i+14]=av.lane(14); 4667 r[i+15]=av.lane(15); 4668 r[i+16]=av.lane(16); 4669 r[i+17]=av.lane(17); 4670 r[i+18]=av.lane(18); 4671 r[i+19]=av.lane(19); 4672 r[i+20]=av.lane(20); 4673 r[i+21]=av.lane(21); 4674 r[i+22]=av.lane(22); 4675 r[i+23]=av.lane(23); 4676 r[i+24]=av.lane(24); 4677 r[i+25]=av.lane(25); 4678 r[i+26]=av.lane(26); 4679 r[i+27]=av.lane(27); 4680 r[i+28]=av.lane(28); 4681 r[i+29]=av.lane(29); 4682 r[i+30]=av.lane(30); 4683 r[i+31]=av.lane(31); 4684 r[i+32]=av.lane(32); 4685 r[i+33]=av.lane(33); 4686 r[i+34]=av.lane(34); 4687 r[i+35]=av.lane(35); 4688 r[i+36]=av.lane(36); 4689 r[i+37]=av.lane(37); 4690 r[i+38]=av.lane(38); 4691 r[i+39]=av.lane(39); 4692 r[i+40]=av.lane(40); 4693 r[i+41]=av.lane(41); 4694 r[i+42]=av.lane(42); 4695 r[i+43]=av.lane(43); 4696 r[i+44]=av.lane(44); 4697 r[i+45]=av.lane(45); 4698 r[i+46]=av.lane(46); 4699 r[i+47]=av.lane(47); 4700 r[i+48]=av.lane(48); 4701 r[i+49]=av.lane(49); 4702 r[i+50]=av.lane(50); 4703 r[i+51]=av.lane(51); 4704 r[i+52]=av.lane(52); 4705 r[i+53]=av.lane(53); 4706 r[i+54]=av.lane(54); 4707 r[i+55]=av.lane(55); 4708 r[i+56]=av.lane(56); 4709 r[i+57]=av.lane(57); 4710 r[i+58]=av.lane(58); 4711 r[i+59]=av.lane(59); 4712 r[i+60]=av.lane(60); 4713 r[i+61]=av.lane(61); 4714 r[i+62]=av.lane(62); 4715 r[i+63]=av.lane(63); 4716 } else { 4717 for (int j = 0; j < SPECIES.length(); j++) { 4718 r[i+j]=av.lane(j); 4719 } 4720 } 4721 } 4722 } 4723 4724 assertArraysEquals(r, a, ShortMaxVectorTests::get); 4725 } 4726 4727 @Test(dataProvider = "shortUnaryOpProvider") 4728 static void BroadcastShortMaxVectorTests(IntFunction<short[]> fa) { 4729 short[] a = fa.apply(SPECIES.length()); 4730 short[] r = new short[a.length]; 4731 4732 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4733 for (int i = 0; i < a.length; i += SPECIES.length()) { 4734 ShortVector.broadcast(SPECIES, a[i]).intoArray(r, i); 4735 } 4736 } 4737 4738 assertBroadcastArraysEquals(r, a); 4739 } 4740 4741 4742 4743 4744 4745 @Test(dataProvider = "shortUnaryOpProvider") 4746 static void ZeroShortMaxVectorTests(IntFunction<short[]> fa) { 4747 short[] a = fa.apply(SPECIES.length()); 4748 short[] r = new short[a.length]; 4749 4750 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4751 for (int i = 0; i < a.length; i += SPECIES.length()) { 4752 ShortVector.zero(SPECIES).intoArray(a, i); 4753 } 4754 } 4755 4756 Assert.assertEquals(a, r); 4757 } 4758 4759 4760 4761 4762 static short[] sliceUnary(short[] a, int origin, int idx) { 4763 short[] res = new short[SPECIES.length()]; 4764 for (int i = 0; i < SPECIES.length(); i++){ 4765 if(i+origin < SPECIES.length()) 4766 res[i] = a[idx+i+origin]; 4767 else 4768 res[i] = (short)0; 4769 } 4770 return res; 4771 } 4772 4773 @Test(dataProvider = "shortUnaryOpProvider") 4774 static void sliceUnaryShortMaxVectorTests(IntFunction<short[]> fa) { 4775 short[] a = fa.apply(SPECIES.length()); 4776 short[] r = new short[a.length]; 4777 int origin = (new java.util.Random()).nextInt(SPECIES.length()); 4778 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4779 for (int i = 0; i < a.length; i += SPECIES.length()) { 4780 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4781 av.slice(origin).intoArray(r, i); 4782 } 4783 } 4784 4785 assertArraysEquals(r, a, origin, ShortMaxVectorTests::sliceUnary); 4786 } 4787 static short[] sliceBinary(short[] a, short[] b, int origin, int idx) { 4788 short[] res = new short[SPECIES.length()]; 4789 for (int i = 0, j = 0; i < SPECIES.length(); i++){ 4790 if(i+origin < SPECIES.length()) 4791 res[i] = a[idx+i+origin]; 4792 else { 4793 res[i] = b[idx+j]; 4794 j++; 4795 } 4796 } 4797 return res; 4798 } 4799 4800 @Test(dataProvider = "shortBinaryOpProvider") 4801 static void sliceBinaryShortMaxVectorTestsBinary(IntFunction<short[]> fa, IntFunction<short[]> fb) { 4802 short[] a = fa.apply(SPECIES.length()); 4803 short[] b = fb.apply(SPECIES.length()); 4804 short[] r = new short[a.length]; 4805 int origin = (new java.util.Random()).nextInt(SPECIES.length()); 4806 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4807 for (int i = 0; i < a.length; i += SPECIES.length()) { 4808 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4809 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4810 av.slice(origin, bv).intoArray(r, i); 4811 } 4812 } 4813 4814 assertArraysEquals(r, a, b, origin, ShortMaxVectorTests::sliceBinary); 4815 } 4816 static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) { 4817 short[] res = new short[SPECIES.length()]; 4818 for (int i = 0, j = 0; i < SPECIES.length(); i++){ 4819 if(i+origin < SPECIES.length()) 4820 res[i] = mask[i] ? a[idx+i+origin] : (short)0; 4821 else { 4822 res[i] = mask[i] ? b[idx+j] : (short)0; 4823 j++; 4824 } 4825 } 4826 return res; 4827 } 4828 4829 @Test(dataProvider = "shortBinaryOpMaskProvider") 4830 static void sliceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 4831 IntFunction<boolean[]> fm) { 4832 short[] a = fa.apply(SPECIES.length()); 4833 short[] b = fb.apply(SPECIES.length()); 4834 boolean[] mask = fm.apply(SPECIES.length()); 4835 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4836 4837 short[] r = new short[a.length]; 4838 int origin = (new java.util.Random()).nextInt(SPECIES.length()); 4839 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4840 for (int i = 0; i < a.length; i += SPECIES.length()) { 4841 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4842 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4843 av.slice(origin, bv, vmask).intoArray(r, i); 4844 } 4845 } 4846 4847 assertArraysEquals(r, a, b, origin, mask, ShortMaxVectorTests::slice); 4848 } 4849 static short[] unsliceUnary(short[] a, int origin, int idx) { 4850 short[] res = new short[SPECIES.length()]; 4851 for (int i = 0, j = 0; i < SPECIES.length(); i++){ 4852 if(i < origin) 4853 res[i] = (short)0; 4854 else { 4855 res[i] = a[idx+j]; 4856 j++; 4857 } 4858 } 4859 return res; 4860 } 4861 4862 @Test(dataProvider = "shortUnaryOpProvider") 4863 static void unsliceUnaryShortMaxVectorTests(IntFunction<short[]> fa) { 4864 short[] a = fa.apply(SPECIES.length()); 4865 short[] r = new short[a.length]; 4866 int origin = (new java.util.Random()).nextInt(SPECIES.length()); 4867 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4868 for (int i = 0; i < a.length; i += SPECIES.length()) { 4869 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4870 av.unslice(origin).intoArray(r, i); 4871 } 4872 } 4873 4874 assertArraysEquals(r, a, origin, ShortMaxVectorTests::unsliceUnary); 4875 } 4876 static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) { 4877 short[] res = new short[SPECIES.length()]; 4878 for (int i = 0, j = 0; i < SPECIES.length(); i++){ 4879 if (part == 0) { 4880 if (i < origin) 4881 res[i] = b[idx+i]; 4882 else { 4883 res[i] = a[idx+j]; 4884 j++; 4885 } 4886 } else if (part == 1) { 4887 if (i < origin) 4888 res[i] = a[idx+SPECIES.length()-origin+i]; 4889 else { 4890 res[i] = b[idx+origin+j]; 4891 j++; 4892 } 4893 } 4894 } 4895 return res; 4896 } 4897 4898 @Test(dataProvider = "shortBinaryOpProvider") 4899 static void unsliceBinaryShortMaxVectorTestsBinary(IntFunction<short[]> fa, IntFunction<short[]> fb) { 4900 short[] a = fa.apply(SPECIES.length()); 4901 short[] b = fb.apply(SPECIES.length()); 4902 short[] r = new short[a.length]; 4903 int origin = (new java.util.Random()).nextInt(SPECIES.length()); 4904 int part = (new java.util.Random()).nextInt(2); 4905 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4906 for (int i = 0; i < a.length; i += SPECIES.length()) { 4907 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4908 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4909 av.unslice(origin, bv, part).intoArray(r, i); 4910 } 4911 } 4912 4913 assertArraysEquals(r, a, b, origin, part, ShortMaxVectorTests::unsliceBinary); 4914 } 4915 static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) { 4916 short[] res = new short[SPECIES.length()]; 4917 for (int i = 0, j = 0; i < SPECIES.length(); i++){ 4918 if(i+origin < SPECIES.length()) 4919 res[i] = b[idx+i+origin]; 4920 else { 4921 res[i] = b[idx+j]; 4922 j++; 4923 } 4924 } 4925 for (int i = 0; i < SPECIES.length(); i++){ 4926 res[i] = mask[i] ? a[idx+i] : res[i]; 4927 } 4928 short[] res1 = new short[SPECIES.length()]; 4929 if (part == 0) { 4930 for (int i = 0, j = 0; i < SPECIES.length(); i++){ 4931 if (i < origin) 4932 res1[i] = b[idx+i]; 4933 else { 4934 res1[i] = res[j]; 4935 j++; 4936 } 4937 } 4938 } else if (part == 1) { 4939 for (int i = 0, j = 0; i < SPECIES.length(); i++){ 4940 if (i < origin) 4941 res1[i] = res[SPECIES.length()-origin+i]; 4942 else { 4943 res1[i] = b[idx+origin+j]; 4944 j++; 4945 } 4946 } 4947 } 4948 return res1; 4949 } 4950 4951 @Test(dataProvider = "shortBinaryOpMaskProvider") 4952 static void unsliceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 4953 IntFunction<boolean[]> fm) { 4954 short[] a = fa.apply(SPECIES.length()); 4955 short[] b = fb.apply(SPECIES.length()); 4956 boolean[] mask = fm.apply(SPECIES.length()); 4957 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4958 short[] r = new short[a.length]; 4959 int origin = (new java.util.Random()).nextInt(SPECIES.length()); 4960 int part = (new java.util.Random()).nextInt(2); 4961 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4962 for (int i = 0; i < a.length; i += SPECIES.length()) { 4963 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 4964 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 4965 av.unslice(origin, bv, part, vmask).intoArray(r, i); 4966 } 4967 } 4968 4969 assertArraysEquals(r, a, b, origin, part, mask, ShortMaxVectorTests::unslice); 4970 } 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 static short BITWISE_BLEND(short a, short b, short c) { 4995 return (short)((a&~(c))|(b&c)); 4996 } 4997 static short bitwiseBlend(short a, short b, short c) { 4998 return (short)((a&~(c))|(b&c)); 4999 } 5000 5001 5002 @Test(dataProvider = "shortTernaryOpProvider") 5003 static void BITWISE_BLENDShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) { 5004 short[] a = fa.apply(SPECIES.length()); 5005 short[] b = fb.apply(SPECIES.length()); 5006 short[] c = fc.apply(SPECIES.length()); 5007 short[] r = fr.apply(SPECIES.length()); 5008 5009 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5010 for (int i = 0; i < a.length; i += SPECIES.length()) { 5011 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5012 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 5013 ShortVector cv = ShortVector.fromArray(SPECIES, c, i); 5014 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i); 5015 } 5016 } 5017 5018 assertArraysEquals(r, a, b, c, ShortMaxVectorTests::BITWISE_BLEND); 5019 } 5020 @Test(dataProvider = "shortTernaryOpProvider") 5021 static void bitwiseBlendShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) { 5022 short[] a = fa.apply(SPECIES.length()); 5023 short[] b = fb.apply(SPECIES.length()); 5024 short[] c = fc.apply(SPECIES.length()); 5025 short[] r = fr.apply(SPECIES.length()); 5026 5027 for (int i = 0; i < a.length; i += SPECIES.length()) { 5028 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5029 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 5030 ShortVector cv = ShortVector.fromArray(SPECIES, c, i); 5031 av.bitwiseBlend(bv, cv).intoArray(r, i); 5032 } 5033 5034 assertArraysEquals(r, a, b, c, ShortMaxVectorTests::bitwiseBlend); 5035 } 5036 5037 5038 @Test(dataProvider = "shortTernaryOpMaskProvider") 5039 static void BITWISE_BLENDShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb, 5040 IntFunction<short[]> fc, IntFunction<boolean[]> fm) { 5041 short[] a = fa.apply(SPECIES.length()); 5042 short[] b = fb.apply(SPECIES.length()); 5043 short[] c = fc.apply(SPECIES.length()); 5044 short[] r = fr.apply(SPECIES.length()); 5045 boolean[] mask = fm.apply(SPECIES.length()); 5046 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5047 5048 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5049 for (int i = 0; i < a.length; i += SPECIES.length()) { 5050 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5051 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 5052 ShortVector cv = ShortVector.fromArray(SPECIES, c, i); 5053 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i); 5054 } 5055 } 5056 5057 assertArraysEquals(r, a, b, c, mask, ShortMaxVectorTests::BITWISE_BLEND); 5058 } 5059 5060 5061 5062 5063 @Test(dataProvider = "shortTernaryOpProvider") 5064 static void BITWISE_BLENDShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) { 5065 short[] a = fa.apply(SPECIES.length()); 5066 short[] b = fb.apply(SPECIES.length()); 5067 short[] c = fc.apply(SPECIES.length()); 5068 short[] r = fr.apply(SPECIES.length()); 5069 5070 for (int i = 0; i < a.length; i += SPECIES.length()) { 5071 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5072 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 5073 av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); 5074 } 5075 assertBroadcastArraysEquals(r, a, b, c, ShortMaxVectorTests::BITWISE_BLEND); 5076 } 5077 5078 @Test(dataProvider = "shortTernaryOpProvider") 5079 static void BITWISE_BLENDShortMaxVectorTestsAltBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) { 5080 short[] a = fa.apply(SPECIES.length()); 5081 short[] b = fb.apply(SPECIES.length()); 5082 short[] c = fc.apply(SPECIES.length()); 5083 short[] r = fr.apply(SPECIES.length()); 5084 5085 for (int i = 0; i < a.length; i += SPECIES.length()) { 5086 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5087 ShortVector cv = ShortVector.fromArray(SPECIES, c, i); 5088 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); 5089 } 5090 assertAltBroadcastArraysEquals(r, a, b, c, ShortMaxVectorTests::BITWISE_BLEND); 5091 } 5092 @Test(dataProvider = "shortTernaryOpProvider") 5093 static void bitwiseBlendShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) { 5094 short[] a = fa.apply(SPECIES.length()); 5095 short[] b = fb.apply(SPECIES.length()); 5096 short[] c = fc.apply(SPECIES.length()); 5097 short[] r = fr.apply(SPECIES.length()); 5098 5099 for (int i = 0; i < a.length; i += SPECIES.length()) { 5100 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5101 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 5102 av.bitwiseBlend(bv, c[i]).intoArray(r, i); 5103 } 5104 assertBroadcastArraysEquals(r, a, b, c, ShortMaxVectorTests::bitwiseBlend); 5105 } 5106 5107 @Test(dataProvider = "shortTernaryOpProvider") 5108 static void bitwiseBlendShortMaxVectorTestsAltBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) { 5109 short[] a = fa.apply(SPECIES.length()); 5110 short[] b = fb.apply(SPECIES.length()); 5111 short[] c = fc.apply(SPECIES.length()); 5112 short[] r = fr.apply(SPECIES.length()); 5113 5114 for (int i = 0; i < a.length; i += SPECIES.length()) { 5115 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5116 ShortVector cv = ShortVector.fromArray(SPECIES, c, i); 5117 av.bitwiseBlend(b[i], cv).intoArray(r, i); 5118 } 5119 assertAltBroadcastArraysEquals(r, a, b, c, ShortMaxVectorTests::bitwiseBlend); 5120 } 5121 5122 5123 @Test(dataProvider = "shortTernaryOpMaskProvider") 5124 static void BITWISE_BLENDShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, 5125 IntFunction<short[]> fc, IntFunction<boolean[]> fm) { 5126 short[] a = fa.apply(SPECIES.length()); 5127 short[] b = fb.apply(SPECIES.length()); 5128 short[] c = fc.apply(SPECIES.length()); 5129 short[] r = fr.apply(SPECIES.length()); 5130 boolean[] mask = fm.apply(SPECIES.length()); 5131 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5132 5133 for (int i = 0; i < a.length; i += SPECIES.length()) { 5134 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5135 ShortVector bv = ShortVector.fromArray(SPECIES, b, i); 5136 av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); 5137 } 5138 5139 assertBroadcastArraysEquals(r, a, b, c, mask, ShortMaxVectorTests::BITWISE_BLEND); 5140 } 5141 5142 @Test(dataProvider = "shortTernaryOpMaskProvider") 5143 static void BITWISE_BLENDShortMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, 5144 IntFunction<short[]> fc, IntFunction<boolean[]> fm) { 5145 short[] a = fa.apply(SPECIES.length()); 5146 short[] b = fb.apply(SPECIES.length()); 5147 short[] c = fc.apply(SPECIES.length()); 5148 short[] r = fr.apply(SPECIES.length()); 5149 boolean[] mask = fm.apply(SPECIES.length()); 5150 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5151 5152 for (int i = 0; i < a.length; i += SPECIES.length()) { 5153 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5154 ShortVector cv = ShortVector.fromArray(SPECIES, c, i); 5155 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); 5156 } 5157 5158 assertAltBroadcastArraysEquals(r, a, b, c, mask, ShortMaxVectorTests::BITWISE_BLEND); 5159 } 5160 5161 5162 5163 5164 @Test(dataProvider = "shortTernaryOpProvider") 5165 static void BITWISE_BLENDShortMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) { 5166 short[] a = fa.apply(SPECIES.length()); 5167 short[] b = fb.apply(SPECIES.length()); 5168 short[] c = fc.apply(SPECIES.length()); 5169 short[] r = fr.apply(SPECIES.length()); 5170 5171 for (int i = 0; i < a.length; i += SPECIES.length()) { 5172 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5173 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); 5174 } 5175 5176 assertDoubleBroadcastArraysEquals(r, a, b, c, ShortMaxVectorTests::BITWISE_BLEND); 5177 } 5178 @Test(dataProvider = "shortTernaryOpProvider") 5179 static void bitwiseBlendShortMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) { 5180 short[] a = fa.apply(SPECIES.length()); 5181 short[] b = fb.apply(SPECIES.length()); 5182 short[] c = fc.apply(SPECIES.length()); 5183 short[] r = fr.apply(SPECIES.length()); 5184 5185 for (int i = 0; i < a.length; i += SPECIES.length()) { 5186 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5187 av.bitwiseBlend(b[i], c[i]).intoArray(r, i); 5188 } 5189 5190 assertDoubleBroadcastArraysEquals(r, a, b, c, ShortMaxVectorTests::bitwiseBlend); 5191 } 5192 5193 5194 @Test(dataProvider = "shortTernaryOpMaskProvider") 5195 static void BITWISE_BLENDShortMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, 5196 IntFunction<short[]> fc, IntFunction<boolean[]> fm) { 5197 short[] a = fa.apply(SPECIES.length()); 5198 short[] b = fb.apply(SPECIES.length()); 5199 short[] c = fc.apply(SPECIES.length()); 5200 short[] r = fr.apply(SPECIES.length()); 5201 boolean[] mask = fm.apply(SPECIES.length()); 5202 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5203 5204 for (int i = 0; i < a.length; i += SPECIES.length()) { 5205 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5206 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); 5207 } 5208 5209 assertDoubleBroadcastArraysEquals(r, a, b, c, mask, ShortMaxVectorTests::BITWISE_BLEND); 5210 } 5211 5212 5213 static short NEG(short a) { 5214 return (short)(-((short)a)); 5215 } 5216 5217 static short neg(short a) { 5218 return (short)(-((short)a)); 5219 } 5220 5221 @Test(dataProvider = "shortUnaryOpProvider") 5222 static void NEGShortMaxVectorTests(IntFunction<short[]> fa) { 5223 short[] a = fa.apply(SPECIES.length()); 5224 short[] r = fr.apply(SPECIES.length()); 5225 5226 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5227 for (int i = 0; i < a.length; i += SPECIES.length()) { 5228 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5229 av.lanewise(VectorOperators.NEG).intoArray(r, i); 5230 } 5231 } 5232 5233 assertArraysEquals(r, a, ShortMaxVectorTests::NEG); 5234 } 5235 5236 @Test(dataProvider = "shortUnaryOpProvider") 5237 static void negShortMaxVectorTests(IntFunction<short[]> fa) { 5238 short[] a = fa.apply(SPECIES.length()); 5239 short[] r = fr.apply(SPECIES.length()); 5240 5241 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5242 for (int i = 0; i < a.length; i += SPECIES.length()) { 5243 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5244 av.neg().intoArray(r, i); 5245 } 5246 } 5247 5248 assertArraysEquals(r, a, ShortMaxVectorTests::neg); 5249 } 5250 5251 @Test(dataProvider = "shortUnaryOpMaskProvider") 5252 static void NEGMaskedShortMaxVectorTests(IntFunction<short[]> fa, 5253 IntFunction<boolean[]> fm) { 5254 short[] a = fa.apply(SPECIES.length()); 5255 short[] r = fr.apply(SPECIES.length()); 5256 boolean[] mask = fm.apply(SPECIES.length()); 5257 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5258 5259 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5260 for (int i = 0; i < a.length; i += SPECIES.length()) { 5261 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5262 av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i); 5263 } 5264 } 5265 5266 assertArraysEquals(r, a, mask, ShortMaxVectorTests::NEG); 5267 } 5268 5269 static short ABS(short a) { 5270 return (short)(Math.abs((short)a)); 5271 } 5272 5273 static short abs(short a) { 5274 return (short)(Math.abs((short)a)); 5275 } 5276 5277 @Test(dataProvider = "shortUnaryOpProvider") 5278 static void ABSShortMaxVectorTests(IntFunction<short[]> fa) { 5279 short[] a = fa.apply(SPECIES.length()); 5280 short[] r = fr.apply(SPECIES.length()); 5281 5282 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5283 for (int i = 0; i < a.length; i += SPECIES.length()) { 5284 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5285 av.lanewise(VectorOperators.ABS).intoArray(r, i); 5286 } 5287 } 5288 5289 assertArraysEquals(r, a, ShortMaxVectorTests::ABS); 5290 } 5291 5292 @Test(dataProvider = "shortUnaryOpProvider") 5293 static void absShortMaxVectorTests(IntFunction<short[]> fa) { 5294 short[] a = fa.apply(SPECIES.length()); 5295 short[] r = fr.apply(SPECIES.length()); 5296 5297 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5298 for (int i = 0; i < a.length; i += SPECIES.length()) { 5299 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5300 av.abs().intoArray(r, i); 5301 } 5302 } 5303 5304 assertArraysEquals(r, a, ShortMaxVectorTests::abs); 5305 } 5306 5307 @Test(dataProvider = "shortUnaryOpMaskProvider") 5308 static void ABSMaskedShortMaxVectorTests(IntFunction<short[]> fa, 5309 IntFunction<boolean[]> fm) { 5310 short[] a = fa.apply(SPECIES.length()); 5311 short[] r = fr.apply(SPECIES.length()); 5312 boolean[] mask = fm.apply(SPECIES.length()); 5313 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5314 5315 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5316 for (int i = 0; i < a.length; i += SPECIES.length()) { 5317 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5318 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i); 5319 } 5320 } 5321 5322 assertArraysEquals(r, a, mask, ShortMaxVectorTests::ABS); 5323 } 5324 5325 5326 static short NOT(short a) { 5327 return (short)(~((short)a)); 5328 } 5329 5330 static short not(short a) { 5331 return (short)(~((short)a)); 5332 } 5333 5334 5335 5336 @Test(dataProvider = "shortUnaryOpProvider") 5337 static void NOTShortMaxVectorTests(IntFunction<short[]> fa) { 5338 short[] a = fa.apply(SPECIES.length()); 5339 short[] r = fr.apply(SPECIES.length()); 5340 5341 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5342 for (int i = 0; i < a.length; i += SPECIES.length()) { 5343 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5344 av.lanewise(VectorOperators.NOT).intoArray(r, i); 5345 } 5346 } 5347 5348 assertArraysEquals(r, a, ShortMaxVectorTests::NOT); 5349 } 5350 5351 @Test(dataProvider = "shortUnaryOpProvider") 5352 static void notShortMaxVectorTests(IntFunction<short[]> fa) { 5353 short[] a = fa.apply(SPECIES.length()); 5354 short[] r = fr.apply(SPECIES.length()); 5355 5356 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5357 for (int i = 0; i < a.length; i += SPECIES.length()) { 5358 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5359 av.not().intoArray(r, i); 5360 } 5361 } 5362 5363 assertArraysEquals(r, a, ShortMaxVectorTests::not); 5364 } 5365 5366 5367 5368 @Test(dataProvider = "shortUnaryOpMaskProvider") 5369 static void NOTMaskedShortMaxVectorTests(IntFunction<short[]> fa, 5370 IntFunction<boolean[]> fm) { 5371 short[] a = fa.apply(SPECIES.length()); 5372 short[] r = fr.apply(SPECIES.length()); 5373 boolean[] mask = fm.apply(SPECIES.length()); 5374 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5375 5376 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5377 for (int i = 0; i < a.length; i += SPECIES.length()) { 5378 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5379 av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i); 5380 } 5381 } 5382 5383 assertArraysEquals(r, a, mask, ShortMaxVectorTests::NOT); 5384 } 5385 5386 5387 5388 static short ZOMO(short a) { 5389 return (short)((a==0?0:-1)); 5390 } 5391 5392 5393 5394 @Test(dataProvider = "shortUnaryOpProvider") 5395 static void ZOMOShortMaxVectorTests(IntFunction<short[]> fa) { 5396 short[] a = fa.apply(SPECIES.length()); 5397 short[] r = fr.apply(SPECIES.length()); 5398 5399 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5400 for (int i = 0; i < a.length; i += SPECIES.length()) { 5401 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5402 av.lanewise(VectorOperators.ZOMO).intoArray(r, i); 5403 } 5404 } 5405 5406 assertArraysEquals(r, a, ShortMaxVectorTests::ZOMO); 5407 } 5408 5409 5410 5411 @Test(dataProvider = "shortUnaryOpMaskProvider") 5412 static void ZOMOMaskedShortMaxVectorTests(IntFunction<short[]> fa, 5413 IntFunction<boolean[]> fm) { 5414 short[] a = fa.apply(SPECIES.length()); 5415 short[] r = fr.apply(SPECIES.length()); 5416 boolean[] mask = fm.apply(SPECIES.length()); 5417 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5418 5419 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5420 for (int i = 0; i < a.length; i += SPECIES.length()) { 5421 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5422 av.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i); 5423 } 5424 } 5425 5426 assertArraysEquals(r, a, mask, ShortMaxVectorTests::ZOMO); 5427 } 5428 5429 5430 5431 5432 5433 @Test(dataProvider = "shortCompareOpProvider") 5434 static void ltShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 5435 short[] a = fa.apply(SPECIES.length()); 5436 short[] b = fb.apply(SPECIES.length()); 5437 5438 for (int i = 0; i < a.length; i += SPECIES.length()) { 5439 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5440 VectorMask<Short> mv = av.lt(b[i]); 5441 5442 // Check results as part of computation. 5443 for (int j = 0; j < SPECIES.length(); j++) { 5444 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); 5445 } 5446 } 5447 } 5448 5449 @Test(dataProvider = "shortCompareOpProvider") 5450 static void eqShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) { 5451 short[] a = fa.apply(SPECIES.length()); 5452 short[] b = fb.apply(SPECIES.length()); 5453 5454 for (int i = 0; i < a.length; i += SPECIES.length()) { 5455 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5456 VectorMask<Short> mv = av.eq(b[i]); 5457 5458 // Check results as part of computation. 5459 for (int j = 0; j < SPECIES.length(); j++) { 5460 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); 5461 } 5462 } 5463 } 5464 5465 @Test(dataProvider = "shortUnaryOpProvider") 5466 static void toIntArrayShortMaxVectorTestsSmokeTest(IntFunction<short[]> fa) { 5467 short[] a = fa.apply(SPECIES.length()); 5468 5469 for (int i = 0; i < a.length; i += SPECIES.length()) { 5470 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5471 int[] r = av.toIntArray(); 5472 assertArraysEquals(r, a, i); 5473 } 5474 } 5475 5476 @Test(dataProvider = "shortUnaryOpProvider") 5477 static void toLongArrayShortMaxVectorTestsSmokeTest(IntFunction<short[]> fa) { 5478 short[] a = fa.apply(SPECIES.length()); 5479 5480 for (int i = 0; i < a.length; i += SPECIES.length()) { 5481 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5482 long[] r = av.toLongArray(); 5483 assertArraysEquals(r, a, i); 5484 } 5485 } 5486 5487 @Test(dataProvider = "shortUnaryOpProvider") 5488 static void toDoubleArrayShortMaxVectorTestsSmokeTest(IntFunction<short[]> fa) { 5489 short[] a = fa.apply(SPECIES.length()); 5490 5491 for (int i = 0; i < a.length; i += SPECIES.length()) { 5492 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5493 double[] r = av.toDoubleArray(); 5494 assertArraysEquals(r, a, i); 5495 } 5496 } 5497 5498 @Test(dataProvider = "shortUnaryOpProvider") 5499 static void toStringShortMaxVectorTestsSmokeTest(IntFunction<short[]> fa) { 5500 short[] a = fa.apply(SPECIES.length()); 5501 5502 for (int i = 0; i < a.length; i += SPECIES.length()) { 5503 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5504 String str = av.toString(); 5505 5506 short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); 5507 Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str); 5508 } 5509 } 5510 5511 @Test(dataProvider = "shortUnaryOpProvider") 5512 static void hashCodeShortMaxVectorTestsSmokeTest(IntFunction<short[]> fa) { 5513 short[] a = fa.apply(SPECIES.length()); 5514 5515 for (int i = 0; i < a.length; i += SPECIES.length()) { 5516 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5517 int hash = av.hashCode(); 5518 5519 short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); 5520 int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); 5521 Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); 5522 } 5523 } 5524 5525 5526 static long ADDReduceLong(short[] a, int idx) { 5527 short res = 0; 5528 for (int i = idx; i < (idx + SPECIES.length()); i++) { 5529 res += a[i]; 5530 } 5531 5532 return (long)res; 5533 } 5534 5535 static long ADDReduceAllLong(short[] a) { 5536 long res = 0; 5537 for (int i = 0; i < a.length; i += SPECIES.length()) { 5538 res += ADDReduceLong(a, i); 5539 } 5540 5541 return res; 5542 } 5543 5544 @Test(dataProvider = "shortUnaryOpProvider") 5545 static void ADDReduceLongShortMaxVectorTests(IntFunction<short[]> fa) { 5546 short[] a = fa.apply(SPECIES.length()); 5547 long[] r = lfr.apply(SPECIES.length()); 5548 long ra = 0; 5549 5550 for (int i = 0; i < a.length; i += SPECIES.length()) { 5551 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5552 r[i] = av.reduceLanesToLong(VectorOperators.ADD); 5553 } 5554 5555 ra = 0; 5556 for (int i = 0; i < a.length; i ++) { 5557 ra += r[i]; 5558 } 5559 5560 assertReductionLongArraysEquals(r, ra, a, 5561 ShortMaxVectorTests::ADDReduceLong, ShortMaxVectorTests::ADDReduceAllLong); 5562 } 5563 5564 static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { 5565 short res = 0; 5566 for (int i = idx; i < (idx + SPECIES.length()); i++) { 5567 if(mask[i % SPECIES.length()]) 5568 res += a[i]; 5569 } 5570 5571 return (long)res; 5572 } 5573 5574 static long ADDReduceAllLongMasked(short[] a, boolean[] mask) { 5575 long res = 0; 5576 for (int i = 0; i < a.length; i += SPECIES.length()) { 5577 res += ADDReduceLongMasked(a, i, mask); 5578 } 5579 5580 return res; 5581 } 5582 5583 @Test(dataProvider = "shortUnaryOpMaskProvider") 5584 static void ADDReduceLongShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) { 5585 short[] a = fa.apply(SPECIES.length()); 5586 long[] r = lfr.apply(SPECIES.length()); 5587 boolean[] mask = fm.apply(SPECIES.length()); 5588 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5589 long ra = 0; 5590 5591 for (int i = 0; i < a.length; i += SPECIES.length()) { 5592 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5593 r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask); 5594 } 5595 5596 ra = 0; 5597 for (int i = 0; i < a.length; i ++) { 5598 ra += r[i]; 5599 } 5600 5601 assertReductionLongArraysEqualsMasked(r, ra, a, mask, 5602 ShortMaxVectorTests::ADDReduceLongMasked, ShortMaxVectorTests::ADDReduceAllLongMasked); 5603 } 5604 5605 @Test(dataProvider = "shortUnaryOpProvider") 5606 static void BroadcastLongShortMaxVectorTestsSmokeTest(IntFunction<short[]> fa) { 5607 short[] a = fa.apply(SPECIES.length()); 5608 short[] r = new short[a.length]; 5609 5610 for (int i = 0; i < a.length; i += SPECIES.length()) { 5611 ShortVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); 5612 } 5613 assertBroadcastArraysEquals(r, a); 5614 } 5615 5616 @Test(dataProvider = "shortBinaryOpMaskProvider") 5617 static void blendShortMaxVectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, 5618 IntFunction<boolean[]> fm) { 5619 short[] a = fa.apply(SPECIES.length()); 5620 short[] b = fb.apply(SPECIES.length()); 5621 short[] r = fr.apply(SPECIES.length()); 5622 boolean[] mask = fm.apply(SPECIES.length()); 5623 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5624 5625 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5626 for (int i = 0; i < a.length; i += SPECIES.length()) { 5627 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5628 av.blend((long)b[i], vmask).intoArray(r, i); 5629 } 5630 } 5631 assertBroadcastLongArraysEquals(r, a, b, mask, ShortMaxVectorTests::blend); 5632 } 5633 5634 5635 @Test(dataProvider = "shortUnaryOpSelectFromProvider") 5636 static void SelectFromShortMaxVectorTests(IntFunction<short[]> fa, 5637 BiFunction<Integer,Integer,short[]> fs) { 5638 short[] a = fa.apply(SPECIES.length()); 5639 short[] order = fs.apply(a.length, SPECIES.length()); 5640 short[] r = fr.apply(SPECIES.length()); 5641 5642 for (int i = 0; i < a.length; i += SPECIES.length()) { 5643 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5644 ShortVector bv = ShortVector.fromArray(SPECIES, order, i); 5645 bv.selectFrom(av).intoArray(r, i); 5646 } 5647 5648 assertSelectFromArraysEquals(r, a, order, SPECIES.length()); 5649 } 5650 5651 @Test(dataProvider = "shortUnaryOpSelectFromMaskProvider") 5652 static void SelectFromShortMaxVectorTestsMaskedSmokeTest(IntFunction<short[]> fa, 5653 BiFunction<Integer,Integer,short[]> fs, 5654 IntFunction<boolean[]> fm) { 5655 short[] a = fa.apply(SPECIES.length()); 5656 short[] order = fs.apply(a.length, SPECIES.length()); 5657 short[] r = fr.apply(SPECIES.length()); 5658 boolean[] mask = fm.apply(SPECIES.length()); 5659 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5660 5661 for (int i = 0; i < a.length; i += SPECIES.length()) { 5662 ShortVector av = ShortVector.fromArray(SPECIES, a, i); 5663 ShortVector bv = ShortVector.fromArray(SPECIES, order, i); 5664 bv.selectFrom(av, vmask).intoArray(r, i); 5665 } 5666 5667 assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); 5668 } 5669 5670 @Test(dataProvider = "shuffleProvider") 5671 static void shuffleMiscellaneousShortMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) { 5672 int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); 5673 5674 for (int i = 0; i < a.length; i += SPECIES.length()) { 5675 var shuffle = VectorShuffle.fromArray(SPECIES, a, i); 5676 int hash = shuffle.hashCode(); 5677 int length = shuffle.length(); 5678 5679 int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); 5680 int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); 5681 Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); 5682 Assert.assertEquals(length, SPECIES.length()); 5683 } 5684 } 5685 5686 @Test(dataProvider = "shuffleProvider") 5687 static void shuffleToStringShortMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) { 5688 int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); 5689 5690 for (int i = 0; i < a.length; i += SPECIES.length()) { 5691 var shuffle = VectorShuffle.fromArray(SPECIES, a, i); 5692 String str = shuffle.toString(); 5693 5694 int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); 5695 Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " + 5696 i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str); 5697 } 5698 } 5699 5700 @Test(dataProvider = "shuffleCompareOpProvider") 5701 static void shuffleEqualsShortMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fa, BiFunction<Integer,Integer,int[]> fb) { 5702 int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); 5703 int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); 5704 5705 for (int i = 0; i < a.length; i += SPECIES.length()) { 5706 var av = VectorShuffle.fromArray(SPECIES, a, i); 5707 var bv = VectorShuffle.fromArray(SPECIES, b, i); 5708 boolean eq = av.equals(bv); 5709 int to = i + SPECIES.length(); 5710 Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to)); 5711 } 5712 } 5713 5714 @Test(dataProvider = "maskCompareOpProvider") 5715 static void maskEqualsShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) { 5716 boolean[] a = fa.apply(SPECIES.length()); 5717 boolean[] b = fb.apply(SPECIES.length()); 5718 5719 for (int i = 0; i < a.length; i += SPECIES.length()) { 5720 var av = SPECIES.loadMask(a, i); 5721 var bv = SPECIES.loadMask(b, i); 5722 boolean equals = av.equals(bv); 5723 int to = i + SPECIES.length(); 5724 Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to)); 5725 } 5726 } 5727 5728 static boolean beq(boolean a, boolean b) { 5729 return (a == b); 5730 } 5731 5732 @Test(dataProvider = "maskCompareOpProvider") 5733 static void maskEqShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) { 5734 boolean[] a = fa.apply(SPECIES.length()); 5735 boolean[] b = fb.apply(SPECIES.length()); 5736 boolean[] r = new boolean[a.length]; 5737 5738 for (int i = 0; i < a.length; i += SPECIES.length()) { 5739 var av = SPECIES.loadMask(a, i); 5740 var bv = SPECIES.loadMask(b, i); 5741 var cv = av.eq(bv); 5742 cv.intoArray(r, i); 5743 } 5744 assertArraysEquals(r, a, b, ShortMaxVectorTests::beq); 5745 } 5746 5747 @Test(dataProvider = "maskProvider") 5748 static void maskHashCodeShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) { 5749 boolean[] a = fa.apply(SPECIES.length()); 5750 5751 for (int i = 0; i < a.length; i += SPECIES.length()) { 5752 var vmask = SPECIES.loadMask(a, i); 5753 int hash = vmask.hashCode(); 5754 5755 boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); 5756 int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); 5757 Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); 5758 } 5759 } 5760 5761 static int maskTrueCount(boolean[] a, int idx) { 5762 int trueCount = 0; 5763 for (int i = idx; i < idx + SPECIES.length(); i++) { 5764 trueCount += a[i] ? 1 : 0; 5765 } 5766 return trueCount; 5767 } 5768 5769 @Test(dataProvider = "maskProvider") 5770 static void maskTrueCountShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) { 5771 boolean[] a = fa.apply(SPECIES.length()); 5772 int[] r = new int[a.length]; 5773 5774 for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { 5775 for (int i = 0; i < a.length; i += SPECIES.length()) { 5776 var vmask = SPECIES.loadMask(a, i); 5777 r[i] = vmask.trueCount(); 5778 } 5779 } 5780 5781 assertMaskReductionArraysEquals(r, a, ShortMaxVectorTests::maskTrueCount); 5782 } 5783 5784 static int maskLastTrue(boolean[] a, int idx) { 5785 int i = idx + SPECIES.length() - 1; 5786 for (; i >= idx; i--) { 5787 if (a[i]) { 5788 break; 5789 } 5790 } 5791 return i - idx; 5792 } 5793 5794 @Test(dataProvider = "maskProvider") 5795 static void maskLastTrueShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) { 5796 boolean[] a = fa.apply(SPECIES.length()); 5797 int[] r = new int[a.length]; 5798 5799 for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { 5800 for (int i = 0; i < a.length; i += SPECIES.length()) { 5801 var vmask = SPECIES.loadMask(a, i); 5802 r[i] = vmask.lastTrue(); 5803 } 5804 } 5805 5806 assertMaskReductionArraysEquals(r, a, ShortMaxVectorTests::maskLastTrue); 5807 } 5808 5809 static int maskFirstTrue(boolean[] a, int idx) { 5810 int i = idx; 5811 for (; i < idx + SPECIES.length(); i++) { 5812 if (a[i]) { 5813 break; 5814 } 5815 } 5816 return i - idx; 5817 } 5818 5819 @Test(dataProvider = "maskProvider") 5820 static void maskFirstTrueShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) { 5821 boolean[] a = fa.apply(SPECIES.length()); 5822 int[] r = new int[a.length]; 5823 5824 for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { 5825 for (int i = 0; i < a.length; i += SPECIES.length()) { 5826 var vmask = SPECIES.loadMask(a, i); 5827 r[i] = vmask.firstTrue(); 5828 } 5829 } 5830 5831 assertMaskReductionArraysEquals(r, a, ShortMaxVectorTests::maskFirstTrue); 5832 } 5833 5834 5835 @DataProvider 5836 public static Object[][] offsetProvider() { 5837 return new Object[][]{ 5838 {0}, 5839 {-1}, 5840 {+1}, 5841 {+2}, 5842 {-2}, 5843 }; 5844 } 5845 5846 @Test(dataProvider = "offsetProvider") 5847 static void indexInRangeShortMaxVectorTestsSmokeTest(int offset) { 5848 int limit = SPECIES.length() * BUFFER_REPS; 5849 for (int i = 0; i < limit; i += SPECIES.length()) { 5850 var actualMask = SPECIES.indexInRange(i + offset, limit); 5851 var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit); 5852 assert(actualMask.equals(expectedMask)); 5853 for (int j = 0; j < SPECIES.length(); j++) { 5854 int index = i + j + offset; 5855 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit); 5856 } 5857 } 5858 } 5859 5860 @DataProvider 5861 public static Object[][] lengthProvider() { 5862 return new Object[][]{ 5863 {0}, 5864 {1}, 5865 {32}, 5866 {37}, 5867 {1024}, 5868 {1024+1}, 5869 {1024+5}, 5870 }; 5871 } 5872 5873 @Test(dataProvider = "lengthProvider") 5874 static void loopBoundShortMaxVectorTestsSmokeTest(int length) { 5875 int actualLoopBound = SPECIES.loopBound(length); 5876 int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); 5877 Assert.assertEquals(actualLoopBound, expectedLoopBound); 5878 } 5879 5880 @Test 5881 static void ElementSizeShortMaxVectorTestsSmokeTest() { 5882 ShortVector av = ShortVector.zero(SPECIES); 5883 int elsize = av.elementSize(); 5884 Assert.assertEquals(elsize, Short.SIZE); 5885 } 5886 5887 @Test 5888 static void VectorShapeShortMaxVectorTestsSmokeTest() { 5889 ShortVector av = ShortVector.zero(SPECIES); 5890 VectorShape vsh = av.shape(); 5891 assert(vsh.equals(VectorShape.S_Max_BIT)); 5892 } 5893 5894 @Test 5895 static void ShapeWithLanesShortMaxVectorTestsSmokeTest() { 5896 ShortVector av = ShortVector.zero(SPECIES); 5897 VectorShape vsh = av.shape(); 5898 VectorSpecies species = vsh.withLanes(short.class); 5899 assert(species.equals(SPECIES)); 5900 } 5901 5902 @Test 5903 static void ElementTypeShortMaxVectorTestsSmokeTest() { 5904 ShortVector av = ShortVector.zero(SPECIES); 5905 assert(av.species().elementType() == short.class); 5906 } 5907 5908 @Test 5909 static void SpeciesElementSizeShortMaxVectorTestsSmokeTest() { 5910 ShortVector av = ShortVector.zero(SPECIES); 5911 assert(av.species().elementSize() == Short.SIZE); 5912 } 5913 5914 @Test 5915 static void VectorTypeShortMaxVectorTestsSmokeTest() { 5916 ShortVector av = ShortVector.zero(SPECIES); 5917 assert(av.species().vectorType() == av.getClass()); 5918 } 5919 5920 @Test 5921 static void WithLanesShortMaxVectorTestsSmokeTest() { 5922 ShortVector av = ShortVector.zero(SPECIES); 5923 VectorSpecies species = av.species().withLanes(short.class); 5924 assert(species.equals(SPECIES)); 5925 } 5926 5927 @Test 5928 static void WithShapeShortMaxVectorTestsSmokeTest() { 5929 ShortVector av = ShortVector.zero(SPECIES); 5930 VectorShape vsh = av.shape(); 5931 VectorSpecies species = av.species().withShape(vsh); 5932 assert(species.equals(SPECIES)); 5933 } 5934 5935 @Test 5936 static void MaskAllTrueShortMaxVectorTestsSmokeTest() { 5937 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5938 Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); 5939 } 5940 } 5941 } 5942 --- EOF ---