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