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