RFR: 8333248: VectorGatherMaskFoldingTest.java failed when maximum vector bits is 64
Gui Cao
gcao at openjdk.org
Thu May 30 10:41:23 UTC 2024
Hi, VectorGatherMaskFoldingTest.java Test fails when max vector bits is 64, when max vector bits is 64, LongVector.SPECIES_MAX.length() and DoubleVector.SPECIES_MAX.length() is 1.
Run VectorGatherMaskFoldingTest.java on aarch64 client mode without `-XX:+IncrementalInlineForceCleanup` Option, the `-XX:+IncrementalInlineForceCleanup` is C2 Option, so we need to remove this Option from the VectorGatherMaskFoldingTest.main method. error message:
Base Test: @Test testDoubleVectorStoreLoadMaskedVector:
compiler.lib.ir_framework.shared.TestRunException: There was an error while invoking @Test method public static void compiler.vectorapi.VectorGatherMaskFoldingTest.testDoubleVectorStoreLoadMaskedVector(). Target: null. Arguments: <void>
at compiler.lib.ir_framework.test.BaseTest.invokeTestMethod(BaseTest.java:84)
at compiler.lib.ir_framework.test.BaseTest.invokeTest(BaseTest.java:71)
at compiler.lib.ir_framework.test.AbstractTest.run(AbstractTest.java:98)
at compiler.lib.ir_framework.test.TestVM.runTests(TestVM.java:861)
at compiler.lib.ir_framework.test.TestVM.start(TestVM.java:252)
at compiler.lib.ir_framework.test.TestVM.main(TestVM.java:165)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at compiler.lib.ir_framework.test.BaseTest.invokeTestMethod(BaseTest.java:80)
... 5 more
Caused by: java.lang.RuntimeException: assertNotEquals: expected [1.0] to not equal [1.0]
at jdk.test.lib.Asserts.fail(Asserts.java:691)
at jdk.test.lib.Asserts.assertNotEquals(Asserts.java:451)
at jdk.test.lib.Asserts.assertNotEquals(Asserts.java:435)
at compiler.vectorapi.VectorGatherMaskFoldingTest.testDoubleVectorStoreLoadMaskedVector(VectorGatherMaskFoldingTest.java:1089)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
... 7 more
For example, the following method will be failed:
private static final VectorSpecies<Long> L_SPECIES = LongVector.SPECIES_MAX;
private static final VectorSpecies<Double> D_SPECIES = DoubleVector.SPECIES_MAX;
...
@Test
@IR(counts = { IRNode.STORE_VECTOR_MASKED, ">= 1", IRNode.LOAD_VECTOR_MASKED, ">= 1" }, applyIfCPUFeatureOr = {"avx512", "true", "sve", "true"})
public static void testDoubleVectorStoreLoadMaskedVector() {
double[] res = new double[D_SPECIES.length()];
doubleVector.intoArray(res, 0, doubleVectorMask);
DoubleVector res2 = DoubleVector.fromArray(D_SPECIES, res, 0, doubleVectorMask);
Asserts.assertNotEquals(res2, doubleVector);
}
in this `testDoubleVectorStoreLoadMaskedVector` test case, the doubleVector data is:[1.0], doubleVectorMask:[true], res2 is:[1.0] So here `Asserts.assertNotEquals(res2, doubleVector);` will assert Error.
By the way, LongVector.SPECIES_MAX/ DoubleVector.SPECIES_MAX is initialized with a call to VectorShape.getMaxVectorBitSize. the aarch64 client jvm mode, VectorShape.getMaxVectorBitSize will return the default 64 bit, and If any CPU does not support vectors like riscv without rvv1.0, the default value of 64 is returned.
/**
* Returns the maximum vector bit size for a given element type.
*
* @param etype the element type.
* @return the maximum vector bit.
*/
/*package-private*/
static int getMaxVectorBitSize(Class<?> etype) {
// VectorSupport.getMaxLaneCount may return -1 if C2 is not enabled,
// or a value smaller than the S_64_BIT.vectorBitSize / elementSizeInBits if MaxVectorSize < 16
// If so default to S_64_BIT
int maxLaneCount = VectorSupport.getMaxLaneCount(etype);
int elementSizeInBits = LaneType.of(etype).elementSize;
return Math.max(maxLaneCount * elementSizeInBits, S_64_BIT.vectorBitSize);
}
The fix, if when max vector bits is 64, which means there is no vector api implementation, we set L_SPECIES to LongVector.SPECIES_128, which will use the vector api default java level implementation.
### Testing
- [x] Run VectorGatherMaskFoldingTest.java on Banana Pi BPI-F3 board (has RVV1.0)
- [x] Run VectorGatherMaskFoldingTest.java on aarch64 server mode with neon
- [x] Run VectorGatherMaskFoldingTest.java on aarch64 client mode without `-XX:+IncrementalInlineForceCleanup` Option
-------------
Commit messages:
- 8333248: VectorGatherMaskFoldingTest.java failed when maximum vector bits is 64
Changes: https://git.openjdk.org/jdk/pull/19473/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=19473&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8333248
Stats: 5 lines in 1 file changed: 3 ins; 1 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/19473.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/19473/head:pull/19473
PR: https://git.openjdk.org/jdk/pull/19473
More information about the hotspot-compiler-dev
mailing list