-
Bug
-
Resolution: Duplicate
-
P3
-
20, 21, 22, 23
-
x86_64
Following test emits incorrect output when JIT compiled by C2 compiler.
import jdk.incubator.vector.*;
import java.util.Arrays;
public class TwoVectorPermuteBug1 {
public static final VectorSpecies<Float> FSP = FloatVector.SPECIES_256;
public static void micro(float [] res, float [] shuf, float [] src1, float [] src2) {
VectorShuffle<Float> vshuf = FloatVector.fromArray(FSP, shuf, 0).toShuffle();
VectorShuffle<Float> vshuf_wrapped = vshuf.wrapIndexes();
FloatVector.fromArray(FSP, src1, 0)
.rearrange(vshuf_wrapped)
.blend(FloatVector.fromArray(FSP, src2, 0)
.rearrange(vshuf_wrapped),
vshuf.laneIsValid().not())
.intoArray(res, 0);
}
public static void main(String [] args) {
float [] res = new float[FSP.length()];
float [] shuf = new float[FSP.length()];
float [] src1 = new float[FSP.length()];
float [] src2 = new float[FSP.length()];
for (int i = 0; i < FSP.length(); i++) {
shuf[i] = i * 2;
}
for (int i = 0; i < FSP.length(); i++) {
src1[i] = i;
src2[i] = i + FSP.length();
}
for (int i = 0; i < 50000; i++) {
micro(res, shuf, src1, src2);
}
long t1 = System.currentTimeMillis();
for (int i = 0; i < 50000; i++) {
micro(res, shuf, src1, src2);
}
long t2 = System.currentTimeMillis();
System.out.println("[time] " + (t2-t1) + " ms [res] " + Arrays.toString(res));
}
}
Works fine other execution engines (Interpreter / C1 compiler).
CPROMPT>java -Xint --add-modules=jdk.incubator.vector -cp . TwoVectorPermuteBug1
WARNING: Using incubator modules: jdk.incubator.vector
[time] 3647 ms [res] [0.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0]
CPROMPT>java -XX:TieredStopAtLevel=3 --add-modules=jdk.incubator.vector -cp . TwoVectorPermuteBug1
WARNING: Using incubator modules: jdk.incubator.vector
[time] 253 ms [res] [0.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0]
CPROMPT>java -XX:-TieredCompilation -Xbatch --add-modules=jdk.incubator.vector -cp . TwoVectorPermuteBug1
WARNING: Using incubator modules: jdk.incubator.vector
[time] 6 ms [res] [0.0, 2.0, 4.0, 6.0, 0.0, 2.0, 4.0, 6.0]
CPROMPT>
import jdk.incubator.vector.*;
import java.util.Arrays;
public class TwoVectorPermuteBug1 {
public static final VectorSpecies<Float> FSP = FloatVector.SPECIES_256;
public static void micro(float [] res, float [] shuf, float [] src1, float [] src2) {
VectorShuffle<Float> vshuf = FloatVector.fromArray(FSP, shuf, 0).toShuffle();
VectorShuffle<Float> vshuf_wrapped = vshuf.wrapIndexes();
FloatVector.fromArray(FSP, src1, 0)
.rearrange(vshuf_wrapped)
.blend(FloatVector.fromArray(FSP, src2, 0)
.rearrange(vshuf_wrapped),
vshuf.laneIsValid().not())
.intoArray(res, 0);
}
public static void main(String [] args) {
float [] res = new float[FSP.length()];
float [] shuf = new float[FSP.length()];
float [] src1 = new float[FSP.length()];
float [] src2 = new float[FSP.length()];
for (int i = 0; i < FSP.length(); i++) {
shuf[i] = i * 2;
}
for (int i = 0; i < FSP.length(); i++) {
src1[i] = i;
src2[i] = i + FSP.length();
}
for (int i = 0; i < 50000; i++) {
micro(res, shuf, src1, src2);
}
long t1 = System.currentTimeMillis();
for (int i = 0; i < 50000; i++) {
micro(res, shuf, src1, src2);
}
long t2 = System.currentTimeMillis();
System.out.println("[time] " + (t2-t1) + " ms [res] " + Arrays.toString(res));
}
}
Works fine other execution engines (Interpreter / C1 compiler).
CPROMPT>java -Xint --add-modules=jdk.incubator.vector -cp . TwoVectorPermuteBug1
WARNING: Using incubator modules: jdk.incubator.vector
[time] 3647 ms [res] [0.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0]
CPROMPT>java -XX:TieredStopAtLevel=3 --add-modules=jdk.incubator.vector -cp . TwoVectorPermuteBug1
WARNING: Using incubator modules: jdk.incubator.vector
[time] 253 ms [res] [0.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0]
CPROMPT>java -XX:-TieredCompilation -Xbatch --add-modules=jdk.incubator.vector -cp . TwoVectorPermuteBug1
WARNING: Using incubator modules: jdk.incubator.vector
[time] 6 ms [res] [0.0, 2.0, 4.0, 6.0, 0.0, 2.0, 4.0, 6.0]
CPROMPT>
- duplicates
-
JDK-8332119 Incorrect IllegalArgumentException for C2 compiled permute kernel
-
- Resolved
-