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