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