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