< prev index next >

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

Print this page




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

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



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

1120     public Long512Vector rotateLanesRight(int j) {
1121         long[] vec = getElements();
1122         long[] res = new long[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 Long512Vector(res);
1132     }
1133 
1134     @Override


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






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


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






1150         }
1151         return new Long512Vector(res);
1152     }
1153 
1154     @Override
1155     @ForceInline
1156     public Long512Vector rearrange(Vector<Long> v,
1157                                   VectorShuffle<Long> s, VectorMask<Long> m) {
1158         return this.rearrange(s).blend(v.rearrange(s), m);
1159     }
1160 
1161     @Override
1162     @ForceInline
1163     public Long512Vector rearrange(VectorShuffle<Long> o1) {
1164         Objects.requireNonNull(o1);
1165         Long512Shuffle s =  (Long512Shuffle)o1;
1166 
1167         return VectorIntrinsics.rearrangeOp(
1168             Long512Vector.class, Long512Shuffle.class, long.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 Long512Shuffle(int[] reorder) {
1374             super(reorder);
1375         }
1376 
1377         public Long512Shuffle(int[] reorder, int i) {
1378             super(reorder, i);
1379         }
1380 
1381         public Long512Shuffle(IntUnaryOperator f) {
1382             super(f);
1383         }
1384 
1385         @Override
1386         public VectorSpecies<Long> species() {
1387             return SPECIES;
1388         }
1389 
1390         @Override
1391         public LongVector toVector() {
1392             long[] va = new long[SPECIES.length()];
1393             for (int i = 0; i < va.length; i++) {
1394               va[i] = (long) lane(i);
1395             }
1396             return LongVector.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 Long512Shuffle rearrange(VectorShuffle<Long> o) {
1426             Long512Shuffle s = (Long512Shuffle) 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 Long512Shuffle(r);
1432         }
1433     }
1434 
1435     // VectorSpecies
1436 
1437     @Override
1438     public VectorSpecies<Long> species() {
1439         return SPECIES;
1440     }
1441 }


1090 
1091     @Override
1092     void forEach(VectorMask<Long> o, FUnCon f) {
1093         boolean[] mbits = ((Long512Mask)o).getBits();
1094         forEach((i, a) -> {
1095             if (mbits[i]) { f.apply(i, a); }
1096         });
1097     }
1098 
1099 
1100     Double512Vector toFP() {
1101         long[] vec = getElements();
1102         double[] res = new double[this.species().length()];
1103         for(int i = 0; i < this.species().length(); i++){
1104             res[i] = Double.longBitsToDouble(vec[i]);
1105         }
1106         return new Double512Vector(res);
1107     }
1108 
1109     @Override
1110     @ForceInline
1111     public Long512Vector 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<Long> PermMask  = VectorShuffle.shuffleIota(SPECIES, L - j);
1118         return this.rearrange(PermMask);
1119       }

1120     }
1121 
1122     @Override
1123     @ForceInline
1124     public Long512Vector 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<Long> PermMask = VectorShuffle.shuffleIota(SPECIES, j);
1131         return this.rearrange(PermMask);
1132       }

1133     }
1134 
1135     @Override
1136     @ForceInline
1137     @SuppressWarnings("unchecked")
1138     public Long512Vector 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          Long512Shuffle     Iota    = (Long512Shuffle)(VectorShuffle.shuffleIota(SPECIES, L-j));
1146          VectorMask<Long> BlendMask = Iota.toVector().lessThan(Long512Vector.broadcast(SPECIES, (long)(L-j)));
1147          Iota    = (Long512Shuffle)(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 Long512Vector 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          Long512Shuffle     Iota    = (Long512Shuffle)(VectorShuffle.shuffleIota(SPECIES, j));
1163          VectorMask<Long> BlendMask = Iota.toVector().greaterThanEq(Long512Vector.broadcast(SPECIES, (long)(j)));
1164          Iota    = (Long512Shuffle)(VectorShuffle.shuffleIota(SPECIES, j));
1165          return ZERO.blend(this.rearrange(Iota),BlendMask);
1166        }

1167     }
1168 
1169     @Override
1170     @ForceInline
1171     public Long512Vector rearrange(Vector<Long> v,
1172                                   VectorShuffle<Long> s, VectorMask<Long> m) {
1173         return this.rearrange(s).blend(v.rearrange(s), m);
1174     }
1175 
1176     @Override
1177     @ForceInline
1178     public Long512Vector rearrange(VectorShuffle<Long> o1) {
1179         Objects.requireNonNull(o1);
1180         Long512Shuffle s =  (Long512Shuffle)o1;
1181 
1182         return VectorIntrinsics.rearrangeOp(
1183             Long512Vector.class, Long512Shuffle.class, long.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 Long512Shuffle(int[] reorder) {
1389             super(reorder);
1390         }
1391 
1392         public Long512Shuffle(int[] reorder, int i) {
1393             super(reorder, i);
1394         }
1395 
1396         public Long512Shuffle(IntUnaryOperator f) {
1397             super(f);
1398         }
1399 
1400         @Override
1401         public VectorSpecies<Long> species() {
1402             return SPECIES;
1403         }
1404 
1405         private LongVector toVector_helper() {

1406             long[] va = new long[SPECIES.length()];
1407             for (int i = 0; i < va.length; i++) {
1408               va[i] = (long) lane(i);
1409             }
1410             return LongVector.fromArray(SPECIES, va, 0);
1411         }
1412 
1413         @Override
1414         @ForceInline
1415         public LongVector toVector() {
1416             return VectorIntrinsics.shuffleToVector(Long512Vector.class, long.class, Long512Shuffle.class, this,
1417                                                     SPECIES.length(), 
1418                                                     (s) -> (((Long512Shuffle)(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 Long512Shuffle rearrange(VectorShuffle<Long> o) {
1449             Long512Shuffle s = (Long512Shuffle) 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 Long512Shuffle(r);
1455         }
1456     }
1457 
1458     // VectorSpecies
1459 
1460     @Override
1461     public VectorSpecies<Long> species() {
1462         return SPECIES;
1463     }
1464 }
< prev index next >