1 /* 2 * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 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.FloatVector; 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 Float128Vector extends AbstractVectorBenchmark { 50 static final VectorSpecies<Float> SPECIES = FloatVector.SPECIES_128; 51 52 static final int INVOC_COUNT = 1; // get rid of outer loop 53 54 55 static float firstNonZero(float a, float b) { 56 return Float.compare(a, (float) 0) != 0 ? a : b; 57 } 58 59 60 @Param("1024") 61 int size; 62 63 float[] fill(IntFunction<Float> f) { 64 float[] array = new float[size]; 65 for (int i = 0; i < array.length; i++) { 66 array[i] = f.apply(i); 67 } 68 return array; 69 } 70 71 float[] a, b, c, r; 72 boolean[] m, mt, rm; 73 int[] s; 74 75 @Setup 76 public void init() { 77 size += size % SPECIES.length(); // FIXME: add post-loops 78 79 a = fill(i -> (float)(2*i)); 80 b = fill(i -> (float)(i+1)); 81 c = fill(i -> (float)(i+5)); 82 r = fill(i -> (float)0); 83 84 m = fillMask(size, i -> (i % 2) == 0); 85 mt = fillMask(size, i -> true); 86 rm = fillMask(size, i -> false); 87 88 s = fillInt(size, i -> RANDOM.nextInt(SPECIES.length())); 89 } 90 91 final IntFunction<float[]> fa = vl -> a; 92 final IntFunction<float[]> fb = vl -> b; 93 final IntFunction<float[]> fc = vl -> c; 94 final IntFunction<float[]> fr = vl -> r; 95 final IntFunction<boolean[]> fm = vl -> m; 96 final IntFunction<boolean[]> fmt = vl -> mt; 97 final IntFunction<boolean[]> fmr = vl -> rm; 98 final BiFunction<Integer,Integer,int[]> fs = (i,j) -> s; 99 100 101 @Benchmark 102 public void ADD(Blackhole bh) { 103 float[] a = fa.apply(SPECIES.length()); 104 float[] b = fb.apply(SPECIES.length()); 105 float[] r = fr.apply(SPECIES.length()); 106 107 for (int ic = 0; ic < INVOC_COUNT; ic++) { 108 for (int i = 0; i < a.length; i += SPECIES.length()) { 109 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 110 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 111 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i); 112 } 113 } 114 115 bh.consume(r); 116 } 117 118 @Benchmark 119 public void ADDMasked(Blackhole bh) { 120 float[] a = fa.apply(SPECIES.length()); 121 float[] b = fb.apply(SPECIES.length()); 122 float[] r = fr.apply(SPECIES.length()); 123 boolean[] mask = fm.apply(SPECIES.length()); 124 VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0); 125 126 for (int ic = 0; ic < INVOC_COUNT; ic++) { 127 for (int i = 0; i < a.length; i += SPECIES.length()) { 128 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 129 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 130 av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i); 131 } 132 } 133 134 bh.consume(r); 135 } 136 137 @Benchmark 138 public void SUB(Blackhole bh) { 139 float[] a = fa.apply(SPECIES.length()); 140 float[] b = fb.apply(SPECIES.length()); 141 float[] r = fr.apply(SPECIES.length()); 142 143 for (int ic = 0; ic < INVOC_COUNT; ic++) { 144 for (int i = 0; i < a.length; i += SPECIES.length()) { 145 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 146 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 147 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i); 148 } 149 } 150 151 bh.consume(r); 152 } 153 154 @Benchmark 155 public void SUBMasked(Blackhole bh) { 156 float[] a = fa.apply(SPECIES.length()); 157 float[] b = fb.apply(SPECIES.length()); 158 float[] r = fr.apply(SPECIES.length()); 159 boolean[] mask = fm.apply(SPECIES.length()); 160 VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0); 161 162 for (int ic = 0; ic < INVOC_COUNT; ic++) { 163 for (int i = 0; i < a.length; i += SPECIES.length()) { 164 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 165 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 166 av.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i); 167 } 168 } 169 170 bh.consume(r); 171 } 172 173 @Benchmark 174 public void MUL(Blackhole bh) { 175 float[] a = fa.apply(SPECIES.length()); 176 float[] b = fb.apply(SPECIES.length()); 177 float[] r = fr.apply(SPECIES.length()); 178 179 for (int ic = 0; ic < INVOC_COUNT; ic++) { 180 for (int i = 0; i < a.length; i += SPECIES.length()) { 181 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 182 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 183 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i); 184 } 185 } 186 187 bh.consume(r); 188 } 189 190 @Benchmark 191 public void MULMasked(Blackhole bh) { 192 float[] a = fa.apply(SPECIES.length()); 193 float[] b = fb.apply(SPECIES.length()); 194 float[] r = fr.apply(SPECIES.length()); 195 boolean[] mask = fm.apply(SPECIES.length()); 196 VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0); 197 198 for (int ic = 0; ic < INVOC_COUNT; ic++) { 199 for (int i = 0; i < a.length; i += SPECIES.length()) { 200 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 201 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 202 av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i); 203 } 204 } 205 206 bh.consume(r); 207 } 208 209 @Benchmark 210 public void DIV(Blackhole bh) { 211 float[] a = fa.apply(SPECIES.length()); 212 float[] b = fb.apply(SPECIES.length()); 213 float[] r = fr.apply(SPECIES.length()); 214 215 for (int ic = 0; ic < INVOC_COUNT; ic++) { 216 for (int i = 0; i < a.length; i += SPECIES.length()) { 217 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 218 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 219 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i); 220 } 221 } 222 223 bh.consume(r); 224 } 225 226 @Benchmark 227 public void DIVMasked(Blackhole bh) { 228 float[] a = fa.apply(SPECIES.length()); 229 float[] b = fb.apply(SPECIES.length()); 230 float[] r = fr.apply(SPECIES.length()); 231 boolean[] mask = fm.apply(SPECIES.length()); 232 VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0); 233 234 for (int ic = 0; ic < INVOC_COUNT; ic++) { 235 for (int i = 0; i < a.length; i += SPECIES.length()) { 236 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 237 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 238 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i); 239 } 240 } 241 242 bh.consume(r); 243 } 244 245 @Benchmark 246 public void FIRST_NONZERO(Blackhole bh) { 247 float[] a = fa.apply(SPECIES.length()); 248 float[] b = fb.apply(SPECIES.length()); 249 float[] r = fr.apply(SPECIES.length()); 250 251 for (int ic = 0; ic < INVOC_COUNT; ic++) { 252 for (int i = 0; i < a.length; i += SPECIES.length()) { 253 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 254 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 255 av.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i); 256 } 257 } 258 259 bh.consume(r); 260 } 261 262 @Benchmark 263 public void FIRST_NONZEROMasked(Blackhole bh) { 264 float[] a = fa.apply(SPECIES.length()); 265 float[] b = fb.apply(SPECIES.length()); 266 float[] r = fr.apply(SPECIES.length()); 267 boolean[] mask = fm.apply(SPECIES.length()); 268 VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0); 269 270 for (int ic = 0; ic < INVOC_COUNT; ic++) { 271 for (int i = 0; i < a.length; i += SPECIES.length()) { 272 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 273 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 274 av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i); 275 } 276 } 277 278 bh.consume(r); 279 } 280 281 @Benchmark 282 public void MIN(Blackhole bh) { 283 float[] a = fa.apply(SPECIES.length()); 284 float[] b = fb.apply(SPECIES.length()); 285 float[] r = fr.apply(SPECIES.length()); 286 287 for (int ic = 0; ic < INVOC_COUNT; ic++) { 288 for (int i = 0; i < a.length; i += SPECIES.length()) { 289 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 290 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 291 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i); 292 } 293 } 294 295 bh.consume(r); 296 } 297 298 @Benchmark 299 public void MAX(Blackhole bh) { 300 float[] a = fa.apply(SPECIES.length()); 301 float[] b = fb.apply(SPECIES.length()); 302 float[] r = fr.apply(SPECIES.length()); 303 304 for (int ic = 0; ic < INVOC_COUNT; ic++) { 305 for (int i = 0; i < a.length; i += SPECIES.length()) { 306 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 307 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 308 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i); 309 } 310 } 311 312 bh.consume(r); 313 } 314 315 @Benchmark 316 public void ADDLanes(Blackhole bh) { 317 float[] a = fa.apply(SPECIES.length()); 318 float ra = 0; 319 320 for (int ic = 0; ic < INVOC_COUNT; ic++) { 321 ra = 0; 322 for (int i = 0; i < a.length; i += SPECIES.length()) { 323 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 324 ra += av.reduceLanes(VectorOperators.ADD); 325 } 326 } 327 bh.consume(ra); 328 } 329 330 @Benchmark 331 public void ADDMaskedLanes(Blackhole bh) { 332 float[] a = fa.apply(SPECIES.length()); 333 boolean[] mask = fm.apply(SPECIES.length()); 334 VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0); 335 float ra = 0; 336 337 for (int ic = 0; ic < INVOC_COUNT; ic++) { 338 ra = 0; 339 for (int i = 0; i < a.length; i += SPECIES.length()) { 340 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 341 ra += av.reduceLanes(VectorOperators.ADD, vmask); 342 } 343 } 344 bh.consume(ra); 345 } 346 347 @Benchmark 348 public void MULLanes(Blackhole bh) { 349 float[] a = fa.apply(SPECIES.length()); 350 float ra = 1; 351 352 for (int ic = 0; ic < INVOC_COUNT; ic++) { 353 ra = 1; 354 for (int i = 0; i < a.length; i += SPECIES.length()) { 355 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 356 ra *= av.reduceLanes(VectorOperators.MUL); 357 } 358 } 359 bh.consume(ra); 360 } 361 362 @Benchmark 363 public void MULMaskedLanes(Blackhole bh) { 364 float[] a = fa.apply(SPECIES.length()); 365 boolean[] mask = fm.apply(SPECIES.length()); 366 VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0); 367 float ra = 1; 368 369 for (int ic = 0; ic < INVOC_COUNT; ic++) { 370 ra = 1; 371 for (int i = 0; i < a.length; i += SPECIES.length()) { 372 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 373 ra *= av.reduceLanes(VectorOperators.MUL, vmask); 374 } 375 } 376 bh.consume(ra); 377 } 378 379 @Benchmark 380 public void MINLanes(Blackhole bh) { 381 float[] a = fa.apply(SPECIES.length()); 382 float ra = Float.POSITIVE_INFINITY; 383 384 for (int ic = 0; ic < INVOC_COUNT; ic++) { 385 ra = Float.POSITIVE_INFINITY; 386 for (int i = 0; i < a.length; i += SPECIES.length()) { 387 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 388 ra = (float) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); 389 } 390 } 391 bh.consume(ra); 392 } 393 394 @Benchmark 395 public void MINMaskedLanes(Blackhole bh) { 396 float[] a = fa.apply(SPECIES.length()); 397 boolean[] mask = fm.apply(SPECIES.length()); 398 VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0); 399 float ra = Float.POSITIVE_INFINITY; 400 401 for (int ic = 0; ic < INVOC_COUNT; ic++) { 402 ra = Float.POSITIVE_INFINITY; 403 for (int i = 0; i < a.length; i += SPECIES.length()) { 404 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 405 ra = (float) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); 406 } 407 } 408 bh.consume(ra); 409 } 410 411 @Benchmark 412 public void MAXLanes(Blackhole bh) { 413 float[] a = fa.apply(SPECIES.length()); 414 float ra = Float.NEGATIVE_INFINITY; 415 416 for (int ic = 0; ic < INVOC_COUNT; ic++) { 417 ra = Float.NEGATIVE_INFINITY; 418 for (int i = 0; i < a.length; i += SPECIES.length()) { 419 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 420 ra = (float) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); 421 } 422 } 423 bh.consume(ra); 424 } 425 426 @Benchmark 427 public void MAXMaskedLanes(Blackhole bh) { 428 float[] a = fa.apply(SPECIES.length()); 429 boolean[] mask = fm.apply(SPECIES.length()); 430 VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0); 431 float ra = Float.NEGATIVE_INFINITY; 432 433 for (int ic = 0; ic < INVOC_COUNT; ic++) { 434 ra = Float.NEGATIVE_INFINITY; 435 for (int i = 0; i < a.length; i += SPECIES.length()) { 436 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 437 ra = (float) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); 438 } 439 } 440 bh.consume(ra); 441 } 442 443 @Benchmark 444 public void FIRST_NONZEROLanes(Blackhole bh) { 445 float[] a = fa.apply(SPECIES.length()); 446 float ra = (float) 0; 447 448 for (int ic = 0; ic < INVOC_COUNT; ic++) { 449 ra = (float) 0; 450 for (int i = 0; i < a.length; i += SPECIES.length()) { 451 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 452 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); 453 } 454 } 455 bh.consume(ra); 456 } 457 458 @Benchmark 459 public void FIRST_NONZEROMaskedLanes(Blackhole bh) { 460 float[] a = fa.apply(SPECIES.length()); 461 boolean[] mask = fm.apply(SPECIES.length()); 462 VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0); 463 float ra = (float) 0; 464 465 for (int ic = 0; ic < INVOC_COUNT; ic++) { 466 ra = (float) 0; 467 for (int i = 0; i < a.length; i += SPECIES.length()) { 468 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 469 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); 470 } 471 } 472 bh.consume(ra); 473 } 474 475 @Benchmark 476 public void withLane(Blackhole bh) { 477 float[] a = fa.apply(SPECIES.length()); 478 float[] r = fr.apply(SPECIES.length()); 479 480 for (int ic = 0; ic < INVOC_COUNT; ic++) { 481 for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { 482 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 483 av.withLane((j++ & (SPECIES.length()-1)), (float)(65535+i)).intoArray(r, i); 484 } 485 } 486 487 bh.consume(r); 488 } 489 490 @Benchmark 491 public Object IS_DEFAULT() { 492 float[] a = fa.apply(size); 493 boolean[] ms = fmt.apply(size); 494 VectorMask<Float> m = VectorMask.fromArray(SPECIES, ms, 0); 495 496 for (int ic = 0; ic < INVOC_COUNT; ic++) { 497 for (int i = 0; i < a.length; i += SPECIES.length()) { 498 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 499 500 // accumulate results, so JIT can't eliminate relevant computations 501 m = m.and(av.test(VectorOperators.IS_DEFAULT)); 502 } 503 } 504 505 return m; 506 } 507 508 @Benchmark 509 public Object IS_NEGATIVE() { 510 float[] a = fa.apply(size); 511 boolean[] ms = fmt.apply(size); 512 VectorMask<Float> m = VectorMask.fromArray(SPECIES, ms, 0); 513 514 for (int ic = 0; ic < INVOC_COUNT; ic++) { 515 for (int i = 0; i < a.length; i += SPECIES.length()) { 516 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 517 518 // accumulate results, so JIT can't eliminate relevant computations 519 m = m.and(av.test(VectorOperators.IS_NEGATIVE)); 520 } 521 } 522 523 return m; 524 } 525 526 @Benchmark 527 public Object IS_FINITE() { 528 float[] a = fa.apply(size); 529 boolean[] ms = fmt.apply(size); 530 VectorMask<Float> m = VectorMask.fromArray(SPECIES, ms, 0); 531 532 for (int ic = 0; ic < INVOC_COUNT; ic++) { 533 for (int i = 0; i < a.length; i += SPECIES.length()) { 534 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 535 536 // accumulate results, so JIT can't eliminate relevant computations 537 m = m.and(av.test(VectorOperators.IS_FINITE)); 538 } 539 } 540 541 return m; 542 } 543 544 @Benchmark 545 public Object IS_NAN() { 546 float[] a = fa.apply(size); 547 boolean[] ms = fmt.apply(size); 548 VectorMask<Float> m = VectorMask.fromArray(SPECIES, ms, 0); 549 550 for (int ic = 0; ic < INVOC_COUNT; ic++) { 551 for (int i = 0; i < a.length; i += SPECIES.length()) { 552 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 553 554 // accumulate results, so JIT can't eliminate relevant computations 555 m = m.and(av.test(VectorOperators.IS_NAN)); 556 } 557 } 558 559 return m; 560 } 561 562 @Benchmark 563 public Object IS_INFINITE() { 564 float[] a = fa.apply(size); 565 boolean[] ms = fmt.apply(size); 566 VectorMask<Float> m = VectorMask.fromArray(SPECIES, ms, 0); 567 568 for (int ic = 0; ic < INVOC_COUNT; ic++) { 569 for (int i = 0; i < a.length; i += SPECIES.length()) { 570 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 571 572 // accumulate results, so JIT can't eliminate relevant computations 573 m = m.and(av.test(VectorOperators.IS_INFINITE)); 574 } 575 } 576 577 return m; 578 } 579 @Benchmark 580 public Object LT() { 581 float[] a = fa.apply(size); 582 float[] b = fb.apply(size); 583 boolean[] ms = fmt.apply(size); 584 VectorMask<Float> m = VectorMask.fromArray(SPECIES, ms, 0); 585 586 for (int ic = 0; ic < INVOC_COUNT; ic++) { 587 for (int i = 0; i < a.length; i += SPECIES.length()) { 588 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 589 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 590 591 // accumulate results, so JIT can't eliminate relevant computations 592 m = m.and(av.compare(VectorOperators.LT, bv)); 593 } 594 } 595 596 return m; 597 } 598 @Benchmark 599 public Object GT() { 600 float[] a = fa.apply(size); 601 float[] b = fb.apply(size); 602 boolean[] ms = fmt.apply(size); 603 VectorMask<Float> m = VectorMask.fromArray(SPECIES, ms, 0); 604 605 for (int ic = 0; ic < INVOC_COUNT; ic++) { 606 for (int i = 0; i < a.length; i += SPECIES.length()) { 607 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 608 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 609 610 // accumulate results, so JIT can't eliminate relevant computations 611 m = m.and(av.compare(VectorOperators.GT, bv)); 612 } 613 } 614 615 return m; 616 } 617 @Benchmark 618 public Object EQ() { 619 float[] a = fa.apply(size); 620 float[] b = fb.apply(size); 621 boolean[] ms = fmt.apply(size); 622 VectorMask<Float> m = VectorMask.fromArray(SPECIES, ms, 0); 623 624 for (int ic = 0; ic < INVOC_COUNT; ic++) { 625 for (int i = 0; i < a.length; i += SPECIES.length()) { 626 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 627 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 628 629 // accumulate results, so JIT can't eliminate relevant computations 630 m = m.and(av.compare(VectorOperators.EQ, bv)); 631 } 632 } 633 634 return m; 635 } 636 @Benchmark 637 public Object NE() { 638 float[] a = fa.apply(size); 639 float[] b = fb.apply(size); 640 boolean[] ms = fmt.apply(size); 641 VectorMask<Float> m = VectorMask.fromArray(SPECIES, ms, 0); 642 643 for (int ic = 0; ic < INVOC_COUNT; ic++) { 644 for (int i = 0; i < a.length; i += SPECIES.length()) { 645 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 646 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 647 648 // accumulate results, so JIT can't eliminate relevant computations 649 m = m.and(av.compare(VectorOperators.NE, bv)); 650 } 651 } 652 653 return m; 654 } 655 @Benchmark 656 public Object LE() { 657 float[] a = fa.apply(size); 658 float[] b = fb.apply(size); 659 boolean[] ms = fmt.apply(size); 660 VectorMask<Float> m = VectorMask.fromArray(SPECIES, ms, 0); 661 662 for (int ic = 0; ic < INVOC_COUNT; ic++) { 663 for (int i = 0; i < a.length; i += SPECIES.length()) { 664 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 665 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 666 667 // accumulate results, so JIT can't eliminate relevant computations 668 m = m.and(av.compare(VectorOperators.LE, bv)); 669 } 670 } 671 672 return m; 673 } 674 @Benchmark 675 public Object GE() { 676 float[] a = fa.apply(size); 677 float[] b = fb.apply(size); 678 boolean[] ms = fmt.apply(size); 679 VectorMask<Float> m = VectorMask.fromArray(SPECIES, ms, 0); 680 681 for (int ic = 0; ic < INVOC_COUNT; ic++) { 682 for (int i = 0; i < a.length; i += SPECIES.length()) { 683 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 684 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 685 686 // accumulate results, so JIT can't eliminate relevant computations 687 m = m.and(av.compare(VectorOperators.GE, bv)); 688 } 689 } 690 691 return m; 692 } 693 694 @Benchmark 695 public void blend(Blackhole bh) { 696 float[] a = fa.apply(SPECIES.length()); 697 float[] b = fb.apply(SPECIES.length()); 698 float[] r = fr.apply(SPECIES.length()); 699 boolean[] mask = fm.apply(SPECIES.length()); 700 VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0); 701 702 for (int ic = 0; ic < INVOC_COUNT; ic++) { 703 for (int i = 0; i < a.length; i += SPECIES.length()) { 704 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 705 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 706 av.blend(bv, vmask).intoArray(r, i); 707 } 708 } 709 710 bh.consume(r); 711 } 712 713 @Benchmark 714 public void rearrange(Blackhole bh) { 715 float[] a = fa.apply(SPECIES.length()); 716 int[] order = fs.apply(a.length, SPECIES.length()); 717 float[] r = fr.apply(SPECIES.length()); 718 719 for (int ic = 0; ic < INVOC_COUNT; ic++) { 720 for (int i = 0; i < a.length; i += SPECIES.length()) { 721 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 722 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i); 723 } 724 } 725 726 bh.consume(r); 727 } 728 @Benchmark 729 public Object compress() { 730 float[] a = fa.apply(size); 731 float[] r = fb.apply(size); 732 boolean[] ms = fmt.apply(size); 733 VectorMask<Float> m = VectorMask.fromArray(SPECIES, ms, 0); 734 735 for (int ic = 0; ic < INVOC_COUNT; ic++) { 736 for (int i = 0; i < a.length; i += SPECIES.length()) { 737 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 738 av.compress(m).intoArray(r, i); 739 } 740 } 741 742 return r; 743 } 744 745 @Benchmark 746 public Object expand() { 747 float[] a = fa.apply(size); 748 float[] r = fb.apply(size); 749 boolean[] ms = fmt.apply(size); 750 VectorMask<Float> m = VectorMask.fromArray(SPECIES, ms, 0); 751 752 for (int ic = 0; ic < INVOC_COUNT; ic++) { 753 for (int i = 0; i < a.length; i += SPECIES.length()) { 754 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 755 av.expand(m).intoArray(r, i); 756 } 757 } 758 759 return r; 760 } 761 762 @Benchmark 763 public Object maskCompress() { 764 boolean[] ms = fmt.apply(size); 765 boolean[] rs = fmt.apply(size); 766 767 for (int ic = 0; ic < INVOC_COUNT; ic++) { 768 for (int i = 0, j = 0; i < ms.length; i += SPECIES.length()) { 769 VectorMask<Float> m = VectorMask.fromArray(SPECIES, ms, i); 770 m.compress().intoArray(rs, j); 771 j += m.trueCount(); 772 } 773 } 774 775 return rs; 776 } 777 778 @Benchmark 779 public void laneextract(Blackhole bh) { 780 float[] a = fa.apply(SPECIES.length()); 781 float[] r = fr.apply(SPECIES.length()); 782 783 for (int ic = 0; ic < INVOC_COUNT; ic++) { 784 for (int i = 0; i < a.length; i += SPECIES.length()) { 785 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 786 int num_lanes = SPECIES.length(); 787 // Manually unroll because full unroll happens after intrinsification. 788 // Unroll is needed because get intrinsic requires for index to be a known constant. 789 if (num_lanes == 1) { 790 r[i]=av.lane(0); 791 } else if (num_lanes == 2) { 792 r[i]=av.lane(0); 793 r[i+1]=av.lane(1); 794 } else if (num_lanes == 4) { 795 r[i]=av.lane(0); 796 r[i+1]=av.lane(1); 797 r[i+2]=av.lane(2); 798 r[i+3]=av.lane(3); 799 } else if (num_lanes == 8) { 800 r[i]=av.lane(0); 801 r[i+1]=av.lane(1); 802 r[i+2]=av.lane(2); 803 r[i+3]=av.lane(3); 804 r[i+4]=av.lane(4); 805 r[i+5]=av.lane(5); 806 r[i+6]=av.lane(6); 807 r[i+7]=av.lane(7); 808 } else if (num_lanes == 16) { 809 r[i]=av.lane(0); 810 r[i+1]=av.lane(1); 811 r[i+2]=av.lane(2); 812 r[i+3]=av.lane(3); 813 r[i+4]=av.lane(4); 814 r[i+5]=av.lane(5); 815 r[i+6]=av.lane(6); 816 r[i+7]=av.lane(7); 817 r[i+8]=av.lane(8); 818 r[i+9]=av.lane(9); 819 r[i+10]=av.lane(10); 820 r[i+11]=av.lane(11); 821 r[i+12]=av.lane(12); 822 r[i+13]=av.lane(13); 823 r[i+14]=av.lane(14); 824 r[i+15]=av.lane(15); 825 } else if (num_lanes == 32) { 826 r[i]=av.lane(0); 827 r[i+1]=av.lane(1); 828 r[i+2]=av.lane(2); 829 r[i+3]=av.lane(3); 830 r[i+4]=av.lane(4); 831 r[i+5]=av.lane(5); 832 r[i+6]=av.lane(6); 833 r[i+7]=av.lane(7); 834 r[i+8]=av.lane(8); 835 r[i+9]=av.lane(9); 836 r[i+10]=av.lane(10); 837 r[i+11]=av.lane(11); 838 r[i+12]=av.lane(12); 839 r[i+13]=av.lane(13); 840 r[i+14]=av.lane(14); 841 r[i+15]=av.lane(15); 842 r[i+16]=av.lane(16); 843 r[i+17]=av.lane(17); 844 r[i+18]=av.lane(18); 845 r[i+19]=av.lane(19); 846 r[i+20]=av.lane(20); 847 r[i+21]=av.lane(21); 848 r[i+22]=av.lane(22); 849 r[i+23]=av.lane(23); 850 r[i+24]=av.lane(24); 851 r[i+25]=av.lane(25); 852 r[i+26]=av.lane(26); 853 r[i+27]=av.lane(27); 854 r[i+28]=av.lane(28); 855 r[i+29]=av.lane(29); 856 r[i+30]=av.lane(30); 857 r[i+31]=av.lane(31); 858 } else if (num_lanes == 64) { 859 r[i]=av.lane(0); 860 r[i+1]=av.lane(1); 861 r[i+2]=av.lane(2); 862 r[i+3]=av.lane(3); 863 r[i+4]=av.lane(4); 864 r[i+5]=av.lane(5); 865 r[i+6]=av.lane(6); 866 r[i+7]=av.lane(7); 867 r[i+8]=av.lane(8); 868 r[i+9]=av.lane(9); 869 r[i+10]=av.lane(10); 870 r[i+11]=av.lane(11); 871 r[i+12]=av.lane(12); 872 r[i+13]=av.lane(13); 873 r[i+14]=av.lane(14); 874 r[i+15]=av.lane(15); 875 r[i+16]=av.lane(16); 876 r[i+17]=av.lane(17); 877 r[i+18]=av.lane(18); 878 r[i+19]=av.lane(19); 879 r[i+20]=av.lane(20); 880 r[i+21]=av.lane(21); 881 r[i+22]=av.lane(22); 882 r[i+23]=av.lane(23); 883 r[i+24]=av.lane(24); 884 r[i+25]=av.lane(25); 885 r[i+26]=av.lane(26); 886 r[i+27]=av.lane(27); 887 r[i+28]=av.lane(28); 888 r[i+29]=av.lane(29); 889 r[i+30]=av.lane(30); 890 r[i+31]=av.lane(31); 891 r[i+32]=av.lane(32); 892 r[i+33]=av.lane(33); 893 r[i+34]=av.lane(34); 894 r[i+35]=av.lane(35); 895 r[i+36]=av.lane(36); 896 r[i+37]=av.lane(37); 897 r[i+38]=av.lane(38); 898 r[i+39]=av.lane(39); 899 r[i+40]=av.lane(40); 900 r[i+41]=av.lane(41); 901 r[i+42]=av.lane(42); 902 r[i+43]=av.lane(43); 903 r[i+44]=av.lane(44); 904 r[i+45]=av.lane(45); 905 r[i+46]=av.lane(46); 906 r[i+47]=av.lane(47); 907 r[i+48]=av.lane(48); 908 r[i+49]=av.lane(49); 909 r[i+50]=av.lane(50); 910 r[i+51]=av.lane(51); 911 r[i+52]=av.lane(52); 912 r[i+53]=av.lane(53); 913 r[i+54]=av.lane(54); 914 r[i+55]=av.lane(55); 915 r[i+56]=av.lane(56); 916 r[i+57]=av.lane(57); 917 r[i+58]=av.lane(58); 918 r[i+59]=av.lane(59); 919 r[i+60]=av.lane(60); 920 r[i+61]=av.lane(61); 921 r[i+62]=av.lane(62); 922 r[i+63]=av.lane(63); 923 } else { 924 for (int j = 0; j < SPECIES.length(); j++) { 925 r[i+j]=av.lane(j); 926 } 927 } 928 } 929 } 930 931 bh.consume(r); 932 } 933 934 @Benchmark 935 public void broadcast(Blackhole bh) { 936 float[] a = fa.apply(SPECIES.length()); 937 float[] r = new float[a.length]; 938 939 for (int ic = 0; ic < INVOC_COUNT; ic++) { 940 for (int i = 0; i < a.length; i += SPECIES.length()) { 941 FloatVector.broadcast(SPECIES, a[i]).intoArray(r, i); 942 } 943 } 944 945 bh.consume(r); 946 } 947 948 @Benchmark 949 public void zero(Blackhole bh) { 950 float[] a = fa.apply(SPECIES.length()); 951 float[] r = new float[a.length]; 952 953 for (int ic = 0; ic < INVOC_COUNT; ic++) { 954 for (int i = 0; i < a.length; i += SPECIES.length()) { 955 FloatVector.zero(SPECIES).intoArray(a, i); 956 } 957 } 958 959 bh.consume(r); 960 } 961 962 @Benchmark 963 public void sliceUnary(Blackhole bh) { 964 float[] a = fa.apply(SPECIES.length()); 965 float[] r = new float[a.length]; 966 int origin = RAND.nextInt(SPECIES.length()); 967 for (int ic = 0; ic < INVOC_COUNT; ic++) { 968 for (int i = 0; i < a.length; i += SPECIES.length()) { 969 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 970 av.slice(origin).intoArray(r, i); 971 } 972 } 973 974 bh.consume(r); 975 } 976 977 @Benchmark 978 public void sliceBinary(Blackhole bh) { 979 float[] a = fa.apply(SPECIES.length()); 980 float[] b = fb.apply(SPECIES.length()); 981 float[] r = new float[a.length]; 982 int origin = RAND.nextInt(SPECIES.length()); 983 for (int ic = 0; ic < INVOC_COUNT; ic++) { 984 for (int i = 0; i < a.length; i += SPECIES.length()) { 985 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 986 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 987 av.slice(origin, bv).intoArray(r, i); 988 } 989 } 990 991 bh.consume(r); 992 } 993 994 @Benchmark 995 public void sliceMasked(Blackhole bh) { 996 float[] a = fa.apply(SPECIES.length()); 997 float[] b = fb.apply(SPECIES.length()); 998 boolean[] mask = fm.apply(SPECIES.length()); 999 VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1000 1001 float[] r = new float[a.length]; 1002 int origin = RAND.nextInt(SPECIES.length()); 1003 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1004 for (int i = 0; i < a.length; i += SPECIES.length()) { 1005 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1006 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 1007 av.slice(origin, bv, vmask).intoArray(r, i); 1008 } 1009 } 1010 1011 bh.consume(r); 1012 } 1013 1014 @Benchmark 1015 public void unsliceUnary(Blackhole bh) { 1016 float[] a = fa.apply(SPECIES.length()); 1017 float[] r = new float[a.length]; 1018 int origin = RAND.nextInt(SPECIES.length()); 1019 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1020 for (int i = 0; i < a.length; i += SPECIES.length()) { 1021 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1022 av.unslice(origin).intoArray(r, i); 1023 } 1024 } 1025 1026 bh.consume(r); 1027 } 1028 1029 @Benchmark 1030 public void unsliceBinary(Blackhole bh) { 1031 float[] a = fa.apply(SPECIES.length()); 1032 float[] b = fb.apply(SPECIES.length()); 1033 float[] r = new float[a.length]; 1034 int origin = RAND.nextInt(SPECIES.length()); 1035 int part = RAND.nextInt(2); 1036 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1037 for (int i = 0; i < a.length; i += SPECIES.length()) { 1038 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1039 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 1040 av.unslice(origin, bv, part).intoArray(r, i); 1041 } 1042 } 1043 1044 bh.consume(r); 1045 } 1046 1047 @Benchmark 1048 public void unsliceMasked(Blackhole bh) { 1049 float[] a = fa.apply(SPECIES.length()); 1050 float[] b = fb.apply(SPECIES.length()); 1051 boolean[] mask = fm.apply(SPECIES.length()); 1052 VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1053 float[] r = new float[a.length]; 1054 int origin = RAND.nextInt(SPECIES.length()); 1055 int part = RAND.nextInt(2); 1056 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1057 for (int i = 0; i < a.length; i += SPECIES.length()) { 1058 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1059 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 1060 av.unslice(origin, bv, part, vmask).intoArray(r, i); 1061 } 1062 } 1063 1064 bh.consume(r); 1065 } 1066 1067 @Benchmark 1068 public void SIN(Blackhole bh) { 1069 float[] a = fa.apply(SPECIES.length()); 1070 float[] r = fr.apply(SPECIES.length()); 1071 1072 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1073 for (int i = 0; i < a.length; i += SPECIES.length()) { 1074 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1075 av.lanewise(VectorOperators.SIN).intoArray(r, i); 1076 } 1077 } 1078 1079 bh.consume(r); 1080 } 1081 1082 @Benchmark 1083 public void EXP(Blackhole bh) { 1084 float[] a = fa.apply(SPECIES.length()); 1085 float[] r = fr.apply(SPECIES.length()); 1086 1087 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1088 for (int i = 0; i < a.length; i += SPECIES.length()) { 1089 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1090 av.lanewise(VectorOperators.EXP).intoArray(r, i); 1091 } 1092 } 1093 1094 bh.consume(r); 1095 } 1096 1097 @Benchmark 1098 public void LOG1P(Blackhole bh) { 1099 float[] a = fa.apply(SPECIES.length()); 1100 float[] r = fr.apply(SPECIES.length()); 1101 1102 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1103 for (int i = 0; i < a.length; i += SPECIES.length()) { 1104 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1105 av.lanewise(VectorOperators.LOG1P).intoArray(r, i); 1106 } 1107 } 1108 1109 bh.consume(r); 1110 } 1111 1112 @Benchmark 1113 public void LOG(Blackhole bh) { 1114 float[] a = fa.apply(SPECIES.length()); 1115 float[] r = fr.apply(SPECIES.length()); 1116 1117 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1118 for (int i = 0; i < a.length; i += SPECIES.length()) { 1119 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1120 av.lanewise(VectorOperators.LOG).intoArray(r, i); 1121 } 1122 } 1123 1124 bh.consume(r); 1125 } 1126 1127 @Benchmark 1128 public void LOG10(Blackhole bh) { 1129 float[] a = fa.apply(SPECIES.length()); 1130 float[] r = fr.apply(SPECIES.length()); 1131 1132 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1133 for (int i = 0; i < a.length; i += SPECIES.length()) { 1134 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1135 av.lanewise(VectorOperators.LOG10).intoArray(r, i); 1136 } 1137 } 1138 1139 bh.consume(r); 1140 } 1141 1142 @Benchmark 1143 public void EXPM1(Blackhole bh) { 1144 float[] a = fa.apply(SPECIES.length()); 1145 float[] r = fr.apply(SPECIES.length()); 1146 1147 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1148 for (int i = 0; i < a.length; i += SPECIES.length()) { 1149 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1150 av.lanewise(VectorOperators.EXPM1).intoArray(r, i); 1151 } 1152 } 1153 1154 bh.consume(r); 1155 } 1156 1157 @Benchmark 1158 public void COS(Blackhole bh) { 1159 float[] a = fa.apply(SPECIES.length()); 1160 float[] r = fr.apply(SPECIES.length()); 1161 1162 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1163 for (int i = 0; i < a.length; i += SPECIES.length()) { 1164 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1165 av.lanewise(VectorOperators.COS).intoArray(r, i); 1166 } 1167 } 1168 1169 bh.consume(r); 1170 } 1171 1172 @Benchmark 1173 public void TAN(Blackhole bh) { 1174 float[] a = fa.apply(SPECIES.length()); 1175 float[] r = fr.apply(SPECIES.length()); 1176 1177 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1178 for (int i = 0; i < a.length; i += SPECIES.length()) { 1179 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1180 av.lanewise(VectorOperators.TAN).intoArray(r, i); 1181 } 1182 } 1183 1184 bh.consume(r); 1185 } 1186 1187 @Benchmark 1188 public void SINH(Blackhole bh) { 1189 float[] a = fa.apply(SPECIES.length()); 1190 float[] r = fr.apply(SPECIES.length()); 1191 1192 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1193 for (int i = 0; i < a.length; i += SPECIES.length()) { 1194 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1195 av.lanewise(VectorOperators.SINH).intoArray(r, i); 1196 } 1197 } 1198 1199 bh.consume(r); 1200 } 1201 1202 @Benchmark 1203 public void COSH(Blackhole bh) { 1204 float[] a = fa.apply(SPECIES.length()); 1205 float[] r = fr.apply(SPECIES.length()); 1206 1207 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1208 for (int i = 0; i < a.length; i += SPECIES.length()) { 1209 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1210 av.lanewise(VectorOperators.COSH).intoArray(r, i); 1211 } 1212 } 1213 1214 bh.consume(r); 1215 } 1216 1217 @Benchmark 1218 public void TANH(Blackhole bh) { 1219 float[] a = fa.apply(SPECIES.length()); 1220 float[] r = fr.apply(SPECIES.length()); 1221 1222 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1223 for (int i = 0; i < a.length; i += SPECIES.length()) { 1224 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1225 av.lanewise(VectorOperators.TANH).intoArray(r, i); 1226 } 1227 } 1228 1229 bh.consume(r); 1230 } 1231 1232 @Benchmark 1233 public void ASIN(Blackhole bh) { 1234 float[] a = fa.apply(SPECIES.length()); 1235 float[] r = fr.apply(SPECIES.length()); 1236 1237 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1238 for (int i = 0; i < a.length; i += SPECIES.length()) { 1239 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1240 av.lanewise(VectorOperators.ASIN).intoArray(r, i); 1241 } 1242 } 1243 1244 bh.consume(r); 1245 } 1246 1247 @Benchmark 1248 public void ACOS(Blackhole bh) { 1249 float[] a = fa.apply(SPECIES.length()); 1250 float[] r = fr.apply(SPECIES.length()); 1251 1252 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1253 for (int i = 0; i < a.length; i += SPECIES.length()) { 1254 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1255 av.lanewise(VectorOperators.ACOS).intoArray(r, i); 1256 } 1257 } 1258 1259 bh.consume(r); 1260 } 1261 1262 @Benchmark 1263 public void ATAN(Blackhole bh) { 1264 float[] a = fa.apply(SPECIES.length()); 1265 float[] r = fr.apply(SPECIES.length()); 1266 1267 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1268 for (int i = 0; i < a.length; i += SPECIES.length()) { 1269 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1270 av.lanewise(VectorOperators.ATAN).intoArray(r, i); 1271 } 1272 } 1273 1274 bh.consume(r); 1275 } 1276 1277 @Benchmark 1278 public void CBRT(Blackhole bh) { 1279 float[] a = fa.apply(SPECIES.length()); 1280 float[] r = fr.apply(SPECIES.length()); 1281 1282 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1283 for (int i = 0; i < a.length; i += SPECIES.length()) { 1284 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1285 av.lanewise(VectorOperators.CBRT).intoArray(r, i); 1286 } 1287 } 1288 1289 bh.consume(r); 1290 } 1291 1292 @Benchmark 1293 public void HYPOT(Blackhole bh) { 1294 float[] a = fa.apply(SPECIES.length()); 1295 float[] b = fb.apply(SPECIES.length()); 1296 float[] r = fr.apply(SPECIES.length()); 1297 1298 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1299 for (int i = 0; i < a.length; i += SPECIES.length()) { 1300 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1301 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 1302 av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i); 1303 } 1304 } 1305 1306 bh.consume(r); 1307 } 1308 1309 @Benchmark 1310 public void POW(Blackhole bh) { 1311 float[] a = fa.apply(SPECIES.length()); 1312 float[] b = fb.apply(SPECIES.length()); 1313 float[] r = fr.apply(SPECIES.length()); 1314 1315 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1316 for (int i = 0; i < a.length; i += SPECIES.length()) { 1317 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1318 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 1319 av.lanewise(VectorOperators.POW, bv).intoArray(r, i); 1320 } 1321 } 1322 1323 bh.consume(r); 1324 } 1325 1326 @Benchmark 1327 public void ATAN2(Blackhole bh) { 1328 float[] a = fa.apply(SPECIES.length()); 1329 float[] b = fb.apply(SPECIES.length()); 1330 float[] r = fr.apply(SPECIES.length()); 1331 1332 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1333 for (int i = 0; i < a.length; i += SPECIES.length()) { 1334 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1335 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 1336 av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i); 1337 } 1338 } 1339 1340 bh.consume(r); 1341 } 1342 1343 @Benchmark 1344 public void FMA(Blackhole bh) { 1345 float[] a = fa.apply(SPECIES.length()); 1346 float[] b = fb.apply(SPECIES.length()); 1347 float[] c = fc.apply(SPECIES.length()); 1348 float[] r = fr.apply(SPECIES.length()); 1349 1350 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1351 for (int i = 0; i < a.length; i += SPECIES.length()) { 1352 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1353 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 1354 FloatVector cv = FloatVector.fromArray(SPECIES, c, i); 1355 av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i); 1356 } 1357 } 1358 1359 bh.consume(r); 1360 } 1361 1362 @Benchmark 1363 public void FMAMasked(Blackhole bh) { 1364 float[] a = fa.apply(SPECIES.length()); 1365 float[] b = fb.apply(SPECIES.length()); 1366 float[] c = fc.apply(SPECIES.length()); 1367 float[] r = fr.apply(SPECIES.length()); 1368 boolean[] mask = fm.apply(SPECIES.length()); 1369 VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1370 1371 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1372 for (int i = 0; i < a.length; i += SPECIES.length()) { 1373 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1374 FloatVector bv = FloatVector.fromArray(SPECIES, b, i); 1375 FloatVector cv = FloatVector.fromArray(SPECIES, c, i); 1376 av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i); 1377 } 1378 } 1379 1380 bh.consume(r); 1381 } 1382 1383 @Benchmark 1384 public void NEG(Blackhole bh) { 1385 float[] a = fa.apply(SPECIES.length()); 1386 float[] r = fr.apply(SPECIES.length()); 1387 1388 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1389 for (int i = 0; i < a.length; i += SPECIES.length()) { 1390 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1391 av.lanewise(VectorOperators.NEG).intoArray(r, i); 1392 } 1393 } 1394 1395 bh.consume(r); 1396 } 1397 1398 @Benchmark 1399 public void NEGMasked(Blackhole bh) { 1400 float[] a = fa.apply(SPECIES.length()); 1401 float[] r = fr.apply(SPECIES.length()); 1402 boolean[] mask = fm.apply(SPECIES.length()); 1403 VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1404 1405 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1406 for (int i = 0; i < a.length; i += SPECIES.length()) { 1407 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1408 av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i); 1409 } 1410 } 1411 1412 bh.consume(r); 1413 } 1414 1415 @Benchmark 1416 public void ABS(Blackhole bh) { 1417 float[] a = fa.apply(SPECIES.length()); 1418 float[] r = fr.apply(SPECIES.length()); 1419 1420 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1421 for (int i = 0; i < a.length; i += SPECIES.length()) { 1422 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1423 av.lanewise(VectorOperators.ABS).intoArray(r, i); 1424 } 1425 } 1426 1427 bh.consume(r); 1428 } 1429 1430 @Benchmark 1431 public void ABSMasked(Blackhole bh) { 1432 float[] a = fa.apply(SPECIES.length()); 1433 float[] r = fr.apply(SPECIES.length()); 1434 boolean[] mask = fm.apply(SPECIES.length()); 1435 VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1436 1437 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1438 for (int i = 0; i < a.length; i += SPECIES.length()) { 1439 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1440 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i); 1441 } 1442 } 1443 1444 bh.consume(r); 1445 } 1446 1447 @Benchmark 1448 public void SQRT(Blackhole bh) { 1449 float[] a = fa.apply(SPECIES.length()); 1450 float[] r = fr.apply(SPECIES.length()); 1451 1452 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1453 for (int i = 0; i < a.length; i += SPECIES.length()) { 1454 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1455 av.lanewise(VectorOperators.SQRT).intoArray(r, i); 1456 } 1457 } 1458 1459 bh.consume(r); 1460 } 1461 1462 @Benchmark 1463 public void SQRTMasked(Blackhole bh) { 1464 float[] a = fa.apply(SPECIES.length()); 1465 float[] r = fr.apply(SPECIES.length()); 1466 boolean[] mask = fm.apply(SPECIES.length()); 1467 VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0); 1468 1469 for (int ic = 0; ic < INVOC_COUNT; ic++) { 1470 for (int i = 0; i < a.length; i += SPECIES.length()) { 1471 FloatVector av = FloatVector.fromArray(SPECIES, a, i); 1472 av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i); 1473 } 1474 } 1475 1476 bh.consume(r); 1477 } 1478 }