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