647 byte[] a = fa.apply(SPECIES.length());
648 byte[] b = fb.apply(SPECIES.length());
649 byte[] r = fr.apply(SPECIES.length());
650 boolean[] mask = fm.apply(SPECIES.length());
651 VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask);
652
653 for (int ic = 0; ic < INVOC_COUNT; ic++) {
654 for (int i = 0; i < a.length; i += SPECIES.length()) {
655 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
656 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
657 av.xor(bv, vmask).intoArray(r, i);
658 }
659 }
660
661 assertArraysEquals(a, b, r, mask, ByteMaxVectorTests::xor);
662 }
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677 static byte aShiftR_unary(byte a, byte b) {
678 return (byte)((a >> (b & 7)));
679 }
680
681 @Test(dataProvider = "byteBinaryOpProvider")
682 static void aShiftRByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
683 byte[] a = fa.apply(SPECIES.length());
684 byte[] b = fb.apply(SPECIES.length());
685 byte[] r = fr.apply(SPECIES.length());
686
687 for (int ic = 0; ic < INVOC_COUNT; ic++) {
688 for (int i = 0; i < a.length; i += SPECIES.length()) {
689 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
690 av.aShiftR((int)b[i]).intoArray(r, i);
691 }
692 }
693
694 assertShiftArraysEquals(a, b, r, ByteMaxVectorTests::aShiftR_unary);
695 }
696
697
698
699 @Test(dataProvider = "byteBinaryOpMaskProvider")
700 static void aShiftRByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
701 IntFunction<boolean[]> fm) {
702 byte[] a = fa.apply(SPECIES.length());
703 byte[] b = fb.apply(SPECIES.length());
704 byte[] r = fr.apply(SPECIES.length());
705 boolean[] mask = fm.apply(SPECIES.length());
706 VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask);
707
708 for (int ic = 0; ic < INVOC_COUNT; ic++) {
709 for (int i = 0; i < a.length; i += SPECIES.length()) {
710 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
711 av.aShiftR((int)b[i], vmask).intoArray(r, i);
712 }
713 }
714
715 assertShiftArraysEquals(a, b, r, mask, ByteMaxVectorTests::aShiftR_unary);
716 }
717
718
719 static byte shiftL_unary(byte a, byte b) {
720 return (byte)((a << (b & 7)));
721 }
722
723 @Test(dataProvider = "byteBinaryOpProvider")
724 static void shiftLByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
725 byte[] a = fa.apply(SPECIES.length());
726 byte[] b = fb.apply(SPECIES.length());
727 byte[] r = fr.apply(SPECIES.length());
728
729 for (int ic = 0; ic < INVOC_COUNT; ic++) {
730 for (int i = 0; i < a.length; i += SPECIES.length()) {
731 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
732 av.shiftL((int)b[i]).intoArray(r, i);
733 }
734 }
735
736 assertShiftArraysEquals(a, b, r, ByteMaxVectorTests::shiftL_unary);
737 }
738
739
740
741 @Test(dataProvider = "byteBinaryOpMaskProvider")
742 static void shiftLByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
743 IntFunction<boolean[]> fm) {
744 byte[] a = fa.apply(SPECIES.length());
745 byte[] b = fb.apply(SPECIES.length());
746 byte[] r = fr.apply(SPECIES.length());
747 boolean[] mask = fm.apply(SPECIES.length());
748 VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask);
749
750 for (int ic = 0; ic < INVOC_COUNT; ic++) {
751 for (int i = 0; i < a.length; i += SPECIES.length()) {
752 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
753 av.shiftL((int)b[i], vmask).intoArray(r, i);
754 }
755 }
756
757 assertShiftArraysEquals(a, b, r, mask, ByteMaxVectorTests::shiftL_unary);
758 }
759
760
761 static byte shiftR_unary(byte a, byte b) {
762 return (byte)(((a & 0xFF) >>> (b & 7)));
763 }
764
765 @Test(dataProvider = "byteBinaryOpProvider")
766 static void shiftRByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
767 byte[] a = fa.apply(SPECIES.length());
768 byte[] b = fb.apply(SPECIES.length());
769 byte[] 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 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
774 av.shiftR((int)b[i]).intoArray(r, i);
775 }
776 }
777
778 assertShiftArraysEquals(a, b, r, ByteMaxVectorTests::shiftR_unary);
779 }
780
781
782
783 @Test(dataProvider = "byteBinaryOpMaskProvider")
784 static void shiftRByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
785 IntFunction<boolean[]> fm) {
786 byte[] a = fa.apply(SPECIES.length());
787 byte[] b = fb.apply(SPECIES.length());
788 byte[] r = fr.apply(SPECIES.length());
789 boolean[] mask = fm.apply(SPECIES.length());
790 VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask);
791
792 for (int ic = 0; ic < INVOC_COUNT; ic++) {
793 for (int i = 0; i < a.length; i += SPECIES.length()) {
794 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
795 av.shiftR((int)b[i], vmask).intoArray(r, i);
796 }
797 }
798
799 assertShiftArraysEquals(a, b, r, mask, ByteMaxVectorTests::shiftR_unary);
800 }
801
802
803
804
805
806
807
808 static byte max(byte a, byte b) {
809 return (byte)(Math.max(a, b));
810 }
811
812 @Test(dataProvider = "byteBinaryOpProvider")
813 static void maxByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
814 byte[] a = fa.apply(SPECIES.length());
815 byte[] b = fb.apply(SPECIES.length());
816 byte[] r = fr.apply(SPECIES.length());
817
818 for (int ic = 0; ic < INVOC_COUNT; ic++) {
819 for (int i = 0; i < a.length; i += SPECIES.length()) {
820 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
821 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
822 av.max(bv).intoArray(r, i);
823 }
824 }
829 return (byte)(Math.min(a, b));
830 }
831
832 @Test(dataProvider = "byteBinaryOpProvider")
833 static void minByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
834 byte[] a = fa.apply(SPECIES.length());
835 byte[] b = fb.apply(SPECIES.length());
836 byte[] r = fr.apply(SPECIES.length());
837
838 for (int ic = 0; ic < INVOC_COUNT; ic++) {
839 for (int i = 0; i < a.length; i += SPECIES.length()) {
840 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
841 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
842 av.min(bv).intoArray(r, i);
843 }
844 }
845
846 assertArraysEquals(a, b, r, ByteMaxVectorTests::min);
847 }
848
849 static byte andAll(byte[] a, int idx) {
850 byte res = -1;
851 for (int i = idx; i < (idx + SPECIES.length()); i++) {
852 res &= a[i];
853 }
854
855 return res;
856 }
857
858 static byte andAll(byte[] a) {
859 byte res = -1;
860 for (int i = 0; i < a.length; i += SPECIES.length()) {
861 byte tmp = -1;
862 for (int j = 0; j < SPECIES.length(); j++) {
863 tmp &= a[i + j];
864 }
865 res &= tmp;
866 }
867
868 return res;
869 }
870
871
872 @Test(dataProvider = "byteUnaryOpProvider")
873 static void andAllByteMaxVectorTests(IntFunction<byte[]> fa) {
874 byte[] a = fa.apply(SPECIES.length());
875 byte[] r = fr.apply(SPECIES.length());
876 byte ra = -1;
877
878 for (int ic = 0; ic < INVOC_COUNT; ic++) {
879 for (int i = 0; i < a.length; i += SPECIES.length()) {
880 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
881 r[i] = av.andAll();
882 }
883 }
884
885 for (int ic = 0; ic < INVOC_COUNT; ic++) {
886 ra = -1;
887 for (int i = 0; i < a.length; i += SPECIES.length()) {
888 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
889 ra &= av.andAll();
890 }
891 }
892
893 assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::andAll, ByteMaxVectorTests::andAll);
894 }
895
896
897 static byte orAll(byte[] a, int idx) {
898 byte res = 0;
899 for (int i = idx; i < (idx + SPECIES.length()); i++) {
900 res |= a[i];
901 }
902
903 return res;
904 }
905
906 static byte orAll(byte[] a) {
907 byte res = 0;
908 for (int i = 0; i < a.length; i += SPECIES.length()) {
909 byte tmp = 0;
910 for (int j = 0; j < SPECIES.length(); j++) {
911 tmp |= a[i + j];
912 }
913 res |= tmp;
914 }
915
916 return res;
917 }
918
919
920 @Test(dataProvider = "byteUnaryOpProvider")
921 static void orAllByteMaxVectorTests(IntFunction<byte[]> fa) {
922 byte[] a = fa.apply(SPECIES.length());
923 byte[] r = fr.apply(SPECIES.length());
924 byte ra = 0;
925
926 for (int ic = 0; ic < INVOC_COUNT; ic++) {
927 for (int i = 0; i < a.length; i += SPECIES.length()) {
928 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
929 r[i] = av.orAll();
930 }
931 }
932
933 for (int ic = 0; ic < INVOC_COUNT; ic++) {
934 ra = 0;
935 for (int i = 0; i < a.length; i += SPECIES.length()) {
936 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
937 ra |= av.orAll();
938 }
939 }
940
941 assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::orAll, ByteMaxVectorTests::orAll);
942 }
943
944
945 static byte xorAll(byte[] a, int idx) {
946 byte res = 0;
947 for (int i = idx; i < (idx + SPECIES.length()); i++) {
948 res ^= a[i];
949 }
950
951 return res;
952 }
953
954 static byte xorAll(byte[] a) {
955 byte res = 0;
956 for (int i = 0; i < a.length; i += SPECIES.length()) {
957 byte tmp = 0;
958 for (int j = 0; j < SPECIES.length(); j++) {
959 tmp ^= a[i + j];
960 }
961 res ^= tmp;
962 }
963
964 return res;
965 }
966
967
968 @Test(dataProvider = "byteUnaryOpProvider")
969 static void xorAllByteMaxVectorTests(IntFunction<byte[]> fa) {
970 byte[] a = fa.apply(SPECIES.length());
971 byte[] r = fr.apply(SPECIES.length());
972 byte ra = 0;
973
974 for (int ic = 0; ic < INVOC_COUNT; ic++) {
975 for (int i = 0; i < a.length; i += SPECIES.length()) {
976 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
977 r[i] = av.xorAll();
978 }
979 }
980
981 for (int ic = 0; ic < INVOC_COUNT; ic++) {
982 ra = 0;
983 for (int i = 0; i < a.length; i += SPECIES.length()) {
984 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
985 ra ^= av.xorAll();
986 }
987 }
988
989 assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::xorAll, ByteMaxVectorTests::xorAll);
990 }
991
992 static byte addAll(byte[] a, int idx) {
993 byte res = 0;
994 for (int i = idx; i < (idx + SPECIES.length()); i++) {
995 res += a[i];
996 }
997
998 return res;
999 }
1000
1001 static byte addAll(byte[] a) {
1002 byte res = 0;
1003 for (int i = 0; i < a.length; i += SPECIES.length()) {
1004 byte tmp = 0;
1005 for (int j = 0; j < SPECIES.length(); j++) {
1006 tmp += a[i + j];
1007 }
1008 res += tmp;
1009 }
1010
1011 return res;
1012 }
1013 @Test(dataProvider = "byteUnaryOpProvider")
1014 static void addAllByteMaxVectorTests(IntFunction<byte[]> fa) {
1015 byte[] a = fa.apply(SPECIES.length());
1016 byte[] r = fr.apply(SPECIES.length());
1017 byte ra = 0;
1018
1019 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1020 for (int i = 0; i < a.length; i += SPECIES.length()) {
1021 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1022 r[i] = av.addAll();
1023 }
1024 }
1025
1026 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1027 ra = 0;
1028 for (int i = 0; i < a.length; i += SPECIES.length()) {
1029 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1030 ra += av.addAll();
1031 }
1032 }
1033
1034 assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::addAll, ByteMaxVectorTests::addAll);
1035 }
1036 static byte mulAll(byte[] a, int idx) {
1037 byte res = 1;
1038 for (int i = idx; i < (idx + SPECIES.length()); i++) {
1039 res *= a[i];
1040 }
1041
1042 return res;
1043 }
1044
1045 static byte mulAll(byte[] a) {
1046 byte res = 1;
1047 for (int i = 0; i < a.length; i += SPECIES.length()) {
1048 byte tmp = 1;
1049 for (int j = 0; j < SPECIES.length(); j++) {
1050 tmp *= a[i + j];
1051 }
1052 res *= tmp;
1053 }
1054
1055 return res;
1056 }
1057 @Test(dataProvider = "byteUnaryOpProvider")
1058 static void mulAllByteMaxVectorTests(IntFunction<byte[]> fa) {
1059 byte[] a = fa.apply(SPECIES.length());
1060 byte[] r = fr.apply(SPECIES.length());
1061 byte ra = 1;
1062
1063 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1064 for (int i = 0; i < a.length; i += SPECIES.length()) {
1065 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1066 r[i] = av.mulAll();
1067 }
1068 }
1069
1070 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1071 ra = 1;
1072 for (int i = 0; i < a.length; i += SPECIES.length()) {
1073 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1074 ra *= av.mulAll();
1075 }
1076 }
1077
1078 assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::mulAll, ByteMaxVectorTests::mulAll);
1079 }
1080 static byte minAll(byte[] a, int idx) {
1081 byte res = Byte.MAX_VALUE;
1082 for (int i = idx; i < (idx + SPECIES.length()); i++) {
1083 res = (byte)Math.min(res, a[i]);
1084 }
1085
1086 return res;
1087 }
1088
1089 static byte minAll(byte[] a) {
1090 byte res = Byte.MAX_VALUE;
1091 for (int i = 0; i < a.length; i++) {
1092 res = (byte)Math.min(res, a[i]);
1093 }
1094
1095 return res;
1096 }
1097 @Test(dataProvider = "byteUnaryOpProvider")
1098 static void minAllByteMaxVectorTests(IntFunction<byte[]> fa) {
1099 byte[] a = fa.apply(SPECIES.length());
1100 byte[] r = fr.apply(SPECIES.length());
1101 byte ra = Byte.MAX_VALUE;
1102
1103 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1104 for (int i = 0; i < a.length; i += SPECIES.length()) {
1105 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1106 r[i] = av.minAll();
1107 }
1108 }
1109
1110 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1111 ra = Byte.MAX_VALUE;
1112 for (int i = 0; i < a.length; i += SPECIES.length()) {
1113 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1114 ra = (byte)Math.min(ra, av.minAll());
1115 }
1116 }
1117
1118 assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::minAll, ByteMaxVectorTests::minAll);
1119 }
1120 static byte maxAll(byte[] a, int idx) {
1121 byte res = Byte.MIN_VALUE;
1122 for (int i = idx; i < (idx + SPECIES.length()); i++) {
1123 res = (byte)Math.max(res, a[i]);
1124 }
1125
1126 return res;
1127 }
1128
1129 static byte maxAll(byte[] a) {
1130 byte res = Byte.MIN_VALUE;
1131 for (int i = 0; i < a.length; i++) {
1132 res = (byte)Math.max(res, a[i]);
1133 }
1134
1135 return res;
1136 }
1137 @Test(dataProvider = "byteUnaryOpProvider")
1138 static void maxAllByteMaxVectorTests(IntFunction<byte[]> fa) {
1139 byte[] a = fa.apply(SPECIES.length());
1140 byte[] r = fr.apply(SPECIES.length());
1141 byte ra = Byte.MIN_VALUE;
1142
1143 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1144 for (int i = 0; i < a.length; i += SPECIES.length()) {
1145 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1146 r[i] = av.maxAll();
1147 }
1148 }
1149
1150 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1151 ra = Byte.MIN_VALUE;
1152 for (int i = 0; i < a.length; i += SPECIES.length()) {
1153 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1154 ra = (byte)Math.max(ra, av.maxAll());
1155 }
1156 }
1157
1158 assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::maxAll, ByteMaxVectorTests::maxAll);
1159 }
1160
1161 static boolean anyTrue(boolean[] a, int idx) {
1162 boolean res = false;
1163 for (int i = idx; i < (idx + SPECIES.length()); i++) {
1164 res |= a[i];
1165 }
1166
1167 return res;
1168 }
1169
1170
1171 @Test(dataProvider = "boolUnaryOpProvider")
1172 static void anyTrueByteMaxVectorTests(IntFunction<boolean[]> fm) {
1173 boolean[] mask = fm.apply(SPECIES.length());
1174 boolean[] r = fmr.apply(SPECIES.length());
1175
1176 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1177 for (int i = 0; i < mask.length; i += SPECIES.length()) {
1178 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, i);
|
647 byte[] a = fa.apply(SPECIES.length());
648 byte[] b = fb.apply(SPECIES.length());
649 byte[] r = fr.apply(SPECIES.length());
650 boolean[] mask = fm.apply(SPECIES.length());
651 VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask);
652
653 for (int ic = 0; ic < INVOC_COUNT; ic++) {
654 for (int i = 0; i < a.length; i += SPECIES.length()) {
655 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
656 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
657 av.xor(bv, vmask).intoArray(r, i);
658 }
659 }
660
661 assertArraysEquals(a, b, r, mask, ByteMaxVectorTests::xor);
662 }
663
664
665
666
667 static byte shiftLeft(byte a, byte b) {
668 return (byte)((a << (b & 0x7)));
669 }
670
671 @Test(dataProvider = "byteBinaryOpProvider")
672 static void shiftLeftByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
673 byte[] a = fa.apply(SPECIES.length());
674 byte[] b = fb.apply(SPECIES.length());
675 byte[] r = fr.apply(SPECIES.length());
676
677 for (int ic = 0; ic < INVOC_COUNT; ic++) {
678 for (int i = 0; i < a.length; i += SPECIES.length()) {
679 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
680 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
681 av.shiftLeft(bv).intoArray(r, i);
682 }
683 }
684
685 assertArraysEquals(a, b, r, ByteMaxVectorTests::shiftLeft);
686 }
687
688
689
690 @Test(dataProvider = "byteBinaryOpMaskProvider")
691 static void shiftLeftByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
692 IntFunction<boolean[]> fm) {
693 byte[] a = fa.apply(SPECIES.length());
694 byte[] b = fb.apply(SPECIES.length());
695 byte[] r = fr.apply(SPECIES.length());
696 boolean[] mask = fm.apply(SPECIES.length());
697 VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask);
698
699 for (int ic = 0; ic < INVOC_COUNT; ic++) {
700 for (int i = 0; i < a.length; i += SPECIES.length()) {
701 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
702 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
703 av.shiftLeft(bv, vmask).intoArray(r, i);
704 }
705 }
706
707 assertArraysEquals(a, b, r, mask, ByteMaxVectorTests::shiftLeft);
708 }
709
710
711
712
713
714
715 static byte shiftRight(byte a, byte b) {
716 return (byte)((a >>> (b & 0x7)));
717 }
718
719 @Test(dataProvider = "byteBinaryOpProvider")
720 static void shiftRightByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
721 byte[] a = fa.apply(SPECIES.length());
722 byte[] b = fb.apply(SPECIES.length());
723 byte[] r = fr.apply(SPECIES.length());
724
725 for (int ic = 0; ic < INVOC_COUNT; ic++) {
726 for (int i = 0; i < a.length; i += SPECIES.length()) {
727 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
728 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
729 av.shiftRight(bv).intoArray(r, i);
730 }
731 }
732
733 assertArraysEquals(a, b, r, ByteMaxVectorTests::shiftRight);
734 }
735
736
737
738 @Test(dataProvider = "byteBinaryOpMaskProvider")
739 static void shiftRightByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
740 IntFunction<boolean[]> fm) {
741 byte[] a = fa.apply(SPECIES.length());
742 byte[] b = fb.apply(SPECIES.length());
743 byte[] r = fr.apply(SPECIES.length());
744 boolean[] mask = fm.apply(SPECIES.length());
745 VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask);
746
747 for (int ic = 0; ic < INVOC_COUNT; ic++) {
748 for (int i = 0; i < a.length; i += SPECIES.length()) {
749 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
750 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
751 av.shiftRight(bv, vmask).intoArray(r, i);
752 }
753 }
754
755 assertArraysEquals(a, b, r, mask, ByteMaxVectorTests::shiftRight);
756 }
757
758
759
760
761
762
763 static byte shiftArithmeticRight(byte a, byte b) {
764 return (byte)((a >> (b & 0x7)));
765 }
766
767 @Test(dataProvider = "byteBinaryOpProvider")
768 static void shiftArithmeticRightByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
769 byte[] a = fa.apply(SPECIES.length());
770 byte[] b = fb.apply(SPECIES.length());
771 byte[] r = fr.apply(SPECIES.length());
772
773 for (int ic = 0; ic < INVOC_COUNT; ic++) {
774 for (int i = 0; i < a.length; i += SPECIES.length()) {
775 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
776 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
777 av.shiftArithmeticRight(bv).intoArray(r, i);
778 }
779 }
780
781 assertArraysEquals(a, b, r, ByteMaxVectorTests::shiftArithmeticRight);
782 }
783
784
785
786 @Test(dataProvider = "byteBinaryOpMaskProvider")
787 static void shiftArithmeticRightByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
788 IntFunction<boolean[]> fm) {
789 byte[] a = fa.apply(SPECIES.length());
790 byte[] b = fb.apply(SPECIES.length());
791 byte[] r = fr.apply(SPECIES.length());
792 boolean[] mask = fm.apply(SPECIES.length());
793 VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask);
794
795 for (int ic = 0; ic < INVOC_COUNT; ic++) {
796 for (int i = 0; i < a.length; i += SPECIES.length()) {
797 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
798 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
799 av.shiftArithmeticRight(bv, vmask).intoArray(r, i);
800 }
801 }
802
803 assertArraysEquals(a, b, r, mask, ByteMaxVectorTests::shiftArithmeticRight);
804 }
805
806
807
808
809
810
811 static byte shiftLeft_unary(byte a, byte b) {
812 return (byte)((a << (b & 7)));
813 }
814
815 @Test(dataProvider = "byteBinaryOpProvider")
816 static void shiftLeftByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
817 byte[] a = fa.apply(SPECIES.length());
818 byte[] b = fb.apply(SPECIES.length());
819 byte[] r = fr.apply(SPECIES.length());
820
821 for (int ic = 0; ic < INVOC_COUNT; ic++) {
822 for (int i = 0; i < a.length; i += SPECIES.length()) {
823 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
824 av.shiftLeft((int)b[i]).intoArray(r, i);
825 }
826 }
827
828 assertShiftArraysEquals(a, b, r, ByteMaxVectorTests::shiftLeft_unary);
829 }
830
831
832
833 @Test(dataProvider = "byteBinaryOpMaskProvider")
834 static void shiftLeftByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
835 IntFunction<boolean[]> fm) {
836 byte[] a = fa.apply(SPECIES.length());
837 byte[] b = fb.apply(SPECIES.length());
838 byte[] r = fr.apply(SPECIES.length());
839 boolean[] mask = fm.apply(SPECIES.length());
840 VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask);
841
842 for (int ic = 0; ic < INVOC_COUNT; ic++) {
843 for (int i = 0; i < a.length; i += SPECIES.length()) {
844 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
845 av.shiftLeft((int)b[i], vmask).intoArray(r, i);
846 }
847 }
848
849 assertShiftArraysEquals(a, b, r, mask, ByteMaxVectorTests::shiftLeft_unary);
850 }
851
852
853
854
855
856
857 static byte shiftRight_unary(byte a, byte b) {
858 return (byte)(((a & 0xFF) >>> (b & 7)));
859 }
860
861 @Test(dataProvider = "byteBinaryOpProvider")
862 static void shiftRightByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
863 byte[] a = fa.apply(SPECIES.length());
864 byte[] b = fb.apply(SPECIES.length());
865 byte[] r = fr.apply(SPECIES.length());
866
867 for (int ic = 0; ic < INVOC_COUNT; ic++) {
868 for (int i = 0; i < a.length; i += SPECIES.length()) {
869 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
870 av.shiftRight((int)b[i]).intoArray(r, i);
871 }
872 }
873
874 assertShiftArraysEquals(a, b, r, ByteMaxVectorTests::shiftRight_unary);
875 }
876
877
878
879 @Test(dataProvider = "byteBinaryOpMaskProvider")
880 static void shiftRightByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
881 IntFunction<boolean[]> fm) {
882 byte[] a = fa.apply(SPECIES.length());
883 byte[] b = fb.apply(SPECIES.length());
884 byte[] r = fr.apply(SPECIES.length());
885 boolean[] mask = fm.apply(SPECIES.length());
886 VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask);
887
888 for (int ic = 0; ic < INVOC_COUNT; ic++) {
889 for (int i = 0; i < a.length; i += SPECIES.length()) {
890 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
891 av.shiftRight((int)b[i], vmask).intoArray(r, i);
892 }
893 }
894
895 assertShiftArraysEquals(a, b, r, mask, ByteMaxVectorTests::shiftRight_unary);
896 }
897
898
899
900
901
902
903 static byte shiftArithmeticRight_unary(byte a, byte b) {
904 return (byte)((a >> (b & 7)));
905 }
906
907 @Test(dataProvider = "byteBinaryOpProvider")
908 static void shiftArithmeticRightByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
909 byte[] a = fa.apply(SPECIES.length());
910 byte[] b = fb.apply(SPECIES.length());
911 byte[] r = fr.apply(SPECIES.length());
912
913 for (int ic = 0; ic < INVOC_COUNT; ic++) {
914 for (int i = 0; i < a.length; i += SPECIES.length()) {
915 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
916 av.shiftArithmeticRight((int)b[i]).intoArray(r, i);
917 }
918 }
919
920 assertShiftArraysEquals(a, b, r, ByteMaxVectorTests::shiftArithmeticRight_unary);
921 }
922
923
924
925 @Test(dataProvider = "byteBinaryOpMaskProvider")
926 static void shiftArithmeticRightByteMaxVectorTestsShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
927 IntFunction<boolean[]> fm) {
928 byte[] a = fa.apply(SPECIES.length());
929 byte[] b = fb.apply(SPECIES.length());
930 byte[] r = fr.apply(SPECIES.length());
931 boolean[] mask = fm.apply(SPECIES.length());
932 VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask);
933
934 for (int ic = 0; ic < INVOC_COUNT; ic++) {
935 for (int i = 0; i < a.length; i += SPECIES.length()) {
936 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
937 av.shiftArithmeticRight((int)b[i], vmask).intoArray(r, i);
938 }
939 }
940
941 assertShiftArraysEquals(a, b, r, mask, ByteMaxVectorTests::shiftArithmeticRight_unary);
942 }
943
944
945
946 static byte max(byte a, byte b) {
947 return (byte)(Math.max(a, b));
948 }
949
950 @Test(dataProvider = "byteBinaryOpProvider")
951 static void maxByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
952 byte[] a = fa.apply(SPECIES.length());
953 byte[] b = fb.apply(SPECIES.length());
954 byte[] r = fr.apply(SPECIES.length());
955
956 for (int ic = 0; ic < INVOC_COUNT; ic++) {
957 for (int i = 0; i < a.length; i += SPECIES.length()) {
958 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
959 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
960 av.max(bv).intoArray(r, i);
961 }
962 }
967 return (byte)(Math.min(a, b));
968 }
969
970 @Test(dataProvider = "byteBinaryOpProvider")
971 static void minByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
972 byte[] a = fa.apply(SPECIES.length());
973 byte[] b = fb.apply(SPECIES.length());
974 byte[] r = fr.apply(SPECIES.length());
975
976 for (int ic = 0; ic < INVOC_COUNT; ic++) {
977 for (int i = 0; i < a.length; i += SPECIES.length()) {
978 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
979 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
980 av.min(bv).intoArray(r, i);
981 }
982 }
983
984 assertArraysEquals(a, b, r, ByteMaxVectorTests::min);
985 }
986
987 static byte andLanes(byte[] a, int idx) {
988 byte res = -1;
989 for (int i = idx; i < (idx + SPECIES.length()); i++) {
990 res &= a[i];
991 }
992
993 return res;
994 }
995
996 static byte andLanes(byte[] a) {
997 byte res = -1;
998 for (int i = 0; i < a.length; i += SPECIES.length()) {
999 byte tmp = -1;
1000 for (int j = 0; j < SPECIES.length(); j++) {
1001 tmp &= a[i + j];
1002 }
1003 res &= tmp;
1004 }
1005
1006 return res;
1007 }
1008
1009
1010 @Test(dataProvider = "byteUnaryOpProvider")
1011 static void andLanesByteMaxVectorTests(IntFunction<byte[]> fa) {
1012 byte[] a = fa.apply(SPECIES.length());
1013 byte[] r = fr.apply(SPECIES.length());
1014 byte ra = -1;
1015
1016 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1017 for (int i = 0; i < a.length; i += SPECIES.length()) {
1018 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1019 r[i] = av.andLanes();
1020 }
1021 }
1022
1023 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1024 ra = -1;
1025 for (int i = 0; i < a.length; i += SPECIES.length()) {
1026 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1027 ra &= av.andLanes();
1028 }
1029 }
1030
1031 assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::andLanes, ByteMaxVectorTests::andLanes);
1032 }
1033
1034
1035 static byte orLanes(byte[] a, int idx) {
1036 byte res = 0;
1037 for (int i = idx; i < (idx + SPECIES.length()); i++) {
1038 res |= a[i];
1039 }
1040
1041 return res;
1042 }
1043
1044 static byte orLanes(byte[] a) {
1045 byte res = 0;
1046 for (int i = 0; i < a.length; i += SPECIES.length()) {
1047 byte tmp = 0;
1048 for (int j = 0; j < SPECIES.length(); j++) {
1049 tmp |= a[i + j];
1050 }
1051 res |= tmp;
1052 }
1053
1054 return res;
1055 }
1056
1057
1058 @Test(dataProvider = "byteUnaryOpProvider")
1059 static void orLanesByteMaxVectorTests(IntFunction<byte[]> fa) {
1060 byte[] a = fa.apply(SPECIES.length());
1061 byte[] r = fr.apply(SPECIES.length());
1062 byte ra = 0;
1063
1064 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1065 for (int i = 0; i < a.length; i += SPECIES.length()) {
1066 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1067 r[i] = av.orLanes();
1068 }
1069 }
1070
1071 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1072 ra = 0;
1073 for (int i = 0; i < a.length; i += SPECIES.length()) {
1074 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1075 ra |= av.orLanes();
1076 }
1077 }
1078
1079 assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::orLanes, ByteMaxVectorTests::orLanes);
1080 }
1081
1082
1083 static byte xorLanes(byte[] a, int idx) {
1084 byte res = 0;
1085 for (int i = idx; i < (idx + SPECIES.length()); i++) {
1086 res ^= a[i];
1087 }
1088
1089 return res;
1090 }
1091
1092 static byte xorLanes(byte[] a) {
1093 byte res = 0;
1094 for (int i = 0; i < a.length; i += SPECIES.length()) {
1095 byte tmp = 0;
1096 for (int j = 0; j < SPECIES.length(); j++) {
1097 tmp ^= a[i + j];
1098 }
1099 res ^= tmp;
1100 }
1101
1102 return res;
1103 }
1104
1105
1106 @Test(dataProvider = "byteUnaryOpProvider")
1107 static void xorLanesByteMaxVectorTests(IntFunction<byte[]> fa) {
1108 byte[] a = fa.apply(SPECIES.length());
1109 byte[] r = fr.apply(SPECIES.length());
1110 byte ra = 0;
1111
1112 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1113 for (int i = 0; i < a.length; i += SPECIES.length()) {
1114 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1115 r[i] = av.xorLanes();
1116 }
1117 }
1118
1119 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1120 ra = 0;
1121 for (int i = 0; i < a.length; i += SPECIES.length()) {
1122 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1123 ra ^= av.xorLanes();
1124 }
1125 }
1126
1127 assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::xorLanes, ByteMaxVectorTests::xorLanes);
1128 }
1129
1130 static byte addLanes(byte[] a, int idx) {
1131 byte res = 0;
1132 for (int i = idx; i < (idx + SPECIES.length()); i++) {
1133 res += a[i];
1134 }
1135
1136 return res;
1137 }
1138
1139 static byte addLanes(byte[] a) {
1140 byte res = 0;
1141 for (int i = 0; i < a.length; i += SPECIES.length()) {
1142 byte tmp = 0;
1143 for (int j = 0; j < SPECIES.length(); j++) {
1144 tmp += a[i + j];
1145 }
1146 res += tmp;
1147 }
1148
1149 return res;
1150 }
1151 @Test(dataProvider = "byteUnaryOpProvider")
1152 static void addLanesByteMaxVectorTests(IntFunction<byte[]> fa) {
1153 byte[] a = fa.apply(SPECIES.length());
1154 byte[] r = fr.apply(SPECIES.length());
1155 byte ra = 0;
1156
1157 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1158 for (int i = 0; i < a.length; i += SPECIES.length()) {
1159 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1160 r[i] = av.addLanes();
1161 }
1162 }
1163
1164 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1165 ra = 0;
1166 for (int i = 0; i < a.length; i += SPECIES.length()) {
1167 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1168 ra += av.addLanes();
1169 }
1170 }
1171
1172 assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::addLanes, ByteMaxVectorTests::addLanes);
1173 }
1174 static byte mulLanes(byte[] a, int idx) {
1175 byte res = 1;
1176 for (int i = idx; i < (idx + SPECIES.length()); i++) {
1177 res *= a[i];
1178 }
1179
1180 return res;
1181 }
1182
1183 static byte mulLanes(byte[] a) {
1184 byte res = 1;
1185 for (int i = 0; i < a.length; i += SPECIES.length()) {
1186 byte tmp = 1;
1187 for (int j = 0; j < SPECIES.length(); j++) {
1188 tmp *= a[i + j];
1189 }
1190 res *= tmp;
1191 }
1192
1193 return res;
1194 }
1195 @Test(dataProvider = "byteUnaryOpProvider")
1196 static void mulLanesByteMaxVectorTests(IntFunction<byte[]> fa) {
1197 byte[] a = fa.apply(SPECIES.length());
1198 byte[] r = fr.apply(SPECIES.length());
1199 byte ra = 1;
1200
1201 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1202 for (int i = 0; i < a.length; i += SPECIES.length()) {
1203 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1204 r[i] = av.mulLanes();
1205 }
1206 }
1207
1208 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1209 ra = 1;
1210 for (int i = 0; i < a.length; i += SPECIES.length()) {
1211 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1212 ra *= av.mulLanes();
1213 }
1214 }
1215
1216 assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::mulLanes, ByteMaxVectorTests::mulLanes);
1217 }
1218 static byte minLanes(byte[] a, int idx) {
1219 byte res = Byte.MAX_VALUE;
1220 for (int i = idx; i < (idx + SPECIES.length()); i++) {
1221 res = (byte)Math.min(res, a[i]);
1222 }
1223
1224 return res;
1225 }
1226
1227 static byte minLanes(byte[] a) {
1228 byte res = Byte.MAX_VALUE;
1229 for (int i = 0; i < a.length; i++) {
1230 res = (byte)Math.min(res, a[i]);
1231 }
1232
1233 return res;
1234 }
1235 @Test(dataProvider = "byteUnaryOpProvider")
1236 static void minLanesByteMaxVectorTests(IntFunction<byte[]> fa) {
1237 byte[] a = fa.apply(SPECIES.length());
1238 byte[] r = fr.apply(SPECIES.length());
1239 byte ra = Byte.MAX_VALUE;
1240
1241 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1242 for (int i = 0; i < a.length; i += SPECIES.length()) {
1243 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1244 r[i] = av.minLanes();
1245 }
1246 }
1247
1248 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1249 ra = Byte.MAX_VALUE;
1250 for (int i = 0; i < a.length; i += SPECIES.length()) {
1251 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1252 ra = (byte)Math.min(ra, av.minLanes());
1253 }
1254 }
1255
1256 assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::minLanes, ByteMaxVectorTests::minLanes);
1257 }
1258 static byte maxLanes(byte[] a, int idx) {
1259 byte res = Byte.MIN_VALUE;
1260 for (int i = idx; i < (idx + SPECIES.length()); i++) {
1261 res = (byte)Math.max(res, a[i]);
1262 }
1263
1264 return res;
1265 }
1266
1267 static byte maxLanes(byte[] a) {
1268 byte res = Byte.MIN_VALUE;
1269 for (int i = 0; i < a.length; i++) {
1270 res = (byte)Math.max(res, a[i]);
1271 }
1272
1273 return res;
1274 }
1275 @Test(dataProvider = "byteUnaryOpProvider")
1276 static void maxLanesByteMaxVectorTests(IntFunction<byte[]> fa) {
1277 byte[] a = fa.apply(SPECIES.length());
1278 byte[] r = fr.apply(SPECIES.length());
1279 byte ra = Byte.MIN_VALUE;
1280
1281 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1282 for (int i = 0; i < a.length; i += SPECIES.length()) {
1283 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1284 r[i] = av.maxLanes();
1285 }
1286 }
1287
1288 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1289 ra = Byte.MIN_VALUE;
1290 for (int i = 0; i < a.length; i += SPECIES.length()) {
1291 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1292 ra = (byte)Math.max(ra, av.maxLanes());
1293 }
1294 }
1295
1296 assertReductionArraysEquals(a, r, ra, ByteMaxVectorTests::maxLanes, ByteMaxVectorTests::maxLanes);
1297 }
1298
1299 static boolean anyTrue(boolean[] a, int idx) {
1300 boolean res = false;
1301 for (int i = idx; i < (idx + SPECIES.length()); i++) {
1302 res |= a[i];
1303 }
1304
1305 return res;
1306 }
1307
1308
1309 @Test(dataProvider = "boolUnaryOpProvider")
1310 static void anyTrueByteMaxVectorTests(IntFunction<boolean[]> fm) {
1311 boolean[] mask = fm.apply(SPECIES.length());
1312 boolean[] r = fmr.apply(SPECIES.length());
1313
1314 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1315 for (int i = 0; i < mask.length; i += SPECIES.length()) {
1316 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, i);
|