< prev index next >

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

Print this page




 146 
 147     @Override
 148     long rOp(long v, FBinOp f) {
 149         long[] vec = getElements();
 150         for (int i = 0; i < length(); i++) {
 151             v = f.apply(i, v, vec[i]);
 152         }
 153         return v;
 154     }
 155 
 156     @Override
 157     @ForceInline
 158     public <F> Vector<F> cast(VectorSpecies<F> s) {
 159         Objects.requireNonNull(s);
 160         if (s.length() != LENGTH)
 161             throw new IllegalArgumentException("Vector length this species length differ");
 162 
 163         return VectorIntrinsics.cast(
 164             Long256Vector.class,
 165             long.class, LENGTH,
 166             s.boxType(),
 167             s.elementType(), LENGTH,
 168             this, s,
 169             (species, vector) -> vector.castDefault(species)
 170         );
 171     }
 172 
 173     @SuppressWarnings("unchecked")
 174     @ForceInline
 175     private <F> Vector<F> castDefault(VectorSpecies<F> s) {
 176         int limit = s.length();
 177 
 178         Class<?> stype = s.elementType();
 179         if (stype == byte.class) {
 180             byte[] a = new byte[limit];
 181             for (int i = 0; i < limit; i++) {
 182                 a[i] = (byte) this.lane(i);
 183             }
 184             return (Vector) ByteVector.fromArray((VectorSpecies<Byte>) s, a, 0);
 185         } else if (stype == short.class) {
 186             short[] a = new short[limit];


 284                 (species, vector) -> vector.defaultReinterpret(species)
 285             );
 286         } else if (stype == double.class) {
 287             return VectorIntrinsics.reinterpret(
 288                 Long256Vector.class,
 289                 long.class, LENGTH,
 290                 Double256Vector.class,
 291                 double.class, Double256Vector.LENGTH,
 292                 this, s,
 293                 (species, vector) -> vector.defaultReinterpret(species)
 294             );
 295         } else {
 296             throw new UnsupportedOperationException("Bad lane type for casting.");
 297         }
 298     }
 299 
 300     @Override
 301     @ForceInline
 302     public LongVector reshape(VectorSpecies<Long> s) {
 303         Objects.requireNonNull(s);
 304         if (s.bitSize() == 64 && (s.boxType() == Long64Vector.class)) {
 305             return VectorIntrinsics.reinterpret(
 306                 Long256Vector.class,
 307                 long.class, LENGTH,
 308                 Long64Vector.class,
 309                 long.class, Long64Vector.LENGTH,
 310                 this, s,
 311                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 312             );
 313         } else if (s.bitSize() == 128 && (s.boxType() == Long128Vector.class)) {
 314             return VectorIntrinsics.reinterpret(
 315                 Long256Vector.class,
 316                 long.class, LENGTH,
 317                 Long128Vector.class,
 318                 long.class, Long128Vector.LENGTH,
 319                 this, s,
 320                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 321             );
 322         } else if (s.bitSize() == 256 && (s.boxType() == Long256Vector.class)) {
 323             return VectorIntrinsics.reinterpret(
 324                 Long256Vector.class,
 325                 long.class, LENGTH,
 326                 Long256Vector.class,
 327                 long.class, Long256Vector.LENGTH,
 328                 this, s,
 329                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 330             );
 331         } else if (s.bitSize() == 512 && (s.boxType() == Long512Vector.class)) {
 332             return VectorIntrinsics.reinterpret(
 333                 Long256Vector.class,
 334                 long.class, LENGTH,
 335                 Long512Vector.class,
 336                 long.class, Long512Vector.LENGTH,
 337                 this, s,
 338                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 339             );
 340         } else if ((s.bitSize() > 0) && (s.bitSize() <= 2048)
 341                 && (s.bitSize() % 128 == 0) && (s.boxType() == LongMaxVector.class)) {
 342             return VectorIntrinsics.reinterpret(
 343                 Long256Vector.class,
 344                 long.class, LENGTH,
 345                 LongMaxVector.class,
 346                 long.class, LongMaxVector.LENGTH,
 347                 this, s,
 348                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 349             );
 350         } else {
 351             throw new InternalError("Unimplemented size");
 352         }
 353     }
 354 
 355     // Binary operations with scalars
 356 
 357     @Override
 358     @ForceInline
 359     public LongVector add(long o) {
 360         return add((Long256Vector)LongVector.broadcast(SPECIES, o));
 361     }


 648     @Override
 649     @ForceInline
 650     public Long256Vector and(Vector<Long> v, VectorMask<Long> m) {
 651         return blend(and(v), m);
 652     }
 653 
 654     @Override
 655     @ForceInline
 656     public Long256Vector or(Vector<Long> v, VectorMask<Long> m) {
 657         return blend(or(v), m);
 658     }
 659 
 660     @Override
 661     @ForceInline
 662     public Long256Vector xor(Vector<Long> v, VectorMask<Long> m) {
 663         return blend(xor(v), m);
 664     }
 665 
 666     @Override
 667     @ForceInline
 668     public Long256Vector shiftL(int s) {
 669         return VectorIntrinsics.broadcastInt(
 670             VECTOR_OP_LSHIFT, Long256Vector.class, long.class, LENGTH,
 671             this, s,
 672             (v, i) -> v.uOp((__, a) -> (long) (a << i)));
 673     }
 674 
 675     @Override
 676     @ForceInline
 677     public Long256Vector shiftL(int s, VectorMask<Long> m) {
 678         return blend(shiftL(s), m);
 679     }
 680 
 681     @Override
 682     @ForceInline
 683     public Long256Vector shiftR(int s) {
 684         return VectorIntrinsics.broadcastInt(
 685             VECTOR_OP_URSHIFT, Long256Vector.class, long.class, LENGTH,
 686             this, s,
 687             (v, i) -> v.uOp((__, a) -> (long) (a >>> i)));
 688     }
 689 
 690     @Override
 691     @ForceInline
 692     public Long256Vector shiftR(int s, VectorMask<Long> m) {
 693         return blend(shiftR(s), m);
 694     }
 695 
 696     @Override
 697     @ForceInline
 698     public Long256Vector aShiftR(int s) {
 699         return VectorIntrinsics.broadcastInt(
 700             VECTOR_OP_RSHIFT, Long256Vector.class, long.class, LENGTH,
 701             this, s,
 702             (v, i) -> v.uOp((__, a) -> (long) (a >> i)));
 703     }
 704 
 705     @Override
 706     @ForceInline
 707     public Long256Vector aShiftR(int s, VectorMask<Long> m) {
 708         return blend(aShiftR(s), m);
 709     }
 710 
 711     @Override
 712     @ForceInline
 713     public Long256Vector shiftL(Vector<Long> s) {
 714         Long256Vector shiftv = (Long256Vector)s;
 715         // As per shift specification for Java, mask the shift count.
 716         shiftv = shiftv.and(LongVector.broadcast(SPECIES, 0x3f));
 717         return VectorIntrinsics.binaryOp(
 718             VECTOR_OP_LSHIFT, Long256Vector.class, long.class, LENGTH,
 719             this, shiftv,
 720             (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a << b)));
 721     }
 722 
 723     @Override
 724     @ForceInline
 725     public Long256Vector shiftR(Vector<Long> s) {
 726         Long256Vector shiftv = (Long256Vector)s;
 727         // As per shift specification for Java, mask the shift count.
 728         shiftv = shiftv.and(LongVector.broadcast(SPECIES, 0x3f));
 729         return VectorIntrinsics.binaryOp(
 730             VECTOR_OP_URSHIFT, Long256Vector.class, long.class, LENGTH,
 731             this, shiftv,
 732             (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a >>> b)));
 733     }
 734 
 735     @Override
 736     @ForceInline
 737     public Long256Vector aShiftR(Vector<Long> s) {
 738         Long256Vector shiftv = (Long256Vector)s;
 739         // As per shift specification for Java, mask the shift count.
 740         shiftv = shiftv.and(LongVector.broadcast(SPECIES, 0x3f));
 741         return VectorIntrinsics.binaryOp(
 742             VECTOR_OP_RSHIFT, Long256Vector.class, long.class, LENGTH,
 743             this, shiftv,
 744             (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a >> b)));
 745     }
 746     // Ternary operations
 747 
 748 
 749     // Type specific horizontal reductions
 750 
 751     @Override
 752     @ForceInline
 753     public long addAll() {
 754         return (long) VectorIntrinsics.reductionCoerced(
 755             VECTOR_OP_ADD, Long256Vector.class, long.class, LENGTH,
 756             this,
 757             v -> (long) v.rOp((long) 0, (i, a, b) -> (long) (a + b)));


1090 
1091     @Override
1092     void forEach(VectorMask<Long> o, FUnCon f) {
1093         boolean[] mbits = ((Long256Mask)o).getBits();
1094         forEach((i, a) -> {
1095             if (mbits[i]) { f.apply(i, a); }
1096         });
1097     }
1098 
1099 
1100     Double256Vector 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 Double256Vector(res);
1107     }
1108 
1109     @Override
1110     public Long256Vector rotateEL(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 Long256Vector(res);
1117     }
1118 
1119     @Override
1120     public Long256Vector rotateER(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 Long256Vector(res);
1132     }
1133 
1134     @Override
1135     public Long256Vector shiftEL(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 Long256Vector(res);
1142     }
1143 
1144     @Override
1145     public Long256Vector shiftER(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 Long256Vector(res);
1152     }
1153 
1154     @Override
1155     @ForceInline
1156     public Long256Vector 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 Long256Vector rearrange(VectorShuffle<Long> o1) {
1164         Objects.requireNonNull(o1);
1165         Long256Shuffle s =  (Long256Shuffle)o1;




 146 
 147     @Override
 148     long rOp(long v, FBinOp f) {
 149         long[] vec = getElements();
 150         for (int i = 0; i < length(); i++) {
 151             v = f.apply(i, v, vec[i]);
 152         }
 153         return v;
 154     }
 155 
 156     @Override
 157     @ForceInline
 158     public <F> Vector<F> cast(VectorSpecies<F> s) {
 159         Objects.requireNonNull(s);
 160         if (s.length() != LENGTH)
 161             throw new IllegalArgumentException("Vector length this species length differ");
 162 
 163         return VectorIntrinsics.cast(
 164             Long256Vector.class,
 165             long.class, LENGTH,
 166             s.vectorType(),
 167             s.elementType(), LENGTH,
 168             this, s,
 169             (species, vector) -> vector.castDefault(species)
 170         );
 171     }
 172 
 173     @SuppressWarnings("unchecked")
 174     @ForceInline
 175     private <F> Vector<F> castDefault(VectorSpecies<F> s) {
 176         int limit = s.length();
 177 
 178         Class<?> stype = s.elementType();
 179         if (stype == byte.class) {
 180             byte[] a = new byte[limit];
 181             for (int i = 0; i < limit; i++) {
 182                 a[i] = (byte) this.lane(i);
 183             }
 184             return (Vector) ByteVector.fromArray((VectorSpecies<Byte>) s, a, 0);
 185         } else if (stype == short.class) {
 186             short[] a = new short[limit];


 284                 (species, vector) -> vector.defaultReinterpret(species)
 285             );
 286         } else if (stype == double.class) {
 287             return VectorIntrinsics.reinterpret(
 288                 Long256Vector.class,
 289                 long.class, LENGTH,
 290                 Double256Vector.class,
 291                 double.class, Double256Vector.LENGTH,
 292                 this, s,
 293                 (species, vector) -> vector.defaultReinterpret(species)
 294             );
 295         } else {
 296             throw new UnsupportedOperationException("Bad lane type for casting.");
 297         }
 298     }
 299 
 300     @Override
 301     @ForceInline
 302     public LongVector reshape(VectorSpecies<Long> s) {
 303         Objects.requireNonNull(s);
 304         if (s.bitSize() == 64 && (s.vectorType() == Long64Vector.class)) {
 305             return VectorIntrinsics.reinterpret(
 306                 Long256Vector.class,
 307                 long.class, LENGTH,
 308                 Long64Vector.class,
 309                 long.class, Long64Vector.LENGTH,
 310                 this, s,
 311                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 312             );
 313         } else if (s.bitSize() == 128 && (s.vectorType() == Long128Vector.class)) {
 314             return VectorIntrinsics.reinterpret(
 315                 Long256Vector.class,
 316                 long.class, LENGTH,
 317                 Long128Vector.class,
 318                 long.class, Long128Vector.LENGTH,
 319                 this, s,
 320                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 321             );
 322         } else if (s.bitSize() == 256 && (s.vectorType() == Long256Vector.class)) {
 323             return VectorIntrinsics.reinterpret(
 324                 Long256Vector.class,
 325                 long.class, LENGTH,
 326                 Long256Vector.class,
 327                 long.class, Long256Vector.LENGTH,
 328                 this, s,
 329                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 330             );
 331         } else if (s.bitSize() == 512 && (s.vectorType() == Long512Vector.class)) {
 332             return VectorIntrinsics.reinterpret(
 333                 Long256Vector.class,
 334                 long.class, LENGTH,
 335                 Long512Vector.class,
 336                 long.class, Long512Vector.LENGTH,
 337                 this, s,
 338                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 339             );
 340         } else if ((s.bitSize() > 0) && (s.bitSize() <= 2048)
 341                 && (s.bitSize() % 128 == 0) && (s.vectorType() == LongMaxVector.class)) {
 342             return VectorIntrinsics.reinterpret(
 343                 Long256Vector.class,
 344                 long.class, LENGTH,
 345                 LongMaxVector.class,
 346                 long.class, LongMaxVector.LENGTH,
 347                 this, s,
 348                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 349             );
 350         } else {
 351             throw new InternalError("Unimplemented size");
 352         }
 353     }
 354 
 355     // Binary operations with scalars
 356 
 357     @Override
 358     @ForceInline
 359     public LongVector add(long o) {
 360         return add((Long256Vector)LongVector.broadcast(SPECIES, o));
 361     }


 648     @Override
 649     @ForceInline
 650     public Long256Vector and(Vector<Long> v, VectorMask<Long> m) {
 651         return blend(and(v), m);
 652     }
 653 
 654     @Override
 655     @ForceInline
 656     public Long256Vector or(Vector<Long> v, VectorMask<Long> m) {
 657         return blend(or(v), m);
 658     }
 659 
 660     @Override
 661     @ForceInline
 662     public Long256Vector xor(Vector<Long> v, VectorMask<Long> m) {
 663         return blend(xor(v), m);
 664     }
 665 
 666     @Override
 667     @ForceInline
 668     public Long256Vector shiftLeft(int s) {
 669         return VectorIntrinsics.broadcastInt(
 670             VECTOR_OP_LSHIFT, Long256Vector.class, long.class, LENGTH,
 671             this, s,
 672             (v, i) -> v.uOp((__, a) -> (long) (a << i)));
 673     }
 674 
 675     @Override
 676     @ForceInline
 677     public Long256Vector shiftLeft(int s, VectorMask<Long> m) {
 678         return blend(shiftLeft(s), m);
 679     }
 680 
 681     @Override
 682     @ForceInline
 683     public Long256Vector shiftRight(int s) {
 684         return VectorIntrinsics.broadcastInt(
 685             VECTOR_OP_URSHIFT, Long256Vector.class, long.class, LENGTH,
 686             this, s,
 687             (v, i) -> v.uOp((__, a) -> (long) (a >>> i)));
 688     }
 689 
 690     @Override
 691     @ForceInline
 692     public Long256Vector shiftRight(int s, VectorMask<Long> m) {
 693         return blend(shiftRight(s), m);
 694     }
 695 
 696     @Override
 697     @ForceInline
 698     public Long256Vector shiftArithmeticRight(int s) {
 699         return VectorIntrinsics.broadcastInt(
 700             VECTOR_OP_RSHIFT, Long256Vector.class, long.class, LENGTH,
 701             this, s,
 702             (v, i) -> v.uOp((__, a) -> (long) (a >> i)));
 703     }
 704 
 705     @Override
 706     @ForceInline
 707     public Long256Vector shiftArithmeticRight(int s, VectorMask<Long> m) {
 708         return blend(shiftArithmeticRight(s), m);
 709     }
 710 
 711     @Override
 712     @ForceInline
 713     public Long256Vector shiftLeft(Vector<Long> s) {
 714         Long256Vector shiftv = (Long256Vector)s;
 715         // As per shift specification for Java, mask the shift count.
 716         shiftv = shiftv.and(LongVector.broadcast(SPECIES, 0x3f));
 717         return VectorIntrinsics.binaryOp(
 718             VECTOR_OP_LSHIFT, Long256Vector.class, long.class, LENGTH,
 719             this, shiftv,
 720             (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a << b)));
 721     }
 722 
 723     @Override
 724     @ForceInline
 725     public Long256Vector shiftRight(Vector<Long> s) {
 726         Long256Vector shiftv = (Long256Vector)s;
 727         // As per shift specification for Java, mask the shift count.
 728         shiftv = shiftv.and(LongVector.broadcast(SPECIES, 0x3f));
 729         return VectorIntrinsics.binaryOp(
 730             VECTOR_OP_URSHIFT, Long256Vector.class, long.class, LENGTH,
 731             this, shiftv,
 732             (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a >>> b)));
 733     }
 734 
 735     @Override
 736     @ForceInline
 737     public Long256Vector shiftArithmeticRight(Vector<Long> s) {
 738         Long256Vector shiftv = (Long256Vector)s;
 739         // As per shift specification for Java, mask the shift count.
 740         shiftv = shiftv.and(LongVector.broadcast(SPECIES, 0x3f));
 741         return VectorIntrinsics.binaryOp(
 742             VECTOR_OP_RSHIFT, Long256Vector.class, long.class, LENGTH,
 743             this, shiftv,
 744             (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a >> b)));
 745     }
 746     // Ternary operations
 747 
 748 
 749     // Type specific horizontal reductions
 750 
 751     @Override
 752     @ForceInline
 753     public long addAll() {
 754         return (long) VectorIntrinsics.reductionCoerced(
 755             VECTOR_OP_ADD, Long256Vector.class, long.class, LENGTH,
 756             this,
 757             v -> (long) v.rOp((long) 0, (i, a, b) -> (long) (a + b)));


1090 
1091     @Override
1092     void forEach(VectorMask<Long> o, FUnCon f) {
1093         boolean[] mbits = ((Long256Mask)o).getBits();
1094         forEach((i, a) -> {
1095             if (mbits[i]) { f.apply(i, a); }
1096         });
1097     }
1098 
1099 
1100     Double256Vector 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 Double256Vector(res);
1107     }
1108 
1109     @Override
1110     public Long256Vector 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 Long256Vector(res);
1117     }
1118 
1119     @Override
1120     public Long256Vector 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 Long256Vector(res);
1132     }
1133 
1134     @Override
1135     public Long256Vector 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 Long256Vector(res);
1142     }
1143 
1144     @Override
1145     public Long256Vector 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 Long256Vector(res);
1152     }
1153 
1154     @Override
1155     @ForceInline
1156     public Long256Vector 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 Long256Vector rearrange(VectorShuffle<Long> o1) {
1164         Objects.requireNonNull(o1);
1165         Long256Shuffle s =  (Long256Shuffle)o1;


< prev index next >