1 /* 2 * Copyright (c) 2018, 2025, 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 * @key randomness 27 * 28 * @library /test/lib 29 * @modules jdk.incubator.vector 30 * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation LongMaxVectorTests 31 */ 32 33 // -- This file was mechanically generated: Do not edit! -- // 34 35 import jdk.incubator.vector.VectorShape; 36 import jdk.incubator.vector.VectorSpecies; 37 import jdk.incubator.vector.VectorShuffle; 38 import jdk.incubator.vector.VectorMask; 39 import jdk.incubator.vector.VectorOperators; 40 import jdk.incubator.vector.Vector; 41 import jdk.incubator.vector.VectorMath; 42 43 import jdk.incubator.vector.LongVector; 44 45 import org.testng.Assert; 46 import org.testng.annotations.DataProvider; 47 import org.testng.annotations.Test; 48 49 import java.lang.Integer; 50 import java.util.List; 51 import java.util.Arrays; 52 import java.util.function.BiFunction; 53 import java.util.function.IntFunction; 54 import java.util.Objects; 55 import java.util.stream.Collectors; 56 import java.util.stream.Stream; 57 58 @Test 59 public class LongMaxVectorTests extends AbstractVectorTest { 60 61 static final VectorSpecies<Long> SPECIES = 62 LongVector.SPECIES_MAX; 63 64 static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); 65 66 static LongVector bcast_vec = LongVector.broadcast(SPECIES, (long)10); 67 68 static VectorShape getMaxBit() { 69 return VectorShape.S_Max_BIT; 70 } 71 72 private static final int Max = 256; // juts so we can do N/Max 73 74 private static final long CONST_SHIFT = Long.SIZE / 2; 75 76 static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max); 77 78 static void assertArraysStrictlyEquals(long[] r, long[] a) { 79 for (int i = 0; i < a.length; i++) { 80 if (r[i] != a[i]) { 81 Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); 82 } 83 } 84 } 85 86 interface FUnOp { 87 long apply(long a); 88 } 89 90 static void assertArraysEquals(long[] r, long[] a, FUnOp f) { 91 int i = 0; 92 try { 93 for (; i < a.length; i++) { 94 Assert.assertEquals(r[i], f.apply(a[i])); 95 } 96 } catch (AssertionError e) { 97 Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); 98 } 99 } 100 101 interface FUnArrayOp { 102 long[] apply(long a); 103 } 104 105 static void assertArraysEquals(long[] r, long[] a, FUnArrayOp f) { 106 int i = 0; 107 try { 108 for (; i < a.length; i += SPECIES.length()) { 109 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), 110 f.apply(a[i])); 111 } 112 } catch (AssertionError e) { 113 long[] ref = f.apply(a[i]); 114 long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); 115 Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) 116 + ", res: " + Arrays.toString(res) 117 + "), at index #" + i); 118 } 119 } 120 121 static void assertArraysEquals(long[] r, long[] a, boolean[] mask, FUnOp f) { 122 int i = 0; 123 try { 124 for (; i < a.length; i++) { 125 Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); 126 } 127 } catch (AssertionError e) { 128 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()]); 129 } 130 } 131 132 interface FReductionOp { 133 long apply(long[] a, int idx); 134 } 135 136 interface FReductionAllOp { 137 long apply(long[] a); 138 } 139 140 static void assertReductionArraysEquals(long[] r, long rc, long[] a, 141 FReductionOp f, FReductionAllOp fa) { 142 int i = 0; 143 try { 144 Assert.assertEquals(rc, fa.apply(a)); 145 for (; i < a.length; i += SPECIES.length()) { 146 Assert.assertEquals(r[i], f.apply(a, i)); 147 } 148 } catch (AssertionError e) { 149 Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); 150 Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); 151 } 152 } 153 154 interface FReductionMaskedOp { 155 long apply(long[] a, int idx, boolean[] mask); 156 } 157 158 interface FReductionAllMaskedOp { 159 long apply(long[] a, boolean[] mask); 160 } 161 162 static void assertReductionArraysEqualsMasked(long[] r, long rc, long[] a, boolean[] mask, 163 FReductionMaskedOp f, FReductionAllMaskedOp fa) { 164 int i = 0; 165 try { 166 Assert.assertEquals(rc, fa.apply(a, mask)); 167 for (; i < a.length; i += SPECIES.length()) { 168 Assert.assertEquals(r[i], f.apply(a, i, mask)); 169 } 170 } catch (AssertionError e) { 171 Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); 172 Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); 173 } 174 } 175 176 177 interface FBoolReductionOp { 178 boolean apply(boolean[] a, int idx); 179 } 180 181 static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { 182 int i = 0; 183 try { 184 for (; i < a.length; i += SPECIES.length()) { 185 Assert.assertEquals(r[i], f.apply(a, i)); 186 } 187 } catch (AssertionError e) { 188 Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); 189 } 190 } 191 192 interface FMaskReductionOp { 193 int apply(boolean[] a, int idx); 194 } 195 196 static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReductionOp f) { 197 int i = 0; 198 try { 199 for (; i < a.length; i += SPECIES.length()) { 200 Assert.assertEquals(r[i], f.apply(a, i)); 201 } 202 } catch (AssertionError e) { 203 Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); 204 } 205 } 206 207 static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vector_len) { 208 int i = 0, j = 0; 209 try { 210 for (; i < a.length; i += vector_len) { 211 for (j = 0; j < vector_len; j++) { 212 Assert.assertEquals(r[i+j], a[i+order[i+j]]); 213 } 214 } 215 } catch (AssertionError e) { 216 int idx = i + j; 217 Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); 218 } 219 } 220 221 static void assertcompressArraysEquals(long[] r, long[] a, boolean[] m, int vector_len) { 222 int i = 0, j = 0, k = 0; 223 try { 224 for (; i < a.length; i += vector_len) { 225 k = 0; 226 for (j = 0; j < vector_len; j++) { 227 if (m[(i + j) % SPECIES.length()]) { 228 Assert.assertEquals(r[i + k], a[i + j]); 229 k++; 230 } 231 } 232 for (; k < vector_len; k++) { 233 Assert.assertEquals(r[i + k], (long)0); 234 } 235 } 236 } catch (AssertionError e) { 237 int idx = i + k; 238 if (m[(i + j) % SPECIES.length()]) { 239 Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); 240 } else { 241 Assert.assertEquals(r[idx], (long)0, "at index #" + idx); 242 } 243 } 244 } 245 246 static void assertexpandArraysEquals(long[] r, long[] a, boolean[] m, int vector_len) { 247 int i = 0, j = 0, k = 0; 248 try { 249 for (; i < a.length; i += vector_len) { 250 k = 0; 251 for (j = 0; j < vector_len; j++) { 252 if (m[(i + j) % SPECIES.length()]) { 253 Assert.assertEquals(r[i + j], a[i + k]); 254 k++; 255 } else { 256 Assert.assertEquals(r[i + j], (long)0); 257 } 258 } 259 } 260 } catch (AssertionError e) { 261 int idx = i + j; 262 if (m[idx % SPECIES.length()]) { 263 Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); 264 } else { 265 Assert.assertEquals(r[idx], (long)0, "at index #" + idx); 266 } 267 } 268 } 269 270 static void assertSelectFromTwoVectorEquals(long[] r, long[] order, long[] a, long[] b, int vector_len) { 271 int i = 0, j = 0; 272 boolean is_exceptional_idx = false; 273 int idx = 0, wrapped_index = 0, oidx = 0; 274 try { 275 for (; i < a.length; i += vector_len) { 276 for (j = 0; j < vector_len; j++) { 277 idx = i + j; 278 wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); 279 is_exceptional_idx = wrapped_index >= vector_len; 280 oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; 281 Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); 282 } 283 } 284 } catch (AssertionError e) { 285 Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); 286 } 287 } 288 289 static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int vector_len) { 290 int i = 0, j = 0; 291 try { 292 for (; i < a.length; i += vector_len) { 293 for (j = 0; j < vector_len; j++) { 294 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); 295 } 296 } 297 } catch (AssertionError e) { 298 int idx = i + j; 299 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); 300 } 301 } 302 303 static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean[] mask, int vector_len) { 304 int i = 0, j = 0; 305 try { 306 for (; i < a.length; i += vector_len) { 307 for (j = 0; j < vector_len; j++) { 308 if (mask[j % SPECIES.length()]) 309 Assert.assertEquals(r[i+j], a[i+order[i+j]]); 310 else 311 Assert.assertEquals(r[i+j], (long)0); 312 } 313 } 314 } catch (AssertionError e) { 315 int idx = i + j; 316 if (mask[j % SPECIES.length()]) 317 Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); 318 else 319 Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); 320 } 321 } 322 323 static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boolean[] mask, int vector_len) { 324 int i = 0, j = 0; 325 try { 326 for (; i < a.length; i += vector_len) { 327 for (j = 0; j < vector_len; j++) { 328 if (mask[j % SPECIES.length()]) 329 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); 330 else 331 Assert.assertEquals(r[i+j], (long)0); 332 } 333 } 334 } catch (AssertionError e) { 335 int idx = i + j; 336 if (mask[j % SPECIES.length()]) 337 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()]); 338 else 339 Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); 340 } 341 } 342 343 static void assertBroadcastArraysEquals(long[] r, long[] a) { 344 int i = 0; 345 for (; i < a.length; i += SPECIES.length()) { 346 int idx = i; 347 for (int j = idx; j < (idx + SPECIES.length()); j++) 348 a[j]=a[idx]; 349 } 350 351 try { 352 for (i = 0; i < a.length; i++) { 353 Assert.assertEquals(r[i], a[i]); 354 } 355 } catch (AssertionError e) { 356 Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); 357 } 358 } 359 360 interface FBinOp { 361 long apply(long a, long b); 362 } 363 364 interface FBinMaskOp { 365 long apply(long a, long b, boolean m); 366 367 static FBinMaskOp lift(FBinOp f) { 368 return (a, b, m) -> m ? f.apply(a, b) : a; 369 } 370 } 371 372 static void assertArraysEqualsAssociative(long[] rl, long[] rr, long[] a, long[] b, long[] c, FBinOp f) { 373 int i = 0; 374 try { 375 for (; i < a.length; i++) { 376 //Left associative 377 Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); 378 379 //Right associative 380 Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); 381 382 //Results equal sanity check 383 Assert.assertEquals(rl[i], rr[i]); 384 } 385 } catch (AssertionError e) { 386 Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); 387 Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); 388 Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); 389 } 390 } 391 392 static void assertArraysEqualsAssociative(long[] rl, long[] rr, long[] a, long[] b, long[] c, boolean[] mask, FBinOp f) { 393 assertArraysEqualsAssociative(rl, rr, a, b, c, mask, FBinMaskOp.lift(f)); 394 } 395 396 static void assertArraysEqualsAssociative(long[] rl, long[] rr, long[] a, long[] b, long[] c, boolean[] mask, FBinMaskOp f) { 397 int i = 0; 398 boolean mask_bit = false; 399 try { 400 for (; i < a.length; i++) { 401 mask_bit = mask[i % SPECIES.length()]; 402 //Left associative 403 Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); 404 405 //Right associative 406 Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); 407 408 //Results equal sanity check 409 Assert.assertEquals(rl[i], rr[i]); 410 } 411 } catch (AssertionError e) { 412 Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); 413 Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); 414 Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); 415 } 416 } 417 418 static void assertArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { 419 int i = 0; 420 try { 421 for (; i < a.length; i++) { 422 Assert.assertEquals(r[i], f.apply(a[i], b[i])); 423 } 424 } catch (AssertionError e) { 425 Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); 426 } 427 } 428 429 static void assertArraysEquals(long[] r, long[] a, long b, FBinOp f) { 430 int i = 0; 431 try { 432 for (; i < a.length; i++) { 433 Assert.assertEquals(r[i], f.apply(a[i], b)); 434 } 435 } catch (AssertionError e) { 436 Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); 437 } 438 } 439 440 static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { 441 int i = 0; 442 try { 443 for (; i < a.length; i++) { 444 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); 445 } 446 } catch (AssertionError e) { 447 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), 448 "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); 449 } 450 } 451 452 static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { 453 int i = 0; 454 try { 455 for (; i < a.length; i++) { 456 Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); 457 } 458 } catch (AssertionError e) { 459 Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()])), 460 "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); 461 } 462 } 463 464 static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { 465 assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); 466 } 467 468 static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { 469 int i = 0; 470 try { 471 for (; i < a.length; i++) { 472 Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); 473 } 474 } catch (AssertionError err) { 475 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()]); 476 } 477 } 478 479 static void assertArraysEquals(long[] r, long[] a, long b, boolean[] mask, FBinOp f) { 480 assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); 481 } 482 483 static void assertArraysEquals(long[] r, long[] a, long b, boolean[] mask, FBinMaskOp f) { 484 int i = 0; 485 try { 486 for (; i < a.length; i++) { 487 Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); 488 } 489 } catch (AssertionError err) { 490 Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); 491 } 492 } 493 494 static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { 495 assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); 496 } 497 498 static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { 499 int i = 0; 500 try { 501 for (; i < a.length; i++) { 502 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); 503 } 504 } catch (AssertionError err) { 505 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], 506 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + 507 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + 508 mask[i % SPECIES.length()]); 509 } 510 } 511 512 static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { 513 assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); 514 } 515 516 static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { 517 int i = 0; 518 try { 519 for (; i < a.length; i++) { 520 Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); 521 } 522 } catch (AssertionError err) { 523 Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), 524 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + 525 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + 526 mask[i % SPECIES.length()]); 527 } 528 } 529 530 static void assertShiftArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { 531 int i = 0; 532 int j = 0; 533 try { 534 for (; j < a.length; j += SPECIES.length()) { 535 for (i = 0; i < SPECIES.length(); i++) { 536 Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); 537 } 538 } 539 } catch (AssertionError e) { 540 Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); 541 } 542 } 543 544 static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) { 545 assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); 546 } 547 548 static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) { 549 int i = 0; 550 int j = 0; 551 try { 552 for (; j < a.length; j += SPECIES.length()) { 553 for (i = 0; i < SPECIES.length(); i++) { 554 Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); 555 } 556 } 557 } catch (AssertionError err) { 558 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]); 559 } 560 } 561 562 interface FBinConstOp { 563 long apply(long a); 564 } 565 566 interface FBinConstMaskOp { 567 long apply(long a, boolean m); 568 569 static FBinConstMaskOp lift(FBinConstOp f) { 570 return (a, m) -> m ? f.apply(a) : a; 571 } 572 } 573 574 static void assertShiftConstEquals(long[] r, long[] a, FBinConstOp f) { 575 int i = 0; 576 int j = 0; 577 try { 578 for (; j < a.length; j += SPECIES.length()) { 579 for (i = 0; i < SPECIES.length(); i++) { 580 Assert.assertEquals(r[i+j], f.apply(a[i+j])); 581 } 582 } 583 } catch (AssertionError e) { 584 Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); 585 } 586 } 587 588 static void assertShiftConstEquals(long[] r, long[] a, boolean[] mask, FBinConstOp f) { 589 assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f)); 590 } 591 592 static void assertShiftConstEquals(long[] r, long[] a, boolean[] mask, FBinConstMaskOp f) { 593 int i = 0; 594 int j = 0; 595 try { 596 for (; j < a.length; j += SPECIES.length()) { 597 for (i = 0; i < SPECIES.length(); i++) { 598 Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); 599 } 600 } 601 } catch (AssertionError err) { 602 Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); 603 } 604 } 605 606 interface FTernOp { 607 long apply(long a, long b, long c); 608 } 609 610 interface FTernMaskOp { 611 long apply(long a, long b, long c, boolean m); 612 613 static FTernMaskOp lift(FTernOp f) { 614 return (a, b, c, m) -> m ? f.apply(a, b, c) : a; 615 } 616 } 617 618 static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { 619 int i = 0; 620 try { 621 for (; i < a.length; i++) { 622 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); 623 } 624 } catch (AssertionError e) { 625 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); 626 } 627 } 628 629 static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) { 630 assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); 631 } 632 633 static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) { 634 int i = 0; 635 try { 636 for (; i < a.length; i++) { 637 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); 638 } 639 } catch (AssertionError err) { 640 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " 641 + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); 642 } 643 } 644 645 static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { 646 int i = 0; 647 try { 648 for (; i < a.length; i++) { 649 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); 650 } 651 } catch (AssertionError e) { 652 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + 653 i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + 654 c[(i / SPECIES.length()) * SPECIES.length()]); 655 } 656 } 657 658 static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { 659 int i = 0; 660 try { 661 for (; i < a.length; i++) { 662 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); 663 } 664 } catch (AssertionError e) { 665 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + 666 i + ", input1 = " + a[i] + ", input2 = " + 667 b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); 668 } 669 } 670 671 static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, 672 FTernOp f) { 673 assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); 674 } 675 676 static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, 677 FTernMaskOp f) { 678 int i = 0; 679 try { 680 for (; i < a.length; i++) { 681 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], 682 mask[i % SPECIES.length()])); 683 } 684 } catch (AssertionError err) { 685 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], 686 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + 687 b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + 688 mask[i % SPECIES.length()]); 689 } 690 } 691 692 static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, 693 FTernOp f) { 694 assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); 695 } 696 697 static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, 698 FTernMaskOp f) { 699 int i = 0; 700 try { 701 for (; i < a.length; i++) { 702 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], 703 mask[i % SPECIES.length()])); 704 } 705 } catch (AssertionError err) { 706 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], 707 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + 708 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + 709 ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); 710 } 711 } 712 713 static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) { 714 int i = 0; 715 try { 716 for (; i < a.length; i++) { 717 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], 718 c[(i / SPECIES.length()) * SPECIES.length()])); 719 } 720 } catch (AssertionError e) { 721 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], 722 c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] 723 + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + 724 c[(i / SPECIES.length()) * SPECIES.length()]); 725 } 726 } 727 728 static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, 729 FTernOp f) { 730 assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); 731 } 732 733 static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, 734 FTernMaskOp f) { 735 int i = 0; 736 try { 737 for (; i < a.length; i++) { 738 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], 739 c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); 740 } 741 } catch (AssertionError err) { 742 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], 743 c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" 744 + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + 745 ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + 746 mask[i % SPECIES.length()]); 747 } 748 } 749 750 751 752 interface FGatherScatterOp { 753 long[] apply(long[] a, int ix, int[] b, int iy); 754 } 755 756 static void assertArraysEquals(long[] r, long[] a, int[] b, FGatherScatterOp f) { 757 int i = 0; 758 try { 759 for (; i < a.length; i += SPECIES.length()) { 760 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), 761 f.apply(a, i, b, i)); 762 } 763 } catch (AssertionError e) { 764 long[] ref = f.apply(a, i, b, i); 765 long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); 766 Assert.assertEquals(res, ref, 767 "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " 768 + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) 769 + ", b: " 770 + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) 771 + " at index #" + i); 772 } 773 } 774 775 interface FGatherMaskedOp { 776 long[] apply(long[] a, int ix, boolean[] mask, int[] b, int iy); 777 } 778 779 interface FScatterMaskedOp { 780 long[] apply(long[] r, long[] a, int ix, boolean[] mask, int[] b, int iy); 781 } 782 783 static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { 784 int i = 0; 785 try { 786 for (; i < a.length; i += SPECIES.length()) { 787 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), 788 f.apply(a, i, mask, b, i)); 789 } 790 } catch (AssertionError e) { 791 long[] ref = f.apply(a, i, mask, b, i); 792 long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); 793 Assert.assertEquals(res, ref, 794 "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " 795 + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) 796 + ", b: " 797 + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) 798 + ", mask: " 799 + Arrays.toString(mask) 800 + " at index #" + i); 801 } 802 } 803 804 static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { 805 int i = 0; 806 try { 807 for (; i < a.length; i += SPECIES.length()) { 808 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), 809 f.apply(r, a, i, mask, b, i)); 810 } 811 } catch (AssertionError e) { 812 long[] ref = f.apply(r, a, i, mask, b, i); 813 long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); 814 Assert.assertEquals(res, ref, 815 "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " 816 + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) 817 + ", b: " 818 + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) 819 + ", r: " 820 + Arrays.toString(Arrays.copyOfRange(r, i, i+SPECIES.length())) 821 + ", mask: " 822 + Arrays.toString(mask) 823 + " at index #" + i); 824 } 825 } 826 827 interface FLaneOp { 828 long[] apply(long[] a, int origin, int idx); 829 } 830 831 static void assertArraysEquals(long[] r, long[] a, int origin, FLaneOp f) { 832 int i = 0; 833 try { 834 for (; i < a.length; i += SPECIES.length()) { 835 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), 836 f.apply(a, origin, i)); 837 } 838 } catch (AssertionError e) { 839 long[] ref = f.apply(a, origin, i); 840 long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); 841 Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) 842 + ", res: " + Arrays.toString(res) 843 + "), at index #" + i); 844 } 845 } 846 847 interface FLaneBop { 848 long[] apply(long[] a, long[] b, int origin, int idx); 849 } 850 851 static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, FLaneBop f) { 852 int i = 0; 853 try { 854 for (; i < a.length; i += SPECIES.length()) { 855 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), 856 f.apply(a, b, origin, i)); 857 } 858 } catch (AssertionError e) { 859 long[] ref = f.apply(a, b, origin, i); 860 long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); 861 Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) 862 + ", res: " + Arrays.toString(res) 863 + "), at index #" + i 864 + ", at origin #" + origin); 865 } 866 } 867 868 interface FLaneMaskedBop { 869 long[] apply(long[] a, long[] b, int origin, boolean[] mask, int idx); 870 } 871 872 static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, boolean[] mask, FLaneMaskedBop f) { 873 int i = 0; 874 try { 875 for (; i < a.length; i += SPECIES.length()) { 876 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), 877 f.apply(a, b, origin, mask, i)); 878 } 879 } catch (AssertionError e) { 880 long[] ref = f.apply(a, b, origin, mask, i); 881 long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); 882 Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) 883 + ", res: " + Arrays.toString(res) 884 + "), at index #" + i 885 + ", at origin #" + origin); 886 } 887 } 888 889 interface FLanePartBop { 890 long[] apply(long[] a, long[] b, int origin, int part, int idx); 891 } 892 893 static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int part, FLanePartBop f) { 894 int i = 0; 895 try { 896 for (; i < a.length; i += SPECIES.length()) { 897 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), 898 f.apply(a, b, origin, part, i)); 899 } 900 } catch (AssertionError e) { 901 long[] ref = f.apply(a, b, origin, part, i); 902 long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); 903 Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) 904 + ", res: " + Arrays.toString(res) 905 + "), at index #" + i 906 + ", at origin #" + origin 907 + ", with part #" + part); 908 } 909 } 910 911 interface FLanePartMaskedBop { 912 long[] apply(long[] a, long[] b, int origin, int part, boolean[] mask, int idx); 913 } 914 915 static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { 916 int i = 0; 917 try { 918 for (; i < a.length; i += SPECIES.length()) { 919 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), 920 f.apply(a, b, origin, part, mask, i)); 921 } 922 } catch (AssertionError e) { 923 long[] ref = f.apply(a, b, origin, part, mask, i); 924 long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); 925 Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) 926 + ", res: " + Arrays.toString(res) 927 + "), at index #" + i 928 + ", at origin #" + origin 929 + ", with part #" + part); 930 } 931 } 932 933 static int intCornerCaseValue(int i) { 934 switch(i % 5) { 935 case 0: 936 return Integer.MAX_VALUE; 937 case 1: 938 return Integer.MIN_VALUE; 939 case 2: 940 return Integer.MIN_VALUE; 941 case 3: 942 return Integer.MAX_VALUE; 943 default: 944 return (int)0; 945 } 946 } 947 948 static final List<IntFunction<long[]>> INT_LONG_GENERATORS = List.of( 949 withToString("long[-i * 5]", (int s) -> { 950 return fill(s * BUFFER_REPS, 951 i -> (long)(-i * 5)); 952 }), 953 withToString("long[i * 5]", (int s) -> { 954 return fill(s * BUFFER_REPS, 955 i -> (long)(i * 5)); 956 }), 957 withToString("long[i + 1]", (int s) -> { 958 return fill(s * BUFFER_REPS, 959 i -> (((long)(i + 1) == 0) ? 1 : (long)(i + 1))); 960 }), 961 withToString("long[intCornerCaseValue(i)]", (int s) -> { 962 return fill(s * BUFFER_REPS, 963 i -> (long)intCornerCaseValue(i)); 964 }) 965 ); 966 967 static void assertArraysEquals(int[] r, long[] a, int offs) { 968 int i = 0; 969 try { 970 for (; i < r.length; i++) { 971 Assert.assertEquals(r[i], (int)(a[i+offs])); 972 } 973 } catch (AssertionError e) { 974 Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); 975 } 976 } 977 978 979 980 static void assertArraysEquals(long[] r, long[] a, int offs) { 981 int i = 0; 982 try { 983 for (; i < r.length; i++) { 984 Assert.assertEquals(r[i], (long)(a[i+offs])); 985 } 986 } catch (AssertionError e) { 987 Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); 988 } 989 } 990 991 static void assertArraysEquals(double[] r, long[] a, int offs) { 992 int i = 0; 993 try { 994 for (; i < r.length; i++) { 995 Assert.assertEquals(r[i], (double)(a[i+offs])); 996 } 997 } catch (AssertionError e) { 998 Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); 999 } 1000 } 1001 1002 static long bits(long e) { 1003 return e; 1004 } 1005 1006 static final List<IntFunction<long[]>> LONG_GENERATORS = List.of( 1007 withToString("long[-i * 5]", (int s) -> { 1008 return fill(s * BUFFER_REPS, 1009 i -> (long)(-i * 5)); 1010 }), 1011 withToString("long[i * 5]", (int s) -> { 1012 return fill(s * BUFFER_REPS, 1013 i -> (long)(i * 5)); 1014 }), 1015 withToString("long[i + 1]", (int s) -> { 1016 return fill(s * BUFFER_REPS, 1017 i -> (((long)(i + 1) == 0) ? 1 : (long)(i + 1))); 1018 }), 1019 withToString("long[cornerCaseValue(i)]", (int s) -> { 1020 return fill(s * BUFFER_REPS, 1021 i -> cornerCaseValue(i)); 1022 }) 1023 ); 1024 1025 static final List<IntFunction<long[]>> LONG_SATURATING_GENERATORS = List.of( 1026 withToString("long[Long.MIN_VALUE]", (int s) -> { 1027 return fill(s * BUFFER_REPS, 1028 i -> (long)(Long.MIN_VALUE)); 1029 }), 1030 withToString("long[Long.MAX_VALUE]", (int s) -> { 1031 return fill(s * BUFFER_REPS, 1032 i -> (long)(Long.MAX_VALUE)); 1033 }), 1034 withToString("long[Long.MAX_VALUE - 100]", (int s) -> { 1035 return fill(s * BUFFER_REPS, 1036 i -> (long)(Long.MAX_VALUE - 100)); 1037 }), 1038 withToString("long[Long.MIN_VALUE + 100]", (int s) -> { 1039 return fill(s * BUFFER_REPS, 1040 i -> (long)(Long.MIN_VALUE + 100)); 1041 }), 1042 withToString("long[-i * 5]", (int s) -> { 1043 return fill(s * BUFFER_REPS, 1044 i -> (long)(-i * 5)); 1045 }), 1046 withToString("long[i * 5]", (int s) -> { 1047 return fill(s * BUFFER_REPS, 1048 i -> (long)(i * 5)); 1049 }) 1050 ); 1051 1052 static final List<IntFunction<long[]>> LONG_SATURATING_GENERATORS_ASSOC = List.of( 1053 withToString("long[Long.MAX_VALUE]", (int s) -> { 1054 return fill(s * BUFFER_REPS, 1055 i -> (long)(Long.MAX_VALUE)); 1056 }), 1057 withToString("long[Long.MAX_VALUE - 100]", (int s) -> { 1058 return fill(s * BUFFER_REPS, 1059 i -> (long)(Long.MAX_VALUE - 100)); 1060 }), 1061 withToString("long[-1]", (int s) -> { 1062 return fill(s * BUFFER_REPS, 1063 i -> (long)(-1)); 1064 }) 1065 ); 1066 1067 // Create combinations of pairs 1068 // @@@ Might be sensitive to order e.g. div by 0 1069 static final List<List<IntFunction<long[]>>> LONG_GENERATOR_PAIRS = 1070 Stream.of(LONG_GENERATORS.get(0)). 1071 flatMap(fa -> LONG_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). 1072 collect(Collectors.toList()); 1073 1074 static final List<List<IntFunction<long[]>>> LONG_SATURATING_GENERATOR_PAIRS = 1075 Stream.of(LONG_GENERATORS.get(0)). 1076 flatMap(fa -> LONG_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). 1077 collect(Collectors.toList()); 1078 1079 static final List<List<IntFunction<long[]>>> LONG_SATURATING_GENERATOR_TRIPLETS = 1080 Stream.of(LONG_GENERATORS.get(1)) 1081 .flatMap(fa -> LONG_SATURATING_GENERATORS_ASSOC.stream().map(fb -> List.of(fa, fb))) 1082 .flatMap(pair -> LONG_SATURATING_GENERATORS_ASSOC.stream().map(f -> List.of(pair.get(0), pair.get(1), f))) 1083 .collect(Collectors.toList()); 1084 1085 @DataProvider 1086 public Object[][] boolUnaryOpProvider() { 1087 return BOOL_ARRAY_GENERATORS.stream(). 1088 map(f -> new Object[]{f}). 1089 toArray(Object[][]::new); 1090 } 1091 1092 static final List<List<IntFunction<long[]>>> LONG_GENERATOR_TRIPLES = 1093 LONG_GENERATOR_PAIRS.stream(). 1094 flatMap(pair -> LONG_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))). 1095 collect(Collectors.toList()); 1096 1097 static final List<IntFunction<long[]>> SELECT_FROM_INDEX_GENERATORS = List.of( 1098 withToString("long[0..VECLEN*2)", (int s) -> { 1099 return fill(s * BUFFER_REPS, 1100 i -> (long)(RAND.nextInt())); 1101 }) 1102 ); 1103 1104 static final List<List<IntFunction<long[]>>> LONG_GENERATOR_SELECT_FROM_TRIPLES = 1105 LONG_GENERATOR_PAIRS.stream(). 1106 flatMap(pair -> SELECT_FROM_INDEX_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))). 1107 collect(Collectors.toList()); 1108 1109 @DataProvider 1110 public Object[][] longBinaryOpProvider() { 1111 return LONG_GENERATOR_PAIRS.stream().map(List::toArray). 1112 toArray(Object[][]::new); 1113 } 1114 1115 @DataProvider 1116 public Object[][] longSaturatingBinaryOpProvider() { 1117 return LONG_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). 1118 toArray(Object[][]::new); 1119 } 1120 1121 @DataProvider 1122 public Object[][] longSaturatingBinaryOpAssocProvider() { 1123 return LONG_SATURATING_GENERATOR_TRIPLETS.stream().map(List::toArray). 1124 toArray(Object[][]::new); 1125 } 1126 1127 @DataProvider 1128 public Object[][] longSaturatingBinaryOpAssocMaskProvider() { 1129 return BOOLEAN_MASK_GENERATORS.stream(). 1130 flatMap(fm -> LONG_SATURATING_GENERATOR_TRIPLETS.stream().map(lfa -> { 1131 return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); 1132 })). 1133 toArray(Object[][]::new); 1134 } 1135 1136 1137 @DataProvider 1138 public Object[][] longIndexedOpProvider() { 1139 return LONG_GENERATOR_PAIRS.stream().map(List::toArray). 1140 toArray(Object[][]::new); 1141 } 1142 1143 @DataProvider 1144 public Object[][] longSaturatingBinaryOpMaskProvider() { 1145 return BOOLEAN_MASK_GENERATORS.stream(). 1146 flatMap(fm -> LONG_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { 1147 return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); 1148 })). 1149 toArray(Object[][]::new); 1150 } 1151 1152 @DataProvider 1153 public Object[][] longSaturatingUnaryOpProvider() { 1154 return LONG_SATURATING_GENERATORS.stream(). 1155 map(f -> new Object[]{f}). 1156 toArray(Object[][]::new); 1157 } 1158 1159 @DataProvider 1160 public Object[][] longSaturatingUnaryOpMaskProvider() { 1161 return BOOLEAN_MASK_GENERATORS.stream(). 1162 flatMap(fm -> LONG_SATURATING_GENERATORS.stream().map(fa -> { 1163 return new Object[] {fa, fm}; 1164 })). 1165 toArray(Object[][]::new); 1166 } 1167 1168 @DataProvider 1169 public Object[][] longBinaryOpMaskProvider() { 1170 return BOOLEAN_MASK_GENERATORS.stream(). 1171 flatMap(fm -> LONG_GENERATOR_PAIRS.stream().map(lfa -> { 1172 return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); 1173 })). 1174 toArray(Object[][]::new); 1175 } 1176 1177 @DataProvider 1178 public Object[][] longTernaryOpProvider() { 1179 return LONG_GENERATOR_TRIPLES.stream().map(List::toArray). 1180 toArray(Object[][]::new); 1181 } 1182 1183 @DataProvider 1184 public Object[][] longSelectFromTwoVectorOpProvider() { 1185 return LONG_GENERATOR_SELECT_FROM_TRIPLES.stream().map(List::toArray). 1186 toArray(Object[][]::new); 1187 } 1188 1189 @DataProvider 1190 public Object[][] longTernaryOpMaskProvider() { 1191 return BOOLEAN_MASK_GENERATORS.stream(). 1192 flatMap(fm -> LONG_GENERATOR_TRIPLES.stream().map(lfa -> { 1193 return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); 1194 })). 1195 toArray(Object[][]::new); 1196 } 1197 1198 @DataProvider 1199 public Object[][] longUnaryOpProvider() { 1200 return LONG_GENERATORS.stream(). 1201 map(f -> new Object[]{f}). 1202 toArray(Object[][]::new); 1203 } 1204 1205 @DataProvider 1206 public Object[][] longUnaryOpMaskProvider() { 1207 return BOOLEAN_MASK_GENERATORS.stream(). 1208 flatMap(fm -> LONG_GENERATORS.stream().map(fa -> { 1209 return new Object[] {fa, fm}; 1210 })). 1211 toArray(Object[][]::new); 1212 } 1213 1214 @DataProvider 1215 public Object[][] longtoIntUnaryOpProvider() { 1216 return INT_LONG_GENERATORS.stream(). 1217 map(f -> new Object[]{f}). 1218 toArray(Object[][]::new); 1219 } 1220 1221 @DataProvider 1222 public Object[][] maskProvider() { 1223 return BOOLEAN_MASK_GENERATORS.stream(). 1224 map(f -> new Object[]{f}). 1225 toArray(Object[][]::new); 1226 } 1227 1228 @DataProvider 1229 public Object[][] maskCompareOpProvider() { 1230 return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). 1231 toArray(Object[][]::new); 1232 } 1233 1234 @DataProvider 1235 public Object[][] shuffleProvider() { 1236 return INT_SHUFFLE_GENERATORS.stream(). 1237 map(f -> new Object[]{f}). 1238 toArray(Object[][]::new); 1239 } 1240 1241 @DataProvider 1242 public Object[][] shuffleCompareOpProvider() { 1243 return INT_SHUFFLE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). 1244 toArray(Object[][]::new); 1245 } 1246 1247 @DataProvider 1248 public Object[][] longUnaryOpShuffleProvider() { 1249 return INT_SHUFFLE_GENERATORS.stream(). 1250 flatMap(fs -> LONG_GENERATORS.stream().map(fa -> { 1251 return new Object[] {fa, fs}; 1252 })). 1253 toArray(Object[][]::new); 1254 } 1255 1256 @DataProvider 1257 public Object[][] longUnaryOpShuffleMaskProvider() { 1258 return BOOLEAN_MASK_GENERATORS.stream(). 1259 flatMap(fm -> INT_SHUFFLE_GENERATORS.stream(). 1260 flatMap(fs -> LONG_GENERATORS.stream().map(fa -> { 1261 return new Object[] {fa, fs, fm}; 1262 }))). 1263 toArray(Object[][]::new); 1264 } 1265 1266 static final List<BiFunction<Integer,Integer,long[]>> LONG_SHUFFLE_GENERATORS = List.of( 1267 withToStringBi("shuffle[random]", (Integer l, Integer m) -> { 1268 long[] a = new long[l]; 1269 int upper = m; 1270 for (int i = 0; i < 1; i++) { 1271 a[i] = (long)RAND.nextInt(upper); 1272 } 1273 return a; 1274 }) 1275 ); 1276 1277 @DataProvider 1278 public Object[][] longUnaryOpSelectFromProvider() { 1279 return LONG_SHUFFLE_GENERATORS.stream(). 1280 flatMap(fs -> LONG_GENERATORS.stream().map(fa -> { 1281 return new Object[] {fa, fs}; 1282 })). 1283 toArray(Object[][]::new); 1284 } 1285 1286 @DataProvider 1287 public Object[][] longUnaryOpSelectFromMaskProvider() { 1288 return BOOLEAN_MASK_GENERATORS.stream(). 1289 flatMap(fm -> LONG_SHUFFLE_GENERATORS.stream(). 1290 flatMap(fs -> LONG_GENERATORS.stream().map(fa -> { 1291 return new Object[] {fa, fs, fm}; 1292 }))). 1293 toArray(Object[][]::new); 1294 } 1295 1296 static final List<IntFunction<long[]>> LONG_COMPARE_GENERATORS = List.of( 1297 withToString("long[i]", (int s) -> { 1298 return fill(s * BUFFER_REPS, 1299 i -> (long)i); 1300 }), 1301 withToString("long[i - length / 2]", (int s) -> { 1302 return fill(s * BUFFER_REPS, 1303 i -> (long)(i - (s * BUFFER_REPS / 2))); 1304 }), 1305 withToString("long[i + 1]", (int s) -> { 1306 return fill(s * BUFFER_REPS, 1307 i -> (long)(i + 1)); 1308 }), 1309 withToString("long[i - 2]", (int s) -> { 1310 return fill(s * BUFFER_REPS, 1311 i -> (long)(i - 2)); 1312 }), 1313 withToString("long[zigZag(i)]", (int s) -> { 1314 return fill(s * BUFFER_REPS, 1315 i -> i%3 == 0 ? (long)i : (i%3 == 1 ? (long)(i + 1) : (long)(i - 2))); 1316 }), 1317 withToString("long[cornerCaseValue(i)]", (int s) -> { 1318 return fill(s * BUFFER_REPS, 1319 i -> cornerCaseValue(i)); 1320 }) 1321 ); 1322 1323 static final List<List<IntFunction<long[]>>> LONG_TEST_GENERATOR_ARGS = 1324 LONG_COMPARE_GENERATORS.stream(). 1325 map(fa -> List.of(fa)). 1326 collect(Collectors.toList()); 1327 1328 @DataProvider 1329 public Object[][] longTestOpProvider() { 1330 return LONG_TEST_GENERATOR_ARGS.stream().map(List::toArray). 1331 toArray(Object[][]::new); 1332 } 1333 1334 @DataProvider 1335 public Object[][] longTestOpMaskProvider() { 1336 return BOOLEAN_MASK_GENERATORS.stream(). 1337 flatMap(fm -> LONG_TEST_GENERATOR_ARGS.stream().map(lfa -> { 1338 return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); 1339 })). 1340 toArray(Object[][]::new); 1341 } 1342 1343 static final List<List<IntFunction<long[]>>> LONG_COMPARE_GENERATOR_PAIRS = 1344 LONG_COMPARE_GENERATORS.stream(). 1345 flatMap(fa -> LONG_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))). 1346 collect(Collectors.toList()); 1347 1348 @DataProvider 1349 public Object[][] longCompareOpProvider() { 1350 return LONG_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). 1351 toArray(Object[][]::new); 1352 } 1353 1354 @DataProvider 1355 public Object[][] longCompareOpMaskProvider() { 1356 return BOOLEAN_MASK_GENERATORS.stream(). 1357 flatMap(fm -> LONG_COMPARE_GENERATOR_PAIRS.stream().map(lfa -> { 1358 return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); 1359 })). 1360 toArray(Object[][]::new); 1361 } 1362 1363 interface ToLongF { 1364 long apply(int i); 1365 } 1366 1367 static long[] fill(int s , ToLongF f) { 1368 return fill(new long[s], f); 1369 } 1370 1371 static long[] fill(long[] a, ToLongF f) { 1372 for (int i = 0; i < a.length; i++) { 1373 a[i] = f.apply(i); 1374 } 1375 return a; 1376 } 1377 1378 static long cornerCaseValue(int i) { 1379 switch(i % 5) { 1380 case 0: 1381 return Long.MAX_VALUE; 1382 case 1: 1383 return Long.MIN_VALUE; 1384 case 2: 1385 return Long.MIN_VALUE; 1386 case 3: 1387 return Long.MAX_VALUE; 1388 default: 1389 return (long)0; 1390 } 1391 } 1392 1393 static final IntFunction<long[]> fr = (vl) -> { 1394 int length = BUFFER_REPS * vl; 1395 return new long[length]; 1396 }; 1397 1398 static final IntFunction<boolean[]> fmr = (vl) -> { 1399 int length = BUFFER_REPS * vl; 1400 return new boolean[length]; 1401 }; 1402 1403 static void replaceZero(long[] a, long v) { 1404 for (int i = 0; i < a.length; i++) { 1405 if (a[i] == 0) { 1406 a[i] = v; 1407 } 1408 } 1409 } 1410 1411 static void replaceZero(long[] a, boolean[] mask, long v) { 1412 for (int i = 0; i < a.length; i++) { 1413 if (mask[i % mask.length] && a[i] == 0) { 1414 a[i] = v; 1415 } 1416 } 1417 } 1418 1419 static long ROL_scalar(long a, long b) { 1420 return Long.rotateLeft(a, ((int)b)); 1421 } 1422 1423 static long ROR_scalar(long a, long b) { 1424 return Long.rotateRight(a, ((int)b)); 1425 } 1426 1427 static long TRAILING_ZEROS_COUNT_scalar(long a) { 1428 return Long.numberOfTrailingZeros(a); 1429 } 1430 1431 static long LEADING_ZEROS_COUNT_scalar(long a) { 1432 return Long.numberOfLeadingZeros(a); 1433 } 1434 1435 static long REVERSE_scalar(long a) { 1436 return Long.reverse(a); 1437 } 1438 1439 static boolean eq(long a, long b) { 1440 return a == b; 1441 } 1442 1443 static boolean neq(long a, long b) { 1444 return a != b; 1445 } 1446 1447 static boolean lt(long a, long b) { 1448 return a < b; 1449 } 1450 1451 static boolean le(long a, long b) { 1452 return a <= b; 1453 } 1454 1455 static boolean gt(long a, long b) { 1456 return a > b; 1457 } 1458 1459 static boolean ge(long a, long b) { 1460 return a >= b; 1461 } 1462 1463 static boolean ult(long a, long b) { 1464 return Long.compareUnsigned(a, b) < 0; 1465 } 1466 1467 static boolean ule(long a, long b) { 1468 return Long.compareUnsigned(a, b) <= 0; 1469 } 1470 1471 static boolean ugt(long a, long b) { 1472 return Long.compareUnsigned(a, b) > 0; 1473 } 1474 1475 static boolean uge(long a, long b) { 1476 return Long.compareUnsigned(a, b) >= 0; 1477 } 1478 1479 static long firstNonZero(long a, long b) { 1480 return Long.compare(a, (long) 0) != 0 ? a : b; 1481 } 1482 1483 @Test 1484 static void smokeTest1() { 1485 LongVector three = LongVector.broadcast(SPECIES, (byte)-3); 1486 LongVector three2 = (LongVector) SPECIES.broadcast(-3); 1487 assert(three.eq(three2).allTrue()); 1488 LongVector three3 = three2.broadcast(1).broadcast(-3); 1489 assert(three.eq(three3).allTrue()); 1490 int scale = 2; 1491 Class<?> ETYPE = long.class; 1492 if (ETYPE == double.class || ETYPE == long.class) 1493 scale = 1000000; 1494 else if (ETYPE == byte.class && SPECIES.length() >= 64) 1495 scale = 1; 1496 LongVector higher = three.addIndex(scale); 1497 VectorMask<Long> m = three.compare(VectorOperators.LE, higher); 1498 assert(m.allTrue()); 1499 m = higher.min((long)-1).test(VectorOperators.IS_NEGATIVE); 1500 assert(m.allTrue()); 1501 long max = higher.reduceLanes(VectorOperators.MAX); 1502 assert(max == -3 + scale * (SPECIES.length()-1)); 1503 } 1504 1505 private static long[] 1506 bothToArray(LongVector a, LongVector b) { 1507 long[] r = new long[a.length() + b.length()]; 1508 a.intoArray(r, 0); 1509 b.intoArray(r, a.length()); 1510 return r; 1511 } 1512 1513 @Test 1514 static void smokeTest2() { 1515 // Do some zipping and shuffling. 1516 LongVector io = (LongVector) SPECIES.broadcast(0).addIndex(1); 1517 LongVector io2 = (LongVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); 1518 Assert.assertEquals(io, io2); 1519 LongVector a = io.add((long)1); //[1,2] 1520 LongVector b = a.neg(); //[-1,-2] 1521 long[] abValues = bothToArray(a,b); //[1,2,-1,-2] 1522 VectorShuffle<Long> zip0 = VectorShuffle.makeZip(SPECIES, 0); 1523 VectorShuffle<Long> zip1 = VectorShuffle.makeZip(SPECIES, 1); 1524 LongVector zab0 = a.rearrange(zip0,b); //[1,-1] 1525 LongVector zab1 = a.rearrange(zip1,b); //[2,-2] 1526 long[] zabValues = bothToArray(zab0, zab1); //[1,-1,2,-2] 1527 // manually zip 1528 long[] manual = new long[zabValues.length]; 1529 for (int i = 0; i < manual.length; i += 2) { 1530 manual[i+0] = abValues[i/2]; 1531 manual[i+1] = abValues[a.length() + i/2]; 1532 } 1533 Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); 1534 VectorShuffle<Long> unz0 = VectorShuffle.makeUnzip(SPECIES, 0); 1535 VectorShuffle<Long> unz1 = VectorShuffle.makeUnzip(SPECIES, 1); 1536 LongVector uab0 = zab0.rearrange(unz0,zab1); 1537 LongVector uab1 = zab0.rearrange(unz1,zab1); 1538 long[] abValues1 = bothToArray(uab0, uab1); 1539 Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); 1540 } 1541 1542 static void iotaShuffle() { 1543 LongVector io = (LongVector) SPECIES.broadcast(0).addIndex(1); 1544 LongVector io2 = (LongVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); 1545 Assert.assertEquals(io, io2); 1546 } 1547 1548 @Test 1549 // Test all shuffle related operations. 1550 static void shuffleTest() { 1551 // To test backend instructions, make sure that C2 is used. 1552 for (int loop = 0; loop < INVOC_COUNT * INVOC_COUNT; loop++) { 1553 iotaShuffle(); 1554 } 1555 } 1556 1557 @Test 1558 void viewAsIntegeralLanesTest() { 1559 Vector<?> asIntegral = SPECIES.zero().viewAsIntegralLanes(); 1560 Assert.assertEquals(asIntegral.species(), SPECIES); 1561 } 1562 1563 @Test 1564 void viewAsFloatingLanesTest() { 1565 Vector<?> asFloating = SPECIES.zero().viewAsFloatingLanes(); 1566 VectorSpecies<?> asFloatingSpecies = asFloating.species(); 1567 Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); 1568 Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); 1569 Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); 1570 Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); 1571 } 1572 1573 @Test 1574 // Test div by 0. 1575 static void bitwiseDivByZeroSmokeTest() { 1576 try { 1577 LongVector a = (LongVector) SPECIES.broadcast(0).addIndex(1); 1578 LongVector b = (LongVector) SPECIES.broadcast(0); 1579 a.div(b); 1580 Assert.fail(); 1581 } catch (ArithmeticException e) { 1582 } 1583 1584 try { 1585 LongVector a = (LongVector) SPECIES.broadcast(0).addIndex(1); 1586 LongVector b = (LongVector) SPECIES.broadcast(0); 1587 VectorMask<Long> m = a.lt((long) 1); 1588 a.div(b, m); 1589 Assert.fail(); 1590 } catch (ArithmeticException e) { 1591 } 1592 } 1593 1594 static long ADD(long a, long b) { 1595 return (long)(a + b); 1596 } 1597 1598 @Test(dataProvider = "longBinaryOpProvider") 1599 static void ADDLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 1600 long[] a = fa.apply(SPECIES.length()); 1601 long[] b = fb.apply(SPECIES.length()); 1602 long[] r = fr.apply(SPECIES.length()); 1603 1604 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1605 for (int i = 0; i < a.length; i += SPECIES.length()) { 1606 LongVector av = LongVector.fromArray(SPECIES, a, i); 1607 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1608 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i); 1609 } 1610 } 1611 1612 assertArraysEquals(r, a, b, LongMaxVectorTests::ADD); 1613 } 1614 1615 static long add(long a, long b) { 1616 return (long)(a + b); 1617 } 1618 1619 @Test(dataProvider = "longBinaryOpProvider") 1620 static void addLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 1621 long[] a = fa.apply(SPECIES.length()); 1622 long[] b = fb.apply(SPECIES.length()); 1623 long[] r = fr.apply(SPECIES.length()); 1624 1625 for (int i = 0; i < a.length; i += SPECIES.length()) { 1626 LongVector av = LongVector.fromArray(SPECIES, a, i); 1627 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1628 av.add(bv).intoArray(r, i); 1629 } 1630 1631 assertArraysEquals(r, a, b, LongMaxVectorTests::add); 1632 } 1633 1634 @Test(dataProvider = "longBinaryOpMaskProvider") 1635 static void ADDLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 1636 IntFunction<boolean[]> fm) { 1637 long[] a = fa.apply(SPECIES.length()); 1638 long[] b = fb.apply(SPECIES.length()); 1639 long[] r = fr.apply(SPECIES.length()); 1640 boolean[] mask = fm.apply(SPECIES.length()); 1641 VectorMask<Long> 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 LongVector av = LongVector.fromArray(SPECIES, a, i); 1646 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1647 av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i); 1648 } 1649 } 1650 1651 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::ADD); 1652 } 1653 1654 @Test(dataProvider = "longBinaryOpMaskProvider") 1655 static void addLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 1656 IntFunction<boolean[]> fm) { 1657 long[] a = fa.apply(SPECIES.length()); 1658 long[] b = fb.apply(SPECIES.length()); 1659 long[] r = fr.apply(SPECIES.length()); 1660 boolean[] mask = fm.apply(SPECIES.length()); 1661 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1662 1663 for (int i = 0; i < a.length; i += SPECIES.length()) { 1664 LongVector av = LongVector.fromArray(SPECIES, a, i); 1665 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1666 av.add(bv, vmask).intoArray(r, i); 1667 } 1668 1669 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::add); 1670 } 1671 1672 static long SUB(long a, long b) { 1673 return (long)(a - b); 1674 } 1675 1676 @Test(dataProvider = "longBinaryOpProvider") 1677 static void SUBLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 1678 long[] a = fa.apply(SPECIES.length()); 1679 long[] b = fb.apply(SPECIES.length()); 1680 long[] r = fr.apply(SPECIES.length()); 1681 1682 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1683 for (int i = 0; i < a.length; i += SPECIES.length()) { 1684 LongVector av = LongVector.fromArray(SPECIES, a, i); 1685 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1686 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i); 1687 } 1688 } 1689 1690 assertArraysEquals(r, a, b, LongMaxVectorTests::SUB); 1691 } 1692 1693 static long sub(long a, long b) { 1694 return (long)(a - b); 1695 } 1696 1697 @Test(dataProvider = "longBinaryOpProvider") 1698 static void subLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 1699 long[] a = fa.apply(SPECIES.length()); 1700 long[] b = fb.apply(SPECIES.length()); 1701 long[] r = fr.apply(SPECIES.length()); 1702 1703 for (int i = 0; i < a.length; i += SPECIES.length()) { 1704 LongVector av = LongVector.fromArray(SPECIES, a, i); 1705 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1706 av.sub(bv).intoArray(r, i); 1707 } 1708 1709 assertArraysEquals(r, a, b, LongMaxVectorTests::sub); 1710 } 1711 1712 @Test(dataProvider = "longBinaryOpMaskProvider") 1713 static void SUBLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 1714 IntFunction<boolean[]> fm) { 1715 long[] a = fa.apply(SPECIES.length()); 1716 long[] b = fb.apply(SPECIES.length()); 1717 long[] r = fr.apply(SPECIES.length()); 1718 boolean[] mask = fm.apply(SPECIES.length()); 1719 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1720 1721 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1722 for (int i = 0; i < a.length; i += SPECIES.length()) { 1723 LongVector av = LongVector.fromArray(SPECIES, a, i); 1724 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1725 av.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i); 1726 } 1727 } 1728 1729 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::SUB); 1730 } 1731 1732 @Test(dataProvider = "longBinaryOpMaskProvider") 1733 static void subLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 1734 IntFunction<boolean[]> fm) { 1735 long[] a = fa.apply(SPECIES.length()); 1736 long[] b = fb.apply(SPECIES.length()); 1737 long[] r = fr.apply(SPECIES.length()); 1738 boolean[] mask = fm.apply(SPECIES.length()); 1739 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1740 1741 for (int i = 0; i < a.length; i += SPECIES.length()) { 1742 LongVector av = LongVector.fromArray(SPECIES, a, i); 1743 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1744 av.sub(bv, vmask).intoArray(r, i); 1745 } 1746 1747 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::sub); 1748 } 1749 1750 static long MUL(long a, long b) { 1751 return (long)(a * b); 1752 } 1753 1754 @Test(dataProvider = "longBinaryOpProvider") 1755 static void MULLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 1756 long[] a = fa.apply(SPECIES.length()); 1757 long[] b = fb.apply(SPECIES.length()); 1758 long[] r = fr.apply(SPECIES.length()); 1759 1760 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1761 for (int i = 0; i < a.length; i += SPECIES.length()) { 1762 LongVector av = LongVector.fromArray(SPECIES, a, i); 1763 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1764 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i); 1765 } 1766 } 1767 1768 assertArraysEquals(r, a, b, LongMaxVectorTests::MUL); 1769 } 1770 1771 static long mul(long a, long b) { 1772 return (long)(a * b); 1773 } 1774 1775 @Test(dataProvider = "longBinaryOpProvider") 1776 static void mulLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 1777 long[] a = fa.apply(SPECIES.length()); 1778 long[] b = fb.apply(SPECIES.length()); 1779 long[] r = fr.apply(SPECIES.length()); 1780 1781 for (int i = 0; i < a.length; i += SPECIES.length()) { 1782 LongVector av = LongVector.fromArray(SPECIES, a, i); 1783 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1784 av.mul(bv).intoArray(r, i); 1785 } 1786 1787 assertArraysEquals(r, a, b, LongMaxVectorTests::mul); 1788 } 1789 1790 @Test(dataProvider = "longBinaryOpMaskProvider") 1791 static void MULLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 1792 IntFunction<boolean[]> fm) { 1793 long[] a = fa.apply(SPECIES.length()); 1794 long[] b = fb.apply(SPECIES.length()); 1795 long[] r = fr.apply(SPECIES.length()); 1796 boolean[] mask = fm.apply(SPECIES.length()); 1797 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1798 1799 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1800 for (int i = 0; i < a.length; i += SPECIES.length()) { 1801 LongVector av = LongVector.fromArray(SPECIES, a, i); 1802 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1803 av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i); 1804 } 1805 } 1806 1807 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::MUL); 1808 } 1809 1810 @Test(dataProvider = "longBinaryOpMaskProvider") 1811 static void mulLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 1812 IntFunction<boolean[]> fm) { 1813 long[] a = fa.apply(SPECIES.length()); 1814 long[] b = fb.apply(SPECIES.length()); 1815 long[] r = fr.apply(SPECIES.length()); 1816 boolean[] mask = fm.apply(SPECIES.length()); 1817 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1818 1819 for (int i = 0; i < a.length; i += SPECIES.length()) { 1820 LongVector av = LongVector.fromArray(SPECIES, a, i); 1821 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1822 av.mul(bv, vmask).intoArray(r, i); 1823 } 1824 1825 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::mul); 1826 } 1827 1828 static long DIV(long a, long b) { 1829 return (long)(a / b); 1830 } 1831 1832 @Test(dataProvider = "longBinaryOpProvider") 1833 static void DIVLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 1834 long[] a = fa.apply(SPECIES.length()); 1835 long[] b = fb.apply(SPECIES.length()); 1836 long[] r = fr.apply(SPECIES.length()); 1837 1838 replaceZero(b, (long) 1); 1839 1840 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1841 for (int i = 0; i < a.length; i += SPECIES.length()) { 1842 LongVector av = LongVector.fromArray(SPECIES, a, i); 1843 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1844 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i); 1845 } 1846 } 1847 1848 assertArraysEquals(r, a, b, LongMaxVectorTests::DIV); 1849 } 1850 1851 static long div(long a, long b) { 1852 return (long)(a / b); 1853 } 1854 1855 @Test(dataProvider = "longBinaryOpProvider") 1856 static void divLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 1857 long[] a = fa.apply(SPECIES.length()); 1858 long[] b = fb.apply(SPECIES.length()); 1859 long[] r = fr.apply(SPECIES.length()); 1860 1861 replaceZero(b, (long) 1); 1862 1863 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1864 for (int i = 0; i < a.length; i += SPECIES.length()) { 1865 LongVector av = LongVector.fromArray(SPECIES, a, i); 1866 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1867 av.div(bv).intoArray(r, i); 1868 } 1869 } 1870 1871 assertArraysEquals(r, a, b, LongMaxVectorTests::div); 1872 } 1873 1874 @Test(dataProvider = "longBinaryOpMaskProvider") 1875 static void DIVLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 1876 IntFunction<boolean[]> fm) { 1877 long[] a = fa.apply(SPECIES.length()); 1878 long[] b = fb.apply(SPECIES.length()); 1879 long[] r = fr.apply(SPECIES.length()); 1880 boolean[] mask = fm.apply(SPECIES.length()); 1881 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1882 1883 replaceZero(b, mask, (long) 1); 1884 1885 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1886 for (int i = 0; i < a.length; i += SPECIES.length()) { 1887 LongVector av = LongVector.fromArray(SPECIES, a, i); 1888 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1889 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i); 1890 } 1891 } 1892 1893 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::DIV); 1894 } 1895 1896 @Test(dataProvider = "longBinaryOpMaskProvider") 1897 static void divLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 1898 IntFunction<boolean[]> fm) { 1899 long[] a = fa.apply(SPECIES.length()); 1900 long[] b = fb.apply(SPECIES.length()); 1901 long[] r = fr.apply(SPECIES.length()); 1902 boolean[] mask = fm.apply(SPECIES.length()); 1903 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1904 1905 replaceZero(b, mask, (long) 1); 1906 1907 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1908 for (int i = 0; i < a.length; i += SPECIES.length()) { 1909 LongVector av = LongVector.fromArray(SPECIES, a, i); 1910 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1911 av.div(bv, vmask).intoArray(r, i); 1912 } 1913 } 1914 1915 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::div); 1916 } 1917 1918 static long FIRST_NONZERO(long a, long b) { 1919 return (long)((a)!=0?a:b); 1920 } 1921 1922 @Test(dataProvider = "longBinaryOpProvider") 1923 static void FIRST_NONZEROLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 1924 long[] a = fa.apply(SPECIES.length()); 1925 long[] b = fb.apply(SPECIES.length()); 1926 long[] r = fr.apply(SPECIES.length()); 1927 1928 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1929 for (int i = 0; i < a.length; i += SPECIES.length()) { 1930 LongVector av = LongVector.fromArray(SPECIES, a, i); 1931 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1932 av.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i); 1933 } 1934 } 1935 1936 assertArraysEquals(r, a, b, LongMaxVectorTests::FIRST_NONZERO); 1937 } 1938 1939 @Test(dataProvider = "longBinaryOpMaskProvider") 1940 static void FIRST_NONZEROLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 1941 IntFunction<boolean[]> fm) { 1942 long[] a = fa.apply(SPECIES.length()); 1943 long[] b = fb.apply(SPECIES.length()); 1944 long[] r = fr.apply(SPECIES.length()); 1945 boolean[] mask = fm.apply(SPECIES.length()); 1946 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1947 1948 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1949 for (int i = 0; i < a.length; i += SPECIES.length()) { 1950 LongVector av = LongVector.fromArray(SPECIES, a, i); 1951 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1952 av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i); 1953 } 1954 } 1955 1956 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::FIRST_NONZERO); 1957 } 1958 1959 static long AND(long a, long b) { 1960 return (long)(a & b); 1961 } 1962 1963 @Test(dataProvider = "longBinaryOpProvider") 1964 static void ANDLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 1965 long[] a = fa.apply(SPECIES.length()); 1966 long[] b = fb.apply(SPECIES.length()); 1967 long[] r = fr.apply(SPECIES.length()); 1968 1969 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1970 for (int i = 0; i < a.length; i += SPECIES.length()) { 1971 LongVector av = LongVector.fromArray(SPECIES, a, i); 1972 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1973 av.lanewise(VectorOperators.AND, bv).intoArray(r, i); 1974 } 1975 } 1976 1977 assertArraysEquals(r, a, b, LongMaxVectorTests::AND); 1978 } 1979 1980 static long and(long a, long b) { 1981 return (long)(a & b); 1982 } 1983 1984 @Test(dataProvider = "longBinaryOpProvider") 1985 static void andLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 1986 long[] a = fa.apply(SPECIES.length()); 1987 long[] b = fb.apply(SPECIES.length()); 1988 long[] r = fr.apply(SPECIES.length()); 1989 1990 for (int i = 0; i < a.length; i += SPECIES.length()) { 1991 LongVector av = LongVector.fromArray(SPECIES, a, i); 1992 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1993 av.and(bv).intoArray(r, i); 1994 } 1995 1996 assertArraysEquals(r, a, b, LongMaxVectorTests::and); 1997 } 1998 1999 @Test(dataProvider = "longBinaryOpMaskProvider") 2000 static void ANDLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 2001 IntFunction<boolean[]> fm) { 2002 long[] a = fa.apply(SPECIES.length()); 2003 long[] b = fb.apply(SPECIES.length()); 2004 long[] r = fr.apply(SPECIES.length()); 2005 boolean[] mask = fm.apply(SPECIES.length()); 2006 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2007 2008 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2009 for (int i = 0; i < a.length; i += SPECIES.length()) { 2010 LongVector av = LongVector.fromArray(SPECIES, a, i); 2011 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2012 av.lanewise(VectorOperators.AND, bv, vmask).intoArray(r, i); 2013 } 2014 } 2015 2016 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::AND); 2017 } 2018 2019 static long AND_NOT(long a, long b) { 2020 return (long)(a & ~b); 2021 } 2022 2023 @Test(dataProvider = "longBinaryOpProvider") 2024 static void AND_NOTLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2025 long[] a = fa.apply(SPECIES.length()); 2026 long[] b = fb.apply(SPECIES.length()); 2027 long[] r = fr.apply(SPECIES.length()); 2028 2029 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2030 for (int i = 0; i < a.length; i += SPECIES.length()) { 2031 LongVector av = LongVector.fromArray(SPECIES, a, i); 2032 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2033 av.lanewise(VectorOperators.AND_NOT, bv).intoArray(r, i); 2034 } 2035 } 2036 2037 assertArraysEquals(r, a, b, LongMaxVectorTests::AND_NOT); 2038 } 2039 2040 @Test(dataProvider = "longBinaryOpMaskProvider") 2041 static void AND_NOTLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 2042 IntFunction<boolean[]> fm) { 2043 long[] a = fa.apply(SPECIES.length()); 2044 long[] b = fb.apply(SPECIES.length()); 2045 long[] r = fr.apply(SPECIES.length()); 2046 boolean[] mask = fm.apply(SPECIES.length()); 2047 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2048 2049 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2050 for (int i = 0; i < a.length; i += SPECIES.length()) { 2051 LongVector av = LongVector.fromArray(SPECIES, a, i); 2052 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2053 av.lanewise(VectorOperators.AND_NOT, bv, vmask).intoArray(r, i); 2054 } 2055 } 2056 2057 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::AND_NOT); 2058 } 2059 2060 static long OR(long a, long b) { 2061 return (long)(a | b); 2062 } 2063 2064 @Test(dataProvider = "longBinaryOpProvider") 2065 static void ORLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2066 long[] a = fa.apply(SPECIES.length()); 2067 long[] b = fb.apply(SPECIES.length()); 2068 long[] r = fr.apply(SPECIES.length()); 2069 2070 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2071 for (int i = 0; i < a.length; i += SPECIES.length()) { 2072 LongVector av = LongVector.fromArray(SPECIES, a, i); 2073 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2074 av.lanewise(VectorOperators.OR, bv).intoArray(r, i); 2075 } 2076 } 2077 2078 assertArraysEquals(r, a, b, LongMaxVectorTests::OR); 2079 } 2080 2081 static long or(long a, long b) { 2082 return (long)(a | b); 2083 } 2084 2085 @Test(dataProvider = "longBinaryOpProvider") 2086 static void orLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2087 long[] a = fa.apply(SPECIES.length()); 2088 long[] b = fb.apply(SPECIES.length()); 2089 long[] r = fr.apply(SPECIES.length()); 2090 2091 for (int i = 0; i < a.length; i += SPECIES.length()) { 2092 LongVector av = LongVector.fromArray(SPECIES, a, i); 2093 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2094 av.or(bv).intoArray(r, i); 2095 } 2096 2097 assertArraysEquals(r, a, b, LongMaxVectorTests::or); 2098 } 2099 2100 @Test(dataProvider = "longBinaryOpMaskProvider") 2101 static void ORLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 2102 IntFunction<boolean[]> fm) { 2103 long[] a = fa.apply(SPECIES.length()); 2104 long[] b = fb.apply(SPECIES.length()); 2105 long[] r = fr.apply(SPECIES.length()); 2106 boolean[] mask = fm.apply(SPECIES.length()); 2107 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2108 2109 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2110 for (int i = 0; i < a.length; i += SPECIES.length()) { 2111 LongVector av = LongVector.fromArray(SPECIES, a, i); 2112 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2113 av.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i); 2114 } 2115 } 2116 2117 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::OR); 2118 } 2119 2120 static long XOR(long a, long b) { 2121 return (long)(a ^ b); 2122 } 2123 2124 @Test(dataProvider = "longBinaryOpProvider") 2125 static void XORLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2126 long[] a = fa.apply(SPECIES.length()); 2127 long[] b = fb.apply(SPECIES.length()); 2128 long[] r = fr.apply(SPECIES.length()); 2129 2130 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2131 for (int i = 0; i < a.length; i += SPECIES.length()) { 2132 LongVector av = LongVector.fromArray(SPECIES, a, i); 2133 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2134 av.lanewise(VectorOperators.XOR, bv).intoArray(r, i); 2135 } 2136 } 2137 2138 assertArraysEquals(r, a, b, LongMaxVectorTests::XOR); 2139 } 2140 2141 @Test(dataProvider = "longBinaryOpMaskProvider") 2142 static void XORLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 2143 IntFunction<boolean[]> fm) { 2144 long[] a = fa.apply(SPECIES.length()); 2145 long[] b = fb.apply(SPECIES.length()); 2146 long[] r = fr.apply(SPECIES.length()); 2147 boolean[] mask = fm.apply(SPECIES.length()); 2148 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2149 2150 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2151 for (int i = 0; i < a.length; i += SPECIES.length()) { 2152 LongVector av = LongVector.fromArray(SPECIES, a, i); 2153 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2154 av.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i); 2155 } 2156 } 2157 2158 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::XOR); 2159 } 2160 2161 static long COMPRESS_BITS(long a, long b) { 2162 return (long)(Long.compress(a, b)); 2163 } 2164 2165 @Test(dataProvider = "longBinaryOpProvider") 2166 static void COMPRESS_BITSLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2167 long[] a = fa.apply(SPECIES.length()); 2168 long[] b = fb.apply(SPECIES.length()); 2169 long[] r = fr.apply(SPECIES.length()); 2170 2171 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2172 for (int i = 0; i < a.length; i += SPECIES.length()) { 2173 LongVector av = LongVector.fromArray(SPECIES, a, i); 2174 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2175 av.lanewise(VectorOperators.COMPRESS_BITS, bv).intoArray(r, i); 2176 } 2177 } 2178 2179 assertArraysEquals(r, a, b, LongMaxVectorTests::COMPRESS_BITS); 2180 } 2181 2182 @Test(dataProvider = "longBinaryOpMaskProvider") 2183 static void COMPRESS_BITSLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 2184 IntFunction<boolean[]> fm) { 2185 long[] a = fa.apply(SPECIES.length()); 2186 long[] b = fb.apply(SPECIES.length()); 2187 long[] r = fr.apply(SPECIES.length()); 2188 boolean[] mask = fm.apply(SPECIES.length()); 2189 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2190 2191 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2192 for (int i = 0; i < a.length; i += SPECIES.length()) { 2193 LongVector av = LongVector.fromArray(SPECIES, a, i); 2194 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2195 av.lanewise(VectorOperators.COMPRESS_BITS, bv, vmask).intoArray(r, i); 2196 } 2197 } 2198 2199 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::COMPRESS_BITS); 2200 } 2201 2202 static long EXPAND_BITS(long a, long b) { 2203 return (long)(Long.expand(a, b)); 2204 } 2205 2206 @Test(dataProvider = "longBinaryOpProvider") 2207 static void EXPAND_BITSLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2208 long[] a = fa.apply(SPECIES.length()); 2209 long[] b = fb.apply(SPECIES.length()); 2210 long[] r = fr.apply(SPECIES.length()); 2211 2212 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2213 for (int i = 0; i < a.length; i += SPECIES.length()) { 2214 LongVector av = LongVector.fromArray(SPECIES, a, i); 2215 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2216 av.lanewise(VectorOperators.EXPAND_BITS, bv).intoArray(r, i); 2217 } 2218 } 2219 2220 assertArraysEquals(r, a, b, LongMaxVectorTests::EXPAND_BITS); 2221 } 2222 2223 @Test(dataProvider = "longBinaryOpMaskProvider") 2224 static void EXPAND_BITSLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 2225 IntFunction<boolean[]> fm) { 2226 long[] a = fa.apply(SPECIES.length()); 2227 long[] b = fb.apply(SPECIES.length()); 2228 long[] r = fr.apply(SPECIES.length()); 2229 boolean[] mask = fm.apply(SPECIES.length()); 2230 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2231 2232 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2233 for (int i = 0; i < a.length; i += SPECIES.length()) { 2234 LongVector av = LongVector.fromArray(SPECIES, a, i); 2235 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2236 av.lanewise(VectorOperators.EXPAND_BITS, bv, vmask).intoArray(r, i); 2237 } 2238 } 2239 2240 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::EXPAND_BITS); 2241 } 2242 2243 @Test(dataProvider = "longBinaryOpProvider") 2244 static void addLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2245 long[] a = fa.apply(SPECIES.length()); 2246 long[] b = fb.apply(SPECIES.length()); 2247 long[] r = fr.apply(SPECIES.length()); 2248 2249 for (int i = 0; i < a.length; i += SPECIES.length()) { 2250 LongVector av = LongVector.fromArray(SPECIES, a, i); 2251 av.add(b[i]).intoArray(r, i); 2252 } 2253 2254 assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::add); 2255 } 2256 2257 @Test(dataProvider = "longBinaryOpMaskProvider") 2258 static void addLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, 2259 IntFunction<boolean[]> fm) { 2260 long[] a = fa.apply(SPECIES.length()); 2261 long[] b = fb.apply(SPECIES.length()); 2262 long[] r = fr.apply(SPECIES.length()); 2263 boolean[] mask = fm.apply(SPECIES.length()); 2264 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2265 2266 for (int i = 0; i < a.length; i += SPECIES.length()) { 2267 LongVector av = LongVector.fromArray(SPECIES, a, i); 2268 av.add(b[i], vmask).intoArray(r, i); 2269 } 2270 2271 assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::add); 2272 } 2273 2274 @Test(dataProvider = "longBinaryOpProvider") 2275 static void subLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2276 long[] a = fa.apply(SPECIES.length()); 2277 long[] b = fb.apply(SPECIES.length()); 2278 long[] r = fr.apply(SPECIES.length()); 2279 2280 for (int i = 0; i < a.length; i += SPECIES.length()) { 2281 LongVector av = LongVector.fromArray(SPECIES, a, i); 2282 av.sub(b[i]).intoArray(r, i); 2283 } 2284 2285 assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::sub); 2286 } 2287 2288 @Test(dataProvider = "longBinaryOpMaskProvider") 2289 static void subLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, 2290 IntFunction<boolean[]> fm) { 2291 long[] a = fa.apply(SPECIES.length()); 2292 long[] b = fb.apply(SPECIES.length()); 2293 long[] r = fr.apply(SPECIES.length()); 2294 boolean[] mask = fm.apply(SPECIES.length()); 2295 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2296 2297 for (int i = 0; i < a.length; i += SPECIES.length()) { 2298 LongVector av = LongVector.fromArray(SPECIES, a, i); 2299 av.sub(b[i], vmask).intoArray(r, i); 2300 } 2301 2302 assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::sub); 2303 } 2304 2305 @Test(dataProvider = "longBinaryOpProvider") 2306 static void mulLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2307 long[] a = fa.apply(SPECIES.length()); 2308 long[] b = fb.apply(SPECIES.length()); 2309 long[] r = fr.apply(SPECIES.length()); 2310 2311 for (int i = 0; i < a.length; i += SPECIES.length()) { 2312 LongVector av = LongVector.fromArray(SPECIES, a, i); 2313 av.mul(b[i]).intoArray(r, i); 2314 } 2315 2316 assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::mul); 2317 } 2318 2319 @Test(dataProvider = "longBinaryOpMaskProvider") 2320 static void mulLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, 2321 IntFunction<boolean[]> fm) { 2322 long[] a = fa.apply(SPECIES.length()); 2323 long[] b = fb.apply(SPECIES.length()); 2324 long[] r = fr.apply(SPECIES.length()); 2325 boolean[] mask = fm.apply(SPECIES.length()); 2326 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2327 2328 for (int i = 0; i < a.length; i += SPECIES.length()) { 2329 LongVector av = LongVector.fromArray(SPECIES, a, i); 2330 av.mul(b[i], vmask).intoArray(r, i); 2331 } 2332 2333 assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::mul); 2334 } 2335 2336 @Test(dataProvider = "longBinaryOpProvider") 2337 static void divLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2338 long[] a = fa.apply(SPECIES.length()); 2339 long[] b = fb.apply(SPECIES.length()); 2340 long[] r = fr.apply(SPECIES.length()); 2341 2342 replaceZero(b, (long) 1); 2343 2344 for (int i = 0; i < a.length; i += SPECIES.length()) { 2345 LongVector av = LongVector.fromArray(SPECIES, a, i); 2346 av.div(b[i]).intoArray(r, i); 2347 } 2348 2349 assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::div); 2350 } 2351 2352 @Test(dataProvider = "longBinaryOpMaskProvider") 2353 static void divLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, 2354 IntFunction<boolean[]> fm) { 2355 long[] a = fa.apply(SPECIES.length()); 2356 long[] b = fb.apply(SPECIES.length()); 2357 long[] r = fr.apply(SPECIES.length()); 2358 boolean[] mask = fm.apply(SPECIES.length()); 2359 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2360 2361 replaceZero(b, (long) 1); 2362 2363 for (int i = 0; i < a.length; i += SPECIES.length()) { 2364 LongVector av = LongVector.fromArray(SPECIES, a, i); 2365 av.div(b[i], vmask).intoArray(r, i); 2366 } 2367 2368 assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::div); 2369 } 2370 2371 @Test(dataProvider = "longBinaryOpProvider") 2372 static void ORLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2373 long[] a = fa.apply(SPECIES.length()); 2374 long[] b = fb.apply(SPECIES.length()); 2375 long[] r = fr.apply(SPECIES.length()); 2376 2377 for (int i = 0; i < a.length; i += SPECIES.length()) { 2378 LongVector av = LongVector.fromArray(SPECIES, a, i); 2379 av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i); 2380 } 2381 2382 assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::OR); 2383 } 2384 2385 @Test(dataProvider = "longBinaryOpProvider") 2386 static void orLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2387 long[] a = fa.apply(SPECIES.length()); 2388 long[] b = fb.apply(SPECIES.length()); 2389 long[] r = fr.apply(SPECIES.length()); 2390 2391 for (int i = 0; i < a.length; i += SPECIES.length()) { 2392 LongVector av = LongVector.fromArray(SPECIES, a, i); 2393 av.or(b[i]).intoArray(r, i); 2394 } 2395 2396 assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::or); 2397 } 2398 2399 @Test(dataProvider = "longBinaryOpMaskProvider") 2400 static void ORLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, 2401 IntFunction<boolean[]> fm) { 2402 long[] a = fa.apply(SPECIES.length()); 2403 long[] b = fb.apply(SPECIES.length()); 2404 long[] r = fr.apply(SPECIES.length()); 2405 boolean[] mask = fm.apply(SPECIES.length()); 2406 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2407 2408 for (int i = 0; i < a.length; i += SPECIES.length()) { 2409 LongVector av = LongVector.fromArray(SPECIES, a, i); 2410 av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i); 2411 } 2412 2413 assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::OR); 2414 } 2415 2416 @Test(dataProvider = "longBinaryOpProvider") 2417 static void ANDLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2418 long[] a = fa.apply(SPECIES.length()); 2419 long[] b = fb.apply(SPECIES.length()); 2420 long[] r = fr.apply(SPECIES.length()); 2421 2422 for (int i = 0; i < a.length; i += SPECIES.length()) { 2423 LongVector av = LongVector.fromArray(SPECIES, a, i); 2424 av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i); 2425 } 2426 2427 assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::AND); 2428 } 2429 2430 @Test(dataProvider = "longBinaryOpProvider") 2431 static void andLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2432 long[] a = fa.apply(SPECIES.length()); 2433 long[] b = fb.apply(SPECIES.length()); 2434 long[] r = fr.apply(SPECIES.length()); 2435 2436 for (int i = 0; i < a.length; i += SPECIES.length()) { 2437 LongVector av = LongVector.fromArray(SPECIES, a, i); 2438 av.and(b[i]).intoArray(r, i); 2439 } 2440 2441 assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::and); 2442 } 2443 2444 @Test(dataProvider = "longBinaryOpMaskProvider") 2445 static void ANDLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, 2446 IntFunction<boolean[]> fm) { 2447 long[] a = fa.apply(SPECIES.length()); 2448 long[] b = fb.apply(SPECIES.length()); 2449 long[] r = fr.apply(SPECIES.length()); 2450 boolean[] mask = fm.apply(SPECIES.length()); 2451 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2452 2453 for (int i = 0; i < a.length; i += SPECIES.length()) { 2454 LongVector av = LongVector.fromArray(SPECIES, a, i); 2455 av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i); 2456 } 2457 2458 assertBroadcastArraysEquals(r, a, b, mask, LongMaxVectorTests::AND); 2459 } 2460 2461 @Test(dataProvider = "longBinaryOpProvider") 2462 static void ORLongMaxVectorTestsBroadcastLongSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2463 long[] a = fa.apply(SPECIES.length()); 2464 long[] b = fb.apply(SPECIES.length()); 2465 long[] r = fr.apply(SPECIES.length()); 2466 2467 for (int i = 0; i < a.length; i += SPECIES.length()) { 2468 LongVector av = LongVector.fromArray(SPECIES, a, i); 2469 av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i); 2470 } 2471 2472 assertBroadcastLongArraysEquals(r, a, b, LongMaxVectorTests::OR); 2473 } 2474 2475 @Test(dataProvider = "longBinaryOpMaskProvider") 2476 static void ORLongMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, 2477 IntFunction<boolean[]> fm) { 2478 long[] a = fa.apply(SPECIES.length()); 2479 long[] b = fb.apply(SPECIES.length()); 2480 long[] r = fr.apply(SPECIES.length()); 2481 boolean[] mask = fm.apply(SPECIES.length()); 2482 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2483 2484 for (int i = 0; i < a.length; i += SPECIES.length()) { 2485 LongVector av = LongVector.fromArray(SPECIES, a, i); 2486 av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i); 2487 } 2488 2489 assertBroadcastLongArraysEquals(r, a, b, mask, LongMaxVectorTests::OR); 2490 } 2491 2492 @Test(dataProvider = "longBinaryOpProvider") 2493 static void ADDLongMaxVectorTestsBroadcastLongSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2494 long[] a = fa.apply(SPECIES.length()); 2495 long[] b = fb.apply(SPECIES.length()); 2496 long[] r = fr.apply(SPECIES.length()); 2497 2498 for (int i = 0; i < a.length; i += SPECIES.length()) { 2499 LongVector av = LongVector.fromArray(SPECIES, a, i); 2500 av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); 2501 } 2502 2503 assertBroadcastLongArraysEquals(r, a, b, LongMaxVectorTests::ADD); 2504 } 2505 2506 @Test(dataProvider = "longBinaryOpMaskProvider") 2507 static void ADDLongMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, 2508 IntFunction<boolean[]> fm) { 2509 long[] a = fa.apply(SPECIES.length()); 2510 long[] b = fb.apply(SPECIES.length()); 2511 long[] r = fr.apply(SPECIES.length()); 2512 boolean[] mask = fm.apply(SPECIES.length()); 2513 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2514 2515 for (int i = 0; i < a.length; i += SPECIES.length()) { 2516 LongVector av = LongVector.fromArray(SPECIES, a, i); 2517 av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); 2518 } 2519 2520 assertBroadcastLongArraysEquals(r, a, b, mask, LongMaxVectorTests::ADD); 2521 } 2522 2523 static long LSHL(long a, long b) { 2524 return (long)((a << b)); 2525 } 2526 2527 @Test(dataProvider = "longBinaryOpProvider") 2528 static void LSHLLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2529 long[] a = fa.apply(SPECIES.length()); 2530 long[] b = fb.apply(SPECIES.length()); 2531 long[] r = fr.apply(SPECIES.length()); 2532 2533 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2534 for (int i = 0; i < a.length; i += SPECIES.length()) { 2535 LongVector av = LongVector.fromArray(SPECIES, a, i); 2536 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2537 av.lanewise(VectorOperators.LSHL, bv).intoArray(r, i); 2538 } 2539 } 2540 2541 assertArraysEquals(r, a, b, LongMaxVectorTests::LSHL); 2542 } 2543 2544 @Test(dataProvider = "longBinaryOpMaskProvider") 2545 static void LSHLLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 2546 IntFunction<boolean[]> fm) { 2547 long[] a = fa.apply(SPECIES.length()); 2548 long[] b = fb.apply(SPECIES.length()); 2549 long[] r = fr.apply(SPECIES.length()); 2550 boolean[] mask = fm.apply(SPECIES.length()); 2551 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2552 2553 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2554 for (int i = 0; i < a.length; i += SPECIES.length()) { 2555 LongVector av = LongVector.fromArray(SPECIES, a, i); 2556 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2557 av.lanewise(VectorOperators.LSHL, bv, vmask).intoArray(r, i); 2558 } 2559 } 2560 2561 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::LSHL); 2562 } 2563 2564 static long ASHR(long a, long b) { 2565 return (long)((a >> b)); 2566 } 2567 2568 @Test(dataProvider = "longBinaryOpProvider") 2569 static void ASHRLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2570 long[] a = fa.apply(SPECIES.length()); 2571 long[] b = fb.apply(SPECIES.length()); 2572 long[] r = fr.apply(SPECIES.length()); 2573 2574 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2575 for (int i = 0; i < a.length; i += SPECIES.length()) { 2576 LongVector av = LongVector.fromArray(SPECIES, a, i); 2577 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2578 av.lanewise(VectorOperators.ASHR, bv).intoArray(r, i); 2579 } 2580 } 2581 2582 assertArraysEquals(r, a, b, LongMaxVectorTests::ASHR); 2583 } 2584 2585 @Test(dataProvider = "longBinaryOpMaskProvider") 2586 static void ASHRLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 2587 IntFunction<boolean[]> fm) { 2588 long[] a = fa.apply(SPECIES.length()); 2589 long[] b = fb.apply(SPECIES.length()); 2590 long[] r = fr.apply(SPECIES.length()); 2591 boolean[] mask = fm.apply(SPECIES.length()); 2592 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2593 2594 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2595 for (int i = 0; i < a.length; i += SPECIES.length()) { 2596 LongVector av = LongVector.fromArray(SPECIES, a, i); 2597 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2598 av.lanewise(VectorOperators.ASHR, bv, vmask).intoArray(r, i); 2599 } 2600 } 2601 2602 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::ASHR); 2603 } 2604 2605 static long LSHR(long a, long b) { 2606 return (long)((a >>> b)); 2607 } 2608 2609 @Test(dataProvider = "longBinaryOpProvider") 2610 static void LSHRLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2611 long[] a = fa.apply(SPECIES.length()); 2612 long[] b = fb.apply(SPECIES.length()); 2613 long[] r = fr.apply(SPECIES.length()); 2614 2615 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2616 for (int i = 0; i < a.length; i += SPECIES.length()) { 2617 LongVector av = LongVector.fromArray(SPECIES, a, i); 2618 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2619 av.lanewise(VectorOperators.LSHR, bv).intoArray(r, i); 2620 } 2621 } 2622 2623 assertArraysEquals(r, a, b, LongMaxVectorTests::LSHR); 2624 } 2625 2626 @Test(dataProvider = "longBinaryOpMaskProvider") 2627 static void LSHRLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 2628 IntFunction<boolean[]> fm) { 2629 long[] a = fa.apply(SPECIES.length()); 2630 long[] b = fb.apply(SPECIES.length()); 2631 long[] r = fr.apply(SPECIES.length()); 2632 boolean[] mask = fm.apply(SPECIES.length()); 2633 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2634 2635 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2636 for (int i = 0; i < a.length; i += SPECIES.length()) { 2637 LongVector av = LongVector.fromArray(SPECIES, a, i); 2638 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2639 av.lanewise(VectorOperators.LSHR, bv, vmask).intoArray(r, i); 2640 } 2641 } 2642 2643 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::LSHR); 2644 } 2645 2646 static long LSHL_unary(long a, long b) { 2647 return (long)((a << b)); 2648 } 2649 2650 @Test(dataProvider = "longBinaryOpProvider") 2651 static void LSHLLongMaxVectorTestsScalarShift(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2652 long[] a = fa.apply(SPECIES.length()); 2653 long[] b = fb.apply(SPECIES.length()); 2654 long[] r = fr.apply(SPECIES.length()); 2655 2656 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2657 for (int i = 0; i < a.length; i += SPECIES.length()) { 2658 LongVector av = LongVector.fromArray(SPECIES, a, i); 2659 av.lanewise(VectorOperators.LSHL, (int)b[i]).intoArray(r, i); 2660 } 2661 } 2662 2663 assertShiftArraysEquals(r, a, b, LongMaxVectorTests::LSHL_unary); 2664 } 2665 2666 @Test(dataProvider = "longBinaryOpMaskProvider") 2667 static void LSHLLongMaxVectorTestsScalarShiftMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 2668 IntFunction<boolean[]> fm) { 2669 long[] a = fa.apply(SPECIES.length()); 2670 long[] b = fb.apply(SPECIES.length()); 2671 long[] r = fr.apply(SPECIES.length()); 2672 boolean[] mask = fm.apply(SPECIES.length()); 2673 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2674 2675 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2676 for (int i = 0; i < a.length; i += SPECIES.length()) { 2677 LongVector av = LongVector.fromArray(SPECIES, a, i); 2678 av.lanewise(VectorOperators.LSHL, (int)b[i], vmask).intoArray(r, i); 2679 } 2680 } 2681 2682 assertShiftArraysEquals(r, a, b, mask, LongMaxVectorTests::LSHL_unary); 2683 } 2684 2685 static long LSHR_unary(long a, long b) { 2686 return (long)((a >>> b)); 2687 } 2688 2689 @Test(dataProvider = "longBinaryOpProvider") 2690 static void LSHRLongMaxVectorTestsScalarShift(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2691 long[] a = fa.apply(SPECIES.length()); 2692 long[] b = fb.apply(SPECIES.length()); 2693 long[] r = fr.apply(SPECIES.length()); 2694 2695 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2696 for (int i = 0; i < a.length; i += SPECIES.length()) { 2697 LongVector av = LongVector.fromArray(SPECIES, a, i); 2698 av.lanewise(VectorOperators.LSHR, (int)b[i]).intoArray(r, i); 2699 } 2700 } 2701 2702 assertShiftArraysEquals(r, a, b, LongMaxVectorTests::LSHR_unary); 2703 } 2704 2705 @Test(dataProvider = "longBinaryOpMaskProvider") 2706 static void LSHRLongMaxVectorTestsScalarShiftMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 2707 IntFunction<boolean[]> fm) { 2708 long[] a = fa.apply(SPECIES.length()); 2709 long[] b = fb.apply(SPECIES.length()); 2710 long[] r = fr.apply(SPECIES.length()); 2711 boolean[] mask = fm.apply(SPECIES.length()); 2712 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2713 2714 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2715 for (int i = 0; i < a.length; i += SPECIES.length()) { 2716 LongVector av = LongVector.fromArray(SPECIES, a, i); 2717 av.lanewise(VectorOperators.LSHR, (int)b[i], vmask).intoArray(r, i); 2718 } 2719 } 2720 2721 assertShiftArraysEquals(r, a, b, mask, LongMaxVectorTests::LSHR_unary); 2722 } 2723 2724 static long ASHR_unary(long a, long b) { 2725 return (long)((a >> b)); 2726 } 2727 2728 @Test(dataProvider = "longBinaryOpProvider") 2729 static void ASHRLongMaxVectorTestsScalarShift(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2730 long[] a = fa.apply(SPECIES.length()); 2731 long[] b = fb.apply(SPECIES.length()); 2732 long[] r = fr.apply(SPECIES.length()); 2733 2734 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2735 for (int i = 0; i < a.length; i += SPECIES.length()) { 2736 LongVector av = LongVector.fromArray(SPECIES, a, i); 2737 av.lanewise(VectorOperators.ASHR, (int)b[i]).intoArray(r, i); 2738 } 2739 } 2740 2741 assertShiftArraysEquals(r, a, b, LongMaxVectorTests::ASHR_unary); 2742 } 2743 2744 @Test(dataProvider = "longBinaryOpMaskProvider") 2745 static void ASHRLongMaxVectorTestsScalarShiftMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 2746 IntFunction<boolean[]> fm) { 2747 long[] a = fa.apply(SPECIES.length()); 2748 long[] b = fb.apply(SPECIES.length()); 2749 long[] r = fr.apply(SPECIES.length()); 2750 boolean[] mask = fm.apply(SPECIES.length()); 2751 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2752 2753 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2754 for (int i = 0; i < a.length; i += SPECIES.length()) { 2755 LongVector av = LongVector.fromArray(SPECIES, a, i); 2756 av.lanewise(VectorOperators.ASHR, (int)b[i], vmask).intoArray(r, i); 2757 } 2758 } 2759 2760 assertShiftArraysEquals(r, a, b, mask, LongMaxVectorTests::ASHR_unary); 2761 } 2762 2763 static long ROR(long a, long b) { 2764 return (long)(ROR_scalar(a,b)); 2765 } 2766 2767 @Test(dataProvider = "longBinaryOpProvider") 2768 static void RORLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2769 long[] a = fa.apply(SPECIES.length()); 2770 long[] b = fb.apply(SPECIES.length()); 2771 long[] r = fr.apply(SPECIES.length()); 2772 2773 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2774 for (int i = 0; i < a.length; i += SPECIES.length()) { 2775 LongVector av = LongVector.fromArray(SPECIES, a, i); 2776 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2777 av.lanewise(VectorOperators.ROR, bv).intoArray(r, i); 2778 } 2779 } 2780 2781 assertArraysEquals(r, a, b, LongMaxVectorTests::ROR); 2782 } 2783 2784 @Test(dataProvider = "longBinaryOpMaskProvider") 2785 static void RORLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 2786 IntFunction<boolean[]> fm) { 2787 long[] a = fa.apply(SPECIES.length()); 2788 long[] b = fb.apply(SPECIES.length()); 2789 long[] r = fr.apply(SPECIES.length()); 2790 boolean[] mask = fm.apply(SPECIES.length()); 2791 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2792 2793 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2794 for (int i = 0; i < a.length; i += SPECIES.length()) { 2795 LongVector av = LongVector.fromArray(SPECIES, a, i); 2796 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2797 av.lanewise(VectorOperators.ROR, bv, vmask).intoArray(r, i); 2798 } 2799 } 2800 2801 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::ROR); 2802 } 2803 2804 static long ROL(long a, long b) { 2805 return (long)(ROL_scalar(a,b)); 2806 } 2807 2808 @Test(dataProvider = "longBinaryOpProvider") 2809 static void ROLLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2810 long[] a = fa.apply(SPECIES.length()); 2811 long[] b = fb.apply(SPECIES.length()); 2812 long[] r = fr.apply(SPECIES.length()); 2813 2814 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2815 for (int i = 0; i < a.length; i += SPECIES.length()) { 2816 LongVector av = LongVector.fromArray(SPECIES, a, i); 2817 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2818 av.lanewise(VectorOperators.ROL, bv).intoArray(r, i); 2819 } 2820 } 2821 2822 assertArraysEquals(r, a, b, LongMaxVectorTests::ROL); 2823 } 2824 2825 @Test(dataProvider = "longBinaryOpMaskProvider") 2826 static void ROLLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 2827 IntFunction<boolean[]> fm) { 2828 long[] a = fa.apply(SPECIES.length()); 2829 long[] b = fb.apply(SPECIES.length()); 2830 long[] r = fr.apply(SPECIES.length()); 2831 boolean[] mask = fm.apply(SPECIES.length()); 2832 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2833 2834 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2835 for (int i = 0; i < a.length; i += SPECIES.length()) { 2836 LongVector av = LongVector.fromArray(SPECIES, a, i); 2837 LongVector bv = LongVector.fromArray(SPECIES, b, i); 2838 av.lanewise(VectorOperators.ROL, bv, vmask).intoArray(r, i); 2839 } 2840 } 2841 2842 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::ROL); 2843 } 2844 2845 static long ROR_unary(long a, long b) { 2846 return (long)(ROR_scalar(a, b)); 2847 } 2848 2849 @Test(dataProvider = "longBinaryOpProvider") 2850 static void RORLongMaxVectorTestsScalarShift(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2851 long[] a = fa.apply(SPECIES.length()); 2852 long[] b = fb.apply(SPECIES.length()); 2853 long[] r = fr.apply(SPECIES.length()); 2854 2855 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2856 for (int i = 0; i < a.length; i += SPECIES.length()) { 2857 LongVector av = LongVector.fromArray(SPECIES, a, i); 2858 av.lanewise(VectorOperators.ROR, (int)b[i]).intoArray(r, i); 2859 } 2860 } 2861 2862 assertShiftArraysEquals(r, a, b, LongMaxVectorTests::ROR_unary); 2863 } 2864 2865 @Test(dataProvider = "longBinaryOpMaskProvider") 2866 static void RORLongMaxVectorTestsScalarShiftMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 2867 IntFunction<boolean[]> fm) { 2868 long[] a = fa.apply(SPECIES.length()); 2869 long[] b = fb.apply(SPECIES.length()); 2870 long[] r = fr.apply(SPECIES.length()); 2871 boolean[] mask = fm.apply(SPECIES.length()); 2872 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2873 2874 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2875 for (int i = 0; i < a.length; i += SPECIES.length()) { 2876 LongVector av = LongVector.fromArray(SPECIES, a, i); 2877 av.lanewise(VectorOperators.ROR, (int)b[i], vmask).intoArray(r, i); 2878 } 2879 } 2880 2881 assertShiftArraysEquals(r, a, b, mask, LongMaxVectorTests::ROR_unary); 2882 } 2883 2884 static long ROL_unary(long a, long b) { 2885 return (long)(ROL_scalar(a, b)); 2886 } 2887 2888 @Test(dataProvider = "longBinaryOpProvider") 2889 static void ROLLongMaxVectorTestsScalarShift(IntFunction<long[]> fa, IntFunction<long[]> fb) { 2890 long[] a = fa.apply(SPECIES.length()); 2891 long[] b = fb.apply(SPECIES.length()); 2892 long[] r = fr.apply(SPECIES.length()); 2893 2894 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2895 for (int i = 0; i < a.length; i += SPECIES.length()) { 2896 LongVector av = LongVector.fromArray(SPECIES, a, i); 2897 av.lanewise(VectorOperators.ROL, (int)b[i]).intoArray(r, i); 2898 } 2899 } 2900 2901 assertShiftArraysEquals(r, a, b, LongMaxVectorTests::ROL_unary); 2902 } 2903 2904 @Test(dataProvider = "longBinaryOpMaskProvider") 2905 static void ROLLongMaxVectorTestsScalarShiftMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 2906 IntFunction<boolean[]> fm) { 2907 long[] a = fa.apply(SPECIES.length()); 2908 long[] b = fb.apply(SPECIES.length()); 2909 long[] r = fr.apply(SPECIES.length()); 2910 boolean[] mask = fm.apply(SPECIES.length()); 2911 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2912 2913 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2914 for (int i = 0; i < a.length; i += SPECIES.length()) { 2915 LongVector av = LongVector.fromArray(SPECIES, a, i); 2916 av.lanewise(VectorOperators.ROL, (int)b[i], vmask).intoArray(r, i); 2917 } 2918 } 2919 2920 assertShiftArraysEquals(r, a, b, mask, LongMaxVectorTests::ROL_unary); 2921 } 2922 static long LSHR_binary_const(long a) { 2923 return (long)((a >>> CONST_SHIFT)); 2924 } 2925 2926 @Test(dataProvider = "longUnaryOpProvider") 2927 static void LSHRLongMaxVectorTestsScalarShiftConst(IntFunction<long[]> fa) { 2928 long[] a = fa.apply(SPECIES.length()); 2929 long[] r = fr.apply(SPECIES.length()); 2930 2931 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2932 for (int i = 0; i < a.length; i += SPECIES.length()) { 2933 LongVector av = LongVector.fromArray(SPECIES, a, i); 2934 av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i); 2935 } 2936 } 2937 2938 assertShiftConstEquals(r, a, LongMaxVectorTests::LSHR_binary_const); 2939 } 2940 2941 @Test(dataProvider = "longUnaryOpMaskProvider") 2942 static void LSHRLongMaxVectorTestsScalarShiftMaskedConst(IntFunction<long[]> fa, 2943 IntFunction<boolean[]> fm) { 2944 long[] a = fa.apply(SPECIES.length()); 2945 long[] r = fr.apply(SPECIES.length()); 2946 boolean[] mask = fm.apply(SPECIES.length()); 2947 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2948 2949 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2950 for (int i = 0; i < a.length; i += SPECIES.length()) { 2951 LongVector av = LongVector.fromArray(SPECIES, a, i); 2952 av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i); 2953 } 2954 } 2955 2956 assertShiftConstEquals(r, a, mask, LongMaxVectorTests::LSHR_binary_const); 2957 } 2958 2959 static long LSHL_binary_const(long a) { 2960 return (long)((a << CONST_SHIFT)); 2961 } 2962 2963 @Test(dataProvider = "longUnaryOpProvider") 2964 static void LSHLLongMaxVectorTestsScalarShiftConst(IntFunction<long[]> fa) { 2965 long[] a = fa.apply(SPECIES.length()); 2966 long[] r = fr.apply(SPECIES.length()); 2967 2968 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2969 for (int i = 0; i < a.length; i += SPECIES.length()) { 2970 LongVector av = LongVector.fromArray(SPECIES, a, i); 2971 av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i); 2972 } 2973 } 2974 2975 assertShiftConstEquals(r, a, LongMaxVectorTests::LSHL_binary_const); 2976 } 2977 2978 @Test(dataProvider = "longUnaryOpMaskProvider") 2979 static void LSHLLongMaxVectorTestsScalarShiftMaskedConst(IntFunction<long[]> fa, 2980 IntFunction<boolean[]> fm) { 2981 long[] a = fa.apply(SPECIES.length()); 2982 long[] r = fr.apply(SPECIES.length()); 2983 boolean[] mask = fm.apply(SPECIES.length()); 2984 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2985 2986 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2987 for (int i = 0; i < a.length; i += SPECIES.length()) { 2988 LongVector av = LongVector.fromArray(SPECIES, a, i); 2989 av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i); 2990 } 2991 } 2992 2993 assertShiftConstEquals(r, a, mask, LongMaxVectorTests::LSHL_binary_const); 2994 } 2995 2996 static long ASHR_binary_const(long a) { 2997 return (long)((a >> CONST_SHIFT)); 2998 } 2999 3000 @Test(dataProvider = "longUnaryOpProvider") 3001 static void ASHRLongMaxVectorTestsScalarShiftConst(IntFunction<long[]> fa) { 3002 long[] a = fa.apply(SPECIES.length()); 3003 long[] r = fr.apply(SPECIES.length()); 3004 3005 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3006 for (int i = 0; i < a.length; i += SPECIES.length()) { 3007 LongVector av = LongVector.fromArray(SPECIES, a, i); 3008 av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i); 3009 } 3010 } 3011 3012 assertShiftConstEquals(r, a, LongMaxVectorTests::ASHR_binary_const); 3013 } 3014 3015 @Test(dataProvider = "longUnaryOpMaskProvider") 3016 static void ASHRLongMaxVectorTestsScalarShiftMaskedConst(IntFunction<long[]> fa, 3017 IntFunction<boolean[]> fm) { 3018 long[] a = fa.apply(SPECIES.length()); 3019 long[] r = fr.apply(SPECIES.length()); 3020 boolean[] mask = fm.apply(SPECIES.length()); 3021 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3022 3023 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3024 for (int i = 0; i < a.length; i += SPECIES.length()) { 3025 LongVector av = LongVector.fromArray(SPECIES, a, i); 3026 av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i); 3027 } 3028 } 3029 3030 assertShiftConstEquals(r, a, mask, LongMaxVectorTests::ASHR_binary_const); 3031 } 3032 3033 static long ROR_binary_const(long a) { 3034 return (long)(ROR_scalar(a, CONST_SHIFT)); 3035 } 3036 3037 @Test(dataProvider = "longUnaryOpProvider") 3038 static void RORLongMaxVectorTestsScalarShiftConst(IntFunction<long[]> fa) { 3039 long[] a = fa.apply(SPECIES.length()); 3040 long[] r = fr.apply(SPECIES.length()); 3041 3042 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3043 for (int i = 0; i < a.length; i += SPECIES.length()) { 3044 LongVector av = LongVector.fromArray(SPECIES, a, i); 3045 av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i); 3046 } 3047 } 3048 3049 assertShiftConstEquals(r, a, LongMaxVectorTests::ROR_binary_const); 3050 } 3051 3052 @Test(dataProvider = "longUnaryOpMaskProvider") 3053 static void RORLongMaxVectorTestsScalarShiftMaskedConst(IntFunction<long[]> fa, 3054 IntFunction<boolean[]> fm) { 3055 long[] a = fa.apply(SPECIES.length()); 3056 long[] r = fr.apply(SPECIES.length()); 3057 boolean[] mask = fm.apply(SPECIES.length()); 3058 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3059 3060 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3061 for (int i = 0; i < a.length; i += SPECIES.length()) { 3062 LongVector av = LongVector.fromArray(SPECIES, a, i); 3063 av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i); 3064 } 3065 } 3066 3067 assertShiftConstEquals(r, a, mask, LongMaxVectorTests::ROR_binary_const); 3068 } 3069 3070 static long ROL_binary_const(long a) { 3071 return (long)(ROL_scalar(a, CONST_SHIFT)); 3072 } 3073 3074 @Test(dataProvider = "longUnaryOpProvider") 3075 static void ROLLongMaxVectorTestsScalarShiftConst(IntFunction<long[]> fa) { 3076 long[] a = fa.apply(SPECIES.length()); 3077 long[] r = fr.apply(SPECIES.length()); 3078 3079 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3080 for (int i = 0; i < a.length; i += SPECIES.length()) { 3081 LongVector av = LongVector.fromArray(SPECIES, a, i); 3082 av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i); 3083 } 3084 } 3085 3086 assertShiftConstEquals(r, a, LongMaxVectorTests::ROL_binary_const); 3087 } 3088 3089 @Test(dataProvider = "longUnaryOpMaskProvider") 3090 static void ROLLongMaxVectorTestsScalarShiftMaskedConst(IntFunction<long[]> fa, 3091 IntFunction<boolean[]> fm) { 3092 long[] a = fa.apply(SPECIES.length()); 3093 long[] r = fr.apply(SPECIES.length()); 3094 boolean[] mask = fm.apply(SPECIES.length()); 3095 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3096 3097 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3098 for (int i = 0; i < a.length; i += SPECIES.length()) { 3099 LongVector av = LongVector.fromArray(SPECIES, a, i); 3100 av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i); 3101 } 3102 } 3103 3104 assertShiftConstEquals(r, a, mask, LongMaxVectorTests::ROL_binary_const); 3105 } 3106 3107 3108 @Test(dataProvider = "longUnaryOpProvider") 3109 static void MINLongMaxVectorTestsWithMemOp(IntFunction<long[]> fa) { 3110 long[] a = fa.apply(SPECIES.length()); 3111 long[] r = fr.apply(SPECIES.length()); 3112 3113 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3114 for (int i = 0; i < a.length; i += SPECIES.length()) { 3115 LongVector av = LongVector.fromArray(SPECIES, a, i); 3116 av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); 3117 } 3118 } 3119 3120 assertArraysEquals(r, a, (long)10, LongMaxVectorTests::MIN); 3121 } 3122 3123 @Test(dataProvider = "longUnaryOpProvider") 3124 static void minLongMaxVectorTestsWithMemOp(IntFunction<long[]> fa) { 3125 long[] a = fa.apply(SPECIES.length()); 3126 long[] r = fr.apply(SPECIES.length()); 3127 3128 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3129 for (int i = 0; i < a.length; i += SPECIES.length()) { 3130 LongVector av = LongVector.fromArray(SPECIES, a, i); 3131 av.min(bcast_vec).intoArray(r, i); 3132 } 3133 } 3134 3135 assertArraysEquals(r, a, (long)10, LongMaxVectorTests::min); 3136 } 3137 3138 @Test(dataProvider = "longUnaryOpMaskProvider") 3139 static void MINLongMaxVectorTestsMaskedWithMemOp(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { 3140 long[] a = fa.apply(SPECIES.length()); 3141 long[] r = fr.apply(SPECIES.length()); 3142 boolean[] mask = fm.apply(SPECIES.length()); 3143 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3144 3145 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3146 for (int i = 0; i < a.length; i += SPECIES.length()) { 3147 LongVector av = LongVector.fromArray(SPECIES, a, i); 3148 av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); 3149 } 3150 } 3151 3152 assertArraysEquals(r, a, (long)10, mask, LongMaxVectorTests::MIN); 3153 } 3154 3155 @Test(dataProvider = "longUnaryOpProvider") 3156 static void MAXLongMaxVectorTestsWithMemOp(IntFunction<long[]> fa) { 3157 long[] a = fa.apply(SPECIES.length()); 3158 long[] r = fr.apply(SPECIES.length()); 3159 3160 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3161 for (int i = 0; i < a.length; i += SPECIES.length()) { 3162 LongVector av = LongVector.fromArray(SPECIES, a, i); 3163 av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); 3164 } 3165 } 3166 3167 assertArraysEquals(r, a, (long)10, LongMaxVectorTests::MAX); 3168 } 3169 3170 @Test(dataProvider = "longUnaryOpProvider") 3171 static void maxLongMaxVectorTestsWithMemOp(IntFunction<long[]> fa) { 3172 long[] a = fa.apply(SPECIES.length()); 3173 long[] r = fr.apply(SPECIES.length()); 3174 3175 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3176 for (int i = 0; i < a.length; i += SPECIES.length()) { 3177 LongVector av = LongVector.fromArray(SPECIES, a, i); 3178 av.max(bcast_vec).intoArray(r, i); 3179 } 3180 } 3181 3182 assertArraysEquals(r, a, (long)10, LongMaxVectorTests::max); 3183 } 3184 3185 @Test(dataProvider = "longUnaryOpMaskProvider") 3186 static void MAXLongMaxVectorTestsMaskedWithMemOp(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { 3187 long[] a = fa.apply(SPECIES.length()); 3188 long[] r = fr.apply(SPECIES.length()); 3189 boolean[] mask = fm.apply(SPECIES.length()); 3190 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3191 3192 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3193 for (int i = 0; i < a.length; i += SPECIES.length()) { 3194 LongVector av = LongVector.fromArray(SPECIES, a, i); 3195 av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); 3196 } 3197 } 3198 3199 assertArraysEquals(r, a, (long)10, mask, LongMaxVectorTests::MAX); 3200 } 3201 3202 static long MIN(long a, long b) { 3203 return (long)(Math.min(a, b)); 3204 } 3205 3206 @Test(dataProvider = "longBinaryOpProvider") 3207 static void MINLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 3208 long[] a = fa.apply(SPECIES.length()); 3209 long[] b = fb.apply(SPECIES.length()); 3210 long[] r = fr.apply(SPECIES.length()); 3211 3212 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3213 for (int i = 0; i < a.length; i += SPECIES.length()) { 3214 LongVector av = LongVector.fromArray(SPECIES, a, i); 3215 LongVector bv = LongVector.fromArray(SPECIES, b, i); 3216 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i); 3217 } 3218 } 3219 3220 assertArraysEquals(r, a, b, LongMaxVectorTests::MIN); 3221 } 3222 3223 static long min(long a, long b) { 3224 return (long)(Math.min(a, b)); 3225 } 3226 3227 @Test(dataProvider = "longBinaryOpProvider") 3228 static void minLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 3229 long[] a = fa.apply(SPECIES.length()); 3230 long[] b = fb.apply(SPECIES.length()); 3231 long[] r = fr.apply(SPECIES.length()); 3232 3233 for (int i = 0; i < a.length; i += SPECIES.length()) { 3234 LongVector av = LongVector.fromArray(SPECIES, a, i); 3235 LongVector bv = LongVector.fromArray(SPECIES, b, i); 3236 av.min(bv).intoArray(r, i); 3237 } 3238 3239 assertArraysEquals(r, a, b, LongMaxVectorTests::min); 3240 } 3241 3242 static long MAX(long a, long b) { 3243 return (long)(Math.max(a, b)); 3244 } 3245 3246 @Test(dataProvider = "longBinaryOpProvider") 3247 static void MAXLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 3248 long[] a = fa.apply(SPECIES.length()); 3249 long[] b = fb.apply(SPECIES.length()); 3250 long[] r = fr.apply(SPECIES.length()); 3251 3252 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3253 for (int i = 0; i < a.length; i += SPECIES.length()) { 3254 LongVector av = LongVector.fromArray(SPECIES, a, i); 3255 LongVector bv = LongVector.fromArray(SPECIES, b, i); 3256 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i); 3257 } 3258 } 3259 3260 assertArraysEquals(r, a, b, LongMaxVectorTests::MAX); 3261 } 3262 3263 static long max(long a, long b) { 3264 return (long)(Math.max(a, b)); 3265 } 3266 3267 @Test(dataProvider = "longBinaryOpProvider") 3268 static void maxLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 3269 long[] a = fa.apply(SPECIES.length()); 3270 long[] b = fb.apply(SPECIES.length()); 3271 long[] r = fr.apply(SPECIES.length()); 3272 3273 for (int i = 0; i < a.length; i += SPECIES.length()) { 3274 LongVector av = LongVector.fromArray(SPECIES, a, i); 3275 LongVector bv = LongVector.fromArray(SPECIES, b, i); 3276 av.max(bv).intoArray(r, i); 3277 } 3278 3279 assertArraysEquals(r, a, b, LongMaxVectorTests::max); 3280 } 3281 3282 static long UMIN(long a, long b) { 3283 return (long)(VectorMath.minUnsigned(a, b)); 3284 } 3285 3286 @Test(dataProvider = "longBinaryOpProvider") 3287 static void UMINLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 3288 long[] a = fa.apply(SPECIES.length()); 3289 long[] b = fb.apply(SPECIES.length()); 3290 long[] r = fr.apply(SPECIES.length()); 3291 3292 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3293 for (int i = 0; i < a.length; i += SPECIES.length()) { 3294 LongVector av = LongVector.fromArray(SPECIES, a, i); 3295 LongVector bv = LongVector.fromArray(SPECIES, b, i); 3296 av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); 3297 } 3298 } 3299 3300 assertArraysEquals(r, a, b, LongMaxVectorTests::UMIN); 3301 } 3302 3303 @Test(dataProvider = "longBinaryOpMaskProvider") 3304 static void UMINLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 3305 IntFunction<boolean[]> fm) { 3306 long[] a = fa.apply(SPECIES.length()); 3307 long[] b = fb.apply(SPECIES.length()); 3308 long[] r = fr.apply(SPECIES.length()); 3309 boolean[] mask = fm.apply(SPECIES.length()); 3310 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3311 3312 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3313 for (int i = 0; i < a.length; i += SPECIES.length()) { 3314 LongVector av = LongVector.fromArray(SPECIES, a, i); 3315 LongVector bv = LongVector.fromArray(SPECIES, b, i); 3316 av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); 3317 } 3318 } 3319 3320 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::UMIN); 3321 } 3322 3323 static long UMAX(long a, long b) { 3324 return (long)(VectorMath.maxUnsigned(a, b)); 3325 } 3326 3327 @Test(dataProvider = "longBinaryOpProvider") 3328 static void UMAXLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 3329 long[] a = fa.apply(SPECIES.length()); 3330 long[] b = fb.apply(SPECIES.length()); 3331 long[] r = fr.apply(SPECIES.length()); 3332 3333 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3334 for (int i = 0; i < a.length; i += SPECIES.length()) { 3335 LongVector av = LongVector.fromArray(SPECIES, a, i); 3336 LongVector bv = LongVector.fromArray(SPECIES, b, i); 3337 av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); 3338 } 3339 } 3340 3341 assertArraysEquals(r, a, b, LongMaxVectorTests::UMAX); 3342 } 3343 3344 @Test(dataProvider = "longBinaryOpMaskProvider") 3345 static void UMAXLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 3346 IntFunction<boolean[]> fm) { 3347 long[] a = fa.apply(SPECIES.length()); 3348 long[] b = fb.apply(SPECIES.length()); 3349 long[] r = fr.apply(SPECIES.length()); 3350 boolean[] mask = fm.apply(SPECIES.length()); 3351 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3352 3353 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3354 for (int i = 0; i < a.length; i += SPECIES.length()) { 3355 LongVector av = LongVector.fromArray(SPECIES, a, i); 3356 LongVector bv = LongVector.fromArray(SPECIES, b, i); 3357 av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); 3358 } 3359 } 3360 3361 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::UMAX); 3362 } 3363 3364 static long SADD(long a, long b) { 3365 return (long)(VectorMath.addSaturating(a, b)); 3366 } 3367 3368 @Test(dataProvider = "longSaturatingBinaryOpProvider") 3369 static void SADDLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 3370 long[] a = fa.apply(SPECIES.length()); 3371 long[] b = fb.apply(SPECIES.length()); 3372 long[] r = fr.apply(SPECIES.length()); 3373 3374 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3375 for (int i = 0; i < a.length; i += SPECIES.length()) { 3376 LongVector av = LongVector.fromArray(SPECIES, a, i); 3377 LongVector bv = LongVector.fromArray(SPECIES, b, i); 3378 av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); 3379 } 3380 } 3381 3382 assertArraysEquals(r, a, b, LongMaxVectorTests::SADD); 3383 } 3384 3385 @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") 3386 static void SADDLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 3387 IntFunction<boolean[]> fm) { 3388 long[] a = fa.apply(SPECIES.length()); 3389 long[] b = fb.apply(SPECIES.length()); 3390 long[] r = fr.apply(SPECIES.length()); 3391 boolean[] mask = fm.apply(SPECIES.length()); 3392 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3393 3394 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3395 for (int i = 0; i < a.length; i += SPECIES.length()) { 3396 LongVector av = LongVector.fromArray(SPECIES, a, i); 3397 LongVector bv = LongVector.fromArray(SPECIES, b, i); 3398 av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); 3399 } 3400 } 3401 3402 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::SADD); 3403 } 3404 3405 static long SSUB(long a, long b) { 3406 return (long)(VectorMath.subSaturating(a, b)); 3407 } 3408 3409 @Test(dataProvider = "longSaturatingBinaryOpProvider") 3410 static void SSUBLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 3411 long[] a = fa.apply(SPECIES.length()); 3412 long[] b = fb.apply(SPECIES.length()); 3413 long[] r = fr.apply(SPECIES.length()); 3414 3415 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3416 for (int i = 0; i < a.length; i += SPECIES.length()) { 3417 LongVector av = LongVector.fromArray(SPECIES, a, i); 3418 LongVector bv = LongVector.fromArray(SPECIES, b, i); 3419 av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); 3420 } 3421 } 3422 3423 assertArraysEquals(r, a, b, LongMaxVectorTests::SSUB); 3424 } 3425 3426 @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") 3427 static void SSUBLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 3428 IntFunction<boolean[]> fm) { 3429 long[] a = fa.apply(SPECIES.length()); 3430 long[] b = fb.apply(SPECIES.length()); 3431 long[] r = fr.apply(SPECIES.length()); 3432 boolean[] mask = fm.apply(SPECIES.length()); 3433 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3434 3435 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3436 for (int i = 0; i < a.length; i += SPECIES.length()) { 3437 LongVector av = LongVector.fromArray(SPECIES, a, i); 3438 LongVector bv = LongVector.fromArray(SPECIES, b, i); 3439 av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); 3440 } 3441 } 3442 3443 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::SSUB); 3444 } 3445 3446 static long SUADD(long a, long b) { 3447 return (long)(VectorMath.addSaturatingUnsigned(a, b)); 3448 } 3449 3450 @Test(dataProvider = "longSaturatingBinaryOpProvider") 3451 static void SUADDLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 3452 long[] a = fa.apply(SPECIES.length()); 3453 long[] b = fb.apply(SPECIES.length()); 3454 long[] r = fr.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 LongVector av = LongVector.fromArray(SPECIES, a, i); 3459 LongVector bv = LongVector.fromArray(SPECIES, b, i); 3460 av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); 3461 } 3462 } 3463 3464 assertArraysEquals(r, a, b, LongMaxVectorTests::SUADD); 3465 } 3466 3467 @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") 3468 static void SUADDLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 3469 IntFunction<boolean[]> fm) { 3470 long[] a = fa.apply(SPECIES.length()); 3471 long[] b = fb.apply(SPECIES.length()); 3472 long[] r = fr.apply(SPECIES.length()); 3473 boolean[] mask = fm.apply(SPECIES.length()); 3474 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3475 3476 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3477 for (int i = 0; i < a.length; i += SPECIES.length()) { 3478 LongVector av = LongVector.fromArray(SPECIES, a, i); 3479 LongVector bv = LongVector.fromArray(SPECIES, b, i); 3480 av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); 3481 } 3482 } 3483 3484 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::SUADD); 3485 } 3486 3487 static long SUSUB(long a, long b) { 3488 return (long)(VectorMath.subSaturatingUnsigned(a, b)); 3489 } 3490 3491 @Test(dataProvider = "longSaturatingBinaryOpProvider") 3492 static void SUSUBLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 3493 long[] a = fa.apply(SPECIES.length()); 3494 long[] b = fb.apply(SPECIES.length()); 3495 long[] r = fr.apply(SPECIES.length()); 3496 3497 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3498 for (int i = 0; i < a.length; i += SPECIES.length()) { 3499 LongVector av = LongVector.fromArray(SPECIES, a, i); 3500 LongVector bv = LongVector.fromArray(SPECIES, b, i); 3501 av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); 3502 } 3503 } 3504 3505 assertArraysEquals(r, a, b, LongMaxVectorTests::SUSUB); 3506 } 3507 3508 @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") 3509 static void SUSUBLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 3510 IntFunction<boolean[]> fm) { 3511 long[] a = fa.apply(SPECIES.length()); 3512 long[] b = fb.apply(SPECIES.length()); 3513 long[] r = fr.apply(SPECIES.length()); 3514 boolean[] mask = fm.apply(SPECIES.length()); 3515 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3516 3517 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3518 for (int i = 0; i < a.length; i += SPECIES.length()) { 3519 LongVector av = LongVector.fromArray(SPECIES, a, i); 3520 LongVector bv = LongVector.fromArray(SPECIES, b, i); 3521 av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); 3522 } 3523 } 3524 3525 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::SUSUB); 3526 } 3527 3528 @Test(dataProvider = "longBinaryOpProvider") 3529 static void MINLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { 3530 long[] a = fa.apply(SPECIES.length()); 3531 long[] b = fb.apply(SPECIES.length()); 3532 long[] r = fr.apply(SPECIES.length()); 3533 3534 for (int i = 0; i < a.length; i += SPECIES.length()) { 3535 LongVector av = LongVector.fromArray(SPECIES, a, i); 3536 av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); 3537 } 3538 3539 assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::MIN); 3540 } 3541 3542 @Test(dataProvider = "longBinaryOpProvider") 3543 static void minLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { 3544 long[] a = fa.apply(SPECIES.length()); 3545 long[] b = fb.apply(SPECIES.length()); 3546 long[] r = fr.apply(SPECIES.length()); 3547 3548 for (int i = 0; i < a.length; i += SPECIES.length()) { 3549 LongVector av = LongVector.fromArray(SPECIES, a, i); 3550 av.min(b[i]).intoArray(r, i); 3551 } 3552 3553 assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::min); 3554 } 3555 3556 @Test(dataProvider = "longBinaryOpProvider") 3557 static void MAXLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { 3558 long[] a = fa.apply(SPECIES.length()); 3559 long[] b = fb.apply(SPECIES.length()); 3560 long[] r = fr.apply(SPECIES.length()); 3561 3562 for (int i = 0; i < a.length; i += SPECIES.length()) { 3563 LongVector av = LongVector.fromArray(SPECIES, a, i); 3564 av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); 3565 } 3566 3567 assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::MAX); 3568 } 3569 3570 @Test(dataProvider = "longBinaryOpProvider") 3571 static void maxLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { 3572 long[] a = fa.apply(SPECIES.length()); 3573 long[] b = fb.apply(SPECIES.length()); 3574 long[] r = fr.apply(SPECIES.length()); 3575 3576 for (int i = 0; i < a.length; i += SPECIES.length()) { 3577 LongVector av = LongVector.fromArray(SPECIES, a, i); 3578 av.max(b[i]).intoArray(r, i); 3579 } 3580 3581 assertBroadcastArraysEquals(r, a, b, LongMaxVectorTests::max); 3582 } 3583 @Test(dataProvider = "longSaturatingBinaryOpAssocProvider") 3584 static void SUADDAssocLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) { 3585 long[] a = fa.apply(SPECIES.length()); 3586 long[] b = fb.apply(SPECIES.length()); 3587 long[] c = fc.apply(SPECIES.length()); 3588 long[] rl = fr.apply(SPECIES.length()); 3589 long[] rr = fr.apply(SPECIES.length()); 3590 3591 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3592 for (int i = 0; i < a.length; i += SPECIES.length()) { 3593 LongVector av = LongVector.fromArray(SPECIES, a, i); 3594 LongVector bv = LongVector.fromArray(SPECIES, b, i); 3595 LongVector cv = LongVector.fromArray(SPECIES, c, i); 3596 av.lanewise(VectorOperators.SUADD, bv).lanewise(VectorOperators.SUADD, cv).intoArray(rl, i); 3597 av.lanewise(VectorOperators.SUADD, bv.lanewise(VectorOperators.SUADD, cv)).intoArray(rr, i); 3598 } 3599 } 3600 3601 assertArraysEqualsAssociative(rl, rr, a, b, c, LongMaxVectorTests::SUADD); 3602 } 3603 3604 @Test(dataProvider = "longSaturatingBinaryOpAssocMaskProvider") 3605 static void SUADDAssocLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 3606 IntFunction<long[]> fc, IntFunction<boolean[]> fm) { 3607 long[] a = fa.apply(SPECIES.length()); 3608 long[] b = fb.apply(SPECIES.length()); 3609 long[] c = fc.apply(SPECIES.length()); 3610 boolean[] mask = fm.apply(SPECIES.length()); 3611 long[] rl = fr.apply(SPECIES.length()); 3612 long[] rr = fr.apply(SPECIES.length()); 3613 3614 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3615 3616 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3617 for (int i = 0; i < a.length; i += SPECIES.length()) { 3618 LongVector av = LongVector.fromArray(SPECIES, a, i); 3619 LongVector bv = LongVector.fromArray(SPECIES, b, i); 3620 LongVector cv = LongVector.fromArray(SPECIES, c, i); 3621 av.lanewise(VectorOperators.SUADD, bv, vmask).lanewise(VectorOperators.SUADD, cv, vmask).intoArray(rl, i); 3622 av.lanewise(VectorOperators.SUADD, bv.lanewise(VectorOperators.SUADD, cv, vmask), vmask).intoArray(rr, i); 3623 } 3624 } 3625 3626 assertArraysEqualsAssociative(rl, rr, a, b, c, mask, LongMaxVectorTests::SUADD); 3627 } 3628 3629 static long ANDReduce(long[] a, int idx) { 3630 long res = -1; 3631 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3632 res &= a[i]; 3633 } 3634 3635 return res; 3636 } 3637 3638 static long ANDReduceAll(long[] a) { 3639 long res = -1; 3640 for (int i = 0; i < a.length; i += SPECIES.length()) { 3641 res &= ANDReduce(a, i); 3642 } 3643 3644 return res; 3645 } 3646 3647 @Test(dataProvider = "longUnaryOpProvider") 3648 static void ANDReduceLongMaxVectorTests(IntFunction<long[]> fa) { 3649 long[] a = fa.apply(SPECIES.length()); 3650 long[] r = fr.apply(SPECIES.length()); 3651 long ra = -1; 3652 3653 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3654 for (int i = 0; i < a.length; i += SPECIES.length()) { 3655 LongVector av = LongVector.fromArray(SPECIES, a, i); 3656 r[i] = av.reduceLanes(VectorOperators.AND); 3657 } 3658 } 3659 3660 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3661 ra = -1; 3662 for (int i = 0; i < a.length; i += SPECIES.length()) { 3663 LongVector av = LongVector.fromArray(SPECIES, a, i); 3664 ra &= av.reduceLanes(VectorOperators.AND); 3665 } 3666 } 3667 3668 assertReductionArraysEquals(r, ra, a, 3669 LongMaxVectorTests::ANDReduce, LongMaxVectorTests::ANDReduceAll); 3670 } 3671 3672 static long ANDReduceMasked(long[] a, int idx, boolean[] mask) { 3673 long res = -1; 3674 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3675 if (mask[i % SPECIES.length()]) 3676 res &= a[i]; 3677 } 3678 3679 return res; 3680 } 3681 3682 static long ANDReduceAllMasked(long[] a, boolean[] mask) { 3683 long res = -1; 3684 for (int i = 0; i < a.length; i += SPECIES.length()) { 3685 res &= ANDReduceMasked(a, i, mask); 3686 } 3687 3688 return res; 3689 } 3690 3691 @Test(dataProvider = "longUnaryOpMaskProvider") 3692 static void ANDReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { 3693 long[] a = fa.apply(SPECIES.length()); 3694 long[] r = fr.apply(SPECIES.length()); 3695 boolean[] mask = fm.apply(SPECIES.length()); 3696 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3697 long ra = -1; 3698 3699 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3700 for (int i = 0; i < a.length; i += SPECIES.length()) { 3701 LongVector av = LongVector.fromArray(SPECIES, a, i); 3702 r[i] = av.reduceLanes(VectorOperators.AND, vmask); 3703 } 3704 } 3705 3706 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3707 ra = -1; 3708 for (int i = 0; i < a.length; i += SPECIES.length()) { 3709 LongVector av = LongVector.fromArray(SPECIES, a, i); 3710 ra &= av.reduceLanes(VectorOperators.AND, vmask); 3711 } 3712 } 3713 3714 assertReductionArraysEqualsMasked(r, ra, a, mask, 3715 LongMaxVectorTests::ANDReduceMasked, LongMaxVectorTests::ANDReduceAllMasked); 3716 } 3717 3718 static long ORReduce(long[] a, int idx) { 3719 long res = 0; 3720 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3721 res |= a[i]; 3722 } 3723 3724 return res; 3725 } 3726 3727 static long ORReduceAll(long[] a) { 3728 long res = 0; 3729 for (int i = 0; i < a.length; i += SPECIES.length()) { 3730 res |= ORReduce(a, i); 3731 } 3732 3733 return res; 3734 } 3735 3736 @Test(dataProvider = "longUnaryOpProvider") 3737 static void ORReduceLongMaxVectorTests(IntFunction<long[]> fa) { 3738 long[] a = fa.apply(SPECIES.length()); 3739 long[] r = fr.apply(SPECIES.length()); 3740 long ra = 0; 3741 3742 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3743 for (int i = 0; i < a.length; i += SPECIES.length()) { 3744 LongVector av = LongVector.fromArray(SPECIES, a, i); 3745 r[i] = av.reduceLanes(VectorOperators.OR); 3746 } 3747 } 3748 3749 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3750 ra = 0; 3751 for (int i = 0; i < a.length; i += SPECIES.length()) { 3752 LongVector av = LongVector.fromArray(SPECIES, a, i); 3753 ra |= av.reduceLanes(VectorOperators.OR); 3754 } 3755 } 3756 3757 assertReductionArraysEquals(r, ra, a, 3758 LongMaxVectorTests::ORReduce, LongMaxVectorTests::ORReduceAll); 3759 } 3760 3761 static long ORReduceMasked(long[] a, int idx, boolean[] mask) { 3762 long res = 0; 3763 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3764 if (mask[i % SPECIES.length()]) 3765 res |= a[i]; 3766 } 3767 3768 return res; 3769 } 3770 3771 static long ORReduceAllMasked(long[] a, boolean[] mask) { 3772 long res = 0; 3773 for (int i = 0; i < a.length; i += SPECIES.length()) { 3774 res |= ORReduceMasked(a, i, mask); 3775 } 3776 3777 return res; 3778 } 3779 3780 @Test(dataProvider = "longUnaryOpMaskProvider") 3781 static void ORReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { 3782 long[] a = fa.apply(SPECIES.length()); 3783 long[] r = fr.apply(SPECIES.length()); 3784 boolean[] mask = fm.apply(SPECIES.length()); 3785 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3786 long ra = 0; 3787 3788 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3789 for (int i = 0; i < a.length; i += SPECIES.length()) { 3790 LongVector av = LongVector.fromArray(SPECIES, a, i); 3791 r[i] = av.reduceLanes(VectorOperators.OR, vmask); 3792 } 3793 } 3794 3795 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3796 ra = 0; 3797 for (int i = 0; i < a.length; i += SPECIES.length()) { 3798 LongVector av = LongVector.fromArray(SPECIES, a, i); 3799 ra |= av.reduceLanes(VectorOperators.OR, vmask); 3800 } 3801 } 3802 3803 assertReductionArraysEqualsMasked(r, ra, a, mask, 3804 LongMaxVectorTests::ORReduceMasked, LongMaxVectorTests::ORReduceAllMasked); 3805 } 3806 3807 static long XORReduce(long[] a, int idx) { 3808 long res = 0; 3809 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3810 res ^= a[i]; 3811 } 3812 3813 return res; 3814 } 3815 3816 static long XORReduceAll(long[] a) { 3817 long res = 0; 3818 for (int i = 0; i < a.length; i += SPECIES.length()) { 3819 res ^= XORReduce(a, i); 3820 } 3821 3822 return res; 3823 } 3824 3825 @Test(dataProvider = "longUnaryOpProvider") 3826 static void XORReduceLongMaxVectorTests(IntFunction<long[]> fa) { 3827 long[] a = fa.apply(SPECIES.length()); 3828 long[] r = fr.apply(SPECIES.length()); 3829 long ra = 0; 3830 3831 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3832 for (int i = 0; i < a.length; i += SPECIES.length()) { 3833 LongVector av = LongVector.fromArray(SPECIES, a, i); 3834 r[i] = av.reduceLanes(VectorOperators.XOR); 3835 } 3836 } 3837 3838 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3839 ra = 0; 3840 for (int i = 0; i < a.length; i += SPECIES.length()) { 3841 LongVector av = LongVector.fromArray(SPECIES, a, i); 3842 ra ^= av.reduceLanes(VectorOperators.XOR); 3843 } 3844 } 3845 3846 assertReductionArraysEquals(r, ra, a, 3847 LongMaxVectorTests::XORReduce, LongMaxVectorTests::XORReduceAll); 3848 } 3849 3850 static long XORReduceMasked(long[] a, int idx, boolean[] mask) { 3851 long res = 0; 3852 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3853 if (mask[i % SPECIES.length()]) 3854 res ^= a[i]; 3855 } 3856 3857 return res; 3858 } 3859 3860 static long XORReduceAllMasked(long[] a, boolean[] mask) { 3861 long res = 0; 3862 for (int i = 0; i < a.length; i += SPECIES.length()) { 3863 res ^= XORReduceMasked(a, i, mask); 3864 } 3865 3866 return res; 3867 } 3868 3869 @Test(dataProvider = "longUnaryOpMaskProvider") 3870 static void XORReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { 3871 long[] a = fa.apply(SPECIES.length()); 3872 long[] r = fr.apply(SPECIES.length()); 3873 boolean[] mask = fm.apply(SPECIES.length()); 3874 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3875 long ra = 0; 3876 3877 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3878 for (int i = 0; i < a.length; i += SPECIES.length()) { 3879 LongVector av = LongVector.fromArray(SPECIES, a, i); 3880 r[i] = av.reduceLanes(VectorOperators.XOR, vmask); 3881 } 3882 } 3883 3884 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3885 ra = 0; 3886 for (int i = 0; i < a.length; i += SPECIES.length()) { 3887 LongVector av = LongVector.fromArray(SPECIES, a, i); 3888 ra ^= av.reduceLanes(VectorOperators.XOR, vmask); 3889 } 3890 } 3891 3892 assertReductionArraysEqualsMasked(r, ra, a, mask, 3893 LongMaxVectorTests::XORReduceMasked, LongMaxVectorTests::XORReduceAllMasked); 3894 } 3895 3896 static long ADDReduce(long[] a, int idx) { 3897 long res = 0; 3898 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3899 res += a[i]; 3900 } 3901 3902 return res; 3903 } 3904 3905 static long ADDReduceAll(long[] a) { 3906 long res = 0; 3907 for (int i = 0; i < a.length; i += SPECIES.length()) { 3908 res += ADDReduce(a, i); 3909 } 3910 3911 return res; 3912 } 3913 3914 @Test(dataProvider = "longUnaryOpProvider") 3915 static void ADDReduceLongMaxVectorTests(IntFunction<long[]> fa) { 3916 long[] a = fa.apply(SPECIES.length()); 3917 long[] r = fr.apply(SPECIES.length()); 3918 long ra = 0; 3919 3920 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3921 for (int i = 0; i < a.length; i += SPECIES.length()) { 3922 LongVector av = LongVector.fromArray(SPECIES, a, i); 3923 r[i] = av.reduceLanes(VectorOperators.ADD); 3924 } 3925 } 3926 3927 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3928 ra = 0; 3929 for (int i = 0; i < a.length; i += SPECIES.length()) { 3930 LongVector av = LongVector.fromArray(SPECIES, a, i); 3931 ra += av.reduceLanes(VectorOperators.ADD); 3932 } 3933 } 3934 3935 assertReductionArraysEquals(r, ra, a, 3936 LongMaxVectorTests::ADDReduce, LongMaxVectorTests::ADDReduceAll); 3937 } 3938 3939 static long ADDReduceMasked(long[] a, int idx, boolean[] mask) { 3940 long res = 0; 3941 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3942 if (mask[i % SPECIES.length()]) 3943 res += a[i]; 3944 } 3945 3946 return res; 3947 } 3948 3949 static long ADDReduceAllMasked(long[] a, boolean[] mask) { 3950 long res = 0; 3951 for (int i = 0; i < a.length; i += SPECIES.length()) { 3952 res += ADDReduceMasked(a, i, mask); 3953 } 3954 3955 return res; 3956 } 3957 3958 @Test(dataProvider = "longUnaryOpMaskProvider") 3959 static void ADDReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { 3960 long[] a = fa.apply(SPECIES.length()); 3961 long[] r = fr.apply(SPECIES.length()); 3962 boolean[] mask = fm.apply(SPECIES.length()); 3963 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 3964 long ra = 0; 3965 3966 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3967 for (int i = 0; i < a.length; i += SPECIES.length()) { 3968 LongVector av = LongVector.fromArray(SPECIES, a, i); 3969 r[i] = av.reduceLanes(VectorOperators.ADD, vmask); 3970 } 3971 } 3972 3973 for (int ic = 0; ic < INVOC_COUNT; ic++) { 3974 ra = 0; 3975 for (int i = 0; i < a.length; i += SPECIES.length()) { 3976 LongVector av = LongVector.fromArray(SPECIES, a, i); 3977 ra += av.reduceLanes(VectorOperators.ADD, vmask); 3978 } 3979 } 3980 3981 assertReductionArraysEqualsMasked(r, ra, a, mask, 3982 LongMaxVectorTests::ADDReduceMasked, LongMaxVectorTests::ADDReduceAllMasked); 3983 } 3984 3985 static long MULReduce(long[] a, int idx) { 3986 long res = 1; 3987 for (int i = idx; i < (idx + SPECIES.length()); i++) { 3988 res *= a[i]; 3989 } 3990 3991 return res; 3992 } 3993 3994 static long MULReduceAll(long[] a) { 3995 long res = 1; 3996 for (int i = 0; i < a.length; i += SPECIES.length()) { 3997 res *= MULReduce(a, i); 3998 } 3999 4000 return res; 4001 } 4002 4003 @Test(dataProvider = "longUnaryOpProvider") 4004 static void MULReduceLongMaxVectorTests(IntFunction<long[]> fa) { 4005 long[] a = fa.apply(SPECIES.length()); 4006 long[] r = fr.apply(SPECIES.length()); 4007 long ra = 1; 4008 4009 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4010 for (int i = 0; i < a.length; i += SPECIES.length()) { 4011 LongVector av = LongVector.fromArray(SPECIES, a, i); 4012 r[i] = av.reduceLanes(VectorOperators.MUL); 4013 } 4014 } 4015 4016 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4017 ra = 1; 4018 for (int i = 0; i < a.length; i += SPECIES.length()) { 4019 LongVector av = LongVector.fromArray(SPECIES, a, i); 4020 ra *= av.reduceLanes(VectorOperators.MUL); 4021 } 4022 } 4023 4024 assertReductionArraysEquals(r, ra, a, 4025 LongMaxVectorTests::MULReduce, LongMaxVectorTests::MULReduceAll); 4026 } 4027 4028 static long MULReduceMasked(long[] a, int idx, boolean[] mask) { 4029 long res = 1; 4030 for (int i = idx; i < (idx + SPECIES.length()); i++) { 4031 if (mask[i % SPECIES.length()]) 4032 res *= a[i]; 4033 } 4034 4035 return res; 4036 } 4037 4038 static long MULReduceAllMasked(long[] a, boolean[] mask) { 4039 long res = 1; 4040 for (int i = 0; i < a.length; i += SPECIES.length()) { 4041 res *= MULReduceMasked(a, i, mask); 4042 } 4043 4044 return res; 4045 } 4046 4047 @Test(dataProvider = "longUnaryOpMaskProvider") 4048 static void MULReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { 4049 long[] a = fa.apply(SPECIES.length()); 4050 long[] r = fr.apply(SPECIES.length()); 4051 boolean[] mask = fm.apply(SPECIES.length()); 4052 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4053 long ra = 1; 4054 4055 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4056 for (int i = 0; i < a.length; i += SPECIES.length()) { 4057 LongVector av = LongVector.fromArray(SPECIES, a, i); 4058 r[i] = av.reduceLanes(VectorOperators.MUL, vmask); 4059 } 4060 } 4061 4062 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4063 ra = 1; 4064 for (int i = 0; i < a.length; i += SPECIES.length()) { 4065 LongVector av = LongVector.fromArray(SPECIES, a, i); 4066 ra *= av.reduceLanes(VectorOperators.MUL, vmask); 4067 } 4068 } 4069 4070 assertReductionArraysEqualsMasked(r, ra, a, mask, 4071 LongMaxVectorTests::MULReduceMasked, LongMaxVectorTests::MULReduceAllMasked); 4072 } 4073 4074 static long MINReduce(long[] a, int idx) { 4075 long res = Long.MAX_VALUE; 4076 for (int i = idx; i < (idx + SPECIES.length()); i++) { 4077 res = (long) Math.min(res, a[i]); 4078 } 4079 4080 return res; 4081 } 4082 4083 static long MINReduceAll(long[] a) { 4084 long res = Long.MAX_VALUE; 4085 for (int i = 0; i < a.length; i += SPECIES.length()) { 4086 res = (long) Math.min(res, MINReduce(a, i)); 4087 } 4088 4089 return res; 4090 } 4091 4092 @Test(dataProvider = "longUnaryOpProvider") 4093 static void MINReduceLongMaxVectorTests(IntFunction<long[]> fa) { 4094 long[] a = fa.apply(SPECIES.length()); 4095 long[] r = fr.apply(SPECIES.length()); 4096 long ra = Long.MAX_VALUE; 4097 4098 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4099 for (int i = 0; i < a.length; i += SPECIES.length()) { 4100 LongVector av = LongVector.fromArray(SPECIES, a, i); 4101 r[i] = av.reduceLanes(VectorOperators.MIN); 4102 } 4103 } 4104 4105 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4106 ra = Long.MAX_VALUE; 4107 for (int i = 0; i < a.length; i += SPECIES.length()) { 4108 LongVector av = LongVector.fromArray(SPECIES, a, i); 4109 ra = (long) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); 4110 } 4111 } 4112 4113 assertReductionArraysEquals(r, ra, a, 4114 LongMaxVectorTests::MINReduce, LongMaxVectorTests::MINReduceAll); 4115 } 4116 4117 static long MINReduceMasked(long[] a, int idx, boolean[] mask) { 4118 long res = Long.MAX_VALUE; 4119 for (int i = idx; i < (idx + SPECIES.length()); i++) { 4120 if (mask[i % SPECIES.length()]) 4121 res = (long) Math.min(res, a[i]); 4122 } 4123 4124 return res; 4125 } 4126 4127 static long MINReduceAllMasked(long[] a, boolean[] mask) { 4128 long res = Long.MAX_VALUE; 4129 for (int i = 0; i < a.length; i += SPECIES.length()) { 4130 res = (long) Math.min(res, MINReduceMasked(a, i, mask)); 4131 } 4132 4133 return res; 4134 } 4135 4136 @Test(dataProvider = "longUnaryOpMaskProvider") 4137 static void MINReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { 4138 long[] a = fa.apply(SPECIES.length()); 4139 long[] r = fr.apply(SPECIES.length()); 4140 boolean[] mask = fm.apply(SPECIES.length()); 4141 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4142 long ra = Long.MAX_VALUE; 4143 4144 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4145 for (int i = 0; i < a.length; i += SPECIES.length()) { 4146 LongVector av = LongVector.fromArray(SPECIES, a, i); 4147 r[i] = av.reduceLanes(VectorOperators.MIN, vmask); 4148 } 4149 } 4150 4151 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4152 ra = Long.MAX_VALUE; 4153 for (int i = 0; i < a.length; i += SPECIES.length()) { 4154 LongVector av = LongVector.fromArray(SPECIES, a, i); 4155 ra = (long) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); 4156 } 4157 } 4158 4159 assertReductionArraysEqualsMasked(r, ra, a, mask, 4160 LongMaxVectorTests::MINReduceMasked, LongMaxVectorTests::MINReduceAllMasked); 4161 } 4162 4163 static long MAXReduce(long[] a, int idx) { 4164 long res = Long.MIN_VALUE; 4165 for (int i = idx; i < (idx + SPECIES.length()); i++) { 4166 res = (long) Math.max(res, a[i]); 4167 } 4168 4169 return res; 4170 } 4171 4172 static long MAXReduceAll(long[] a) { 4173 long res = Long.MIN_VALUE; 4174 for (int i = 0; i < a.length; i += SPECIES.length()) { 4175 res = (long) Math.max(res, MAXReduce(a, i)); 4176 } 4177 4178 return res; 4179 } 4180 4181 @Test(dataProvider = "longUnaryOpProvider") 4182 static void MAXReduceLongMaxVectorTests(IntFunction<long[]> fa) { 4183 long[] a = fa.apply(SPECIES.length()); 4184 long[] r = fr.apply(SPECIES.length()); 4185 long ra = Long.MIN_VALUE; 4186 4187 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4188 for (int i = 0; i < a.length; i += SPECIES.length()) { 4189 LongVector av = LongVector.fromArray(SPECIES, a, i); 4190 r[i] = av.reduceLanes(VectorOperators.MAX); 4191 } 4192 } 4193 4194 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4195 ra = Long.MIN_VALUE; 4196 for (int i = 0; i < a.length; i += SPECIES.length()) { 4197 LongVector av = LongVector.fromArray(SPECIES, a, i); 4198 ra = (long) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); 4199 } 4200 } 4201 4202 assertReductionArraysEquals(r, ra, a, 4203 LongMaxVectorTests::MAXReduce, LongMaxVectorTests::MAXReduceAll); 4204 } 4205 4206 static long MAXReduceMasked(long[] a, int idx, boolean[] mask) { 4207 long res = Long.MIN_VALUE; 4208 for (int i = idx; i < (idx + SPECIES.length()); i++) { 4209 if (mask[i % SPECIES.length()]) 4210 res = (long) Math.max(res, a[i]); 4211 } 4212 4213 return res; 4214 } 4215 4216 static long MAXReduceAllMasked(long[] a, boolean[] mask) { 4217 long res = Long.MIN_VALUE; 4218 for (int i = 0; i < a.length; i += SPECIES.length()) { 4219 res = (long) Math.max(res, MAXReduceMasked(a, i, mask)); 4220 } 4221 4222 return res; 4223 } 4224 4225 @Test(dataProvider = "longUnaryOpMaskProvider") 4226 static void MAXReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { 4227 long[] a = fa.apply(SPECIES.length()); 4228 long[] r = fr.apply(SPECIES.length()); 4229 boolean[] mask = fm.apply(SPECIES.length()); 4230 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4231 long ra = Long.MIN_VALUE; 4232 4233 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4234 for (int i = 0; i < a.length; i += SPECIES.length()) { 4235 LongVector av = LongVector.fromArray(SPECIES, a, i); 4236 r[i] = av.reduceLanes(VectorOperators.MAX, vmask); 4237 } 4238 } 4239 4240 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4241 ra = Long.MIN_VALUE; 4242 for (int i = 0; i < a.length; i += SPECIES.length()) { 4243 LongVector av = LongVector.fromArray(SPECIES, a, i); 4244 ra = (long) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); 4245 } 4246 } 4247 4248 assertReductionArraysEqualsMasked(r, ra, a, mask, 4249 LongMaxVectorTests::MAXReduceMasked, LongMaxVectorTests::MAXReduceAllMasked); 4250 } 4251 4252 static long UMINReduce(long[] a, int idx) { 4253 long res = Long.MAX_VALUE; 4254 for (int i = idx; i < (idx + SPECIES.length()); i++) { 4255 res = (long) VectorMath.minUnsigned(res, a[i]); 4256 } 4257 4258 return res; 4259 } 4260 4261 static long UMINReduceAll(long[] a) { 4262 long res = Long.MAX_VALUE; 4263 for (int i = 0; i < a.length; i += SPECIES.length()) { 4264 res = (long) VectorMath.minUnsigned(res, UMINReduce(a, i)); 4265 } 4266 4267 return res; 4268 } 4269 4270 @Test(dataProvider = "longUnaryOpProvider") 4271 static void UMINReduceLongMaxVectorTests(IntFunction<long[]> fa) { 4272 long[] a = fa.apply(SPECIES.length()); 4273 long[] r = fr.apply(SPECIES.length()); 4274 long ra = Long.MAX_VALUE; 4275 4276 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4277 for (int i = 0; i < a.length; i += SPECIES.length()) { 4278 LongVector av = LongVector.fromArray(SPECIES, a, i); 4279 r[i] = av.reduceLanes(VectorOperators.UMIN); 4280 } 4281 } 4282 4283 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4284 ra = Long.MAX_VALUE; 4285 for (int i = 0; i < a.length; i += SPECIES.length()) { 4286 LongVector av = LongVector.fromArray(SPECIES, a, i); 4287 ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); 4288 } 4289 } 4290 4291 assertReductionArraysEquals(r, ra, a, 4292 LongMaxVectorTests::UMINReduce, LongMaxVectorTests::UMINReduceAll); 4293 } 4294 4295 static long UMINReduceMasked(long[] a, int idx, boolean[] mask) { 4296 long res = Long.MAX_VALUE; 4297 for (int i = idx; i < (idx + SPECIES.length()); i++) { 4298 if (mask[i % SPECIES.length()]) 4299 res = (long) VectorMath.minUnsigned(res, a[i]); 4300 } 4301 4302 return res; 4303 } 4304 4305 static long UMINReduceAllMasked(long[] a, boolean[] mask) { 4306 long res = Long.MAX_VALUE; 4307 for (int i = 0; i < a.length; i += SPECIES.length()) { 4308 res = (long) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); 4309 } 4310 4311 return res; 4312 } 4313 4314 @Test(dataProvider = "longUnaryOpMaskProvider") 4315 static void UMINReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { 4316 long[] a = fa.apply(SPECIES.length()); 4317 long[] r = fr.apply(SPECIES.length()); 4318 boolean[] mask = fm.apply(SPECIES.length()); 4319 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4320 long ra = Long.MAX_VALUE; 4321 4322 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4323 for (int i = 0; i < a.length; i += SPECIES.length()) { 4324 LongVector av = LongVector.fromArray(SPECIES, a, i); 4325 r[i] = av.reduceLanes(VectorOperators.UMIN, vmask); 4326 } 4327 } 4328 4329 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4330 ra = Long.MAX_VALUE; 4331 for (int i = 0; i < a.length; i += SPECIES.length()) { 4332 LongVector av = LongVector.fromArray(SPECIES, a, i); 4333 ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); 4334 } 4335 } 4336 4337 assertReductionArraysEqualsMasked(r, ra, a, mask, 4338 LongMaxVectorTests::UMINReduceMasked, LongMaxVectorTests::UMINReduceAllMasked); 4339 } 4340 4341 static long UMAXReduce(long[] a, int idx) { 4342 long res = Long.MIN_VALUE; 4343 for (int i = idx; i < (idx + SPECIES.length()); i++) { 4344 res = (long) VectorMath.maxUnsigned(res, a[i]); 4345 } 4346 4347 return res; 4348 } 4349 4350 static long UMAXReduceAll(long[] a) { 4351 long res = Long.MIN_VALUE; 4352 for (int i = 0; i < a.length; i += SPECIES.length()) { 4353 res = (long) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); 4354 } 4355 4356 return res; 4357 } 4358 4359 @Test(dataProvider = "longUnaryOpProvider") 4360 static void UMAXReduceLongMaxVectorTests(IntFunction<long[]> fa) { 4361 long[] a = fa.apply(SPECIES.length()); 4362 long[] r = fr.apply(SPECIES.length()); 4363 long ra = Long.MIN_VALUE; 4364 4365 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4366 for (int i = 0; i < a.length; i += SPECIES.length()) { 4367 LongVector av = LongVector.fromArray(SPECIES, a, i); 4368 r[i] = av.reduceLanes(VectorOperators.UMAX); 4369 } 4370 } 4371 4372 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4373 ra = Long.MIN_VALUE; 4374 for (int i = 0; i < a.length; i += SPECIES.length()) { 4375 LongVector av = LongVector.fromArray(SPECIES, a, i); 4376 ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); 4377 } 4378 } 4379 4380 assertReductionArraysEquals(r, ra, a, 4381 LongMaxVectorTests::UMAXReduce, LongMaxVectorTests::UMAXReduceAll); 4382 } 4383 4384 static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) { 4385 long res = Long.MIN_VALUE; 4386 for (int i = idx; i < (idx + SPECIES.length()); i++) { 4387 if (mask[i % SPECIES.length()]) 4388 res = (long) VectorMath.maxUnsigned(res, a[i]); 4389 } 4390 4391 return res; 4392 } 4393 4394 static long UMAXReduceAllMasked(long[] a, boolean[] mask) { 4395 long res = Long.MIN_VALUE; 4396 for (int i = 0; i < a.length; i += SPECIES.length()) { 4397 res = (long) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); 4398 } 4399 4400 return res; 4401 } 4402 4403 @Test(dataProvider = "longUnaryOpMaskProvider") 4404 static void UMAXReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { 4405 long[] a = fa.apply(SPECIES.length()); 4406 long[] r = fr.apply(SPECIES.length()); 4407 boolean[] mask = fm.apply(SPECIES.length()); 4408 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4409 long ra = Long.MIN_VALUE; 4410 4411 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4412 for (int i = 0; i < a.length; i += SPECIES.length()) { 4413 LongVector av = LongVector.fromArray(SPECIES, a, i); 4414 r[i] = av.reduceLanes(VectorOperators.UMAX, vmask); 4415 } 4416 } 4417 4418 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4419 ra = Long.MIN_VALUE; 4420 for (int i = 0; i < a.length; i += SPECIES.length()) { 4421 LongVector av = LongVector.fromArray(SPECIES, a, i); 4422 ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); 4423 } 4424 } 4425 4426 assertReductionArraysEqualsMasked(r, ra, a, mask, 4427 LongMaxVectorTests::UMAXReduceMasked, LongMaxVectorTests::UMAXReduceAllMasked); 4428 } 4429 4430 static long FIRST_NONZEROReduce(long[] a, int idx) { 4431 long res = (long) 0; 4432 for (int i = idx; i < (idx + SPECIES.length()); i++) { 4433 res = firstNonZero(res, a[i]); 4434 } 4435 4436 return res; 4437 } 4438 4439 static long FIRST_NONZEROReduceAll(long[] a) { 4440 long res = (long) 0; 4441 for (int i = 0; i < a.length; i += SPECIES.length()) { 4442 res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); 4443 } 4444 4445 return res; 4446 } 4447 4448 @Test(dataProvider = "longUnaryOpProvider") 4449 static void FIRST_NONZEROReduceLongMaxVectorTests(IntFunction<long[]> fa) { 4450 long[] a = fa.apply(SPECIES.length()); 4451 long[] r = fr.apply(SPECIES.length()); 4452 long ra = (long) 0; 4453 4454 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4455 for (int i = 0; i < a.length; i += SPECIES.length()) { 4456 LongVector av = LongVector.fromArray(SPECIES, a, i); 4457 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO); 4458 } 4459 } 4460 4461 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4462 ra = (long) 0; 4463 for (int i = 0; i < a.length; i += SPECIES.length()) { 4464 LongVector av = LongVector.fromArray(SPECIES, a, i); 4465 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); 4466 } 4467 } 4468 4469 assertReductionArraysEquals(r, ra, a, 4470 LongMaxVectorTests::FIRST_NONZEROReduce, LongMaxVectorTests::FIRST_NONZEROReduceAll); 4471 } 4472 4473 static long FIRST_NONZEROReduceMasked(long[] a, int idx, boolean[] mask) { 4474 long res = (long) 0; 4475 for (int i = idx; i < (idx + SPECIES.length()); i++) { 4476 if (mask[i % SPECIES.length()]) 4477 res = firstNonZero(res, a[i]); 4478 } 4479 4480 return res; 4481 } 4482 4483 static long FIRST_NONZEROReduceAllMasked(long[] a, boolean[] mask) { 4484 long res = (long) 0; 4485 for (int i = 0; i < a.length; i += SPECIES.length()) { 4486 res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); 4487 } 4488 4489 return res; 4490 } 4491 4492 @Test(dataProvider = "longUnaryOpMaskProvider") 4493 static void FIRST_NONZEROReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { 4494 long[] a = fa.apply(SPECIES.length()); 4495 long[] r = fr.apply(SPECIES.length()); 4496 boolean[] mask = fm.apply(SPECIES.length()); 4497 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4498 long ra = (long) 0; 4499 4500 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4501 for (int i = 0; i < a.length; i += SPECIES.length()) { 4502 LongVector av = LongVector.fromArray(SPECIES, a, i); 4503 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask); 4504 } 4505 } 4506 4507 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4508 ra = (long) 0; 4509 for (int i = 0; i < a.length; i += SPECIES.length()) { 4510 LongVector av = LongVector.fromArray(SPECIES, a, i); 4511 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); 4512 } 4513 } 4514 4515 assertReductionArraysEqualsMasked(r, ra, a, mask, 4516 LongMaxVectorTests::FIRST_NONZEROReduceMasked, LongMaxVectorTests::FIRST_NONZEROReduceAllMasked); 4517 } 4518 4519 static boolean anyTrue(boolean[] a, int idx) { 4520 boolean res = false; 4521 for (int i = idx; i < (idx + SPECIES.length()); i++) { 4522 res |= a[i]; 4523 } 4524 4525 return res; 4526 } 4527 4528 @Test(dataProvider = "boolUnaryOpProvider") 4529 static void anyTrueLongMaxVectorTests(IntFunction<boolean[]> fm) { 4530 boolean[] mask = fm.apply(SPECIES.length()); 4531 boolean[] r = fmr.apply(SPECIES.length()); 4532 4533 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4534 for (int i = 0; i < mask.length; i += SPECIES.length()) { 4535 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, i); 4536 r[i] = vmask.anyTrue(); 4537 } 4538 } 4539 4540 assertReductionBoolArraysEquals(r, mask, LongMaxVectorTests::anyTrue); 4541 } 4542 4543 static boolean allTrue(boolean[] a, int idx) { 4544 boolean res = true; 4545 for (int i = idx; i < (idx + SPECIES.length()); i++) { 4546 res &= a[i]; 4547 } 4548 4549 return res; 4550 } 4551 4552 @Test(dataProvider = "boolUnaryOpProvider") 4553 static void allTrueLongMaxVectorTests(IntFunction<boolean[]> fm) { 4554 boolean[] mask = fm.apply(SPECIES.length()); 4555 boolean[] r = fmr.apply(SPECIES.length()); 4556 4557 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4558 for (int i = 0; i < mask.length; i += SPECIES.length()) { 4559 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, i); 4560 r[i] = vmask.allTrue(); 4561 } 4562 } 4563 4564 assertReductionBoolArraysEquals(r, mask, LongMaxVectorTests::allTrue); 4565 } 4566 4567 static long SUADDReduce(long[] a, int idx) { 4568 long res = 0; 4569 for (int i = idx; i < (idx + SPECIES.length()); i++) { 4570 res = (long) VectorMath.addSaturatingUnsigned(res, a[i]); 4571 } 4572 4573 return res; 4574 } 4575 4576 static long SUADDReduceAll(long[] a) { 4577 long res = 0; 4578 for (int i = 0; i < a.length; i += SPECIES.length()) { 4579 res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); 4580 } 4581 4582 return res; 4583 } 4584 4585 @Test(dataProvider = "longSaturatingUnaryOpProvider") 4586 static void SUADDReduceLongMaxVectorTests(IntFunction<long[]> fa) { 4587 long[] a = fa.apply(SPECIES.length()); 4588 long[] r = fr.apply(SPECIES.length()); 4589 long ra = 0; 4590 4591 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4592 for (int i = 0; i < a.length; i += SPECIES.length()) { 4593 LongVector av = LongVector.fromArray(SPECIES, a, i); 4594 r[i] = av.reduceLanes(VectorOperators.SUADD); 4595 } 4596 } 4597 4598 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4599 ra = 0; 4600 for (int i = 0; i < a.length; i += SPECIES.length()) { 4601 LongVector av = LongVector.fromArray(SPECIES, a, i); 4602 ra = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); 4603 } 4604 } 4605 4606 assertReductionArraysEquals(r, ra, a, 4607 LongMaxVectorTests::SUADDReduce, LongMaxVectorTests::SUADDReduceAll); 4608 } 4609 4610 static long SUADDReduceMasked(long[] a, int idx, boolean[] mask) { 4611 long res = 0; 4612 for (int i = idx; i < (idx + SPECIES.length()); i++) { 4613 if (mask[i % SPECIES.length()]) 4614 res = (long) VectorMath.addSaturatingUnsigned(res, a[i]); 4615 } 4616 4617 return res; 4618 } 4619 4620 static long SUADDReduceAllMasked(long[] a, boolean[] mask) { 4621 long res = 0; 4622 for (int i = 0; i < a.length; i += SPECIES.length()) { 4623 res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); 4624 } 4625 4626 return res; 4627 } 4628 @Test(dataProvider = "longSaturatingUnaryOpMaskProvider") 4629 static void SUADDReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { 4630 long[] a = fa.apply(SPECIES.length()); 4631 long[] r = fr.apply(SPECIES.length()); 4632 boolean[] mask = fm.apply(SPECIES.length()); 4633 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4634 long ra = 0; 4635 4636 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4637 for (int i = 0; i < a.length; i += SPECIES.length()) { 4638 LongVector av = LongVector.fromArray(SPECIES, a, i); 4639 r[i] = av.reduceLanes(VectorOperators.SUADD, vmask); 4640 } 4641 } 4642 4643 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4644 ra = 0; 4645 for (int i = 0; i < a.length; i += SPECIES.length()) { 4646 LongVector av = LongVector.fromArray(SPECIES, a, i); 4647 ra = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); 4648 } 4649 } 4650 4651 assertReductionArraysEqualsMasked(r, ra, a, mask, 4652 LongMaxVectorTests::SUADDReduceMasked, LongMaxVectorTests::SUADDReduceAllMasked); 4653 } 4654 4655 @Test(dataProvider = "longBinaryOpProvider") 4656 static void withLongMaxVectorTests(IntFunction<long []> fa, IntFunction<long []> fb) { 4657 long[] a = fa.apply(SPECIES.length()); 4658 long[] b = fb.apply(SPECIES.length()); 4659 long[] r = fr.apply(SPECIES.length()); 4660 4661 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4662 for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { 4663 LongVector av = LongVector.fromArray(SPECIES, a, i); 4664 av.withLane(j, b[i + j]).intoArray(r, i); 4665 a[i + j] = b[i + j]; 4666 j = (j + 1) & (SPECIES.length() - 1); 4667 } 4668 } 4669 4670 4671 assertArraysStrictlyEquals(r, a); 4672 } 4673 4674 static boolean testIS_DEFAULT(long a) { 4675 return bits(a)==0; 4676 } 4677 4678 @Test(dataProvider = "longTestOpProvider") 4679 static void IS_DEFAULTLongMaxVectorTests(IntFunction<long[]> fa) { 4680 long[] a = fa.apply(SPECIES.length()); 4681 4682 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4683 for (int i = 0; i < a.length; i += SPECIES.length()) { 4684 LongVector av = LongVector.fromArray(SPECIES, a, i); 4685 VectorMask<Long> mv = av.test(VectorOperators.IS_DEFAULT); 4686 4687 // Check results as part of computation. 4688 for (int j = 0; j < SPECIES.length(); j++) { 4689 Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); 4690 } 4691 } 4692 } 4693 } 4694 4695 @Test(dataProvider = "longTestOpMaskProvider") 4696 static void IS_DEFAULTMaskedLongMaxVectorTests(IntFunction<long[]> fa, 4697 IntFunction<boolean[]> fm) { 4698 long[] a = fa.apply(SPECIES.length()); 4699 boolean[] mask = fm.apply(SPECIES.length()); 4700 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4701 4702 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4703 for (int i = 0; i < a.length; i += SPECIES.length()) { 4704 LongVector av = LongVector.fromArray(SPECIES, a, i); 4705 VectorMask<Long> mv = av.test(VectorOperators.IS_DEFAULT, vmask); 4706 4707 // Check results as part of computation. 4708 for (int j = 0; j < SPECIES.length(); j++) { 4709 Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); 4710 } 4711 } 4712 } 4713 } 4714 4715 static boolean testIS_NEGATIVE(long a) { 4716 return bits(a)<0; 4717 } 4718 4719 @Test(dataProvider = "longTestOpProvider") 4720 static void IS_NEGATIVELongMaxVectorTests(IntFunction<long[]> fa) { 4721 long[] a = fa.apply(SPECIES.length()); 4722 4723 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4724 for (int i = 0; i < a.length; i += SPECIES.length()) { 4725 LongVector av = LongVector.fromArray(SPECIES, a, i); 4726 VectorMask<Long> mv = av.test(VectorOperators.IS_NEGATIVE); 4727 4728 // Check results as part of computation. 4729 for (int j = 0; j < SPECIES.length(); j++) { 4730 Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); 4731 } 4732 } 4733 } 4734 } 4735 4736 @Test(dataProvider = "longTestOpMaskProvider") 4737 static void IS_NEGATIVEMaskedLongMaxVectorTests(IntFunction<long[]> fa, 4738 IntFunction<boolean[]> fm) { 4739 long[] a = fa.apply(SPECIES.length()); 4740 boolean[] mask = fm.apply(SPECIES.length()); 4741 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4742 4743 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4744 for (int i = 0; i < a.length; i += SPECIES.length()) { 4745 LongVector av = LongVector.fromArray(SPECIES, a, i); 4746 VectorMask<Long> mv = av.test(VectorOperators.IS_NEGATIVE, vmask); 4747 4748 // Check results as part of computation. 4749 for (int j = 0; j < SPECIES.length(); j++) { 4750 Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); 4751 } 4752 } 4753 } 4754 } 4755 4756 @Test(dataProvider = "longCompareOpProvider") 4757 static void LTLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 4758 long[] a = fa.apply(SPECIES.length()); 4759 long[] b = fb.apply(SPECIES.length()); 4760 4761 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4762 for (int i = 0; i < a.length; i += SPECIES.length()) { 4763 LongVector av = LongVector.fromArray(SPECIES, a, i); 4764 LongVector bv = LongVector.fromArray(SPECIES, b, i); 4765 VectorMask<Long> mv = av.compare(VectorOperators.LT, bv); 4766 4767 // Check results as part of computation. 4768 for (int j = 0; j < SPECIES.length(); j++) { 4769 Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); 4770 } 4771 } 4772 } 4773 } 4774 4775 @Test(dataProvider = "longCompareOpProvider") 4776 static void ltLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 4777 long[] a = fa.apply(SPECIES.length()); 4778 long[] b = fb.apply(SPECIES.length()); 4779 4780 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4781 for (int i = 0; i < a.length; i += SPECIES.length()) { 4782 LongVector av = LongVector.fromArray(SPECIES, a, i); 4783 LongVector bv = LongVector.fromArray(SPECIES, b, i); 4784 VectorMask<Long> mv = av.lt(bv); 4785 4786 // Check results as part of computation. 4787 for (int j = 0; j < SPECIES.length(); j++) { 4788 Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); 4789 } 4790 } 4791 } 4792 } 4793 4794 @Test(dataProvider = "longCompareOpMaskProvider") 4795 static void LTLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 4796 IntFunction<boolean[]> fm) { 4797 long[] a = fa.apply(SPECIES.length()); 4798 long[] b = fb.apply(SPECIES.length()); 4799 boolean[] mask = fm.apply(SPECIES.length()); 4800 4801 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4802 4803 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4804 for (int i = 0; i < a.length; i += SPECIES.length()) { 4805 LongVector av = LongVector.fromArray(SPECIES, a, i); 4806 LongVector bv = LongVector.fromArray(SPECIES, b, i); 4807 VectorMask<Long> mv = av.compare(VectorOperators.LT, bv, vmask); 4808 4809 // Check results as part of computation. 4810 for (int j = 0; j < SPECIES.length(); j++) { 4811 Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j])); 4812 } 4813 } 4814 } 4815 } 4816 4817 @Test(dataProvider = "longCompareOpProvider") 4818 static void GTLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 4819 long[] a = fa.apply(SPECIES.length()); 4820 long[] b = fb.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 LongVector av = LongVector.fromArray(SPECIES, a, i); 4825 LongVector bv = LongVector.fromArray(SPECIES, b, i); 4826 VectorMask<Long> mv = av.compare(VectorOperators.GT, bv); 4827 4828 // Check results as part of computation. 4829 for (int j = 0; j < SPECIES.length(); j++) { 4830 Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); 4831 } 4832 } 4833 } 4834 } 4835 4836 @Test(dataProvider = "longCompareOpMaskProvider") 4837 static void GTLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 4838 IntFunction<boolean[]> fm) { 4839 long[] a = fa.apply(SPECIES.length()); 4840 long[] b = fb.apply(SPECIES.length()); 4841 boolean[] mask = fm.apply(SPECIES.length()); 4842 4843 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4844 4845 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4846 for (int i = 0; i < a.length; i += SPECIES.length()) { 4847 LongVector av = LongVector.fromArray(SPECIES, a, i); 4848 LongVector bv = LongVector.fromArray(SPECIES, b, i); 4849 VectorMask<Long> mv = av.compare(VectorOperators.GT, bv, vmask); 4850 4851 // Check results as part of computation. 4852 for (int j = 0; j < SPECIES.length(); j++) { 4853 Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j])); 4854 } 4855 } 4856 } 4857 } 4858 4859 @Test(dataProvider = "longCompareOpProvider") 4860 static void EQLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 4861 long[] a = fa.apply(SPECIES.length()); 4862 long[] b = fb.apply(SPECIES.length()); 4863 4864 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4865 for (int i = 0; i < a.length; i += SPECIES.length()) { 4866 LongVector av = LongVector.fromArray(SPECIES, a, i); 4867 LongVector bv = LongVector.fromArray(SPECIES, b, i); 4868 VectorMask<Long> mv = av.compare(VectorOperators.EQ, bv); 4869 4870 // Check results as part of computation. 4871 for (int j = 0; j < SPECIES.length(); j++) { 4872 Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); 4873 } 4874 } 4875 } 4876 } 4877 4878 @Test(dataProvider = "longCompareOpProvider") 4879 static void eqLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 4880 long[] a = fa.apply(SPECIES.length()); 4881 long[] b = fb.apply(SPECIES.length()); 4882 4883 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4884 for (int i = 0; i < a.length; i += SPECIES.length()) { 4885 LongVector av = LongVector.fromArray(SPECIES, a, i); 4886 LongVector bv = LongVector.fromArray(SPECIES, b, i); 4887 VectorMask<Long> mv = av.eq(bv); 4888 4889 // Check results as part of computation. 4890 for (int j = 0; j < SPECIES.length(); j++) { 4891 Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); 4892 } 4893 } 4894 } 4895 } 4896 4897 @Test(dataProvider = "longCompareOpMaskProvider") 4898 static void EQLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 4899 IntFunction<boolean[]> fm) { 4900 long[] a = fa.apply(SPECIES.length()); 4901 long[] b = fb.apply(SPECIES.length()); 4902 boolean[] mask = fm.apply(SPECIES.length()); 4903 4904 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4905 4906 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4907 for (int i = 0; i < a.length; i += SPECIES.length()) { 4908 LongVector av = LongVector.fromArray(SPECIES, a, i); 4909 LongVector bv = LongVector.fromArray(SPECIES, b, i); 4910 VectorMask<Long> mv = av.compare(VectorOperators.EQ, bv, vmask); 4911 4912 // Check results as part of computation. 4913 for (int j = 0; j < SPECIES.length(); j++) { 4914 Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j])); 4915 } 4916 } 4917 } 4918 } 4919 4920 @Test(dataProvider = "longCompareOpProvider") 4921 static void NELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 4922 long[] a = fa.apply(SPECIES.length()); 4923 long[] b = fb.apply(SPECIES.length()); 4924 4925 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4926 for (int i = 0; i < a.length; i += SPECIES.length()) { 4927 LongVector av = LongVector.fromArray(SPECIES, a, i); 4928 LongVector bv = LongVector.fromArray(SPECIES, b, i); 4929 VectorMask<Long> mv = av.compare(VectorOperators.NE, bv); 4930 4931 // Check results as part of computation. 4932 for (int j = 0; j < SPECIES.length(); j++) { 4933 Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); 4934 } 4935 } 4936 } 4937 } 4938 4939 @Test(dataProvider = "longCompareOpMaskProvider") 4940 static void NELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 4941 IntFunction<boolean[]> fm) { 4942 long[] a = fa.apply(SPECIES.length()); 4943 long[] b = fb.apply(SPECIES.length()); 4944 boolean[] mask = fm.apply(SPECIES.length()); 4945 4946 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4947 4948 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4949 for (int i = 0; i < a.length; i += SPECIES.length()) { 4950 LongVector av = LongVector.fromArray(SPECIES, a, i); 4951 LongVector bv = LongVector.fromArray(SPECIES, b, i); 4952 VectorMask<Long> mv = av.compare(VectorOperators.NE, bv, vmask); 4953 4954 // Check results as part of computation. 4955 for (int j = 0; j < SPECIES.length(); j++) { 4956 Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j])); 4957 } 4958 } 4959 } 4960 } 4961 4962 @Test(dataProvider = "longCompareOpProvider") 4963 static void LELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 4964 long[] a = fa.apply(SPECIES.length()); 4965 long[] b = fb.apply(SPECIES.length()); 4966 4967 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4968 for (int i = 0; i < a.length; i += SPECIES.length()) { 4969 LongVector av = LongVector.fromArray(SPECIES, a, i); 4970 LongVector bv = LongVector.fromArray(SPECIES, b, i); 4971 VectorMask<Long> mv = av.compare(VectorOperators.LE, bv); 4972 4973 // Check results as part of computation. 4974 for (int j = 0; j < SPECIES.length(); j++) { 4975 Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); 4976 } 4977 } 4978 } 4979 } 4980 4981 @Test(dataProvider = "longCompareOpMaskProvider") 4982 static void LELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 4983 IntFunction<boolean[]> fm) { 4984 long[] a = fa.apply(SPECIES.length()); 4985 long[] b = fb.apply(SPECIES.length()); 4986 boolean[] mask = fm.apply(SPECIES.length()); 4987 4988 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 4989 4990 for (int ic = 0; ic < INVOC_COUNT; ic++) { 4991 for (int i = 0; i < a.length; i += SPECIES.length()) { 4992 LongVector av = LongVector.fromArray(SPECIES, a, i); 4993 LongVector bv = LongVector.fromArray(SPECIES, b, i); 4994 VectorMask<Long> mv = av.compare(VectorOperators.LE, bv, vmask); 4995 4996 // Check results as part of computation. 4997 for (int j = 0; j < SPECIES.length(); j++) { 4998 Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j])); 4999 } 5000 } 5001 } 5002 } 5003 5004 @Test(dataProvider = "longCompareOpProvider") 5005 static void GELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 5006 long[] a = fa.apply(SPECIES.length()); 5007 long[] b = fb.apply(SPECIES.length()); 5008 5009 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5010 for (int i = 0; i < a.length; i += SPECIES.length()) { 5011 LongVector av = LongVector.fromArray(SPECIES, a, i); 5012 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5013 VectorMask<Long> mv = av.compare(VectorOperators.GE, bv); 5014 5015 // Check results as part of computation. 5016 for (int j = 0; j < SPECIES.length(); j++) { 5017 Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); 5018 } 5019 } 5020 } 5021 } 5022 5023 @Test(dataProvider = "longCompareOpMaskProvider") 5024 static void GELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 5025 IntFunction<boolean[]> fm) { 5026 long[] a = fa.apply(SPECIES.length()); 5027 long[] b = fb.apply(SPECIES.length()); 5028 boolean[] mask = fm.apply(SPECIES.length()); 5029 5030 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5031 5032 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5033 for (int i = 0; i < a.length; i += SPECIES.length()) { 5034 LongVector av = LongVector.fromArray(SPECIES, a, i); 5035 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5036 VectorMask<Long> mv = av.compare(VectorOperators.GE, bv, vmask); 5037 5038 // Check results as part of computation. 5039 for (int j = 0; j < SPECIES.length(); j++) { 5040 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j])); 5041 } 5042 } 5043 } 5044 } 5045 5046 @Test(dataProvider = "longCompareOpProvider") 5047 static void ULTLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 5048 long[] a = fa.apply(SPECIES.length()); 5049 long[] b = fb.apply(SPECIES.length()); 5050 5051 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5052 for (int i = 0; i < a.length; i += SPECIES.length()) { 5053 LongVector av = LongVector.fromArray(SPECIES, a, i); 5054 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5055 VectorMask<Long> mv = av.compare(VectorOperators.ULT, bv); 5056 5057 // Check results as part of computation. 5058 for (int j = 0; j < SPECIES.length(); j++) { 5059 Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); 5060 } 5061 } 5062 } 5063 } 5064 5065 @Test(dataProvider = "longCompareOpMaskProvider") 5066 static void ULTLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 5067 IntFunction<boolean[]> fm) { 5068 long[] a = fa.apply(SPECIES.length()); 5069 long[] b = fb.apply(SPECIES.length()); 5070 boolean[] mask = fm.apply(SPECIES.length()); 5071 5072 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5073 5074 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5075 for (int i = 0; i < a.length; i += SPECIES.length()) { 5076 LongVector av = LongVector.fromArray(SPECIES, a, i); 5077 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5078 VectorMask<Long> mv = av.compare(VectorOperators.ULT, bv, vmask); 5079 5080 // Check results as part of computation. 5081 for (int j = 0; j < SPECIES.length(); j++) { 5082 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j])); 5083 } 5084 } 5085 } 5086 } 5087 5088 @Test(dataProvider = "longCompareOpProvider") 5089 static void UGTLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 5090 long[] a = fa.apply(SPECIES.length()); 5091 long[] b = fb.apply(SPECIES.length()); 5092 5093 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5094 for (int i = 0; i < a.length; i += SPECIES.length()) { 5095 LongVector av = LongVector.fromArray(SPECIES, a, i); 5096 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5097 VectorMask<Long> mv = av.compare(VectorOperators.UGT, bv); 5098 5099 // Check results as part of computation. 5100 for (int j = 0; j < SPECIES.length(); j++) { 5101 Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); 5102 } 5103 } 5104 } 5105 } 5106 5107 @Test(dataProvider = "longCompareOpMaskProvider") 5108 static void UGTLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 5109 IntFunction<boolean[]> fm) { 5110 long[] a = fa.apply(SPECIES.length()); 5111 long[] b = fb.apply(SPECIES.length()); 5112 boolean[] mask = fm.apply(SPECIES.length()); 5113 5114 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5115 5116 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5117 for (int i = 0; i < a.length; i += SPECIES.length()) { 5118 LongVector av = LongVector.fromArray(SPECIES, a, i); 5119 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5120 VectorMask<Long> mv = av.compare(VectorOperators.UGT, bv, vmask); 5121 5122 // Check results as part of computation. 5123 for (int j = 0; j < SPECIES.length(); j++) { 5124 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j])); 5125 } 5126 } 5127 } 5128 } 5129 5130 @Test(dataProvider = "longCompareOpProvider") 5131 static void ULELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 5132 long[] a = fa.apply(SPECIES.length()); 5133 long[] b = fb.apply(SPECIES.length()); 5134 5135 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5136 for (int i = 0; i < a.length; i += SPECIES.length()) { 5137 LongVector av = LongVector.fromArray(SPECIES, a, i); 5138 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5139 VectorMask<Long> mv = av.compare(VectorOperators.ULE, bv); 5140 5141 // Check results as part of computation. 5142 for (int j = 0; j < SPECIES.length(); j++) { 5143 Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); 5144 } 5145 } 5146 } 5147 } 5148 5149 @Test(dataProvider = "longCompareOpMaskProvider") 5150 static void ULELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 5151 IntFunction<boolean[]> fm) { 5152 long[] a = fa.apply(SPECIES.length()); 5153 long[] b = fb.apply(SPECIES.length()); 5154 boolean[] mask = fm.apply(SPECIES.length()); 5155 5156 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5157 5158 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5159 for (int i = 0; i < a.length; i += SPECIES.length()) { 5160 LongVector av = LongVector.fromArray(SPECIES, a, i); 5161 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5162 VectorMask<Long> mv = av.compare(VectorOperators.ULE, bv, vmask); 5163 5164 // Check results as part of computation. 5165 for (int j = 0; j < SPECIES.length(); j++) { 5166 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j])); 5167 } 5168 } 5169 } 5170 } 5171 5172 @Test(dataProvider = "longCompareOpProvider") 5173 static void UGELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) { 5174 long[] a = fa.apply(SPECIES.length()); 5175 long[] b = fb.apply(SPECIES.length()); 5176 5177 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5178 for (int i = 0; i < a.length; i += SPECIES.length()) { 5179 LongVector av = LongVector.fromArray(SPECIES, a, i); 5180 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5181 VectorMask<Long> mv = av.compare(VectorOperators.UGE, bv); 5182 5183 // Check results as part of computation. 5184 for (int j = 0; j < SPECIES.length(); j++) { 5185 Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); 5186 } 5187 } 5188 } 5189 } 5190 5191 @Test(dataProvider = "longCompareOpMaskProvider") 5192 static void UGELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 5193 IntFunction<boolean[]> fm) { 5194 long[] a = fa.apply(SPECIES.length()); 5195 long[] b = fb.apply(SPECIES.length()); 5196 boolean[] mask = fm.apply(SPECIES.length()); 5197 5198 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5199 5200 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5201 for (int i = 0; i < a.length; i += SPECIES.length()) { 5202 LongVector av = LongVector.fromArray(SPECIES, a, i); 5203 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5204 VectorMask<Long> mv = av.compare(VectorOperators.UGE, bv, vmask); 5205 5206 // Check results as part of computation. 5207 for (int j = 0; j < SPECIES.length(); j++) { 5208 Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j])); 5209 } 5210 } 5211 } 5212 } 5213 5214 @Test(dataProvider = "longCompareOpProvider") 5215 static void LTLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { 5216 long[] a = fa.apply(SPECIES.length()); 5217 long[] b = fb.apply(SPECIES.length()); 5218 5219 for (int i = 0; i < a.length; i += SPECIES.length()) { 5220 LongVector av = LongVector.fromArray(SPECIES, a, i); 5221 VectorMask<Long> mv = av.compare(VectorOperators.LT, b[i]); 5222 5223 // Check results as part of computation. 5224 for (int j = 0; j < SPECIES.length(); j++) { 5225 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); 5226 } 5227 } 5228 } 5229 5230 @Test(dataProvider = "longCompareOpMaskProvider") 5231 static void LTLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, 5232 IntFunction<long[]> fb, IntFunction<boolean[]> fm) { 5233 long[] a = fa.apply(SPECIES.length()); 5234 long[] b = fb.apply(SPECIES.length()); 5235 boolean[] mask = fm.apply(SPECIES.length()); 5236 5237 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5238 5239 for (int i = 0; i < a.length; i += SPECIES.length()) { 5240 LongVector av = LongVector.fromArray(SPECIES, a, i); 5241 VectorMask<Long> mv = av.compare(VectorOperators.LT, b[i], vmask); 5242 5243 // Check results as part of computation. 5244 for (int j = 0; j < SPECIES.length(); j++) { 5245 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); 5246 } 5247 } 5248 } 5249 5250 5251 @Test(dataProvider = "longCompareOpProvider") 5252 static void EQLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { 5253 long[] a = fa.apply(SPECIES.length()); 5254 long[] b = fb.apply(SPECIES.length()); 5255 5256 for (int i = 0; i < a.length; i += SPECIES.length()) { 5257 LongVector av = LongVector.fromArray(SPECIES, a, i); 5258 VectorMask<Long> mv = av.compare(VectorOperators.EQ, b[i]); 5259 5260 // Check results as part of computation. 5261 for (int j = 0; j < SPECIES.length(); j++) { 5262 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); 5263 } 5264 } 5265 } 5266 5267 @Test(dataProvider = "longCompareOpMaskProvider") 5268 static void EQLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, 5269 IntFunction<long[]> fb, IntFunction<boolean[]> fm) { 5270 long[] a = fa.apply(SPECIES.length()); 5271 long[] b = fb.apply(SPECIES.length()); 5272 boolean[] mask = fm.apply(SPECIES.length()); 5273 5274 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5275 5276 for (int i = 0; i < a.length; i += SPECIES.length()) { 5277 LongVector av = LongVector.fromArray(SPECIES, a, i); 5278 VectorMask<Long> mv = av.compare(VectorOperators.EQ, b[i], vmask); 5279 5280 // Check results as part of computation. 5281 for (int j = 0; j < SPECIES.length(); j++) { 5282 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); 5283 } 5284 } 5285 } 5286 5287 5288 static long blend(long a, long b, boolean mask) { 5289 return mask ? b : a; 5290 } 5291 5292 @Test(dataProvider = "longBinaryOpMaskProvider") 5293 static void blendLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, 5294 IntFunction<boolean[]> fm) { 5295 long[] a = fa.apply(SPECIES.length()); 5296 long[] b = fb.apply(SPECIES.length()); 5297 long[] r = fr.apply(SPECIES.length()); 5298 boolean[] mask = fm.apply(SPECIES.length()); 5299 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5300 5301 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5302 for (int i = 0; i < a.length; i += SPECIES.length()) { 5303 LongVector av = LongVector.fromArray(SPECIES, a, i); 5304 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5305 av.blend(bv, vmask).intoArray(r, i); 5306 } 5307 } 5308 5309 assertArraysEquals(r, a, b, mask, LongMaxVectorTests::blend); 5310 } 5311 5312 @Test(dataProvider = "longUnaryOpShuffleProvider") 5313 static void RearrangeLongMaxVectorTests(IntFunction<long[]> fa, 5314 BiFunction<Integer,Integer,int[]> fs) { 5315 long[] a = fa.apply(SPECIES.length()); 5316 int[] order = fs.apply(a.length, SPECIES.length()); 5317 long[] r = fr.apply(SPECIES.length()); 5318 5319 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5320 for (int i = 0; i < a.length; i += SPECIES.length()) { 5321 LongVector av = LongVector.fromArray(SPECIES, a, i); 5322 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i); 5323 } 5324 } 5325 5326 assertRearrangeArraysEquals(r, a, order, SPECIES.length()); 5327 } 5328 5329 @Test(dataProvider = "longUnaryOpShuffleMaskProvider") 5330 static void RearrangeLongMaxVectorTestsMaskedSmokeTest(IntFunction<long[]> fa, 5331 BiFunction<Integer,Integer,int[]> fs, 5332 IntFunction<boolean[]> fm) { 5333 long[] a = fa.apply(SPECIES.length()); 5334 int[] order = fs.apply(a.length, SPECIES.length()); 5335 long[] r = fr.apply(SPECIES.length()); 5336 boolean[] mask = fm.apply(SPECIES.length()); 5337 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5338 5339 for (int i = 0; i < a.length; i += SPECIES.length()) { 5340 LongVector av = LongVector.fromArray(SPECIES, a, i); 5341 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); 5342 } 5343 5344 assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); 5345 } 5346 5347 @Test(dataProvider = "longUnaryOpMaskProvider") 5348 static void compressLongMaxVectorTests(IntFunction<long[]> fa, 5349 IntFunction<boolean[]> fm) { 5350 long[] a = fa.apply(SPECIES.length()); 5351 long[] r = fr.apply(SPECIES.length()); 5352 boolean[] mask = fm.apply(SPECIES.length()); 5353 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5354 5355 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5356 for (int i = 0; i < a.length; i += SPECIES.length()) { 5357 LongVector av = LongVector.fromArray(SPECIES, a, i); 5358 av.compress(vmask).intoArray(r, i); 5359 } 5360 } 5361 5362 assertcompressArraysEquals(r, a, mask, SPECIES.length()); 5363 } 5364 5365 @Test(dataProvider = "longUnaryOpMaskProvider") 5366 static void expandLongMaxVectorTests(IntFunction<long[]> fa, 5367 IntFunction<boolean[]> fm) { 5368 long[] a = fa.apply(SPECIES.length()); 5369 long[] r = fr.apply(SPECIES.length()); 5370 boolean[] mask = fm.apply(SPECIES.length()); 5371 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5372 5373 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5374 for (int i = 0; i < a.length; i += SPECIES.length()) { 5375 LongVector av = LongVector.fromArray(SPECIES, a, i); 5376 av.expand(vmask).intoArray(r, i); 5377 } 5378 } 5379 5380 assertexpandArraysEquals(r, a, mask, SPECIES.length()); 5381 } 5382 5383 @Test(dataProvider = "longUnaryOpProvider") 5384 static void getLongMaxVectorTests(IntFunction<long[]> fa) { 5385 long[] a = fa.apply(SPECIES.length()); 5386 long[] r = fr.apply(SPECIES.length()); 5387 5388 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5389 for (int i = 0; i < a.length; i += SPECIES.length()) { 5390 LongVector av = LongVector.fromArray(SPECIES, a, i); 5391 int num_lanes = SPECIES.length(); 5392 // Manually unroll because full unroll happens after intrinsification. 5393 // Unroll is needed because get intrinsic requires for index to be a known constant. 5394 if (num_lanes == 1) { 5395 r[i]=av.lane(0); 5396 } else if (num_lanes == 2) { 5397 r[i]=av.lane(0); 5398 r[i+1]=av.lane(1); 5399 } else if (num_lanes == 4) { 5400 r[i]=av.lane(0); 5401 r[i+1]=av.lane(1); 5402 r[i+2]=av.lane(2); 5403 r[i+3]=av.lane(3); 5404 } else if (num_lanes == 8) { 5405 r[i]=av.lane(0); 5406 r[i+1]=av.lane(1); 5407 r[i+2]=av.lane(2); 5408 r[i+3]=av.lane(3); 5409 r[i+4]=av.lane(4); 5410 r[i+5]=av.lane(5); 5411 r[i+6]=av.lane(6); 5412 r[i+7]=av.lane(7); 5413 } else if (num_lanes == 16) { 5414 r[i]=av.lane(0); 5415 r[i+1]=av.lane(1); 5416 r[i+2]=av.lane(2); 5417 r[i+3]=av.lane(3); 5418 r[i+4]=av.lane(4); 5419 r[i+5]=av.lane(5); 5420 r[i+6]=av.lane(6); 5421 r[i+7]=av.lane(7); 5422 r[i+8]=av.lane(8); 5423 r[i+9]=av.lane(9); 5424 r[i+10]=av.lane(10); 5425 r[i+11]=av.lane(11); 5426 r[i+12]=av.lane(12); 5427 r[i+13]=av.lane(13); 5428 r[i+14]=av.lane(14); 5429 r[i+15]=av.lane(15); 5430 } else if (num_lanes == 32) { 5431 r[i]=av.lane(0); 5432 r[i+1]=av.lane(1); 5433 r[i+2]=av.lane(2); 5434 r[i+3]=av.lane(3); 5435 r[i+4]=av.lane(4); 5436 r[i+5]=av.lane(5); 5437 r[i+6]=av.lane(6); 5438 r[i+7]=av.lane(7); 5439 r[i+8]=av.lane(8); 5440 r[i+9]=av.lane(9); 5441 r[i+10]=av.lane(10); 5442 r[i+11]=av.lane(11); 5443 r[i+12]=av.lane(12); 5444 r[i+13]=av.lane(13); 5445 r[i+14]=av.lane(14); 5446 r[i+15]=av.lane(15); 5447 r[i+16]=av.lane(16); 5448 r[i+17]=av.lane(17); 5449 r[i+18]=av.lane(18); 5450 r[i+19]=av.lane(19); 5451 r[i+20]=av.lane(20); 5452 r[i+21]=av.lane(21); 5453 r[i+22]=av.lane(22); 5454 r[i+23]=av.lane(23); 5455 r[i+24]=av.lane(24); 5456 r[i+25]=av.lane(25); 5457 r[i+26]=av.lane(26); 5458 r[i+27]=av.lane(27); 5459 r[i+28]=av.lane(28); 5460 r[i+29]=av.lane(29); 5461 r[i+30]=av.lane(30); 5462 r[i+31]=av.lane(31); 5463 } else if (num_lanes == 64) { 5464 r[i]=av.lane(0); 5465 r[i+1]=av.lane(1); 5466 r[i+2]=av.lane(2); 5467 r[i+3]=av.lane(3); 5468 r[i+4]=av.lane(4); 5469 r[i+5]=av.lane(5); 5470 r[i+6]=av.lane(6); 5471 r[i+7]=av.lane(7); 5472 r[i+8]=av.lane(8); 5473 r[i+9]=av.lane(9); 5474 r[i+10]=av.lane(10); 5475 r[i+11]=av.lane(11); 5476 r[i+12]=av.lane(12); 5477 r[i+13]=av.lane(13); 5478 r[i+14]=av.lane(14); 5479 r[i+15]=av.lane(15); 5480 r[i+16]=av.lane(16); 5481 r[i+17]=av.lane(17); 5482 r[i+18]=av.lane(18); 5483 r[i+19]=av.lane(19); 5484 r[i+20]=av.lane(20); 5485 r[i+21]=av.lane(21); 5486 r[i+22]=av.lane(22); 5487 r[i+23]=av.lane(23); 5488 r[i+24]=av.lane(24); 5489 r[i+25]=av.lane(25); 5490 r[i+26]=av.lane(26); 5491 r[i+27]=av.lane(27); 5492 r[i+28]=av.lane(28); 5493 r[i+29]=av.lane(29); 5494 r[i+30]=av.lane(30); 5495 r[i+31]=av.lane(31); 5496 r[i+32]=av.lane(32); 5497 r[i+33]=av.lane(33); 5498 r[i+34]=av.lane(34); 5499 r[i+35]=av.lane(35); 5500 r[i+36]=av.lane(36); 5501 r[i+37]=av.lane(37); 5502 r[i+38]=av.lane(38); 5503 r[i+39]=av.lane(39); 5504 r[i+40]=av.lane(40); 5505 r[i+41]=av.lane(41); 5506 r[i+42]=av.lane(42); 5507 r[i+43]=av.lane(43); 5508 r[i+44]=av.lane(44); 5509 r[i+45]=av.lane(45); 5510 r[i+46]=av.lane(46); 5511 r[i+47]=av.lane(47); 5512 r[i+48]=av.lane(48); 5513 r[i+49]=av.lane(49); 5514 r[i+50]=av.lane(50); 5515 r[i+51]=av.lane(51); 5516 r[i+52]=av.lane(52); 5517 r[i+53]=av.lane(53); 5518 r[i+54]=av.lane(54); 5519 r[i+55]=av.lane(55); 5520 r[i+56]=av.lane(56); 5521 r[i+57]=av.lane(57); 5522 r[i+58]=av.lane(58); 5523 r[i+59]=av.lane(59); 5524 r[i+60]=av.lane(60); 5525 r[i+61]=av.lane(61); 5526 r[i+62]=av.lane(62); 5527 r[i+63]=av.lane(63); 5528 } else { 5529 for (int j = 0; j < SPECIES.length(); j++) { 5530 r[i+j]=av.lane(j); 5531 } 5532 } 5533 } 5534 } 5535 5536 assertArraysStrictlyEquals(r, a); 5537 } 5538 5539 @Test(dataProvider = "longUnaryOpProvider") 5540 static void BroadcastLongMaxVectorTests(IntFunction<long[]> fa) { 5541 long[] a = fa.apply(SPECIES.length()); 5542 long[] r = new long[a.length]; 5543 5544 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5545 for (int i = 0; i < a.length; i += SPECIES.length()) { 5546 LongVector.broadcast(SPECIES, a[i]).intoArray(r, i); 5547 } 5548 } 5549 5550 assertBroadcastArraysEquals(r, a); 5551 } 5552 5553 @Test(dataProvider = "longUnaryOpProvider") 5554 static void ZeroLongMaxVectorTests(IntFunction<long[]> fa) { 5555 long[] a = fa.apply(SPECIES.length()); 5556 long[] r = new long[a.length]; 5557 5558 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5559 for (int i = 0; i < a.length; i += SPECIES.length()) { 5560 LongVector.zero(SPECIES).intoArray(a, i); 5561 } 5562 } 5563 5564 Assert.assertEquals(a, r); 5565 } 5566 5567 static long[] sliceUnary(long[] a, int origin, int idx) { 5568 long[] res = new long[SPECIES.length()]; 5569 for (int i = 0; i < SPECIES.length(); i++){ 5570 if(i+origin < SPECIES.length()) 5571 res[i] = a[idx+i+origin]; 5572 else 5573 res[i] = (long)0; 5574 } 5575 return res; 5576 } 5577 5578 @Test(dataProvider = "longUnaryOpProvider") 5579 static void sliceUnaryLongMaxVectorTests(IntFunction<long[]> fa) { 5580 long[] a = fa.apply(SPECIES.length()); 5581 long[] r = new long[a.length]; 5582 int origin = RAND.nextInt(SPECIES.length()); 5583 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5584 for (int i = 0; i < a.length; i += SPECIES.length()) { 5585 LongVector av = LongVector.fromArray(SPECIES, a, i); 5586 av.slice(origin).intoArray(r, i); 5587 } 5588 } 5589 5590 assertArraysEquals(r, a, origin, LongMaxVectorTests::sliceUnary); 5591 } 5592 5593 static long[] sliceBinary(long[] a, long[] b, int origin, int idx) { 5594 long[] res = new long[SPECIES.length()]; 5595 for (int i = 0, j = 0; i < SPECIES.length(); i++){ 5596 if(i+origin < SPECIES.length()) 5597 res[i] = a[idx+i+origin]; 5598 else { 5599 res[i] = b[idx+j]; 5600 j++; 5601 } 5602 } 5603 return res; 5604 } 5605 5606 @Test(dataProvider = "longBinaryOpProvider") 5607 static void sliceBinaryLongMaxVectorTestsBinary(IntFunction<long[]> fa, IntFunction<long[]> fb) { 5608 long[] a = fa.apply(SPECIES.length()); 5609 long[] b = fb.apply(SPECIES.length()); 5610 long[] r = new long[a.length]; 5611 int origin = RAND.nextInt(SPECIES.length()); 5612 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5613 for (int i = 0; i < a.length; i += SPECIES.length()) { 5614 LongVector av = LongVector.fromArray(SPECIES, a, i); 5615 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5616 av.slice(origin, bv).intoArray(r, i); 5617 } 5618 } 5619 5620 assertArraysEquals(r, a, b, origin, LongMaxVectorTests::sliceBinary); 5621 } 5622 5623 static long[] slice(long[] a, long[] b, int origin, boolean[] mask, int idx) { 5624 long[] res = new long[SPECIES.length()]; 5625 for (int i = 0, j = 0; i < SPECIES.length(); i++){ 5626 if(i+origin < SPECIES.length()) 5627 res[i] = mask[i] ? a[idx+i+origin] : (long)0; 5628 else { 5629 res[i] = mask[i] ? b[idx+j] : (long)0; 5630 j++; 5631 } 5632 } 5633 return res; 5634 } 5635 5636 @Test(dataProvider = "longBinaryOpMaskProvider") 5637 static void sliceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 5638 IntFunction<boolean[]> fm) { 5639 long[] a = fa.apply(SPECIES.length()); 5640 long[] b = fb.apply(SPECIES.length()); 5641 boolean[] mask = fm.apply(SPECIES.length()); 5642 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5643 5644 long[] r = new long[a.length]; 5645 int origin = RAND.nextInt(SPECIES.length()); 5646 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5647 for (int i = 0; i < a.length; i += SPECIES.length()) { 5648 LongVector av = LongVector.fromArray(SPECIES, a, i); 5649 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5650 av.slice(origin, bv, vmask).intoArray(r, i); 5651 } 5652 } 5653 5654 assertArraysEquals(r, a, b, origin, mask, LongMaxVectorTests::slice); 5655 } 5656 5657 static long[] unsliceUnary(long[] a, int origin, int idx) { 5658 long[] res = new long[SPECIES.length()]; 5659 for (int i = 0, j = 0; i < SPECIES.length(); i++){ 5660 if(i < origin) 5661 res[i] = (long)0; 5662 else { 5663 res[i] = a[idx+j]; 5664 j++; 5665 } 5666 } 5667 return res; 5668 } 5669 5670 @Test(dataProvider = "longUnaryOpProvider") 5671 static void unsliceUnaryLongMaxVectorTests(IntFunction<long[]> fa) { 5672 long[] a = fa.apply(SPECIES.length()); 5673 long[] r = new long[a.length]; 5674 int origin = RAND.nextInt(SPECIES.length()); 5675 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5676 for (int i = 0; i < a.length; i += SPECIES.length()) { 5677 LongVector av = LongVector.fromArray(SPECIES, a, i); 5678 av.unslice(origin).intoArray(r, i); 5679 } 5680 } 5681 5682 assertArraysEquals(r, a, origin, LongMaxVectorTests::unsliceUnary); 5683 } 5684 5685 static long[] unsliceBinary(long[] a, long[] b, int origin, int part, int idx) { 5686 long[] res = new long[SPECIES.length()]; 5687 for (int i = 0, j = 0; i < SPECIES.length(); i++){ 5688 if (part == 0) { 5689 if (i < origin) 5690 res[i] = b[idx+i]; 5691 else { 5692 res[i] = a[idx+j]; 5693 j++; 5694 } 5695 } else if (part == 1) { 5696 if (i < origin) 5697 res[i] = a[idx+SPECIES.length()-origin+i]; 5698 else { 5699 res[i] = b[idx+origin+j]; 5700 j++; 5701 } 5702 } 5703 } 5704 return res; 5705 } 5706 5707 @Test(dataProvider = "longBinaryOpProvider") 5708 static void unsliceBinaryLongMaxVectorTestsBinary(IntFunction<long[]> fa, IntFunction<long[]> fb) { 5709 long[] a = fa.apply(SPECIES.length()); 5710 long[] b = fb.apply(SPECIES.length()); 5711 long[] r = new long[a.length]; 5712 int origin = RAND.nextInt(SPECIES.length()); 5713 int part = RAND.nextInt(2); 5714 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5715 for (int i = 0; i < a.length; i += SPECIES.length()) { 5716 LongVector av = LongVector.fromArray(SPECIES, a, i); 5717 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5718 av.unslice(origin, bv, part).intoArray(r, i); 5719 } 5720 } 5721 5722 assertArraysEquals(r, a, b, origin, part, LongMaxVectorTests::unsliceBinary); 5723 } 5724 5725 static long[] unslice(long[] a, long[] b, int origin, int part, boolean[] mask, int idx) { 5726 long[] res = new long[SPECIES.length()]; 5727 for (int i = 0, j = 0; i < SPECIES.length(); i++){ 5728 if(i+origin < SPECIES.length()) 5729 res[i] = b[idx+i+origin]; 5730 else { 5731 res[i] = b[idx+j]; 5732 j++; 5733 } 5734 } 5735 for (int i = 0; i < SPECIES.length(); i++){ 5736 res[i] = mask[i] ? a[idx+i] : res[i]; 5737 } 5738 long[] res1 = new long[SPECIES.length()]; 5739 if (part == 0) { 5740 for (int i = 0, j = 0; i < SPECIES.length(); i++){ 5741 if (i < origin) 5742 res1[i] = b[idx+i]; 5743 else { 5744 res1[i] = res[j]; 5745 j++; 5746 } 5747 } 5748 } else if (part == 1) { 5749 for (int i = 0, j = 0; i < SPECIES.length(); i++){ 5750 if (i < origin) 5751 res1[i] = res[SPECIES.length()-origin+i]; 5752 else { 5753 res1[i] = b[idx+origin+j]; 5754 j++; 5755 } 5756 } 5757 } 5758 return res1; 5759 } 5760 5761 @Test(dataProvider = "longBinaryOpMaskProvider") 5762 static void unsliceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 5763 IntFunction<boolean[]> fm) { 5764 long[] a = fa.apply(SPECIES.length()); 5765 long[] b = fb.apply(SPECIES.length()); 5766 boolean[] mask = fm.apply(SPECIES.length()); 5767 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5768 long[] r = new long[a.length]; 5769 int origin = RAND.nextInt(SPECIES.length()); 5770 int part = RAND.nextInt(2); 5771 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5772 for (int i = 0; i < a.length; i += SPECIES.length()) { 5773 LongVector av = LongVector.fromArray(SPECIES, a, i); 5774 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5775 av.unslice(origin, bv, part, vmask).intoArray(r, i); 5776 } 5777 } 5778 5779 assertArraysEquals(r, a, b, origin, part, mask, LongMaxVectorTests::unslice); 5780 } 5781 5782 static long BITWISE_BLEND(long a, long b, long c) { 5783 return (long)((a&~(c))|(b&c)); 5784 } 5785 5786 static long bitwiseBlend(long a, long b, long c) { 5787 return (long)((a&~(c))|(b&c)); 5788 } 5789 5790 @Test(dataProvider = "longTernaryOpProvider") 5791 static void BITWISE_BLENDLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) { 5792 long[] a = fa.apply(SPECIES.length()); 5793 long[] b = fb.apply(SPECIES.length()); 5794 long[] c = fc.apply(SPECIES.length()); 5795 long[] r = fr.apply(SPECIES.length()); 5796 5797 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5798 for (int i = 0; i < a.length; i += SPECIES.length()) { 5799 LongVector av = LongVector.fromArray(SPECIES, a, i); 5800 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5801 LongVector cv = LongVector.fromArray(SPECIES, c, i); 5802 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i); 5803 } 5804 } 5805 5806 assertArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND); 5807 } 5808 5809 @Test(dataProvider = "longTernaryOpProvider") 5810 static void bitwiseBlendLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) { 5811 long[] a = fa.apply(SPECIES.length()); 5812 long[] b = fb.apply(SPECIES.length()); 5813 long[] c = fc.apply(SPECIES.length()); 5814 long[] r = fr.apply(SPECIES.length()); 5815 5816 for (int i = 0; i < a.length; i += SPECIES.length()) { 5817 LongVector av = LongVector.fromArray(SPECIES, a, i); 5818 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5819 LongVector cv = LongVector.fromArray(SPECIES, c, i); 5820 av.bitwiseBlend(bv, cv).intoArray(r, i); 5821 } 5822 5823 assertArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend); 5824 } 5825 5826 @Test(dataProvider = "longTernaryOpMaskProvider") 5827 static void BITWISE_BLENDLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb, 5828 IntFunction<long[]> fc, IntFunction<boolean[]> fm) { 5829 long[] a = fa.apply(SPECIES.length()); 5830 long[] b = fb.apply(SPECIES.length()); 5831 long[] c = fc.apply(SPECIES.length()); 5832 long[] r = fr.apply(SPECIES.length()); 5833 boolean[] mask = fm.apply(SPECIES.length()); 5834 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5835 5836 for (int ic = 0; ic < INVOC_COUNT; ic++) { 5837 for (int i = 0; i < a.length; i += SPECIES.length()) { 5838 LongVector av = LongVector.fromArray(SPECIES, a, i); 5839 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5840 LongVector cv = LongVector.fromArray(SPECIES, c, i); 5841 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i); 5842 } 5843 } 5844 5845 assertArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND); 5846 } 5847 5848 @Test(dataProvider = "longTernaryOpProvider") 5849 static void BITWISE_BLENDLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) { 5850 long[] a = fa.apply(SPECIES.length()); 5851 long[] b = fb.apply(SPECIES.length()); 5852 long[] c = fc.apply(SPECIES.length()); 5853 long[] r = fr.apply(SPECIES.length()); 5854 5855 for (int i = 0; i < a.length; i += SPECIES.length()) { 5856 LongVector av = LongVector.fromArray(SPECIES, a, i); 5857 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5858 av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i); 5859 } 5860 assertBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND); 5861 } 5862 5863 @Test(dataProvider = "longTernaryOpProvider") 5864 static void BITWISE_BLENDLongMaxVectorTestsAltBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) { 5865 long[] a = fa.apply(SPECIES.length()); 5866 long[] b = fb.apply(SPECIES.length()); 5867 long[] c = fc.apply(SPECIES.length()); 5868 long[] r = fr.apply(SPECIES.length()); 5869 5870 for (int i = 0; i < a.length; i += SPECIES.length()) { 5871 LongVector av = LongVector.fromArray(SPECIES, a, i); 5872 LongVector cv = LongVector.fromArray(SPECIES, c, i); 5873 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i); 5874 } 5875 assertAltBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND); 5876 } 5877 5878 @Test(dataProvider = "longTernaryOpProvider") 5879 static void bitwiseBlendLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) { 5880 long[] a = fa.apply(SPECIES.length()); 5881 long[] b = fb.apply(SPECIES.length()); 5882 long[] c = fc.apply(SPECIES.length()); 5883 long[] r = fr.apply(SPECIES.length()); 5884 5885 for (int i = 0; i < a.length; i += SPECIES.length()) { 5886 LongVector av = LongVector.fromArray(SPECIES, a, i); 5887 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5888 av.bitwiseBlend(bv, c[i]).intoArray(r, i); 5889 } 5890 assertBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend); 5891 } 5892 5893 @Test(dataProvider = "longTernaryOpProvider") 5894 static void bitwiseBlendLongMaxVectorTestsAltBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) { 5895 long[] a = fa.apply(SPECIES.length()); 5896 long[] b = fb.apply(SPECIES.length()); 5897 long[] c = fc.apply(SPECIES.length()); 5898 long[] r = fr.apply(SPECIES.length()); 5899 5900 for (int i = 0; i < a.length; i += SPECIES.length()) { 5901 LongVector av = LongVector.fromArray(SPECIES, a, i); 5902 LongVector cv = LongVector.fromArray(SPECIES, c, i); 5903 av.bitwiseBlend(b[i], cv).intoArray(r, i); 5904 } 5905 assertAltBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend); 5906 } 5907 5908 @Test(dataProvider = "longTernaryOpMaskProvider") 5909 static void BITWISE_BLENDLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, 5910 IntFunction<long[]> fc, IntFunction<boolean[]> fm) { 5911 long[] a = fa.apply(SPECIES.length()); 5912 long[] b = fb.apply(SPECIES.length()); 5913 long[] c = fc.apply(SPECIES.length()); 5914 long[] r = fr.apply(SPECIES.length()); 5915 boolean[] mask = fm.apply(SPECIES.length()); 5916 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5917 5918 for (int i = 0; i < a.length; i += SPECIES.length()) { 5919 LongVector av = LongVector.fromArray(SPECIES, a, i); 5920 LongVector bv = LongVector.fromArray(SPECIES, b, i); 5921 av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i); 5922 } 5923 5924 assertBroadcastArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND); 5925 } 5926 5927 @Test(dataProvider = "longTernaryOpMaskProvider") 5928 static void BITWISE_BLENDLongMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, 5929 IntFunction<long[]> fc, IntFunction<boolean[]> fm) { 5930 long[] a = fa.apply(SPECIES.length()); 5931 long[] b = fb.apply(SPECIES.length()); 5932 long[] c = fc.apply(SPECIES.length()); 5933 long[] r = fr.apply(SPECIES.length()); 5934 boolean[] mask = fm.apply(SPECIES.length()); 5935 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5936 5937 for (int i = 0; i < a.length; i += SPECIES.length()) { 5938 LongVector av = LongVector.fromArray(SPECIES, a, i); 5939 LongVector cv = LongVector.fromArray(SPECIES, c, i); 5940 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i); 5941 } 5942 5943 assertAltBroadcastArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND); 5944 } 5945 5946 @Test(dataProvider = "longTernaryOpProvider") 5947 static void BITWISE_BLENDLongMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) { 5948 long[] a = fa.apply(SPECIES.length()); 5949 long[] b = fb.apply(SPECIES.length()); 5950 long[] c = fc.apply(SPECIES.length()); 5951 long[] r = fr.apply(SPECIES.length()); 5952 5953 for (int i = 0; i < a.length; i += SPECIES.length()) { 5954 LongVector av = LongVector.fromArray(SPECIES, a, i); 5955 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i); 5956 } 5957 5958 assertDoubleBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND); 5959 } 5960 5961 @Test(dataProvider = "longTernaryOpProvider") 5962 static void bitwiseBlendLongMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) { 5963 long[] a = fa.apply(SPECIES.length()); 5964 long[] b = fb.apply(SPECIES.length()); 5965 long[] c = fc.apply(SPECIES.length()); 5966 long[] r = fr.apply(SPECIES.length()); 5967 5968 for (int i = 0; i < a.length; i += SPECIES.length()) { 5969 LongVector av = LongVector.fromArray(SPECIES, a, i); 5970 av.bitwiseBlend(b[i], c[i]).intoArray(r, i); 5971 } 5972 5973 assertDoubleBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend); 5974 } 5975 5976 @Test(dataProvider = "longTernaryOpMaskProvider") 5977 static void BITWISE_BLENDLongMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, 5978 IntFunction<long[]> fc, IntFunction<boolean[]> fm) { 5979 long[] a = fa.apply(SPECIES.length()); 5980 long[] b = fb.apply(SPECIES.length()); 5981 long[] c = fc.apply(SPECIES.length()); 5982 long[] r = fr.apply(SPECIES.length()); 5983 boolean[] mask = fm.apply(SPECIES.length()); 5984 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 5985 5986 for (int i = 0; i < a.length; i += SPECIES.length()) { 5987 LongVector av = LongVector.fromArray(SPECIES, a, i); 5988 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i); 5989 } 5990 5991 assertDoubleBroadcastArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND); 5992 } 5993 5994 static long NEG(long a) { 5995 return (long)(-((long)a)); 5996 } 5997 5998 static long neg(long a) { 5999 return (long)(-((long)a)); 6000 } 6001 6002 @Test(dataProvider = "longUnaryOpProvider") 6003 static void NEGLongMaxVectorTests(IntFunction<long[]> fa) { 6004 long[] a = fa.apply(SPECIES.length()); 6005 long[] r = fr.apply(SPECIES.length()); 6006 6007 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6008 for (int i = 0; i < a.length; i += SPECIES.length()) { 6009 LongVector av = LongVector.fromArray(SPECIES, a, i); 6010 av.lanewise(VectorOperators.NEG).intoArray(r, i); 6011 } 6012 } 6013 6014 assertArraysEquals(r, a, LongMaxVectorTests::NEG); 6015 } 6016 6017 @Test(dataProvider = "longUnaryOpProvider") 6018 static void negLongMaxVectorTests(IntFunction<long[]> fa) { 6019 long[] a = fa.apply(SPECIES.length()); 6020 long[] r = fr.apply(SPECIES.length()); 6021 6022 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6023 for (int i = 0; i < a.length; i += SPECIES.length()) { 6024 LongVector av = LongVector.fromArray(SPECIES, a, i); 6025 av.neg().intoArray(r, i); 6026 } 6027 } 6028 6029 assertArraysEquals(r, a, LongMaxVectorTests::neg); 6030 } 6031 6032 @Test(dataProvider = "longUnaryOpMaskProvider") 6033 static void NEGMaskedLongMaxVectorTests(IntFunction<long[]> fa, 6034 IntFunction<boolean[]> fm) { 6035 long[] a = fa.apply(SPECIES.length()); 6036 long[] r = fr.apply(SPECIES.length()); 6037 boolean[] mask = fm.apply(SPECIES.length()); 6038 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 6039 6040 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6041 for (int i = 0; i < a.length; i += SPECIES.length()) { 6042 LongVector av = LongVector.fromArray(SPECIES, a, i); 6043 av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i); 6044 } 6045 } 6046 6047 assertArraysEquals(r, a, mask, LongMaxVectorTests::NEG); 6048 } 6049 6050 static long ABS(long a) { 6051 return (long)(Math.abs((long)a)); 6052 } 6053 6054 static long abs(long a) { 6055 return (long)(Math.abs((long)a)); 6056 } 6057 6058 @Test(dataProvider = "longUnaryOpProvider") 6059 static void ABSLongMaxVectorTests(IntFunction<long[]> fa) { 6060 long[] a = fa.apply(SPECIES.length()); 6061 long[] r = fr.apply(SPECIES.length()); 6062 6063 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6064 for (int i = 0; i < a.length; i += SPECIES.length()) { 6065 LongVector av = LongVector.fromArray(SPECIES, a, i); 6066 av.lanewise(VectorOperators.ABS).intoArray(r, i); 6067 } 6068 } 6069 6070 assertArraysEquals(r, a, LongMaxVectorTests::ABS); 6071 } 6072 6073 @Test(dataProvider = "longUnaryOpProvider") 6074 static void absLongMaxVectorTests(IntFunction<long[]> fa) { 6075 long[] a = fa.apply(SPECIES.length()); 6076 long[] r = fr.apply(SPECIES.length()); 6077 6078 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6079 for (int i = 0; i < a.length; i += SPECIES.length()) { 6080 LongVector av = LongVector.fromArray(SPECIES, a, i); 6081 av.abs().intoArray(r, i); 6082 } 6083 } 6084 6085 assertArraysEquals(r, a, LongMaxVectorTests::abs); 6086 } 6087 6088 @Test(dataProvider = "longUnaryOpMaskProvider") 6089 static void ABSMaskedLongMaxVectorTests(IntFunction<long[]> fa, 6090 IntFunction<boolean[]> fm) { 6091 long[] a = fa.apply(SPECIES.length()); 6092 long[] r = fr.apply(SPECIES.length()); 6093 boolean[] mask = fm.apply(SPECIES.length()); 6094 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 6095 6096 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6097 for (int i = 0; i < a.length; i += SPECIES.length()) { 6098 LongVector av = LongVector.fromArray(SPECIES, a, i); 6099 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i); 6100 } 6101 } 6102 6103 assertArraysEquals(r, a, mask, LongMaxVectorTests::ABS); 6104 } 6105 6106 static long NOT(long a) { 6107 return (long)(~((long)a)); 6108 } 6109 6110 static long not(long a) { 6111 return (long)(~((long)a)); 6112 } 6113 6114 @Test(dataProvider = "longUnaryOpProvider") 6115 static void NOTLongMaxVectorTests(IntFunction<long[]> fa) { 6116 long[] a = fa.apply(SPECIES.length()); 6117 long[] r = fr.apply(SPECIES.length()); 6118 6119 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6120 for (int i = 0; i < a.length; i += SPECIES.length()) { 6121 LongVector av = LongVector.fromArray(SPECIES, a, i); 6122 av.lanewise(VectorOperators.NOT).intoArray(r, i); 6123 } 6124 } 6125 6126 assertArraysEquals(r, a, LongMaxVectorTests::NOT); 6127 } 6128 6129 @Test(dataProvider = "longUnaryOpProvider") 6130 static void notLongMaxVectorTests(IntFunction<long[]> fa) { 6131 long[] a = fa.apply(SPECIES.length()); 6132 long[] r = fr.apply(SPECIES.length()); 6133 6134 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6135 for (int i = 0; i < a.length; i += SPECIES.length()) { 6136 LongVector av = LongVector.fromArray(SPECIES, a, i); 6137 av.not().intoArray(r, i); 6138 } 6139 } 6140 6141 assertArraysEquals(r, a, LongMaxVectorTests::not); 6142 } 6143 6144 @Test(dataProvider = "longUnaryOpMaskProvider") 6145 static void NOTMaskedLongMaxVectorTests(IntFunction<long[]> fa, 6146 IntFunction<boolean[]> fm) { 6147 long[] a = fa.apply(SPECIES.length()); 6148 long[] r = fr.apply(SPECIES.length()); 6149 boolean[] mask = fm.apply(SPECIES.length()); 6150 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 6151 6152 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6153 for (int i = 0; i < a.length; i += SPECIES.length()) { 6154 LongVector av = LongVector.fromArray(SPECIES, a, i); 6155 av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i); 6156 } 6157 } 6158 6159 assertArraysEquals(r, a, mask, LongMaxVectorTests::NOT); 6160 } 6161 6162 static long ZOMO(long a) { 6163 return (long)((a==0?0:-1)); 6164 } 6165 6166 @Test(dataProvider = "longUnaryOpProvider") 6167 static void ZOMOLongMaxVectorTests(IntFunction<long[]> fa) { 6168 long[] a = fa.apply(SPECIES.length()); 6169 long[] r = fr.apply(SPECIES.length()); 6170 6171 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6172 for (int i = 0; i < a.length; i += SPECIES.length()) { 6173 LongVector av = LongVector.fromArray(SPECIES, a, i); 6174 av.lanewise(VectorOperators.ZOMO).intoArray(r, i); 6175 } 6176 } 6177 6178 assertArraysEquals(r, a, LongMaxVectorTests::ZOMO); 6179 } 6180 6181 @Test(dataProvider = "longUnaryOpMaskProvider") 6182 static void ZOMOMaskedLongMaxVectorTests(IntFunction<long[]> fa, 6183 IntFunction<boolean[]> fm) { 6184 long[] a = fa.apply(SPECIES.length()); 6185 long[] r = fr.apply(SPECIES.length()); 6186 boolean[] mask = fm.apply(SPECIES.length()); 6187 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 6188 6189 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6190 for (int i = 0; i < a.length; i += SPECIES.length()) { 6191 LongVector av = LongVector.fromArray(SPECIES, a, i); 6192 av.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i); 6193 } 6194 } 6195 6196 assertArraysEquals(r, a, mask, LongMaxVectorTests::ZOMO); 6197 } 6198 6199 static long BIT_COUNT(long a) { 6200 return (long)(Long.bitCount(a)); 6201 } 6202 6203 @Test(dataProvider = "longUnaryOpProvider") 6204 static void BIT_COUNTLongMaxVectorTests(IntFunction<long[]> fa) { 6205 long[] a = fa.apply(SPECIES.length()); 6206 long[] r = fr.apply(SPECIES.length()); 6207 6208 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6209 for (int i = 0; i < a.length; i += SPECIES.length()) { 6210 LongVector av = LongVector.fromArray(SPECIES, a, i); 6211 av.lanewise(VectorOperators.BIT_COUNT).intoArray(r, i); 6212 } 6213 } 6214 6215 assertArraysEquals(r, a, LongMaxVectorTests::BIT_COUNT); 6216 } 6217 6218 @Test(dataProvider = "longUnaryOpMaskProvider") 6219 static void BIT_COUNTMaskedLongMaxVectorTests(IntFunction<long[]> fa, 6220 IntFunction<boolean[]> fm) { 6221 long[] a = fa.apply(SPECIES.length()); 6222 long[] r = fr.apply(SPECIES.length()); 6223 boolean[] mask = fm.apply(SPECIES.length()); 6224 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 6225 6226 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6227 for (int i = 0; i < a.length; i += SPECIES.length()) { 6228 LongVector av = LongVector.fromArray(SPECIES, a, i); 6229 av.lanewise(VectorOperators.BIT_COUNT, vmask).intoArray(r, i); 6230 } 6231 } 6232 6233 assertArraysEquals(r, a, mask, LongMaxVectorTests::BIT_COUNT); 6234 } 6235 6236 static long TRAILING_ZEROS_COUNT(long a) { 6237 return (long)(TRAILING_ZEROS_COUNT_scalar(a)); 6238 } 6239 6240 @Test(dataProvider = "longUnaryOpProvider") 6241 static void TRAILING_ZEROS_COUNTLongMaxVectorTests(IntFunction<long[]> fa) { 6242 long[] a = fa.apply(SPECIES.length()); 6243 long[] r = fr.apply(SPECIES.length()); 6244 6245 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6246 for (int i = 0; i < a.length; i += SPECIES.length()) { 6247 LongVector av = LongVector.fromArray(SPECIES, a, i); 6248 av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT).intoArray(r, i); 6249 } 6250 } 6251 6252 assertArraysEquals(r, a, LongMaxVectorTests::TRAILING_ZEROS_COUNT); 6253 } 6254 6255 @Test(dataProvider = "longUnaryOpMaskProvider") 6256 static void TRAILING_ZEROS_COUNTMaskedLongMaxVectorTests(IntFunction<long[]> fa, 6257 IntFunction<boolean[]> fm) { 6258 long[] a = fa.apply(SPECIES.length()); 6259 long[] r = fr.apply(SPECIES.length()); 6260 boolean[] mask = fm.apply(SPECIES.length()); 6261 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 6262 6263 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6264 for (int i = 0; i < a.length; i += SPECIES.length()) { 6265 LongVector av = LongVector.fromArray(SPECIES, a, i); 6266 av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT, vmask).intoArray(r, i); 6267 } 6268 } 6269 6270 assertArraysEquals(r, a, mask, LongMaxVectorTests::TRAILING_ZEROS_COUNT); 6271 } 6272 6273 static long LEADING_ZEROS_COUNT(long a) { 6274 return (long)(LEADING_ZEROS_COUNT_scalar(a)); 6275 } 6276 6277 @Test(dataProvider = "longUnaryOpProvider") 6278 static void LEADING_ZEROS_COUNTLongMaxVectorTests(IntFunction<long[]> fa) { 6279 long[] a = fa.apply(SPECIES.length()); 6280 long[] r = fr.apply(SPECIES.length()); 6281 6282 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6283 for (int i = 0; i < a.length; i += SPECIES.length()) { 6284 LongVector av = LongVector.fromArray(SPECIES, a, i); 6285 av.lanewise(VectorOperators.LEADING_ZEROS_COUNT).intoArray(r, i); 6286 } 6287 } 6288 6289 assertArraysEquals(r, a, LongMaxVectorTests::LEADING_ZEROS_COUNT); 6290 } 6291 6292 @Test(dataProvider = "longUnaryOpMaskProvider") 6293 static void LEADING_ZEROS_COUNTMaskedLongMaxVectorTests(IntFunction<long[]> fa, 6294 IntFunction<boolean[]> fm) { 6295 long[] a = fa.apply(SPECIES.length()); 6296 long[] r = fr.apply(SPECIES.length()); 6297 boolean[] mask = fm.apply(SPECIES.length()); 6298 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 6299 6300 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6301 for (int i = 0; i < a.length; i += SPECIES.length()) { 6302 LongVector av = LongVector.fromArray(SPECIES, a, i); 6303 av.lanewise(VectorOperators.LEADING_ZEROS_COUNT, vmask).intoArray(r, i); 6304 } 6305 } 6306 6307 assertArraysEquals(r, a, mask, LongMaxVectorTests::LEADING_ZEROS_COUNT); 6308 } 6309 6310 static long REVERSE(long a) { 6311 return (long)(REVERSE_scalar(a)); 6312 } 6313 6314 @Test(dataProvider = "longUnaryOpProvider") 6315 static void REVERSELongMaxVectorTests(IntFunction<long[]> fa) { 6316 long[] a = fa.apply(SPECIES.length()); 6317 long[] r = fr.apply(SPECIES.length()); 6318 6319 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6320 for (int i = 0; i < a.length; i += SPECIES.length()) { 6321 LongVector av = LongVector.fromArray(SPECIES, a, i); 6322 av.lanewise(VectorOperators.REVERSE).intoArray(r, i); 6323 } 6324 } 6325 6326 assertArraysEquals(r, a, LongMaxVectorTests::REVERSE); 6327 } 6328 6329 @Test(dataProvider = "longUnaryOpMaskProvider") 6330 static void REVERSEMaskedLongMaxVectorTests(IntFunction<long[]> fa, 6331 IntFunction<boolean[]> fm) { 6332 long[] a = fa.apply(SPECIES.length()); 6333 long[] r = fr.apply(SPECIES.length()); 6334 boolean[] mask = fm.apply(SPECIES.length()); 6335 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 6336 6337 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6338 for (int i = 0; i < a.length; i += SPECIES.length()) { 6339 LongVector av = LongVector.fromArray(SPECIES, a, i); 6340 av.lanewise(VectorOperators.REVERSE, vmask).intoArray(r, i); 6341 } 6342 } 6343 6344 assertArraysEquals(r, a, mask, LongMaxVectorTests::REVERSE); 6345 } 6346 6347 static long REVERSE_BYTES(long a) { 6348 return (long)(Long.reverseBytes(a)); 6349 } 6350 6351 @Test(dataProvider = "longUnaryOpProvider") 6352 static void REVERSE_BYTESLongMaxVectorTests(IntFunction<long[]> fa) { 6353 long[] a = fa.apply(SPECIES.length()); 6354 long[] r = fr.apply(SPECIES.length()); 6355 6356 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6357 for (int i = 0; i < a.length; i += SPECIES.length()) { 6358 LongVector av = LongVector.fromArray(SPECIES, a, i); 6359 av.lanewise(VectorOperators.REVERSE_BYTES).intoArray(r, i); 6360 } 6361 } 6362 6363 assertArraysEquals(r, a, LongMaxVectorTests::REVERSE_BYTES); 6364 } 6365 6366 @Test(dataProvider = "longUnaryOpMaskProvider") 6367 static void REVERSE_BYTESMaskedLongMaxVectorTests(IntFunction<long[]> fa, 6368 IntFunction<boolean[]> fm) { 6369 long[] a = fa.apply(SPECIES.length()); 6370 long[] r = fr.apply(SPECIES.length()); 6371 boolean[] mask = fm.apply(SPECIES.length()); 6372 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 6373 6374 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6375 for (int i = 0; i < a.length; i += SPECIES.length()) { 6376 LongVector av = LongVector.fromArray(SPECIES, a, i); 6377 av.lanewise(VectorOperators.REVERSE_BYTES, vmask).intoArray(r, i); 6378 } 6379 } 6380 6381 assertArraysEquals(r, a, mask, LongMaxVectorTests::REVERSE_BYTES); 6382 } 6383 6384 @Test(dataProvider = "longCompareOpProvider") 6385 static void ltLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { 6386 long[] a = fa.apply(SPECIES.length()); 6387 long[] b = fb.apply(SPECIES.length()); 6388 6389 for (int i = 0; i < a.length; i += SPECIES.length()) { 6390 LongVector av = LongVector.fromArray(SPECIES, a, i); 6391 VectorMask<Long> mv = av.lt(b[i]); 6392 6393 // Check results as part of computation. 6394 for (int j = 0; j < SPECIES.length(); j++) { 6395 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); 6396 } 6397 } 6398 } 6399 6400 @Test(dataProvider = "longCompareOpProvider") 6401 static void eqLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { 6402 long[] a = fa.apply(SPECIES.length()); 6403 long[] b = fb.apply(SPECIES.length()); 6404 6405 for (int i = 0; i < a.length; i += SPECIES.length()) { 6406 LongVector av = LongVector.fromArray(SPECIES, a, i); 6407 VectorMask<Long> mv = av.eq(b[i]); 6408 6409 // Check results as part of computation. 6410 for (int j = 0; j < SPECIES.length(); j++) { 6411 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); 6412 } 6413 } 6414 } 6415 6416 @Test(dataProvider = "longtoIntUnaryOpProvider") 6417 static void toIntArrayLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) { 6418 long[] a = fa.apply(SPECIES.length()); 6419 6420 for (int i = 0; i < a.length; i += SPECIES.length()) { 6421 LongVector av = LongVector.fromArray(SPECIES, a, i); 6422 int[] r = av.toIntArray(); 6423 assertArraysEquals(r, a, i); 6424 } 6425 } 6426 6427 @Test(dataProvider = "longUnaryOpProvider") 6428 static void toLongArrayLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) { 6429 long[] a = fa.apply(SPECIES.length()); 6430 6431 for (int i = 0; i < a.length; i += SPECIES.length()) { 6432 LongVector av = LongVector.fromArray(SPECIES, a, i); 6433 long[] r = av.toLongArray(); 6434 assertArraysEquals(r, a, i); 6435 } 6436 } 6437 6438 @Test(dataProvider = "longUnaryOpProvider") 6439 static void toDoubleArrayLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) { 6440 long[] a = fa.apply(SPECIES.length()); 6441 6442 for (int i = 0; i < a.length; i += SPECIES.length()) { 6443 LongVector av = LongVector.fromArray(SPECIES, a, i); 6444 double[] r = av.toDoubleArray(); 6445 assertArraysEquals(r, a, i); 6446 } 6447 } 6448 6449 @Test(dataProvider = "longUnaryOpProvider") 6450 static void toStringLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) { 6451 long[] a = fa.apply(SPECIES.length()); 6452 6453 for (int i = 0; i < a.length; i += SPECIES.length()) { 6454 LongVector av = LongVector.fromArray(SPECIES, a, i); 6455 String str = av.toString(); 6456 6457 long subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); 6458 Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str); 6459 } 6460 } 6461 6462 @Test(dataProvider = "longUnaryOpProvider") 6463 static void hashCodeLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) { 6464 long[] a = fa.apply(SPECIES.length()); 6465 6466 for (int i = 0; i < a.length; i += SPECIES.length()) { 6467 LongVector av = LongVector.fromArray(SPECIES, a, i); 6468 int hash = av.hashCode(); 6469 6470 long subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); 6471 int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); 6472 Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); 6473 } 6474 } 6475 6476 6477 6478 @Test(dataProvider = "longUnaryOpProvider") 6479 static void ADDReduceLongLongMaxVectorTests(IntFunction<long[]> fa) { 6480 long[] a = fa.apply(SPECIES.length()); 6481 long[] r = fr.apply(SPECIES.length()); 6482 long ra = 0; 6483 6484 for (int i = 0; i < a.length; i += SPECIES.length()) { 6485 LongVector av = LongVector.fromArray(SPECIES, a, i); 6486 r[i] = av.reduceLanesToLong(VectorOperators.ADD); 6487 } 6488 6489 ra = 0; 6490 for (int i = 0; i < a.length; i ++) { 6491 ra += r[i]; 6492 } 6493 6494 assertReductionArraysEquals(r, ra, a, 6495 LongMaxVectorTests::ADDReduce, LongMaxVectorTests::ADDReduceAll); 6496 } 6497 6498 @Test(dataProvider = "longUnaryOpMaskProvider") 6499 static void ADDReduceLongLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) { 6500 long[] a = fa.apply(SPECIES.length()); 6501 long[] r = fr.apply(SPECIES.length()); 6502 boolean[] mask = fm.apply(SPECIES.length()); 6503 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 6504 long ra = 0; 6505 6506 for (int i = 0; i < a.length; i += SPECIES.length()) { 6507 LongVector av = LongVector.fromArray(SPECIES, a, i); 6508 r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask); 6509 } 6510 6511 ra = 0; 6512 for (int i = 0; i < a.length; i ++) { 6513 ra += r[i]; 6514 } 6515 6516 assertReductionArraysEqualsMasked(r, ra, a, mask, 6517 LongMaxVectorTests::ADDReduceMasked, LongMaxVectorTests::ADDReduceAllMasked); 6518 } 6519 6520 @Test(dataProvider = "longUnaryOpSelectFromProvider") 6521 static void SelectFromLongMaxVectorTests(IntFunction<long[]> fa, 6522 BiFunction<Integer,Integer,long[]> fs) { 6523 long[] a = fa.apply(SPECIES.length()); 6524 long[] order = fs.apply(a.length, SPECIES.length()); 6525 long[] r = fr.apply(SPECIES.length()); 6526 6527 for (int i = 0; i < a.length; i += SPECIES.length()) { 6528 LongVector av = LongVector.fromArray(SPECIES, a, i); 6529 LongVector bv = LongVector.fromArray(SPECIES, order, i); 6530 bv.selectFrom(av).intoArray(r, i); 6531 } 6532 6533 assertSelectFromArraysEquals(r, a, order, SPECIES.length()); 6534 } 6535 6536 @Test(dataProvider = "longSelectFromTwoVectorOpProvider") 6537 static void SelectFromTwoVectorLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) { 6538 long[] a = fa.apply(SPECIES.length()); 6539 long[] b = fb.apply(SPECIES.length()); 6540 long[] idx = fc.apply(SPECIES.length()); 6541 long[] r = fr.apply(SPECIES.length()); 6542 6543 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6544 for (int i = 0; i < idx.length; i += SPECIES.length()) { 6545 LongVector av = LongVector.fromArray(SPECIES, a, i); 6546 LongVector bv = LongVector.fromArray(SPECIES, b, i); 6547 LongVector idxv = LongVector.fromArray(SPECIES, idx, i); 6548 idxv.selectFrom(av, bv).intoArray(r, i); 6549 } 6550 } 6551 assertSelectFromTwoVectorEquals(r, idx, a, b, SPECIES.length()); 6552 } 6553 6554 @Test(dataProvider = "longUnaryOpSelectFromMaskProvider") 6555 static void SelectFromLongMaxVectorTestsMaskedSmokeTest(IntFunction<long[]> fa, 6556 BiFunction<Integer,Integer,long[]> fs, 6557 IntFunction<boolean[]> fm) { 6558 long[] a = fa.apply(SPECIES.length()); 6559 long[] order = fs.apply(a.length, SPECIES.length()); 6560 long[] r = fr.apply(SPECIES.length()); 6561 boolean[] mask = fm.apply(SPECIES.length()); 6562 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 6563 6564 for (int i = 0; i < a.length; i += SPECIES.length()) { 6565 LongVector av = LongVector.fromArray(SPECIES, a, i); 6566 LongVector bv = LongVector.fromArray(SPECIES, order, i); 6567 bv.selectFrom(av, vmask).intoArray(r, i); 6568 } 6569 6570 assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); 6571 } 6572 6573 @Test(dataProvider = "shuffleProvider") 6574 static void shuffleMiscellaneousLongMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) { 6575 int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); 6576 6577 for (int i = 0; i < a.length; i += SPECIES.length()) { 6578 var shuffle = VectorShuffle.fromArray(SPECIES, a, i); 6579 int hash = shuffle.hashCode(); 6580 int length = shuffle.length(); 6581 6582 int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); 6583 int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); 6584 Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); 6585 Assert.assertEquals(length, SPECIES.length()); 6586 } 6587 } 6588 6589 @Test(dataProvider = "shuffleProvider") 6590 static void shuffleToStringLongMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) { 6591 int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); 6592 6593 for (int i = 0; i < a.length; i += SPECIES.length()) { 6594 var shuffle = VectorShuffle.fromArray(SPECIES, a, i); 6595 String str = shuffle.toString(); 6596 6597 int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); 6598 Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " + 6599 i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str); 6600 } 6601 } 6602 6603 @Test(dataProvider = "shuffleCompareOpProvider") 6604 static void shuffleEqualsLongMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fa, BiFunction<Integer,Integer,int[]> fb) { 6605 int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); 6606 int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); 6607 6608 for (int i = 0; i < a.length; i += SPECIES.length()) { 6609 var av = VectorShuffle.fromArray(SPECIES, a, i); 6610 var bv = VectorShuffle.fromArray(SPECIES, b, i); 6611 boolean eq = av.equals(bv); 6612 int to = i + SPECIES.length(); 6613 Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to)); 6614 } 6615 } 6616 6617 @Test(dataProvider = "maskCompareOpProvider") 6618 static void maskEqualsLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) { 6619 boolean[] a = fa.apply(SPECIES.length()); 6620 boolean[] b = fb.apply(SPECIES.length()); 6621 6622 for (int i = 0; i < a.length; i += SPECIES.length()) { 6623 var av = SPECIES.loadMask(a, i); 6624 var bv = SPECIES.loadMask(b, i); 6625 boolean equals = av.equals(bv); 6626 int to = i + SPECIES.length(); 6627 Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to)); 6628 } 6629 } 6630 6631 static boolean band(boolean a, boolean b) { 6632 return a & b; 6633 } 6634 6635 @Test(dataProvider = "maskCompareOpProvider") 6636 static void maskAndLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) { 6637 boolean[] a = fa.apply(SPECIES.length()); 6638 boolean[] b = fb.apply(SPECIES.length()); 6639 boolean[] r = new boolean[a.length]; 6640 6641 for (int i = 0; i < a.length; i += SPECIES.length()) { 6642 var av = SPECIES.loadMask(a, i); 6643 var bv = SPECIES.loadMask(b, i); 6644 var cv = av.and(bv); 6645 cv.intoArray(r, i); 6646 } 6647 assertArraysEquals(r, a, b, LongMaxVectorTests::band); 6648 } 6649 6650 static boolean bor(boolean a, boolean b) { 6651 return a | b; 6652 } 6653 6654 @Test(dataProvider = "maskCompareOpProvider") 6655 static void maskOrLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) { 6656 boolean[] a = fa.apply(SPECIES.length()); 6657 boolean[] b = fb.apply(SPECIES.length()); 6658 boolean[] r = new boolean[a.length]; 6659 6660 for (int i = 0; i < a.length; i += SPECIES.length()) { 6661 var av = SPECIES.loadMask(a, i); 6662 var bv = SPECIES.loadMask(b, i); 6663 var cv = av.or(bv); 6664 cv.intoArray(r, i); 6665 } 6666 assertArraysEquals(r, a, b, LongMaxVectorTests::bor); 6667 } 6668 6669 static boolean bxor(boolean a, boolean b) { 6670 return a != b; 6671 } 6672 6673 @Test(dataProvider = "maskCompareOpProvider") 6674 static void maskXorLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) { 6675 boolean[] a = fa.apply(SPECIES.length()); 6676 boolean[] b = fb.apply(SPECIES.length()); 6677 boolean[] r = new boolean[a.length]; 6678 6679 for (int i = 0; i < a.length; i += SPECIES.length()) { 6680 var av = SPECIES.loadMask(a, i); 6681 var bv = SPECIES.loadMask(b, i); 6682 var cv = av.xor(bv); 6683 cv.intoArray(r, i); 6684 } 6685 assertArraysEquals(r, a, b, LongMaxVectorTests::bxor); 6686 } 6687 6688 static boolean bandNot(boolean a, boolean b) { 6689 return a & !b; 6690 } 6691 6692 @Test(dataProvider = "maskCompareOpProvider") 6693 static void maskAndNotLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) { 6694 boolean[] a = fa.apply(SPECIES.length()); 6695 boolean[] b = fb.apply(SPECIES.length()); 6696 boolean[] r = new boolean[a.length]; 6697 6698 for (int i = 0; i < a.length; i += SPECIES.length()) { 6699 var av = SPECIES.loadMask(a, i); 6700 var bv = SPECIES.loadMask(b, i); 6701 var cv = av.andNot(bv); 6702 cv.intoArray(r, i); 6703 } 6704 assertArraysEquals(r, a, b, LongMaxVectorTests::bandNot); 6705 } 6706 6707 static boolean beq(boolean a, boolean b) { 6708 return (a == b); 6709 } 6710 6711 @Test(dataProvider = "maskCompareOpProvider") 6712 static void maskEqLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) { 6713 boolean[] a = fa.apply(SPECIES.length()); 6714 boolean[] b = fb.apply(SPECIES.length()); 6715 boolean[] r = new boolean[a.length]; 6716 6717 for (int i = 0; i < a.length; i += SPECIES.length()) { 6718 var av = SPECIES.loadMask(a, i); 6719 var bv = SPECIES.loadMask(b, i); 6720 var cv = av.eq(bv); 6721 cv.intoArray(r, i); 6722 } 6723 assertArraysEquals(r, a, b, LongMaxVectorTests::beq); 6724 } 6725 6726 @Test(dataProvider = "maskProvider") 6727 static void maskHashCodeLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) { 6728 boolean[] a = fa.apply(SPECIES.length()); 6729 6730 for (int i = 0; i < a.length; i += SPECIES.length()) { 6731 var vmask = SPECIES.loadMask(a, i); 6732 int hash = vmask.hashCode(); 6733 6734 boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); 6735 int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); 6736 Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); 6737 } 6738 } 6739 6740 static int maskTrueCount(boolean[] a, int idx) { 6741 int trueCount = 0; 6742 for (int i = idx; i < idx + SPECIES.length(); i++) { 6743 trueCount += a[i] ? 1 : 0; 6744 } 6745 return trueCount; 6746 } 6747 6748 @Test(dataProvider = "maskProvider") 6749 static void maskTrueCountLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) { 6750 boolean[] a = fa.apply(SPECIES.length()); 6751 int[] r = new int[a.length]; 6752 6753 for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { 6754 for (int i = 0; i < a.length; i += SPECIES.length()) { 6755 var vmask = SPECIES.loadMask(a, i); 6756 r[i] = vmask.trueCount(); 6757 } 6758 } 6759 6760 assertMaskReductionArraysEquals(r, a, LongMaxVectorTests::maskTrueCount); 6761 } 6762 6763 static int maskLastTrue(boolean[] a, int idx) { 6764 int i = idx + SPECIES.length() - 1; 6765 for (; i >= idx; i--) { 6766 if (a[i]) { 6767 break; 6768 } 6769 } 6770 return i - idx; 6771 } 6772 6773 @Test(dataProvider = "maskProvider") 6774 static void maskLastTrueLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) { 6775 boolean[] a = fa.apply(SPECIES.length()); 6776 int[] r = new int[a.length]; 6777 6778 for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { 6779 for (int i = 0; i < a.length; i += SPECIES.length()) { 6780 var vmask = SPECIES.loadMask(a, i); 6781 r[i] = vmask.lastTrue(); 6782 } 6783 } 6784 6785 assertMaskReductionArraysEquals(r, a, LongMaxVectorTests::maskLastTrue); 6786 } 6787 6788 static int maskFirstTrue(boolean[] a, int idx) { 6789 int i = idx; 6790 for (; i < idx + SPECIES.length(); i++) { 6791 if (a[i]) { 6792 break; 6793 } 6794 } 6795 return i - idx; 6796 } 6797 6798 @Test(dataProvider = "maskProvider") 6799 static void maskFirstTrueLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) { 6800 boolean[] a = fa.apply(SPECIES.length()); 6801 int[] r = new int[a.length]; 6802 6803 for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { 6804 for (int i = 0; i < a.length; i += SPECIES.length()) { 6805 var vmask = SPECIES.loadMask(a, i); 6806 r[i] = vmask.firstTrue(); 6807 } 6808 } 6809 6810 assertMaskReductionArraysEquals(r, a, LongMaxVectorTests::maskFirstTrue); 6811 } 6812 6813 @Test(dataProvider = "maskProvider") 6814 static void maskCompressLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) { 6815 int trueCount = 0; 6816 boolean[] a = fa.apply(SPECIES.length()); 6817 6818 for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { 6819 for (int i = 0; i < a.length; i += SPECIES.length()) { 6820 var vmask = SPECIES.loadMask(a, i); 6821 trueCount = vmask.trueCount(); 6822 var rmask = vmask.compress(); 6823 for (int j = 0; j < SPECIES.length(); j++) { 6824 Assert.assertEquals(rmask.laneIsSet(j), j < trueCount); 6825 } 6826 } 6827 } 6828 } 6829 6830 6831 @DataProvider 6832 public static Object[][] offsetProvider() { 6833 return new Object[][]{ 6834 {0}, 6835 {-1}, 6836 {+1}, 6837 {+2}, 6838 {-2}, 6839 }; 6840 } 6841 6842 @Test(dataProvider = "offsetProvider") 6843 static void indexInRangeLongMaxVectorTestsSmokeTest(int offset) { 6844 int limit = SPECIES.length() * BUFFER_REPS; 6845 for (int i = 0; i < limit; i += SPECIES.length()) { 6846 var actualMask = SPECIES.indexInRange(i + offset, limit); 6847 var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit); 6848 assert(actualMask.equals(expectedMask)); 6849 for (int j = 0; j < SPECIES.length(); j++) { 6850 int index = i + j + offset; 6851 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit); 6852 } 6853 } 6854 } 6855 6856 @Test(dataProvider = "offsetProvider") 6857 static void indexInRangeLongLongMaxVectorTestsSmokeTest(int offset) { 6858 long limit = SPECIES.length() * BUFFER_REPS; 6859 for (long i = 0; i < limit; i += SPECIES.length()) { 6860 var actualMask = SPECIES.indexInRange(i + offset, limit); 6861 var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit); 6862 assert(actualMask.equals(expectedMask)); 6863 for (int j = 0; j < SPECIES.length(); j++) { 6864 long index = i + j + offset; 6865 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit); 6866 } 6867 } 6868 } 6869 6870 @DataProvider 6871 public static Object[][] lengthProvider() { 6872 return new Object[][]{ 6873 {0}, 6874 {1}, 6875 {32}, 6876 {37}, 6877 {1024}, 6878 {1024+1}, 6879 {1024+5}, 6880 }; 6881 } 6882 6883 @Test(dataProvider = "lengthProvider") 6884 static void loopBoundLongMaxVectorTestsSmokeTest(int length) { 6885 int actualLoopBound = SPECIES.loopBound(length); 6886 int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); 6887 Assert.assertEquals(actualLoopBound, expectedLoopBound); 6888 } 6889 6890 @Test(dataProvider = "lengthProvider") 6891 static void loopBoundLongLongMaxVectorTestsSmokeTest(int _length) { 6892 long length = _length; 6893 long actualLoopBound = SPECIES.loopBound(length); 6894 long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); 6895 Assert.assertEquals(actualLoopBound, expectedLoopBound); 6896 } 6897 6898 @Test 6899 static void ElementSizeLongMaxVectorTestsSmokeTest() { 6900 LongVector av = LongVector.zero(SPECIES); 6901 int elsize = av.elementSize(); 6902 Assert.assertEquals(elsize, Long.SIZE); 6903 } 6904 6905 @Test 6906 static void VectorShapeLongMaxVectorTestsSmokeTest() { 6907 LongVector av = LongVector.zero(SPECIES); 6908 VectorShape vsh = av.shape(); 6909 assert(vsh.equals(VectorShape.S_Max_BIT)); 6910 } 6911 6912 @Test 6913 static void ShapeWithLanesLongMaxVectorTestsSmokeTest() { 6914 LongVector av = LongVector.zero(SPECIES); 6915 VectorShape vsh = av.shape(); 6916 VectorSpecies species = vsh.withLanes(long.class); 6917 assert(species.equals(SPECIES)); 6918 } 6919 6920 @Test 6921 static void ElementTypeLongMaxVectorTestsSmokeTest() { 6922 LongVector av = LongVector.zero(SPECIES); 6923 assert(av.species().elementType() == long.class); 6924 } 6925 6926 @Test 6927 static void SpeciesElementSizeLongMaxVectorTestsSmokeTest() { 6928 LongVector av = LongVector.zero(SPECIES); 6929 assert(av.species().elementSize() == Long.SIZE); 6930 } 6931 6932 @Test 6933 static void VectorTypeLongMaxVectorTestsSmokeTest() { 6934 LongVector av = LongVector.zero(SPECIES); 6935 assert(av.species().vectorType() == av.getClass()); 6936 } 6937 6938 @Test 6939 static void WithLanesLongMaxVectorTestsSmokeTest() { 6940 LongVector av = LongVector.zero(SPECIES); 6941 VectorSpecies species = av.species().withLanes(long.class); 6942 assert(species.equals(SPECIES)); 6943 } 6944 6945 @Test 6946 static void WithShapeLongMaxVectorTestsSmokeTest() { 6947 LongVector av = LongVector.zero(SPECIES); 6948 VectorShape vsh = av.shape(); 6949 VectorSpecies species = av.species().withShape(vsh); 6950 assert(species.equals(SPECIES)); 6951 } 6952 6953 @Test 6954 static void MaskAllTrueLongMaxVectorTestsSmokeTest() { 6955 for (int ic = 0; ic < INVOC_COUNT; ic++) { 6956 Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); 6957 } 6958 } 6959 } --- EOF ---