< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java

Print this page




1090 
1091     @Override
1092     void forEach(VectorMask<Integer> o, FUnCon f) {
1093         boolean[] mbits = ((Int512Mask)o).getBits();
1094         forEach((i, a) -> {
1095             if (mbits[i]) { f.apply(i, a); }
1096         });
1097     }
1098 
1099 
1100     Float512Vector toFP() {
1101         int[] vec = getElements();
1102         float[] res = new float[this.species().length()];
1103         for(int i = 0; i < this.species().length(); i++){
1104             res[i] = Float.intBitsToFloat(vec[i]);
1105         }
1106         return new Float512Vector(res);
1107     }
1108 
1109     @Override

1110     public Int512Vector rotateLanesLeft(int j) {
1111         int[] vec = getElements();
1112         int[] res = new int[length()];
1113         for (int i = 0; i < length(); i++){
1114             res[(j + i) % length()] = vec[i];



1115         }
1116         return new Int512Vector(res);
1117     }
1118 
1119     @Override

1120     public Int512Vector rotateLanesRight(int j) {
1121         int[] vec = getElements();
1122         int[] res = new int[length()];
1123         for (int i = 0; i < length(); i++){
1124             int z = i - j;
1125             if(j < 0) {
1126                 res[length() + z] = vec[i];
1127             } else {
1128                 res[z] = vec[i];
1129             }

1130         }
1131         return new Int512Vector(res);
1132     }
1133 
1134     @Override


1135     public Int512Vector shiftLanesLeft(int j) {
1136         int[] vec = getElements();
1137         int[] res = new int[length()];
1138         for (int i = 0; i < length() - j; i++) {
1139             res[i] = vec[i + j];






1140         }
1141         return new Int512Vector(res);
1142     }
1143 
1144     @Override


