1 /* 2 * Copyright (c) 2018, 2024, 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 package org.openjdk.bench.jdk.incubator.vector.operation; 25 26 // -- This file was mechanically generated: Do not edit! -- // 27 28 import jdk.incubator.vector.Vector; 29 import jdk.incubator.vector.VectorMask; 30 import jdk.incubator.vector.VectorOperators; 31 import jdk.incubator.vector.VectorShape; 32 import jdk.incubator.vector.VectorSpecies; 33 import jdk.incubator.vector.VectorShuffle; 34 import jdk.incubator.vector.LongVector; 35 36 import java.util.concurrent.TimeUnit; 37 import java.util.function.BiFunction; 38 import java.util.function.IntFunction; 39 40 import org.openjdk.jmh.annotations.*; 41 import org.openjdk.jmh.infra.Blackhole; 42 43 @BenchmarkMode(Mode.Throughput) 44 @OutputTimeUnit(TimeUnit.MILLISECONDS) 45 @State(Scope.Benchmark) 46 @Warmup(iterations = 3, time = 1) 47 @Measurement(iterations = 5, time = 1) 48 @Fork(value = 1, jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) 49 public class Long128Vector extends AbstractVectorBenchmark { 50 static final VectorSpecies<Long> SPECIES = LongVector.SPECIES_128; 51 52 static final int INVOC_COUNT = 1; // get rid of outer loop 53 54 static void replaceZero(long[] a, long v) { 55 for (int i = 0; i < a.length; i++) { 56 if (a[i] == 0) { 57 a[i] = v; 58 } 59 } 60 } 61 62 static void replaceZero(long[] a, boolean[] mask, long v) { 63 for (int i = 0; i < a.length; i++) { 64 if (mask[i % mask.length] && a[i] == 0) { 65 a[i] = v; 66 } 67 } 68 } 69 70 static long firstNonZero(long a, long b) { 71 return Long.compare(a, (long) 0) != 0 ? a : b; 72 } 73 74 private static final long CONST_SHIFT = Long.SIZE / 2; 75 76 @Param("1024") 77 int size; 78 79 long[] fill(IntFunction<Long> f) { 80 long[] array = new long[size]; 81 for (int i = 0; i < array.length; i++) { 82 array[i] = f.apply(i); 83 } 84 return array; 85 } 86 87 long[] a, b, c, r; 88 boolean[] m, mt, rm; 89 int[] s; 90 91 @Setup 92 public void init() { 93 size += size % SPECIES.length(); // FIXME: add post-loops 94 95 a = fill(i -> (long)(2*i)); 96 b = fill(i -> (long)(i+1)); 97 c = fill(i -> (long)(i+5)); 98 r = fill(i -> (long)0); 99 100 m = fillMask(size, i -> (i % 2) == 0); 101 mt = fillMask(size, i -> true); 102 rm = fillMask(size, i -> false); 103 104 s = fillInt(size, i -> RAND.nextInt(SPECIES.length())); 105 } 106 107 final IntFunction<long[]> fa = vl -> a; 108 final IntFunction<long[]> fb = vl -> b; 109 final IntFunction<long[]> fc = vl -> c; 110 final IntFunction<long[]> fr = vl -> r; 111 final IntFunction<boolean[]> fm = vl -> m; 112 final IntFunction<boolean[]> fmt = vl -> mt; 113 final IntFunction<boolean[]> fmr = vl -> rm; 114 final BiFunction<Integer,Integer,int[]> fs = (i,j) -> s; 115 116 117 @Benchmark 118 public void ADD(Blackhole bh) { 119 long[] a = fa.apply(SPECIES.length()); 120 long[] b = fb.apply(SPECIES.length()); 121 long[] r = fr.apply(SPECIES.length()); 122 123 for (int ic = 0; ic < INVOC_COUNT; ic++) { 124 for (int i = 0; i < a.length; i += SPECIES.length()) { 125 LongVector av = LongVector.fromArray(SPECIES, a, i); 126 LongVector bv = LongVector.fromArray(SPECIES, b, i); 127 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i); 128 } 129 } 130 131 bh.consume(r); 132 } 133 134 @Benchmark 135 public void ADDMasked(Blackhole bh) { 136 long[] a = fa.apply(SPECIES.length()); 137 long[] b = fb.apply(SPECIES.length()); 138 long[] r = fr.apply(SPECIES.length()); 139 boolean[] mask = fm.apply(SPECIES.length()); 140 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 141 142 for (int ic = 0; ic < INVOC_COUNT; ic++) { 143 for (int i = 0; i < a.length; i += SPECIES.length()) { 144 LongVector av = LongVector.fromArray(SPECIES, a, i); 145 LongVector bv = LongVector.fromArray(SPECIES, b, i); 146 av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i); 147 } 148 } 149 150 bh.consume(r); 151 } 152 153 @Benchmark 154 public void SUB(Blackhole bh) { 155 long[] a = fa.apply(SPECIES.length()); 156 long[] b = fb.apply(SPECIES.length()); 157 long[] r = fr.apply(SPECIES.length()); 158 159 for (int ic = 0; ic < INVOC_COUNT; ic++) { 160 for (int i = 0; i < a.length; i += SPECIES.length()) { 161 LongVector av = LongVector.fromArray(SPECIES, a, i); 162 LongVector bv = LongVector.fromArray(SPECIES, b, i); 163 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i); 164 } 165 } 166 167 bh.consume(r); 168 } 169 170 @Benchmark 171 public void SUBMasked(Blackhole bh) { 172 long[] a = fa.apply(SPECIES.length()); 173 long[] b = fb.apply(SPECIES.length()); 174 long[] r = fr.apply(SPECIES.length()); 175 boolean[] mask = fm.apply(SPECIES.length()); 176 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 177 178 for (int ic = 0; ic < INVOC_COUNT; ic++) { 179 for (int i = 0; i < a.length; i += SPECIES.length()) { 180 LongVector av = LongVector.fromArray(SPECIES, a, i); 181 LongVector bv = LongVector.fromArray(SPECIES, b, i); 182 av.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i); 183 } 184 } 185 186 bh.consume(r); 187 } 188 189 @Benchmark 190 public void MUL(Blackhole bh) { 191 long[] a = fa.apply(SPECIES.length()); 192 long[] b = fb.apply(SPECIES.length()); 193 long[] r = fr.apply(SPECIES.length()); 194 195 for (int ic = 0; ic < INVOC_COUNT; ic++) { 196 for (int i = 0; i < a.length; i += SPECIES.length()) { 197 LongVector av = LongVector.fromArray(SPECIES, a, i); 198 LongVector bv = LongVector.fromArray(SPECIES, b, i); 199 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i); 200 } 201 } 202 203 bh.consume(r); 204 } 205 206 @Benchmark 207 public void MULMasked(Blackhole bh) { 208 long[] a = fa.apply(SPECIES.length()); 209 long[] b = fb.apply(SPECIES.length()); 210 long[] r = fr.apply(SPECIES.length()); 211 boolean[] mask = fm.apply(SPECIES.length()); 212 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 213 214 for (int ic = 0; ic < INVOC_COUNT; ic++) { 215 for (int i = 0; i < a.length; i += SPECIES.length()) { 216 LongVector av = LongVector.fromArray(SPECIES, a, i); 217 LongVector bv = LongVector.fromArray(SPECIES, b, i); 218 av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i); 219 } 220 } 221 222 bh.consume(r); 223 } 224 225 @Benchmark 226 public void DIV(Blackhole bh) { 227 long[] a = fa.apply(SPECIES.length()); 228 long[] b = fb.apply(SPECIES.length()); 229 long[] r = fr.apply(SPECIES.length()); 230 231 replaceZero(b, (long) 1); 232 233 for (int ic = 0; ic < INVOC_COUNT; ic++) { 234 for (int i = 0; i < a.length; i += SPECIES.length()) { 235 LongVector av = LongVector.fromArray(SPECIES, a, i); 236 LongVector bv = LongVector.fromArray(SPECIES, b, i); 237 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i); 238 } 239 } 240 241 bh.consume(r); 242 } 243 244 @Benchmark 245 public void DIVMasked(Blackhole bh) { 246 long[] a = fa.apply(SPECIES.length()); 247 long[] b = fb.apply(SPECIES.length()); 248 long[] r = fr.apply(SPECIES.length()); 249 boolean[] mask = fm.apply(SPECIES.length()); 250 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 251 252 replaceZero(b, mask, (long) 1); 253 254 for (int ic = 0; ic < INVOC_COUNT; ic++) { 255 for (int i = 0; i < a.length; i += SPECIES.length()) { 256 LongVector av = LongVector.fromArray(SPECIES, a, i); 257 LongVector bv = LongVector.fromArray(SPECIES, b, i); 258 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i); 259 } 260 } 261 262 bh.consume(r); 263 } 264 265 @Benchmark 266 public void FIRST_NONZERO(Blackhole bh) { 267 long[] a = fa.apply(SPECIES.length()); 268 long[] b = fb.apply(SPECIES.length()); 269 long[] r = fr.apply(SPECIES.length()); 270 271 for (int ic = 0; ic < INVOC_COUNT; ic++) { 272 for (int i = 0; i < a.length; i += SPECIES.length()) { 273 LongVector av = LongVector.fromArray(SPECIES, a, i); 274 LongVector bv = LongVector.fromArray(SPECIES, b, i); 275 av.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i); 276 } 277 } 278 279 bh.consume(r); 280 } 281 282 @Benchmark 283 public void FIRST_NONZEROMasked(Blackhole bh) { 284 long[] a = fa.apply(SPECIES.length()); 285 long[] b = fb.apply(SPECIES.length()); 286 long[] r = fr.apply(SPECIES.length()); 287 boolean[] mask = fm.apply(SPECIES.length()); 288 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 289 290 for (int ic = 0; ic < INVOC_COUNT; ic++) { 291 for (int i = 0; i < a.length; i += SPECIES.length()) { 292 LongVector av = LongVector.fromArray(SPECIES, a, i); 293 LongVector bv = LongVector.fromArray(SPECIES, b, i); 294 av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i); 295 } 296 } 297 298 bh.consume(r); 299 } 300 301 @Benchmark 302 public void AND(Blackhole bh) { 303 long[] a = fa.apply(SPECIES.length()); 304 long[] b = fb.apply(SPECIES.length()); 305 long[] r = fr.apply(SPECIES.length()); 306 307 for (int ic = 0; ic < INVOC_COUNT; ic++) { 308 for (int i = 0; i < a.length; i += SPECIES.length()) { 309 LongVector av = LongVector.fromArray(SPECIES, a, i); 310 LongVector bv = LongVector.fromArray(SPECIES, b, i); 311 av.lanewise(VectorOperators.AND, bv).intoArray(r, i); 312 } 313 } 314 315 bh.consume(r); 316 } 317 318 @Benchmark 319 public void ANDMasked(Blackhole bh) { 320 long[] a = fa.apply(SPECIES.length()); 321 long[] b = fb.apply(SPECIES.length()); 322 long[] r = fr.apply(SPECIES.length()); 323 boolean[] mask = fm.apply(SPECIES.length()); 324 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 325 326 for (int ic = 0; ic < INVOC_COUNT; ic++) { 327 for (int i = 0; i < a.length; i += SPECIES.length()) { 328 LongVector av = LongVector.fromArray(SPECIES, a, i); 329 LongVector bv = LongVector.fromArray(SPECIES, b, i); 330 av.lanewise(VectorOperators.AND, bv, vmask).intoArray(r, i); 331 } 332 } 333 334 bh.consume(r); 335 } 336 337 @Benchmark 338 public void AND_NOT(Blackhole bh) { 339 long[] a = fa.apply(SPECIES.length()); 340 long[] b = fb.apply(SPECIES.length()); 341 long[] r = fr.apply(SPECIES.length()); 342 343 for (int ic = 0; ic < INVOC_COUNT; ic++) { 344 for (int i = 0; i < a.length; i += SPECIES.length()) { 345 LongVector av = LongVector.fromArray(SPECIES, a, i); 346 LongVector bv = LongVector.fromArray(SPECIES, b, i); 347 av.lanewise(VectorOperators.AND_NOT, bv).intoArray(r, i); 348 } 349 } 350 351 bh.consume(r); 352 } 353 354 @Benchmark 355 public void AND_NOTMasked(Blackhole bh) { 356 long[] a = fa.apply(SPECIES.length()); 357 long[] b = fb.apply(SPECIES.length()); 358 long[] r = fr.apply(SPECIES.length()); 359 boolean[] mask = fm.apply(SPECIES.length()); 360 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 361 362 for (int ic = 0; ic < INVOC_COUNT; ic++) { 363 for (int i = 0; i < a.length; i += SPECIES.length()) { 364 LongVector av = LongVector.fromArray(SPECIES, a, i); 365 LongVector bv = LongVector.fromArray(SPECIES, b, i); 366 av.lanewise(VectorOperators.AND_NOT, bv, vmask).intoArray(r, i); 367 } 368 } 369 370 bh.consume(r); 371 } 372 373 @Benchmark 374 public void OR(Blackhole bh) { 375 long[] a = fa.apply(SPECIES.length()); 376 long[] b = fb.apply(SPECIES.length()); 377 long[] r = fr.apply(SPECIES.length()); 378 379 for (int ic = 0; ic < INVOC_COUNT; ic++) { 380 for (int i = 0; i < a.length; i += SPECIES.length()) { 381 LongVector av = LongVector.fromArray(SPECIES, a, i); 382 LongVector bv = LongVector.fromArray(SPECIES, b, i); 383 av.lanewise(VectorOperators.OR, bv).intoArray(r, i); 384 } 385 } 386 387 bh.consume(r); 388 } 389 390 @Benchmark 391 public void ORMasked(Blackhole bh) { 392 long[] a = fa.apply(SPECIES.length()); 393 long[] b = fb.apply(SPECIES.length()); 394 long[] r = fr.apply(SPECIES.length()); 395 boolean[] mask = fm.apply(SPECIES.length()); 396 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 397 398 for (int ic = 0; ic < INVOC_COUNT; ic++) { 399 for (int i = 0; i < a.length; i += SPECIES.length()) { 400 LongVector av = LongVector.fromArray(SPECIES, a, i); 401 LongVector bv = LongVector.fromArray(SPECIES, b, i); 402 av.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i); 403 } 404 } 405 406 bh.consume(r); 407 } 408 409 @Benchmark 410 public void XOR(Blackhole bh) { 411 long[] a = fa.apply(SPECIES.length()); 412 long[] b = fb.apply(SPECIES.length()); 413 long[] r = fr.apply(SPECIES.length()); 414 415 for (int ic = 0; ic < INVOC_COUNT; ic++) { 416 for (int i = 0; i < a.length; i += SPECIES.length()) { 417 LongVector av = LongVector.fromArray(SPECIES, a, i); 418 LongVector bv = LongVector.fromArray(SPECIES, b, i); 419 av.lanewise(VectorOperators.XOR, bv).intoArray(r, i); 420 } 421 } 422 423 bh.consume(r); 424 } 425 426 @Benchmark 427 public void XORMasked(Blackhole bh) { 428 long[] a = fa.apply(SPECIES.length()); 429 long[] b = fb.apply(SPECIES.length()); 430 long[] r = fr.apply(SPECIES.length()); 431 boolean[] mask = fm.apply(SPECIES.length()); 432 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 433 434 for (int ic = 0; ic < INVOC_COUNT; ic++) { 435 for (int i = 0; i < a.length; i += SPECIES.length()) { 436 LongVector av = LongVector.fromArray(SPECIES, a, i); 437 LongVector bv = LongVector.fromArray(SPECIES, b, i); 438 av.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i); 439 } 440 } 441 442 bh.consume(r); 443 } 444 445 @Benchmark 446 public void COMPRESS_BITS(Blackhole bh) { 447 long[] a = fa.apply(SPECIES.length()); 448 long[] b = fb.apply(SPECIES.length()); 449 long[] r = fr.apply(SPECIES.length()); 450 451 for (int ic = 0; ic < INVOC_COUNT; ic++) { 452 for (int i = 0; i < a.length; i += SPECIES.length()) { 453 LongVector av = LongVector.fromArray(SPECIES, a, i); 454 LongVector bv = LongVector.fromArray(SPECIES, b, i); 455 av.lanewise(VectorOperators.COMPRESS_BITS, bv).intoArray(r, i); 456 } 457 } 458 459 bh.consume(r); 460 } 461 462 @Benchmark 463 public void COMPRESS_BITSMasked(Blackhole bh) { 464 long[] a = fa.apply(SPECIES.length()); 465 long[] b = fb.apply(SPECIES.length()); 466 long[] r = fr.apply(SPECIES.length()); 467 boolean[] mask = fm.apply(SPECIES.length()); 468 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 469 470 for (int ic = 0; ic < INVOC_COUNT; ic++) { 471 for (int i = 0; i < a.length; i += SPECIES.length()) { 472 LongVector av = LongVector.fromArray(SPECIES, a, i); 473 LongVector bv = LongVector.fromArray(SPECIES, b, i); 474 av.lanewise(VectorOperators.COMPRESS_BITS, bv, vmask).intoArray(r, i); 475 } 476 } 477 478 bh.consume(r); 479 } 480 481 @Benchmark 482 public void EXPAND_BITS(Blackhole bh) { 483 long[] a = fa.apply(SPECIES.length()); 484 long[] b = fb.apply(SPECIES.length()); 485 long[] r = fr.apply(SPECIES.length()); 486 487 for (int ic = 0; ic < INVOC_COUNT; ic++) { 488 for (int i = 0; i < a.length; i += SPECIES.length()) { 489 LongVector av = LongVector.fromArray(SPECIES, a, i); 490 LongVector bv = LongVector.fromArray(SPECIES, b, i); 491 av.lanewise(VectorOperators.EXPAND_BITS, bv).intoArray(r, i); 492 } 493 } 494 495 bh.consume(r); 496 } 497 498 @Benchmark 499 public void EXPAND_BITSMasked(Blackhole bh) { 500 long[] a = fa.apply(SPECIES.length()); 501 long[] b = fb.apply(SPECIES.length()); 502 long[] r = fr.apply(SPECIES.length()); 503 boolean[] mask = fm.apply(SPECIES.length()); 504 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 505 506 for (int ic = 0; ic < INVOC_COUNT; ic++) { 507 for (int i = 0; i < a.length; i += SPECIES.length()) { 508 LongVector av = LongVector.fromArray(SPECIES, a, i); 509 LongVector bv = LongVector.fromArray(SPECIES, b, i); 510 av.lanewise(VectorOperators.EXPAND_BITS, bv, vmask).intoArray(r, i); 511 } 512 } 513 514 bh.consume(r); 515 } 516 517 @Benchmark 518 public void LSHL(Blackhole bh) { 519 long[] a = fa.apply(SPECIES.length()); 520 long[] b = fb.apply(SPECIES.length()); 521 long[] r = fr.apply(SPECIES.length()); 522 523 for (int ic = 0; ic < INVOC_COUNT; ic++) { 524 for (int i = 0; i < a.length; i += SPECIES.length()) { 525 LongVector av = LongVector.fromArray(SPECIES, a, i); 526 LongVector bv = LongVector.fromArray(SPECIES, b, i); 527 av.lanewise(VectorOperators.LSHL, bv).intoArray(r, i); 528 } 529 } 530 531 bh.consume(r); 532 } 533 534 @Benchmark 535 public void LSHLMasked(Blackhole bh) { 536 long[] a = fa.apply(SPECIES.length()); 537 long[] b = fb.apply(SPECIES.length()); 538 long[] r = fr.apply(SPECIES.length()); 539 boolean[] mask = fm.apply(SPECIES.length()); 540 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 541 542 for (int ic = 0; ic < INVOC_COUNT; ic++) { 543 for (int i = 0; i < a.length; i += SPECIES.length()) { 544 LongVector av = LongVector.fromArray(SPECIES, a, i); 545 LongVector bv = LongVector.fromArray(SPECIES, b, i); 546 av.lanewise(VectorOperators.LSHL, bv, vmask).intoArray(r, i); 547 } 548 } 549 550 bh.consume(r); 551 } 552 553 @Benchmark 554 public void ASHR(Blackhole bh) { 555 long[] a = fa.apply(SPECIES.length()); 556 long[] b = fb.apply(SPECIES.length()); 557 long[] r = fr.apply(SPECIES.length()); 558 559 for (int ic = 0; ic < INVOC_COUNT; ic++) { 560 for (int i = 0; i < a.length; i += SPECIES.length()) { 561 LongVector av = LongVector.fromArray(SPECIES, a, i); 562 LongVector bv = LongVector.fromArray(SPECIES, b, i); 563 av.lanewise(VectorOperators.ASHR, bv).intoArray(r, i); 564 } 565 } 566 567 bh.consume(r); 568 } 569 570 @Benchmark 571 public void ASHRMasked(Blackhole bh) { 572 long[] a = fa.apply(SPECIES.length()); 573 long[] b = fb.apply(SPECIES.length()); 574 long[] r = fr.apply(SPECIES.length()); 575 boolean[] mask = fm.apply(SPECIES.length()); 576 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 577 578 for (int ic = 0; ic < INVOC_COUNT; ic++) { 579 for (int i = 0; i < a.length; i += SPECIES.length()) { 580 LongVector av = LongVector.fromArray(SPECIES, a, i); 581 LongVector bv = LongVector.fromArray(SPECIES, b, i); 582 av.lanewise(VectorOperators.ASHR, bv, vmask).intoArray(r, i); 583 } 584 } 585 586 bh.consume(r); 587 } 588 589 @Benchmark 590 public void LSHR(Blackhole bh) { 591 long[] a = fa.apply(SPECIES.length()); 592 long[] b = fb.apply(SPECIES.length()); 593 long[] r = fr.apply(SPECIES.length()); 594 595 for (int ic = 0; ic < INVOC_COUNT; ic++) { 596 for (int i = 0; i < a.length; i += SPECIES.length()) { 597 LongVector av = LongVector.fromArray(SPECIES, a, i); 598 LongVector bv = LongVector.fromArray(SPECIES, b, i); 599 av.lanewise(VectorOperators.LSHR, bv).intoArray(r, i); 600 } 601 } 602 603 bh.consume(r); 604 } 605 606 @Benchmark 607 public void LSHRMasked(Blackhole bh) { 608 long[] a = fa.apply(SPECIES.length()); 609 long[] b = fb.apply(SPECIES.length()); 610 long[] r = fr.apply(SPECIES.length()); 611 boolean[] mask = fm.apply(SPECIES.length()); 612 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 613 614 for (int ic = 0; ic < INVOC_COUNT; ic++) { 615 for (int i = 0; i < a.length; i += SPECIES.length()) { 616 LongVector av = LongVector.fromArray(SPECIES, a, i); 617 LongVector bv = LongVector.fromArray(SPECIES, b, i); 618 av.lanewise(VectorOperators.LSHR, bv, vmask).intoArray(r, i); 619 } 620 } 621 622 bh.consume(r); 623 } 624 625 @Benchmark 626 public void LSHLShift(Blackhole bh) { 627 long[] a = fa.apply(SPECIES.length()); 628 long[] b = fb.apply(SPECIES.length()); 629 long[] r = fr.apply(SPECIES.length()); 630 631 for (int ic = 0; ic < INVOC_COUNT; ic++) { 632 for (int i = 0; i < a.length; i += SPECIES.length()) { 633 LongVector av = LongVector.fromArray(SPECIES, a, i); 634 av.lanewise(VectorOperators.LSHL, (int)b[i]).intoArray(r, i); 635 } 636 } 637 638 bh.consume(r); 639 } 640 641 @Benchmark 642 public void LSHLMaskedShift(Blackhole bh) { 643 long[] a = fa.apply(SPECIES.length()); 644 long[] b = fb.apply(SPECIES.length()); 645 long[] r = fr.apply(SPECIES.length()); 646 boolean[] mask = fm.apply(SPECIES.length()); 647 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 648 649 for (int ic = 0; ic < INVOC_COUNT; ic++) { 650 for (int i = 0; i < a.length; i += SPECIES.length()) { 651 LongVector av = LongVector.fromArray(SPECIES, a, i); 652 av.lanewise(VectorOperators.LSHL, (int)b[i], vmask).intoArray(r, i); 653 } 654 } 655 656 bh.consume(r); 657 } 658 659 @Benchmark 660 public void LSHRShift(Blackhole bh) { 661 long[] a = fa.apply(SPECIES.length()); 662 long[] b = fb.apply(SPECIES.length()); 663 long[] r = fr.apply(SPECIES.length()); 664 665 for (int ic = 0; ic < INVOC_COUNT; ic++) { 666 for (int i = 0; i < a.length; i += SPECIES.length()) { 667 LongVector av = LongVector.fromArray(SPECIES, a, i); 668 av.lanewise(VectorOperators.LSHR, (int)b[i]).intoArray(r, i); 669 } 670 } 671 672 bh.consume(r); 673 } 674 675 @Benchmark 676 public void LSHRMaskedShift(Blackhole bh) { 677 long[] a = fa.apply(SPECIES.length()); 678 long[] b = fb.apply(SPECIES.length()); 679 long[] r = fr.apply(SPECIES.length()); 680 boolean[] mask = fm.apply(SPECIES.length()); 681 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 682 683 for (int ic = 0; ic < INVOC_COUNT; ic++) { 684 for (int i = 0; i < a.length; i += SPECIES.length()) { 685 LongVector av = LongVector.fromArray(SPECIES, a, i); 686 av.lanewise(VectorOperators.LSHR, (int)b[i], vmask).intoArray(r, i); 687 } 688 } 689 690 bh.consume(r); 691 } 692 693 @Benchmark 694 public void ASHRShift(Blackhole bh) { 695 long[] a = fa.apply(SPECIES.length()); 696 long[] b = fb.apply(SPECIES.length()); 697 long[] r = fr.apply(SPECIES.length()); 698 699 for (int ic = 0; ic < INVOC_COUNT; ic++) { 700 for (int i = 0; i < a.length; i += SPECIES.length()) { 701 LongVector av = LongVector.fromArray(SPECIES, a, i); 702 av.lanewise(VectorOperators.ASHR, (int)b[i]).intoArray(r, i); 703 } 704 } 705 706 bh.consume(r); 707 } 708 709 @Benchmark 710 public void ASHRMaskedShift(Blackhole bh) { 711 long[] a = fa.apply(SPECIES.length()); 712 long[] b = fb.apply(SPECIES.length()); 713 long[] r = fr.apply(SPECIES.length()); 714 boolean[] mask = fm.apply(SPECIES.length()); 715 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 716 717 for (int ic = 0; ic < INVOC_COUNT; ic++) { 718 for (int i = 0; i < a.length; i += SPECIES.length()) { 719 LongVector av = LongVector.fromArray(SPECIES, a, i); 720 av.lanewise(VectorOperators.ASHR, (int)b[i], vmask).intoArray(r, i); 721 } 722 } 723 724 bh.consume(r); 725 } 726 727 @Benchmark 728 public void ROR(Blackhole bh) { 729 long[] a = fa.apply(SPECIES.length()); 730 long[] b = fb.apply(SPECIES.length()); 731 long[] r = fr.apply(SPECIES.length()); 732 733 for (int ic = 0; ic < INVOC_COUNT; ic++) { 734 for (int i = 0; i < a.length; i += SPECIES.length()) { 735 LongVector av = LongVector.fromArray(SPECIES, a, i); 736 LongVector bv = LongVector.fromArray(SPECIES, b, i); 737 av.lanewise(VectorOperators.ROR, bv).intoArray(r, i); 738 } 739 } 740 741 bh.consume(r); 742 } 743 744 @Benchmark 745 public void RORMasked(Blackhole bh) { 746 long[] a = fa.apply(SPECIES.length()); 747 long[] b = fb.apply(SPECIES.length()); 748 long[] r = fr.apply(SPECIES.length()); 749 boolean[] mask = fm.apply(SPECIES.length()); 750 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 751 752 for (int ic = 0; ic < INVOC_COUNT; ic++) { 753 for (int i = 0; i < a.length; i += SPECIES.length()) { 754 LongVector av = LongVector.fromArray(SPECIES, a, i); 755 LongVector bv = LongVector.fromArray(SPECIES, b, i); 756 av.lanewise(VectorOperators.ROR, bv, vmask).intoArray(r, i); 757 } 758 } 759 760 bh.consume(r); 761 } 762 763 @Benchmark 764 public void ROL(Blackhole bh) { 765 long[] a = fa.apply(SPECIES.length()); 766 long[] b = fb.apply(SPECIES.length()); 767 long[] r = fr.apply(SPECIES.length()); 768 769 for (int ic = 0; ic < INVOC_COUNT; ic++) { 770 for (int i = 0; i < a.length; i += SPECIES.length()) { 771 LongVector av = LongVector.fromArray(SPECIES, a, i); 772 LongVector bv = LongVector.fromArray(SPECIES, b, i); 773 av.lanewise(VectorOperators.ROL, bv).intoArray(r, i); 774 } 775 } 776 777 bh.consume(r); 778 } 779 780 @Benchmark 781 public void ROLMasked(Blackhole bh) { 782 long[] a = fa.apply(SPECIES.length()); 783 long[] b = fb.apply(SPECIES.length()); 784 long[] r = fr.apply(SPECIES.length()); 785 boolean[] mask = fm.apply(SPECIES.length()); 786 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 787 788 for (int ic = 0; ic < INVOC_COUNT; ic++) { 789 for (int i = 0; i < a.length; i += SPECIES.length()) { 790 LongVector av = LongVector.fromArray(SPECIES, a, i); 791 LongVector bv = LongVector.fromArray(SPECIES, b, i); 792 av.lanewise(VectorOperators.ROL, bv, vmask).intoArray(r, i); 793 } 794 } 795 796 bh.consume(r); 797 } 798 799 @Benchmark 800 public void RORShift(Blackhole bh) { 801 long[] a = fa.apply(SPECIES.length()); 802 long[] b = fb.apply(SPECIES.length()); 803 long[] r = fr.apply(SPECIES.length()); 804 805 for (int ic = 0; ic < INVOC_COUNT; ic++) { 806 for (int i = 0; i < a.length; i += SPECIES.length()) { 807 LongVector av = LongVector.fromArray(SPECIES, a, i); 808 av.lanewise(VectorOperators.ROR, (int)b[i]).intoArray(r, i); 809 } 810 } 811 812 bh.consume(r); 813 } 814 815 @Benchmark 816 public void RORMaskedShift(Blackhole bh) { 817 long[] a = fa.apply(SPECIES.length()); 818 long[] b = fb.apply(SPECIES.length()); 819 long[] r = fr.apply(SPECIES.length()); 820 boolean[] mask = fm.apply(SPECIES.length()); 821 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 822 823 for (int ic = 0; ic < INVOC_COUNT; ic++) { 824 for (int i = 0; i < a.length; i += SPECIES.length()) { 825 LongVector av = LongVector.fromArray(SPECIES, a, i); 826 av.lanewise(VectorOperators.ROR, (int)b[i], vmask).intoArray(r, i); 827 } 828 } 829 830 bh.consume(r); 831 } 832 833 @Benchmark 834 public void ROLShift(Blackhole bh) { 835 long[] a = fa.apply(SPECIES.length()); 836 long[] b = fb.apply(SPECIES.length()); 837 long[] r = fr.apply(SPECIES.length()); 838 839 for (int ic = 0; ic < INVOC_COUNT; ic++) { 840 for (int i = 0; i < a.length; i += SPECIES.length()) { 841 LongVector av = LongVector.fromArray(SPECIES, a, i); 842 av.lanewise(VectorOperators.ROL, (int)b[i]).intoArray(r, i); 843 } 844 } 845 846 bh.consume(r); 847 } 848 849 @Benchmark 850 public void ROLMaskedShift(Blackhole bh) { 851 long[] a = fa.apply(SPECIES.length()); 852 long[] b = fb.apply(SPECIES.length()); 853 long[] r = fr.apply(SPECIES.length()); 854 boolean[] mask = fm.apply(SPECIES.length()); 855 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 856 857 for (int ic = 0; ic < INVOC_COUNT; ic++) { 858 for (int i = 0; i < a.length; i += SPECIES.length()) { 859 LongVector av = LongVector.fromArray(SPECIES, a, i); 860 av.lanewise(VectorOperators.ROL, (int)b[i], vmask).intoArray(r, i); 861 } 862 } 863 864 bh.consume(r); 865 } 866 867 @Benchmark 868 public void LSHRShiftConst(Blackhole bh) { 869 long[] a = fa.apply(SPECIES.length()); 870 long[] r = fr.apply(SPECIES.length()); 871 872 for (int ic = 0; ic < INVOC_COUNT; ic++) { 873 for (int i = 0; i < a.length; i += SPECIES.length()) { 874 LongVector av = LongVector.fromArray(SPECIES, a, i); 875 av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i); 876 } 877 } 878 879 bh.consume(r); 880 } 881 882 @Benchmark 883 public void LSHRMaskedShiftConst(Blackhole bh) { 884 long[] a = fa.apply(SPECIES.length()); 885 long[] r = fr.apply(SPECIES.length()); 886 boolean[] mask = fm.apply(SPECIES.length()); 887 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 888 889 for (int ic = 0; ic < INVOC_COUNT; ic++) { 890 for (int i = 0; i < a.length; i += SPECIES.length()) { 891 LongVector av = LongVector.fromArray(SPECIES, a, i); 892 av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i); 893 } 894 } 895 896 bh.consume(r); 897 } 898 899 @Benchmark 900 public void LSHLShiftConst(Blackhole bh) { 901 long[] a = fa.apply(SPECIES.length()); 902 long[] r = fr.apply(SPECIES.length()); 903 904 for (int ic = 0; ic < INVOC_COUNT; ic++) { 905 for (int i = 0; i < a.length; i += SPECIES.length()) { 906 LongVector av = LongVector.fromArray(SPECIES, a, i); 907 av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i); 908 } 909 } 910 911 bh.consume(r); 912 } 913 914 @Benchmark 915 public void LSHLMaskedShiftConst(Blackhole bh) { 916 long[] a = fa.apply(SPECIES.length()); 917 long[] r = fr.apply(SPECIES.length()); 918 boolean[] mask = fm.apply(SPECIES.length()); 919 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 920 921 for (int ic = 0; ic < INVOC_COUNT; ic++) { 922 for (int i = 0; i < a.length; i += SPECIES.length()) { 923 LongVector av = LongVector.fromArray(SPECIES, a, i); 924 av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i); 925 } 926 } 927 928 bh.consume(r); 929 } 930 931 @Benchmark 932 public void ASHRShiftConst(Blackhole bh) { 933 long[] a = fa.apply(SPECIES.length()); 934 long[] r = fr.apply(SPECIES.length()); 935 936 for (int ic = 0; ic < INVOC_COUNT; ic++) { 937 for (int i = 0; i < a.length; i += SPECIES.length()) { 938 LongVector av = LongVector.fromArray(SPECIES, a, i); 939 av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i); 940 } 941 } 942 943 bh.consume(r); 944 } 945 946 @Benchmark 947 public void ASHRMaskedShiftConst(Blackhole bh) { 948 long[] a = fa.apply(SPECIES.length()); 949 long[] r = fr.apply(SPECIES.length()); 950 boolean[] mask = fm.apply(SPECIES.length()); 951 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 952 953 for (int ic = 0; ic < INVOC_COUNT; ic++) { 954 for (int i = 0; i < a.length; i += SPECIES.length()) { 955 LongVector av = LongVector.fromArray(SPECIES, a, i); 956 av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i); 957 } 958 } 959 960 bh.consume(r); 961 } 962 963 @Benchmark 964 public void RORShiftConst(Blackhole bh) { 965 long[] a = fa.apply(SPECIES.length()); 966 long[] r = fr.apply(SPECIES.length()); 967 968 for (int ic = 0; ic < INVOC_COUNT; ic++) { 969 for (int i = 0; i < a.length; i += SPECIES.length()) { 970 LongVector av = LongVector.fromArray(SPECIES, a, i); 971 av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i); 972 } 973 } 974 975 bh.consume(r); 976 } 977 978 @Benchmark 979 public void RORMaskedShiftConst(Blackhole bh) { 980 long[] a = fa.apply(SPECIES.length()); 981 long[] r = fr.apply(SPECIES.length()); 982 boolean[] mask = fm.apply(SPECIES.length()); 983 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 984 985 for (int ic = 0; ic < INVOC_COUNT; ic++) { 986 for (int i = 0; i < a.length; i += SPECIES.length()) { 987 LongVector av = LongVector.fromArray(SPECIES, a, i); 988 av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i); 989 } 990 } 991 992 bh.consume(r); 993 } 994 995 @Benchmark 996 public void ROLShiftConst(Blackhole bh) { 997 long[] a = fa.apply(SPECIES.length()); 998 long[] r = fr.apply(SPECIES.length()); 999 1000 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1001 for (int i = 0; i < a.length; i += SPECIES.length()) { 1002 LongVector av = LongVector.fromArray(SPECIES, a, i); 1003 av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i); 1004 } 1005 } 1006 1007 bh.consume(r); 1008 } 1009 1010 @Benchmark 1011 public void ROLMaskedShiftConst(Blackhole bh) { 1012 long[] a = fa.apply(SPECIES.length()); 1013 long[] r = fr.apply(SPECIES.length()); 1014 boolean[] mask = fm.apply(SPECIES.length()); 1015 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1016 1017 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1018 for (int i = 0; i < a.length; i += SPECIES.length()) { 1019 LongVector av = LongVector.fromArray(SPECIES, a, i); 1020 av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i); 1021 } 1022 } 1023 1024 bh.consume(r); 1025 } 1026 1027 @Benchmark 1028 public void MIN(Blackhole bh) { 1029 long[] a = fa.apply(SPECIES.length()); 1030 long[] b = fb.apply(SPECIES.length()); 1031 long[] r = fr.apply(SPECIES.length()); 1032 1033 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1034 for (int i = 0; i < a.length; i += SPECIES.length()) { 1035 LongVector av = LongVector.fromArray(SPECIES, a, i); 1036 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1037 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i); 1038 } 1039 } 1040 1041 bh.consume(r); 1042 } 1043 1044 @Benchmark 1045 public void MAX(Blackhole bh) { 1046 long[] a = fa.apply(SPECIES.length()); 1047 long[] b = fb.apply(SPECIES.length()); 1048 long[] r = fr.apply(SPECIES.length()); 1049 1050 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1051 for (int i = 0; i < a.length; i += SPECIES.length()) { 1052 LongVector av = LongVector.fromArray(SPECIES, a, i); 1053 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1054 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i); 1055 } 1056 } 1057 1058 bh.consume(r); 1059 } 1060 1061 @Benchmark 1062 public void ANDLanes(Blackhole bh) { 1063 long[] a = fa.apply(SPECIES.length()); 1064 long ra = -1; 1065 1066 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1067 ra = -1; 1068 for (int i = 0; i < a.length; i += SPECIES.length()) { 1069 LongVector av = LongVector.fromArray(SPECIES, a, i); 1070 ra &= av.reduceLanes(VectorOperators.AND); 1071 } 1072 } 1073 bh.consume(ra); 1074 } 1075 1076 @Benchmark 1077 public void ANDMaskedLanes(Blackhole bh) { 1078 long[] a = fa.apply(SPECIES.length()); 1079 boolean[] mask = fm.apply(SPECIES.length()); 1080 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1081 long ra = -1; 1082 1083 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1084 ra = -1; 1085 for (int i = 0; i < a.length; i += SPECIES.length()) { 1086 LongVector av = LongVector.fromArray(SPECIES, a, i); 1087 ra &= av.reduceLanes(VectorOperators.AND, vmask); 1088 } 1089 } 1090 bh.consume(ra); 1091 } 1092 1093 @Benchmark 1094 public void ORLanes(Blackhole bh) { 1095 long[] a = fa.apply(SPECIES.length()); 1096 long ra = 0; 1097 1098 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1099 ra = 0; 1100 for (int i = 0; i < a.length; i += SPECIES.length()) { 1101 LongVector av = LongVector.fromArray(SPECIES, a, i); 1102 ra |= av.reduceLanes(VectorOperators.OR); 1103 } 1104 } 1105 bh.consume(ra); 1106 } 1107 1108 @Benchmark 1109 public void ORMaskedLanes(Blackhole bh) { 1110 long[] a = fa.apply(SPECIES.length()); 1111 boolean[] mask = fm.apply(SPECIES.length()); 1112 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1113 long ra = 0; 1114 1115 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1116 ra = 0; 1117 for (int i = 0; i < a.length; i += SPECIES.length()) { 1118 LongVector av = LongVector.fromArray(SPECIES, a, i); 1119 ra |= av.reduceLanes(VectorOperators.OR, vmask); 1120 } 1121 } 1122 bh.consume(ra); 1123 } 1124 1125 @Benchmark 1126 public void XORLanes(Blackhole bh) { 1127 long[] a = fa.apply(SPECIES.length()); 1128 long ra = 0; 1129 1130 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1131 ra = 0; 1132 for (int i = 0; i < a.length; i += SPECIES.length()) { 1133 LongVector av = LongVector.fromArray(SPECIES, a, i); 1134 ra ^= av.reduceLanes(VectorOperators.XOR); 1135 } 1136 } 1137 bh.consume(ra); 1138 } 1139 1140 @Benchmark 1141 public void XORMaskedLanes(Blackhole bh) { 1142 long[] a = fa.apply(SPECIES.length()); 1143 boolean[] mask = fm.apply(SPECIES.length()); 1144 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1145 long ra = 0; 1146 1147 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1148 ra = 0; 1149 for (int i = 0; i < a.length; i += SPECIES.length()) { 1150 LongVector av = LongVector.fromArray(SPECIES, a, i); 1151 ra ^= av.reduceLanes(VectorOperators.XOR, vmask); 1152 } 1153 } 1154 bh.consume(ra); 1155 } 1156 1157 @Benchmark 1158 public void ADDLanes(Blackhole bh) { 1159 long[] a = fa.apply(SPECIES.length()); 1160 long ra = 0; 1161 1162 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1163 ra = 0; 1164 for (int i = 0; i < a.length; i += SPECIES.length()) { 1165 LongVector av = LongVector.fromArray(SPECIES, a, i); 1166 ra += av.reduceLanes(VectorOperators.ADD); 1167 } 1168 } 1169 bh.consume(ra); 1170 } 1171 1172 @Benchmark 1173 public void ADDMaskedLanes(Blackhole bh) { 1174 long[] a = fa.apply(SPECIES.length()); 1175 boolean[] mask = fm.apply(SPECIES.length()); 1176 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1177 long ra = 0; 1178 1179 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1180 ra = 0; 1181 for (int i = 0; i < a.length; i += SPECIES.length()) { 1182 LongVector av = LongVector.fromArray(SPECIES, a, i); 1183 ra += av.reduceLanes(VectorOperators.ADD, vmask); 1184 } 1185 } 1186 bh.consume(ra); 1187 } 1188 1189 @Benchmark 1190 public void MULLanes(Blackhole bh) { 1191 long[] a = fa.apply(SPECIES.length()); 1192 long ra = 1; 1193 1194 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1195 ra = 1; 1196 for (int i = 0; i < a.length; i += SPECIES.length()) { 1197 LongVector av = LongVector.fromArray(SPECIES, a, i); 1198 ra *= av.reduceLanes(VectorOperators.MUL); 1199 } 1200 } 1201 bh.consume(ra); 1202 } 1203 1204 @Benchmark 1205 public void MULMaskedLanes(Blackhole bh) { 1206 long[] a = fa.apply(SPECIES.length()); 1207 boolean[] mask = fm.apply(SPECIES.length()); 1208 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1209 long ra = 1; 1210 1211 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1212 ra = 1; 1213 for (int i = 0; i < a.length; i += SPECIES.length()) { 1214 LongVector av = LongVector.fromArray(SPECIES, a, i); 1215 ra *= av.reduceLanes(VectorOperators.MUL, vmask); 1216 } 1217 } 1218 bh.consume(ra); 1219 } 1220 1221 @Benchmark 1222 public void MINLanes(Blackhole bh) { 1223 long[] a = fa.apply(SPECIES.length()); 1224 long ra = Long.MAX_VALUE; 1225 1226 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1227 ra = Long.MAX_VALUE; 1228 for (int i = 0; i < a.length; i += SPECIES.length()) { 1229 LongVector av = LongVector.fromArray(SPECIES, a, i); 1230 ra = (long) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); 1231 } 1232 } 1233 bh.consume(ra); 1234 } 1235 1236 @Benchmark 1237 public void MINMaskedLanes(Blackhole bh) { 1238 long[] a = fa.apply(SPECIES.length()); 1239 boolean[] mask = fm.apply(SPECIES.length()); 1240 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1241 long ra = Long.MAX_VALUE; 1242 1243 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1244 ra = Long.MAX_VALUE; 1245 for (int i = 0; i < a.length; i += SPECIES.length()) { 1246 LongVector av = LongVector.fromArray(SPECIES, a, i); 1247 ra = (long) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); 1248 } 1249 } 1250 bh.consume(ra); 1251 } 1252 1253 @Benchmark 1254 public void MAXLanes(Blackhole bh) { 1255 long[] a = fa.apply(SPECIES.length()); 1256 long ra = Long.MIN_VALUE; 1257 1258 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1259 ra = Long.MIN_VALUE; 1260 for (int i = 0; i < a.length; i += SPECIES.length()) { 1261 LongVector av = LongVector.fromArray(SPECIES, a, i); 1262 ra = (long) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); 1263 } 1264 } 1265 bh.consume(ra); 1266 } 1267 1268 @Benchmark 1269 public void MAXMaskedLanes(Blackhole bh) { 1270 long[] a = fa.apply(SPECIES.length()); 1271 boolean[] mask = fm.apply(SPECIES.length()); 1272 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1273 long ra = Long.MIN_VALUE; 1274 1275 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1276 ra = Long.MIN_VALUE; 1277 for (int i = 0; i < a.length; i += SPECIES.length()) { 1278 LongVector av = LongVector.fromArray(SPECIES, a, i); 1279 ra = (long) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); 1280 } 1281 } 1282 bh.consume(ra); 1283 } 1284 1285 @Benchmark 1286 public void FIRST_NONZEROLanes(Blackhole bh) { 1287 long[] a = fa.apply(SPECIES.length()); 1288 long ra = (long) 0; 1289 1290 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1291 ra = (long) 0; 1292 for (int i = 0; i < a.length; i += SPECIES.length()) { 1293 LongVector av = LongVector.fromArray(SPECIES, a, i); 1294 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); 1295 } 1296 } 1297 bh.consume(ra); 1298 } 1299 1300 @Benchmark 1301 public void FIRST_NONZEROMaskedLanes(Blackhole bh) { 1302 long[] a = fa.apply(SPECIES.length()); 1303 boolean[] mask = fm.apply(SPECIES.length()); 1304 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1305 long ra = (long) 0; 1306 1307 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1308 ra = (long) 0; 1309 for (int i = 0; i < a.length; i += SPECIES.length()) { 1310 LongVector av = LongVector.fromArray(SPECIES, a, i); 1311 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); 1312 } 1313 } 1314 bh.consume(ra); 1315 } 1316 1317 @Benchmark 1318 public void anyTrue(Blackhole bh) { 1319 boolean[] mask = fm.apply(SPECIES.length()); 1320 boolean[] r = fmr.apply(SPECIES.length()); 1321 1322 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1323 for (int i = 0; i < mask.length; i += SPECIES.length()) { 1324 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, i); 1325 r[i] = vmask.anyTrue(); 1326 } 1327 } 1328 1329 bh.consume(r); 1330 } 1331 1332 @Benchmark 1333 public void allTrue(Blackhole bh) { 1334 boolean[] mask = fm.apply(SPECIES.length()); 1335 boolean[] r = fmr.apply(SPECIES.length()); 1336 1337 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1338 for (int i = 0; i < mask.length; i += SPECIES.length()) { 1339 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, i); 1340 r[i] = vmask.allTrue(); 1341 } 1342 } 1343 1344 bh.consume(r); 1345 } 1346 1347 @Benchmark 1348 public void withLane(Blackhole bh) { 1349 long[] a = fa.apply(SPECIES.length()); 1350 long[] r = fr.apply(SPECIES.length()); 1351 1352 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1353 for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { 1354 LongVector av = LongVector.fromArray(SPECIES, a, i); 1355 av.withLane((j++ & (SPECIES.length()-1)), (long)(65535+i)).intoArray(r, i); 1356 } 1357 } 1358 1359 bh.consume(r); 1360 } 1361 1362 @Benchmark 1363 public Object IS_DEFAULT() { 1364 long[] a = fa.apply(size); 1365 boolean[] ms = fmt.apply(size); 1366 VectorMask<Long> m = VectorMask.fromArray(SPECIES, ms, 0); 1367 1368 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1369 for (int i = 0; i < a.length; i += SPECIES.length()) { 1370 LongVector av = LongVector.fromArray(SPECIES, a, i); 1371 1372 // accumulate results, so JIT can't eliminate relevant computations 1373 m = m.and(av.test(VectorOperators.IS_DEFAULT)); 1374 } 1375 } 1376 1377 return m; 1378 } 1379 1380 @Benchmark 1381 public Object IS_NEGATIVE() { 1382 long[] a = fa.apply(size); 1383 boolean[] ms = fmt.apply(size); 1384 VectorMask<Long> m = VectorMask.fromArray(SPECIES, ms, 0); 1385 1386 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1387 for (int i = 0; i < a.length; i += SPECIES.length()) { 1388 LongVector av = LongVector.fromArray(SPECIES, a, i); 1389 1390 // accumulate results, so JIT can't eliminate relevant computations 1391 m = m.and(av.test(VectorOperators.IS_NEGATIVE)); 1392 } 1393 } 1394 1395 return m; 1396 } 1397 @Benchmark 1398 public Object LT() { 1399 long[] a = fa.apply(size); 1400 long[] b = fb.apply(size); 1401 boolean[] ms = fmt.apply(size); 1402 VectorMask<Long> m = VectorMask.fromArray(SPECIES, ms, 0); 1403 1404 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1405 for (int i = 0; i < a.length; i += SPECIES.length()) { 1406 LongVector av = LongVector.fromArray(SPECIES, a, i); 1407 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1408 1409 // accumulate results, so JIT can't eliminate relevant computations 1410 m = m.and(av.compare(VectorOperators.LT, bv)); 1411 } 1412 } 1413 1414 return m; 1415 } 1416 @Benchmark 1417 public Object GT() { 1418 long[] a = fa.apply(size); 1419 long[] b = fb.apply(size); 1420 boolean[] ms = fmt.apply(size); 1421 VectorMask<Long> m = VectorMask.fromArray(SPECIES, ms, 0); 1422 1423 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1424 for (int i = 0; i < a.length; i += SPECIES.length()) { 1425 LongVector av = LongVector.fromArray(SPECIES, a, i); 1426 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1427 1428 // accumulate results, so JIT can't eliminate relevant computations 1429 m = m.and(av.compare(VectorOperators.GT, bv)); 1430 } 1431 } 1432 1433 return m; 1434 } 1435 @Benchmark 1436 public Object EQ() { 1437 long[] a = fa.apply(size); 1438 long[] b = fb.apply(size); 1439 boolean[] ms = fmt.apply(size); 1440 VectorMask<Long> m = VectorMask.fromArray(SPECIES, ms, 0); 1441 1442 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1443 for (int i = 0; i < a.length; i += SPECIES.length()) { 1444 LongVector av = LongVector.fromArray(SPECIES, a, i); 1445 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1446 1447 // accumulate results, so JIT can't eliminate relevant computations 1448 m = m.and(av.compare(VectorOperators.EQ, bv)); 1449 } 1450 } 1451 1452 return m; 1453 } 1454 @Benchmark 1455 public Object NE() { 1456 long[] a = fa.apply(size); 1457 long[] b = fb.apply(size); 1458 boolean[] ms = fmt.apply(size); 1459 VectorMask<Long> m = VectorMask.fromArray(SPECIES, ms, 0); 1460 1461 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1462 for (int i = 0; i < a.length; i += SPECIES.length()) { 1463 LongVector av = LongVector.fromArray(SPECIES, a, i); 1464 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1465 1466 // accumulate results, so JIT can't eliminate relevant computations 1467 m = m.and(av.compare(VectorOperators.NE, bv)); 1468 } 1469 } 1470 1471 return m; 1472 } 1473 @Benchmark 1474 public Object LE() { 1475 long[] a = fa.apply(size); 1476 long[] b = fb.apply(size); 1477 boolean[] ms = fmt.apply(size); 1478 VectorMask<Long> m = VectorMask.fromArray(SPECIES, ms, 0); 1479 1480 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1481 for (int i = 0; i < a.length; i += SPECIES.length()) { 1482 LongVector av = LongVector.fromArray(SPECIES, a, i); 1483 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1484 1485 // accumulate results, so JIT can't eliminate relevant computations 1486 m = m.and(av.compare(VectorOperators.LE, bv)); 1487 } 1488 } 1489 1490 return m; 1491 } 1492 @Benchmark 1493 public Object GE() { 1494 long[] a = fa.apply(size); 1495 long[] b = fb.apply(size); 1496 boolean[] ms = fmt.apply(size); 1497 VectorMask<Long> m = VectorMask.fromArray(SPECIES, ms, 0); 1498 1499 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1500 for (int i = 0; i < a.length; i += SPECIES.length()) { 1501 LongVector av = LongVector.fromArray(SPECIES, a, i); 1502 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1503 1504 // accumulate results, so JIT can't eliminate relevant computations 1505 m = m.and(av.compare(VectorOperators.GE, bv)); 1506 } 1507 } 1508 1509 return m; 1510 } 1511 @Benchmark 1512 public Object UNSIGNED_LT() { 1513 long[] a = fa.apply(size); 1514 long[] b = fb.apply(size); 1515 boolean[] ms = fmt.apply(size); 1516 VectorMask<Long> m = VectorMask.fromArray(SPECIES, ms, 0); 1517 1518 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1519 for (int i = 0; i < a.length; i += SPECIES.length()) { 1520 LongVector av = LongVector.fromArray(SPECIES, a, i); 1521 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1522 1523 // accumulate results, so JIT can't eliminate relevant computations 1524 m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); 1525 } 1526 } 1527 1528 return m; 1529 } 1530 @Benchmark 1531 public Object UNSIGNED_GT() { 1532 long[] a = fa.apply(size); 1533 long[] b = fb.apply(size); 1534 boolean[] ms = fmt.apply(size); 1535 VectorMask<Long> m = VectorMask.fromArray(SPECIES, ms, 0); 1536 1537 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1538 for (int i = 0; i < a.length; i += SPECIES.length()) { 1539 LongVector av = LongVector.fromArray(SPECIES, a, i); 1540 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1541 1542 // accumulate results, so JIT can't eliminate relevant computations 1543 m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); 1544 } 1545 } 1546 1547 return m; 1548 } 1549 @Benchmark 1550 public Object UNSIGNED_LE() { 1551 long[] a = fa.apply(size); 1552 long[] b = fb.apply(size); 1553 boolean[] ms = fmt.apply(size); 1554 VectorMask<Long> m = VectorMask.fromArray(SPECIES, ms, 0); 1555 1556 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1557 for (int i = 0; i < a.length; i += SPECIES.length()) { 1558 LongVector av = LongVector.fromArray(SPECIES, a, i); 1559 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1560 1561 // accumulate results, so JIT can't eliminate relevant computations 1562 m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); 1563 } 1564 } 1565 1566 return m; 1567 } 1568 @Benchmark 1569 public Object UNSIGNED_GE() { 1570 long[] a = fa.apply(size); 1571 long[] b = fb.apply(size); 1572 boolean[] ms = fmt.apply(size); 1573 VectorMask<Long> m = VectorMask.fromArray(SPECIES, ms, 0); 1574 1575 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1576 for (int i = 0; i < a.length; i += SPECIES.length()) { 1577 LongVector av = LongVector.fromArray(SPECIES, a, i); 1578 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1579 1580 // accumulate results, so JIT can't eliminate relevant computations 1581 m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); 1582 } 1583 } 1584 1585 return m; 1586 } 1587 1588 @Benchmark 1589 public void blend(Blackhole bh) { 1590 long[] a = fa.apply(SPECIES.length()); 1591 long[] b = fb.apply(SPECIES.length()); 1592 long[] r = fr.apply(SPECIES.length()); 1593 boolean[] mask = fm.apply(SPECIES.length()); 1594 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1595 1596 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1597 for (int i = 0; i < a.length; i += SPECIES.length()) { 1598 LongVector av = LongVector.fromArray(SPECIES, a, i); 1599 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1600 av.blend(bv, vmask).intoArray(r, i); 1601 } 1602 } 1603 1604 bh.consume(r); 1605 } 1606 1607 @Benchmark 1608 public void rearrange(Blackhole bh) { 1609 long[] a = fa.apply(SPECIES.length()); 1610 int[] order = fs.apply(a.length, SPECIES.length()); 1611 long[] r = fr.apply(SPECIES.length()); 1612 1613 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1614 for (int i = 0; i < a.length; i += SPECIES.length()) { 1615 LongVector av = LongVector.fromArray(SPECIES, a, i); 1616 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i); 1617 } 1618 } 1619 1620 bh.consume(r); 1621 } 1622 @Benchmark 1623 public Object compress() { 1624 long[] a = fa.apply(size); 1625 long[] r = fb.apply(size); 1626 boolean[] ms = fmt.apply(size); 1627 VectorMask<Long> m = VectorMask.fromArray(SPECIES, ms, 0); 1628 1629 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1630 for (int i = 0; i < a.length; i += SPECIES.length()) { 1631 LongVector av = LongVector.fromArray(SPECIES, a, i); 1632 av.compress(m).intoArray(r, i); 1633 } 1634 } 1635 1636 return r; 1637 } 1638 1639 @Benchmark 1640 public Object expand() { 1641 long[] a = fa.apply(size); 1642 long[] r = fb.apply(size); 1643 boolean[] ms = fmt.apply(size); 1644 VectorMask<Long> m = VectorMask.fromArray(SPECIES, ms, 0); 1645 1646 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1647 for (int i = 0; i < a.length; i += SPECIES.length()) { 1648 LongVector av = LongVector.fromArray(SPECIES, a, i); 1649 av.expand(m).intoArray(r, i); 1650 } 1651 } 1652 1653 return r; 1654 } 1655 1656 @Benchmark 1657 public Object maskCompress() { 1658 boolean[] ms = fmt.apply(size); 1659 boolean[] rs = fmt.apply(size); 1660 1661 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1662 for (int i = 0, j = 0; i < ms.length; i += SPECIES.length()) { 1663 VectorMask<Long> m = VectorMask.fromArray(SPECIES, ms, i); 1664 m.compress().intoArray(rs, j); 1665 j += m.trueCount(); 1666 } 1667 } 1668 1669 return rs; 1670 } 1671 1672 @Benchmark 1673 public void laneextract(Blackhole bh) { 1674 long[] a = fa.apply(SPECIES.length()); 1675 long[] r = fr.apply(SPECIES.length()); 1676 1677 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1678 for (int i = 0; i < a.length; i += SPECIES.length()) { 1679 LongVector av = LongVector.fromArray(SPECIES, a, i); 1680 int num_lanes = SPECIES.length(); 1681 // Manually unroll because full unroll happens after intrinsification. 1682 // Unroll is needed because get intrinsic requires for index to be a known constant. 1683 if (num_lanes == 1) { 1684 r[i]=av.lane(0); 1685 } else if (num_lanes == 2) { 1686 r[i]=av.lane(0); 1687 r[i+1]=av.lane(1); 1688 } else if (num_lanes == 4) { 1689 r[i]=av.lane(0); 1690 r[i+1]=av.lane(1); 1691 r[i+2]=av.lane(2); 1692 r[i+3]=av.lane(3); 1693 } else if (num_lanes == 8) { 1694 r[i]=av.lane(0); 1695 r[i+1]=av.lane(1); 1696 r[i+2]=av.lane(2); 1697 r[i+3]=av.lane(3); 1698 r[i+4]=av.lane(4); 1699 r[i+5]=av.lane(5); 1700 r[i+6]=av.lane(6); 1701 r[i+7]=av.lane(7); 1702 } else if (num_lanes == 16) { 1703 r[i]=av.lane(0); 1704 r[i+1]=av.lane(1); 1705 r[i+2]=av.lane(2); 1706 r[i+3]=av.lane(3); 1707 r[i+4]=av.lane(4); 1708 r[i+5]=av.lane(5); 1709 r[i+6]=av.lane(6); 1710 r[i+7]=av.lane(7); 1711 r[i+8]=av.lane(8); 1712 r[i+9]=av.lane(9); 1713 r[i+10]=av.lane(10); 1714 r[i+11]=av.lane(11); 1715 r[i+12]=av.lane(12); 1716 r[i+13]=av.lane(13); 1717 r[i+14]=av.lane(14); 1718 r[i+15]=av.lane(15); 1719 } else if (num_lanes == 32) { 1720 r[i]=av.lane(0); 1721 r[i+1]=av.lane(1); 1722 r[i+2]=av.lane(2); 1723 r[i+3]=av.lane(3); 1724 r[i+4]=av.lane(4); 1725 r[i+5]=av.lane(5); 1726 r[i+6]=av.lane(6); 1727 r[i+7]=av.lane(7); 1728 r[i+8]=av.lane(8); 1729 r[i+9]=av.lane(9); 1730 r[i+10]=av.lane(10); 1731 r[i+11]=av.lane(11); 1732 r[i+12]=av.lane(12); 1733 r[i+13]=av.lane(13); 1734 r[i+14]=av.lane(14); 1735 r[i+15]=av.lane(15); 1736 r[i+16]=av.lane(16); 1737 r[i+17]=av.lane(17); 1738 r[i+18]=av.lane(18); 1739 r[i+19]=av.lane(19); 1740 r[i+20]=av.lane(20); 1741 r[i+21]=av.lane(21); 1742 r[i+22]=av.lane(22); 1743 r[i+23]=av.lane(23); 1744 r[i+24]=av.lane(24); 1745 r[i+25]=av.lane(25); 1746 r[i+26]=av.lane(26); 1747 r[i+27]=av.lane(27); 1748 r[i+28]=av.lane(28); 1749 r[i+29]=av.lane(29); 1750 r[i+30]=av.lane(30); 1751 r[i+31]=av.lane(31); 1752 } else if (num_lanes == 64) { 1753 r[i]=av.lane(0); 1754 r[i+1]=av.lane(1); 1755 r[i+2]=av.lane(2); 1756 r[i+3]=av.lane(3); 1757 r[i+4]=av.lane(4); 1758 r[i+5]=av.lane(5); 1759 r[i+6]=av.lane(6); 1760 r[i+7]=av.lane(7); 1761 r[i+8]=av.lane(8); 1762 r[i+9]=av.lane(9); 1763 r[i+10]=av.lane(10); 1764 r[i+11]=av.lane(11); 1765 r[i+12]=av.lane(12); 1766 r[i+13]=av.lane(13); 1767 r[i+14]=av.lane(14); 1768 r[i+15]=av.lane(15); 1769 r[i+16]=av.lane(16); 1770 r[i+17]=av.lane(17); 1771 r[i+18]=av.lane(18); 1772 r[i+19]=av.lane(19); 1773 r[i+20]=av.lane(20); 1774 r[i+21]=av.lane(21); 1775 r[i+22]=av.lane(22); 1776 r[i+23]=av.lane(23); 1777 r[i+24]=av.lane(24); 1778 r[i+25]=av.lane(25); 1779 r[i+26]=av.lane(26); 1780 r[i+27]=av.lane(27); 1781 r[i+28]=av.lane(28); 1782 r[i+29]=av.lane(29); 1783 r[i+30]=av.lane(30); 1784 r[i+31]=av.lane(31); 1785 r[i+32]=av.lane(32); 1786 r[i+33]=av.lane(33); 1787 r[i+34]=av.lane(34); 1788 r[i+35]=av.lane(35); 1789 r[i+36]=av.lane(36); 1790 r[i+37]=av.lane(37); 1791 r[i+38]=av.lane(38); 1792 r[i+39]=av.lane(39); 1793 r[i+40]=av.lane(40); 1794 r[i+41]=av.lane(41); 1795 r[i+42]=av.lane(42); 1796 r[i+43]=av.lane(43); 1797 r[i+44]=av.lane(44); 1798 r[i+45]=av.lane(45); 1799 r[i+46]=av.lane(46); 1800 r[i+47]=av.lane(47); 1801 r[i+48]=av.lane(48); 1802 r[i+49]=av.lane(49); 1803 r[i+50]=av.lane(50); 1804 r[i+51]=av.lane(51); 1805 r[i+52]=av.lane(52); 1806 r[i+53]=av.lane(53); 1807 r[i+54]=av.lane(54); 1808 r[i+55]=av.lane(55); 1809 r[i+56]=av.lane(56); 1810 r[i+57]=av.lane(57); 1811 r[i+58]=av.lane(58); 1812 r[i+59]=av.lane(59); 1813 r[i+60]=av.lane(60); 1814 r[i+61]=av.lane(61); 1815 r[i+62]=av.lane(62); 1816 r[i+63]=av.lane(63); 1817 } else { 1818 for (int j = 0; j < SPECIES.length(); j++) { 1819 r[i+j]=av.lane(j); 1820 } 1821 } 1822 } 1823 } 1824 1825 bh.consume(r); 1826 } 1827 1828 @Benchmark 1829 public void broadcast(Blackhole bh) { 1830 long[] a = fa.apply(SPECIES.length()); 1831 long[] r = new long[a.length]; 1832 1833 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1834 for (int i = 0; i < a.length; i += SPECIES.length()) { 1835 LongVector.broadcast(SPECIES, a[i]).intoArray(r, i); 1836 } 1837 } 1838 1839 bh.consume(r); 1840 } 1841 1842 @Benchmark 1843 public void zero(Blackhole bh) { 1844 long[] a = fa.apply(SPECIES.length()); 1845 long[] r = new long[a.length]; 1846 1847 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1848 for (int i = 0; i < a.length; i += SPECIES.length()) { 1849 LongVector.zero(SPECIES).intoArray(a, i); 1850 } 1851 } 1852 1853 bh.consume(r); 1854 } 1855 1856 @Benchmark 1857 public void sliceUnary(Blackhole bh) { 1858 long[] a = fa.apply(SPECIES.length()); 1859 long[] r = new long[a.length]; 1860 int origin = RAND.nextInt(SPECIES.length()); 1861 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1862 for (int i = 0; i < a.length; i += SPECIES.length()) { 1863 LongVector av = LongVector.fromArray(SPECIES, a, i); 1864 av.slice(origin).intoArray(r, i); 1865 } 1866 } 1867 1868 bh.consume(r); 1869 } 1870 1871 @Benchmark 1872 public void sliceBinary(Blackhole bh) { 1873 long[] a = fa.apply(SPECIES.length()); 1874 long[] b = fb.apply(SPECIES.length()); 1875 long[] r = new long[a.length]; 1876 int origin = RAND.nextInt(SPECIES.length()); 1877 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1878 for (int i = 0; i < a.length; i += SPECIES.length()) { 1879 LongVector av = LongVector.fromArray(SPECIES, a, i); 1880 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1881 av.slice(origin, bv).intoArray(r, i); 1882 } 1883 } 1884 1885 bh.consume(r); 1886 } 1887 1888 @Benchmark 1889 public void sliceMasked(Blackhole bh) { 1890 long[] a = fa.apply(SPECIES.length()); 1891 long[] b = fb.apply(SPECIES.length()); 1892 boolean[] mask = fm.apply(SPECIES.length()); 1893 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1894 1895 long[] r = new long[a.length]; 1896 int origin = RAND.nextInt(SPECIES.length()); 1897 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1898 for (int i = 0; i < a.length; i += SPECIES.length()) { 1899 LongVector av = LongVector.fromArray(SPECIES, a, i); 1900 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1901 av.slice(origin, bv, vmask).intoArray(r, i); 1902 } 1903 } 1904 1905 bh.consume(r); 1906 } 1907 1908 @Benchmark 1909 public void unsliceUnary(Blackhole bh) { 1910 long[] a = fa.apply(SPECIES.length()); 1911 long[] r = new long[a.length]; 1912 int origin = RAND.nextInt(SPECIES.length()); 1913 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1914 for (int i = 0; i < a.length; i += SPECIES.length()) { 1915 LongVector av = LongVector.fromArray(SPECIES, a, i); 1916 av.unslice(origin).intoArray(r, i); 1917 } 1918 } 1919 1920 bh.consume(r); 1921 } 1922 1923 @Benchmark 1924 public void unsliceBinary(Blackhole bh) { 1925 long[] a = fa.apply(SPECIES.length()); 1926 long[] b = fb.apply(SPECIES.length()); 1927 long[] r = new long[a.length]; 1928 int origin = RAND.nextInt(SPECIES.length()); 1929 int part = RAND.nextInt(2); 1930 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1931 for (int i = 0; i < a.length; i += SPECIES.length()) { 1932 LongVector av = LongVector.fromArray(SPECIES, a, i); 1933 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1934 av.unslice(origin, bv, part).intoArray(r, i); 1935 } 1936 } 1937 1938 bh.consume(r); 1939 } 1940 1941 @Benchmark 1942 public void unsliceMasked(Blackhole bh) { 1943 long[] a = fa.apply(SPECIES.length()); 1944 long[] b = fb.apply(SPECIES.length()); 1945 boolean[] mask = fm.apply(SPECIES.length()); 1946 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1947 long[] r = new long[a.length]; 1948 int origin = RAND.nextInt(SPECIES.length()); 1949 int part = RAND.nextInt(2); 1950 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1951 for (int i = 0; i < a.length; i += SPECIES.length()) { 1952 LongVector av = LongVector.fromArray(SPECIES, a, i); 1953 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1954 av.unslice(origin, bv, part, vmask).intoArray(r, i); 1955 } 1956 } 1957 1958 bh.consume(r); 1959 } 1960 1961 @Benchmark 1962 public void BITWISE_BLEND(Blackhole bh) { 1963 long[] a = fa.apply(SPECIES.length()); 1964 long[] b = fb.apply(SPECIES.length()); 1965 long[] c = fc.apply(SPECIES.length()); 1966 long[] r = fr.apply(SPECIES.length()); 1967 1968 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1969 for (int i = 0; i < a.length; i += SPECIES.length()) { 1970 LongVector av = LongVector.fromArray(SPECIES, a, i); 1971 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1972 LongVector cv = LongVector.fromArray(SPECIES, c, i); 1973 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i); 1974 } 1975 } 1976 1977 bh.consume(r); 1978 } 1979 1980 @Benchmark 1981 public void BITWISE_BLENDMasked(Blackhole bh) { 1982 long[] a = fa.apply(SPECIES.length()); 1983 long[] b = fb.apply(SPECIES.length()); 1984 long[] c = fc.apply(SPECIES.length()); 1985 long[] r = fr.apply(SPECIES.length()); 1986 boolean[] mask = fm.apply(SPECIES.length()); 1987 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1988 1989 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1990 for (int i = 0; i < a.length; i += SPECIES.length()) { 1991 LongVector av = LongVector.fromArray(SPECIES, a, i); 1992 LongVector bv = LongVector.fromArray(SPECIES, b, i); 1993 LongVector cv = LongVector.fromArray(SPECIES, c, i); 1994 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i); 1995 } 1996 } 1997 1998 bh.consume(r); 1999 } 2000 2001 @Benchmark 2002 public void NEG(Blackhole bh) { 2003 long[] a = fa.apply(SPECIES.length()); 2004 long[] r = fr.apply(SPECIES.length()); 2005 2006 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2007 for (int i = 0; i < a.length; i += SPECIES.length()) { 2008 LongVector av = LongVector.fromArray(SPECIES, a, i); 2009 av.lanewise(VectorOperators.NEG).intoArray(r, i); 2010 } 2011 } 2012 2013 bh.consume(r); 2014 } 2015 2016 @Benchmark 2017 public void NEGMasked(Blackhole bh) { 2018 long[] a = fa.apply(SPECIES.length()); 2019 long[] r = fr.apply(SPECIES.length()); 2020 boolean[] mask = fm.apply(SPECIES.length()); 2021 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2022 2023 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2024 for (int i = 0; i < a.length; i += SPECIES.length()) { 2025 LongVector av = LongVector.fromArray(SPECIES, a, i); 2026 av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i); 2027 } 2028 } 2029 2030 bh.consume(r); 2031 } 2032 2033 @Benchmark 2034 public void ABS(Blackhole bh) { 2035 long[] a = fa.apply(SPECIES.length()); 2036 long[] r = fr.apply(SPECIES.length()); 2037 2038 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2039 for (int i = 0; i < a.length; i += SPECIES.length()) { 2040 LongVector av = LongVector.fromArray(SPECIES, a, i); 2041 av.lanewise(VectorOperators.ABS).intoArray(r, i); 2042 } 2043 } 2044 2045 bh.consume(r); 2046 } 2047 2048 @Benchmark 2049 public void ABSMasked(Blackhole bh) { 2050 long[] a = fa.apply(SPECIES.length()); 2051 long[] r = fr.apply(SPECIES.length()); 2052 boolean[] mask = fm.apply(SPECIES.length()); 2053 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2054 2055 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2056 for (int i = 0; i < a.length; i += SPECIES.length()) { 2057 LongVector av = LongVector.fromArray(SPECIES, a, i); 2058 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i); 2059 } 2060 } 2061 2062 bh.consume(r); 2063 } 2064 2065 @Benchmark 2066 public void NOT(Blackhole bh) { 2067 long[] a = fa.apply(SPECIES.length()); 2068 long[] r = fr.apply(SPECIES.length()); 2069 2070 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2071 for (int i = 0; i < a.length; i += SPECIES.length()) { 2072 LongVector av = LongVector.fromArray(SPECIES, a, i); 2073 av.lanewise(VectorOperators.NOT).intoArray(r, i); 2074 } 2075 } 2076 2077 bh.consume(r); 2078 } 2079 2080 @Benchmark 2081 public void NOTMasked(Blackhole bh) { 2082 long[] a = fa.apply(SPECIES.length()); 2083 long[] r = fr.apply(SPECIES.length()); 2084 boolean[] mask = fm.apply(SPECIES.length()); 2085 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2086 2087 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2088 for (int i = 0; i < a.length; i += SPECIES.length()) { 2089 LongVector av = LongVector.fromArray(SPECIES, a, i); 2090 av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i); 2091 } 2092 } 2093 2094 bh.consume(r); 2095 } 2096 2097 @Benchmark 2098 public void ZOMO(Blackhole bh) { 2099 long[] a = fa.apply(SPECIES.length()); 2100 long[] r = fr.apply(SPECIES.length()); 2101 2102 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2103 for (int i = 0; i < a.length; i += SPECIES.length()) { 2104 LongVector av = LongVector.fromArray(SPECIES, a, i); 2105 av.lanewise(VectorOperators.ZOMO).intoArray(r, i); 2106 } 2107 } 2108 2109 bh.consume(r); 2110 } 2111 2112 @Benchmark 2113 public void ZOMOMasked(Blackhole bh) { 2114 long[] a = fa.apply(SPECIES.length()); 2115 long[] r = fr.apply(SPECIES.length()); 2116 boolean[] mask = fm.apply(SPECIES.length()); 2117 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2118 2119 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2120 for (int i = 0; i < a.length; i += SPECIES.length()) { 2121 LongVector av = LongVector.fromArray(SPECIES, a, i); 2122 av.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i); 2123 } 2124 } 2125 2126 bh.consume(r); 2127 } 2128 2129 @Benchmark 2130 public void BIT_COUNT(Blackhole bh) { 2131 long[] a = fa.apply(SPECIES.length()); 2132 long[] r = fr.apply(SPECIES.length()); 2133 2134 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2135 for (int i = 0; i < a.length; i += SPECIES.length()) { 2136 LongVector av = LongVector.fromArray(SPECIES, a, i); 2137 av.lanewise(VectorOperators.BIT_COUNT).intoArray(r, i); 2138 } 2139 } 2140 2141 bh.consume(r); 2142 } 2143 2144 @Benchmark 2145 public void BIT_COUNTMasked(Blackhole bh) { 2146 long[] a = fa.apply(SPECIES.length()); 2147 long[] r = fr.apply(SPECIES.length()); 2148 boolean[] mask = fm.apply(SPECIES.length()); 2149 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2150 2151 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2152 for (int i = 0; i < a.length; i += SPECIES.length()) { 2153 LongVector av = LongVector.fromArray(SPECIES, a, i); 2154 av.lanewise(VectorOperators.BIT_COUNT, vmask).intoArray(r, i); 2155 } 2156 } 2157 2158 bh.consume(r); 2159 } 2160 2161 @Benchmark 2162 public void TRAILING_ZEROS_COUNT(Blackhole bh) { 2163 long[] a = fa.apply(SPECIES.length()); 2164 long[] r = fr.apply(SPECIES.length()); 2165 2166 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2167 for (int i = 0; i < a.length; i += SPECIES.length()) { 2168 LongVector av = LongVector.fromArray(SPECIES, a, i); 2169 av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT).intoArray(r, i); 2170 } 2171 } 2172 2173 bh.consume(r); 2174 } 2175 2176 @Benchmark 2177 public void TRAILING_ZEROS_COUNTMasked(Blackhole bh) { 2178 long[] a = fa.apply(SPECIES.length()); 2179 long[] r = fr.apply(SPECIES.length()); 2180 boolean[] mask = fm.apply(SPECIES.length()); 2181 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2182 2183 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2184 for (int i = 0; i < a.length; i += SPECIES.length()) { 2185 LongVector av = LongVector.fromArray(SPECIES, a, i); 2186 av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT, vmask).intoArray(r, i); 2187 } 2188 } 2189 2190 bh.consume(r); 2191 } 2192 2193 @Benchmark 2194 public void LEADING_ZEROS_COUNT(Blackhole bh) { 2195 long[] a = fa.apply(SPECIES.length()); 2196 long[] r = fr.apply(SPECIES.length()); 2197 2198 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2199 for (int i = 0; i < a.length; i += SPECIES.length()) { 2200 LongVector av = LongVector.fromArray(SPECIES, a, i); 2201 av.lanewise(VectorOperators.LEADING_ZEROS_COUNT).intoArray(r, i); 2202 } 2203 } 2204 2205 bh.consume(r); 2206 } 2207 2208 @Benchmark 2209 public void LEADING_ZEROS_COUNTMasked(Blackhole bh) { 2210 long[] a = fa.apply(SPECIES.length()); 2211 long[] r = fr.apply(SPECIES.length()); 2212 boolean[] mask = fm.apply(SPECIES.length()); 2213 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2214 2215 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2216 for (int i = 0; i < a.length; i += SPECIES.length()) { 2217 LongVector av = LongVector.fromArray(SPECIES, a, i); 2218 av.lanewise(VectorOperators.LEADING_ZEROS_COUNT, vmask).intoArray(r, i); 2219 } 2220 } 2221 2222 bh.consume(r); 2223 } 2224 2225 @Benchmark 2226 public void REVERSE(Blackhole bh) { 2227 long[] a = fa.apply(SPECIES.length()); 2228 long[] r = fr.apply(SPECIES.length()); 2229 2230 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2231 for (int i = 0; i < a.length; i += SPECIES.length()) { 2232 LongVector av = LongVector.fromArray(SPECIES, a, i); 2233 av.lanewise(VectorOperators.REVERSE).intoArray(r, i); 2234 } 2235 } 2236 2237 bh.consume(r); 2238 } 2239 2240 @Benchmark 2241 public void REVERSEMasked(Blackhole bh) { 2242 long[] a = fa.apply(SPECIES.length()); 2243 long[] r = fr.apply(SPECIES.length()); 2244 boolean[] mask = fm.apply(SPECIES.length()); 2245 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2246 2247 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2248 for (int i = 0; i < a.length; i += SPECIES.length()) { 2249 LongVector av = LongVector.fromArray(SPECIES, a, i); 2250 av.lanewise(VectorOperators.REVERSE, vmask).intoArray(r, i); 2251 } 2252 } 2253 2254 bh.consume(r); 2255 } 2256 2257 @Benchmark 2258 public void REVERSE_BYTES(Blackhole bh) { 2259 long[] a = fa.apply(SPECIES.length()); 2260 long[] r = fr.apply(SPECIES.length()); 2261 2262 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2263 for (int i = 0; i < a.length; i += SPECIES.length()) { 2264 LongVector av = LongVector.fromArray(SPECIES, a, i); 2265 av.lanewise(VectorOperators.REVERSE_BYTES).intoArray(r, i); 2266 } 2267 } 2268 2269 bh.consume(r); 2270 } 2271 2272 @Benchmark 2273 public void REVERSE_BYTESMasked(Blackhole bh) { 2274 long[] a = fa.apply(SPECIES.length()); 2275 long[] r = fr.apply(SPECIES.length()); 2276 boolean[] mask = fm.apply(SPECIES.length()); 2277 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0); 2278 2279 for (int ic = 0; ic < INVOC_COUNT; ic++) { 2280 for (int i = 0; i < a.length; i += SPECIES.length()) { 2281 LongVector av = LongVector.fromArray(SPECIES, a, i); 2282 av.lanewise(VectorOperators.REVERSE_BYTES, vmask).intoArray(r, i); 2283 } 2284 } 2285 2286 bh.consume(r); 2287 } 2288 }