diff --git a/test/hotspot/jtreg/compiler/vectorapi/TestVectorOperationsWithPartialSize.java b/test/hotspot/jtreg/compiler/vectorapi/TestVectorOperationsWithPartialSize.java index 6fd20b7e2fb62..122fa522e5077 100644 --- a/test/hotspot/jtreg/compiler/vectorapi/TestVectorOperationsWithPartialSize.java +++ b/test/hotspot/jtreg/compiler/vectorapi/TestVectorOperationsWithPartialSize.java @@ -76,8 +76,12 @@ public class TestVectorOperationsWithPartialSize { random.fill(random.ints(), ia); random.fill(random.longs(), la); - random.fill(random.floats(), fa); - random.fill(random.doubles(), da); + // Use a range of 1~3000 for floating point values to keep the tests + // effectiveness while avoiding the large precision differences introduced + // by the add reduction APIs, especially since the Vector API does not + // guarantee a specific calculation order for such operations. + random.fill(random.uniformFloats(1.0f, 3000.0f), fa); + random.fill(random.uniformDoubles(1.0, 3000.0), da); random.fill(random.uniformInts(0, ISPEC_128.length()), indices); for (int i = 0; i < SIZE; i++) { m[i] = i % 2 == 0; @@ -160,7 +164,7 @@ private static int reduceLanes(int init, int[] arr, int vlen, binOpInt f) { return result; } - private static long reduceLanes(long init, long[] arr, int vlen,binOpLong f) { + private static long reduceLanes(long init, long[] arr, int vlen, binOpLong f) { long result = init; for (int i = 0; i < vlen; i++) { result = f.apply(arr[i], result); @@ -226,7 +230,6 @@ private static void verifyAddReductionFloat(float actual, float[] arr, int vlen) float tolerance = Math.ulp(expected) * ROUNDING_ERROR_FACTOR_ADD; if (Math.abs(expected - actual) > tolerance) { throw new RuntimeException( - "assertEqualsWithTolerance" + ": expected " + expected + " but was " + actual + " (tolerance: " + tolerance + ", diff: " + Math.abs(expected - actual) + ")" ); @@ -243,7 +246,6 @@ private static void verifyAddReductionDouble(double actual, double[] arr, int vl double tolerance = Math.ulp(expected) * ROUNDING_ERROR_FACTOR_ADD; if (Math.abs(expected - actual) > tolerance) { throw new RuntimeException( - "assertEqualsWithTolerance" + ": expected " + expected + " but was " + actual + " (tolerance: " + tolerance + ", diff: " + Math.abs(expected - actual) + ")" );