1145     public Int512Vector shiftLanesRight(int j) {
1146         int[] vec = getElements();
1147         int[] res = new int[length()];
1148         for (int i = 0; i < length() - j; i++){
1149             res[i + j] = vec[i];






1150         }
1151         return new Int512Vector(res);
1152     }
1153 
1154     @Override
1155     @ForceInline
1156     public Int512Vector rearrange(Vector<Integer> v,
1157                                   VectorShuffle<Integer> s, VectorMask<Integer> m) {
1158         return this.rearrange(s).blend(v.rearrange(s), m);
1159     }
1160 
1161     @Override
1162     @ForceInline
1163     public Int512Vector rearrange(VectorShuffle<Integer> o1) {
1164         Objects.requireNonNull(o1);
1165         Int512Shuffle s =  (Int512Shuffle)o1;
1166 
1167         return VectorIntrinsics.rearrangeOp(
1168             Int512Vector.class, Int512Shuffle.class, int.class, LENGTH,
1169             this, s,
1170             (v1, s_) -> v1.uOp((i, a) -> {
1171                 int ei = s_.lane(i);


1370             super(reorder);
1371         }
1372 
1373         public Int512Shuffle(int[] reorder) {
1374             super(reorder);
1375         }
1376 
1377         public Int512Shuffle(int[] reorder, int i) {
1378             super(reorder, i);
1379         }
1380 
1381         public Int512Shuffle(IntUnaryOperator f) {
1382             super(f);
1383         }
1384 
1385         @Override
1386         public VectorSpecies<Integer> species() {
1387             return SPECIES;
1388         }
1389 
1390         @Override
1391         public IntVector toVector() {
1392             int[] va = new int[SPECIES.length()];
1393             for (int i = 0; i < va.length; i++) {
1394               va[i] = (int) lane(i);
1395             }
1396             return IntVector.fromArray(SPECIES, va, 0);
1397         }
1398 
1399         @Override
1400         @ForceInline








1401         @SuppressWarnings("unchecked")
1402         public <F> VectorShuffle<F> cast(VectorSpecies<F> species) {
1403             if (length() != species.length())
1404                 throw new IllegalArgumentException("Shuffle length and species length differ");
1405             Class<?> stype = species.elementType();
1406             int [] shuffleArray = toArray();
1407             if (stype == byte.class) {
1408                 return (VectorShuffle<F>) new Byte512Vector.Byte512Shuffle(shuffleArray);
1409             } else if (stype == short.class) {
1410                 return (VectorShuffle<F>) new Short512Vector.Short512Shuffle(shuffleArray);
1411             } else if (stype == int.class) {
1412                 return (VectorShuffle<F>) new Int512Vector.Int512Shuffle(shuffleArray);
1413             } else if (stype == long.class) {
1414                 return (VectorShuffle<F>) new Long512Vector.Long512Shuffle(shuffleArray);
1415             } else if (stype == float.class) {
1416                 return (VectorShuffle<F>) new Float512Vector.Float512Shuffle(shuffleArray);
1417             } else if (stype == double.class) {
1418                 return (VectorShuffle<F>) new Double512Vector.Double512Shuffle(shuffleArray);
1419             } else {
1420                 throw new UnsupportedOperationException("Bad lane type for casting.");
1421             }
1422         }

1423 
1424         @Override
1425         public Int512Shuffle rearrange(VectorShuffle<Integer> o) {
1426             Int512Shuffle s = (Int512Shuffle) o;
1427             byte[] r = new byte[reorder.length];
1428             for (int i = 0; i < reorder.length; i++) {
1429                 r[i] = reorder[s.reorder[i]];
1430             }
1431             return new Int512Shuffle(r);
1432         }
1433     }
1434 
1435     // VectorSpecies
1436 
1437     @Override
1438     public VectorSpecies<Integer> species() {
1439         return SPECIES;
1440     }
1441 }


1090 
1091     @Override
1092     void forEach(VectorMask<Integer> o, FUnCon f) {
1093         boolean[] mbits = ((Int512Mask)o).getBits();
1094         forEach((i, a) -> {
1095             if (mbits[i]) { f.apply(i, a); }
1096         });
1097     }
1098 
1099 
1100     Float512Vector toFP() {
1101         int[] vec = getElements();
1102         float[] res = new float[this.species().length()];
1103         for(int i = 0; i < this.species().length(); i++){
1104             res[i] = Float.intBitsToFloat(vec[i]);
1105         }
1106         return new Float512Vector(res);
1107     }
1108 
1109     @Override
1110     @ForceInline
1111     public Int512Vector rotateLanesLeft(int j) {
1112       int L = length();
1113       if (j < 0) {
1114          throw new IllegalArgumentException("Index " + j + " must be zero or positive");
1115       } else {
1116         j = j & (L-1);
1117         VectorShuffle<Integer> PermMask  = VectorShuffle.shuffleIota(SPECIES, L - j);
1118         return this.rearrange(PermMask);
1119       }

1120     }
1121 
1122     @Override
1123     @ForceInline
1124     public Int512Vector rotateLanesRight(int j) {
1125       int L = length();
1126       if (j < 0) {
1127          throw new IllegalArgumentException("Index " + j + " must be zero or positive");



1128       } else {
1129         j = j & (L-1);
1130         VectorShuffle<Integer> PermMask = VectorShuffle.shuffleIota(SPECIES, j);
1131         return this.rearrange(PermMask);
1132       }

1133     }
1134 
1135     @Override
1136     @ForceInline
1137     @SuppressWarnings("unchecked")
1138     public Int512Vector shiftLanesLeft(int j) {
1139        int L = length();
1140        if (j < 0) {
1141          throw new IllegalArgumentException("Index " + j + " must be zero or positive");
1142        } else if ( j >= L ) {
1143          return ZERO;
1144        } else {
1145          Int512Shuffle     Iota    = (Int512Shuffle)(VectorShuffle.shuffleIota(SPECIES, L-j));
1146          VectorMask<Integer> BlendMask = Iota.toVector().lessThan(Int512Vector.broadcast(SPECIES, (int)(L-j)));
1147          Iota    = (Int512Shuffle)(VectorShuffle.shuffleIota(SPECIES, L -j));
1148          return ZERO.blend(this.rearrange(Iota),BlendMask);
1149        }

1150     }
1151 
1152     @Override
1153     @ForceInline
1154     @SuppressWarnings("unchecked")
1155     public Int512Vector shiftLanesRight(int j) {
1156        int L = length();
1157        if (j < 0) {
1158          throw new IllegalArgumentException("Index " + j + " must be zero or positive");
1159        } else if ( j >= L ) {
1160          return ZERO;
1161        } else {
1162          Int512Shuffle     Iota    = (Int512Shuffle)(VectorShuffle.shuffleIota(SPECIES, j));
1163          VectorMask<Integer> BlendMask = Iota.toVector().greaterThanEq(Int512Vector.broadcast(SPECIES, (int)(j)));
1164          Iota    = (Int512Shuffle)(VectorShuffle.shuffleIota(SPECIES, j));
1165          return ZERO.blend(this.rearrange(Iota),BlendMask);
1166        }

1167     }
1168 
1169     @Override
1170     @ForceInline
1171     public Int512Vector rearrange(Vector<Integer> v,
1172                                   VectorShuffle<Integer> s, VectorMask<Integer> m) {
1173         return this.rearrange(s).blend(v.rearrange(s), m);
1174     }
1175 
1176     @Override
1177     @ForceInline
1178     public Int512Vector rearrange(VectorShuffle<Integer> o1) {
1179         Objects.requireNonNull(o1);
1180         Int512Shuffle s =  (Int512Shuffle)o1;
1181 
1182         return VectorIntrinsics.rearrangeOp(
1183             Int512Vector.class, Int512Shuffle.class, int.class, LENGTH,
1184             this, s,
1185             (v1, s_) -> v1.uOp((i, a) -> {
1186                 int ei = s_.lane(i);


1385             super(reorder);
1386         }
1387 
1388         public Int512Shuffle(int[] reorder) {
1389             super(reorder);
1390         }
1391 
1392         public Int512Shuffle(int[] reorder, int i) {
1393             super(reorder, i);
1394         }
1395 
1396         public Int512Shuffle(IntUnaryOperator f) {
1397             super(f);
1398         }
1399 
1400         @Override
1401         public VectorSpecies<Integer> species() {
1402             return SPECIES;
1403         }
1404 
1405         private IntVector toVector_helper() {

1406             int[] va = new int[SPECIES.length()];
1407             for (int i = 0; i < va.length; i++) {
1408               va[i] = (int) lane(i);
1409             }
1410             return IntVector.fromArray(SPECIES, va, 0);
1411         }
1412 
1413         @Override
1414         @ForceInline
1415         public IntVector toVector() {
1416             return VectorIntrinsics.shuffleToVector(Int512Vector.class, int.class, Int512Shuffle.class, this,
1417                                                     SPECIES.length(), 
1418                                                     (s) -> (((Int512Shuffle)(s)).toVector_helper()));
1419         }
1420 
1421         @Override
1422         @ForceInline
1423         @SuppressWarnings("unchecked")
1424         public <F> VectorShuffle<F> cast(VectorSpecies<F> species) {
1425             if (length() != species.length())
1426                 throw new IllegalArgumentException("Shuffle length and species length differ");
1427             Class<?> stype = species.elementType();
1428             int [] shuffleArray = toArray();
1429             if (stype == byte.class) {
1430                 return (VectorShuffle<F>) new Byte512Vector.Byte512Shuffle(shuffleArray);
1431             } else if (stype == short.class) {
1432                 return (VectorShuffle<F>) new Short512Vector.Short512Shuffle(shuffleArray);
1433             } else if (stype == int.class) {
1434                 return (VectorShuffle<F>) new Int512Vector.Int512Shuffle(shuffleArray);
1435             } else if (stype == long.class) {
1436                 return (VectorShuffle<F>) new Long512Vector.Long512Shuffle(shuffleArray);
1437             } else if (stype == float.class) {
1438                 return (VectorShuffle<F>) new Float512Vector.Float512Shuffle(shuffleArray);
1439             } else if (stype == double.class) {
1440                 return (VectorShuffle<F>) new Double512Vector.Double512Shuffle(shuffleArray);
1441             } else {
1442                 throw new UnsupportedOperationException("Bad lane type for casting.");
1443             }
1444         }
1445 
1446 
1447         @Override
1448         public Int512Shuffle rearrange(VectorShuffle<Integer> o) {
1449             Int512Shuffle s = (Int512Shuffle) o;
1450             byte[] r = new byte[reorder.length];
1451             for (int i = 0; i < reorder.length; i++) {
1452                 r[i] = reorder[s.reorder[i]];
1453             }
1454             return new Int512Shuffle(r);
1455         }
1456     }
1457 
1458     // VectorSpecies
1459 
1460     @Override
1461     public VectorSpecies<Integer> species() {
1462         return SPECIES;
1463     }
1464 }
< prev index next >