1 /*
2 * Copyright (c) 2018, 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
21 * questions.
22 */
468 public void min(Blackhole bh) {
469 byte[] a = fa.apply(SPECIES.length());
470 byte[] b = fb.apply(SPECIES.length());
471 byte[] r = fr.apply(SPECIES.length());
472
473 for (int ic = 0; ic < INVOC_COUNT; ic++) {
474 for (int i = 0; i < a.length; i += SPECIES.length()) {
475 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
476 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
477 av.min(bv).intoArray(r, i);
478 }
479 }
480
481 bh.consume(r);
482 }
483
484
485 @Benchmark
486 public void andAll(Blackhole bh) {
487 byte[] a = fa.apply(SPECIES.length());
488 byte[] r = fr.apply(SPECIES.length());
489 byte ra = -1;
490
491 for (int ic = 0; ic < INVOC_COUNT; ic++) {
492 for (int i = 0; i < a.length; i += SPECIES.length()) {
493 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
494 r[i] = av.andAll();
495 }
496 }
497
498 for (int ic = 0; ic < INVOC_COUNT; ic++) {
499 ra = -1;
500 for (int i = 0; i < a.length; i += SPECIES.length()) {
501 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
502 ra &= av.andAll();
503 }
504 }
505
506 bh.consume(ra);
507 bh.consume(r);
508 }
509
510
511
512 @Benchmark
513 public void orAll(Blackhole bh) {
514 byte[] a = fa.apply(SPECIES.length());
515 byte[] r = fr.apply(SPECIES.length());
516 byte ra = 0;
517
518 for (int ic = 0; ic < INVOC_COUNT; ic++) {
519 for (int i = 0; i < a.length; i += SPECIES.length()) {
520 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
521 r[i] = av.orAll();
522 }
523 }
524
525 for (int ic = 0; ic < INVOC_COUNT; ic++) {
526 ra = 0;
527 for (int i = 0; i < a.length; i += SPECIES.length()) {
528 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
529 ra |= av.orAll();
530 }
531 }
532
533 bh.consume(ra);
534 bh.consume(r);
535 }
536
537
538
539 @Benchmark
540 public void xorAll(Blackhole bh) {
541 byte[] a = fa.apply(SPECIES.length());
542 byte[] r = fr.apply(SPECIES.length());
543 byte ra = 0;
544
545 for (int ic = 0; ic < INVOC_COUNT; ic++) {
546 for (int i = 0; i < a.length; i += SPECIES.length()) {
547 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
548 r[i] = av.xorAll();
549 }
550 }
551
552 for (int ic = 0; ic < INVOC_COUNT; ic++) {
553 ra = 0;
554 for (int i = 0; i < a.length; i += SPECIES.length()) {
555 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
556 ra ^= av.xorAll();
557 }
558 }
559
560 bh.consume(ra);
561 bh.consume(r);
562 }
563
564
565 @Benchmark
566 public void addAll(Blackhole bh) {
567 byte[] a = fa.apply(SPECIES.length());
568 byte[] r = fr.apply(SPECIES.length());
569 byte ra = 0;
570
571 for (int ic = 0; ic < INVOC_COUNT; ic++) {
572 for (int i = 0; i < a.length; i += SPECIES.length()) {
573 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
574 r[i] = av.addAll();
575 }
576 }
577
578 for (int ic = 0; ic < INVOC_COUNT; ic++) {
579 ra = 0;
580 for (int i = 0; i < a.length; i += SPECIES.length()) {
581 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
582 ra += av.addAll();
583 }
584 }
585
586 bh.consume(ra);
587 bh.consume(r);
588 }
589
590 @Benchmark
591 public void mulAll(Blackhole bh) {
592 byte[] a = fa.apply(SPECIES.length());
593 byte[] r = fr.apply(SPECIES.length());
594 byte ra = 1;
595
596 for (int ic = 0; ic < INVOC_COUNT; ic++) {
597 for (int i = 0; i < a.length; i += SPECIES.length()) {
598 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
599 r[i] = av.mulAll();
600 }
601 }
602
603 for (int ic = 0; ic < INVOC_COUNT; ic++) {
604 ra = 1;
605 for (int i = 0; i < a.length; i += SPECIES.length()) {
606 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
607 ra *= av.mulAll();
608 }
609 }
610
611 bh.consume(ra);
612 bh.consume(r);
613 }
614
615 @Benchmark
616 public void minAll(Blackhole bh) {
617 byte[] a = fa.apply(SPECIES.length());
618 byte[] r = fr.apply(SPECIES.length());
619 byte ra = Byte.MAX_VALUE;
620
621 for (int ic = 0; ic < INVOC_COUNT; ic++) {
622 for (int i = 0; i < a.length; i += SPECIES.length()) {
623 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
624 r[i] = av.minAll();
625 }
626 }
627
628 for (int ic = 0; ic < INVOC_COUNT; ic++) {
629 ra = Byte.MAX_VALUE;
630 for (int i = 0; i < a.length; i += SPECIES.length()) {
631 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
632 ra = (byte)Math.min(ra, av.minAll());
633 }
634 }
635
636 bh.consume(ra);
637 bh.consume(r);
638 }
639
640 @Benchmark
641 public void maxAll(Blackhole bh) {
642 byte[] a = fa.apply(SPECIES.length());
643 byte[] r = fr.apply(SPECIES.length());
644 byte ra = Byte.MIN_VALUE;
645
646 for (int ic = 0; ic < INVOC_COUNT; ic++) {
647 for (int i = 0; i < a.length; i += SPECIES.length()) {
648 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
649 r[i] = av.maxAll();
650 }
651 }
652
653 for (int ic = 0; ic < INVOC_COUNT; ic++) {
654 ra = Byte.MIN_VALUE;
655 for (int i = 0; i < a.length; i += SPECIES.length()) {
656 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
657 ra = (byte)Math.max(ra, av.maxAll());
658 }
659 }
660
661 bh.consume(ra);
662 bh.consume(r);
663 }
664
665
666 @Benchmark
667 public void anyTrue(Blackhole bh) {
668 boolean[] mask = fm.apply(SPECIES.length());
669 boolean[] r = fmr.apply(SPECIES.length());
670
671 for (int ic = 0; ic < INVOC_COUNT; ic++) {
672 for (int i = 0; i < mask.length; i += SPECIES.length()) {
673 Vector.Mask<Byte> vmask = ByteVector.maskFromArray(SPECIES, mask, i);
674 r[i] = vmask.anyTrue();
675 }
676 }
677
678 bh.consume(r);
679 }
680
681
682
|
1 /*
2 * Copyright (c) 2018, 2019, 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
21 * questions.
22 */
468 public void min(Blackhole bh) {
469 byte[] a = fa.apply(SPECIES.length());
470 byte[] b = fb.apply(SPECIES.length());
471 byte[] r = fr.apply(SPECIES.length());
472
473 for (int ic = 0; ic < INVOC_COUNT; ic++) {
474 for (int i = 0; i < a.length; i += SPECIES.length()) {
475 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
476 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
477 av.min(bv).intoArray(r, i);
478 }
479 }
480
481 bh.consume(r);
482 }
483
484
485 @Benchmark
486 public void andAll(Blackhole bh) {
487 byte[] a = fa.apply(SPECIES.length());
488 byte ra = -1;
489
490 for (int ic = 0; ic < INVOC_COUNT; ic++) {
491 ra = -1;
492 for (int i = 0; i < a.length; i += SPECIES.length()) {
493 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
494 ra &= av.andAll();
495 }
496 }
497 bh.consume(ra);
498 }
499
500
501
502 @Benchmark
503 public void orAll(Blackhole bh) {
504 byte[] a = fa.apply(SPECIES.length());
505 byte ra = 0;
506
507 for (int ic = 0; ic < INVOC_COUNT; ic++) {
508 ra = 0;
509 for (int i = 0; i < a.length; i += SPECIES.length()) {
510 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
511 ra |= av.orAll();
512 }
513 }
514 bh.consume(ra);
515 }
516
517
518
519 @Benchmark
520 public void xorAll(Blackhole bh) {
521 byte[] a = fa.apply(SPECIES.length());
522 byte ra = 0;
523
524 for (int ic = 0; ic < INVOC_COUNT; ic++) {
525 ra = 0;
526 for (int i = 0; i < a.length; i += SPECIES.length()) {
527 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
528 ra ^= av.xorAll();
529 }
530 }
531 bh.consume(ra);
532 }
533
534
535 @Benchmark
536 public void addAll(Blackhole bh) {
537 byte[] a = fa.apply(SPECIES.length());
538 byte ra = 0;
539
540 for (int ic = 0; ic < INVOC_COUNT; ic++) {
541 ra = 0;
542 for (int i = 0; i < a.length; i += SPECIES.length()) {
543 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
544 ra += av.addAll();
545 }
546 }
547 bh.consume(ra);
548 }
549
550 @Benchmark
551 public void mulAll(Blackhole bh) {
552 byte[] a = fa.apply(SPECIES.length());
553 byte ra = 1;
554
555 for (int ic = 0; ic < INVOC_COUNT; ic++) {
556 ra = 1;
557 for (int i = 0; i < a.length; i += SPECIES.length()) {
558 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
559 ra *= av.mulAll();
560 }
561 }
562 bh.consume(ra);
563 }
564
565 @Benchmark
566 public void minAll(Blackhole bh) {
567 byte[] a = fa.apply(SPECIES.length());
568 byte ra = Byte.MAX_VALUE;
569
570 for (int ic = 0; ic < INVOC_COUNT; ic++) {
571 ra = Byte.MAX_VALUE;
572 for (int i = 0; i < a.length; i += SPECIES.length()) {
573 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
574 ra = (byte)Math.min(ra, av.minAll());
575 }
576 }
577 bh.consume(ra);
578 }
579
580 @Benchmark
581 public void maxAll(Blackhole bh) {
582 byte[] a = fa.apply(SPECIES.length());
583 byte ra = Byte.MIN_VALUE;
584
585 for (int ic = 0; ic < INVOC_COUNT; ic++) {
586 ra = Byte.MIN_VALUE;
587 for (int i = 0; i < a.length; i += SPECIES.length()) {
588 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
589 ra = (byte)Math.max(ra, av.maxAll());
590 }
591 }
592 bh.consume(ra);
593 }
594
595
596 @Benchmark
597 public void anyTrue(Blackhole bh) {
598 boolean[] mask = fm.apply(SPECIES.length());
599 boolean[] r = fmr.apply(SPECIES.length());
600
601 for (int ic = 0; ic < INVOC_COUNT; ic++) {
602 for (int i = 0; i < mask.length; i += SPECIES.length()) {
603 Vector.Mask<Byte> vmask = ByteVector.maskFromArray(SPECIES, mask, i);
604 r[i] = vmask.anyTrue();
605 }
606 }
607
608 bh.consume(r);
609 }
610
611
612
|