From a44f551c6346da2b0475af840b3777610e416c79 Mon Sep 17 00:00:00 2001 From: Xiaohong Gong Date: Wed, 17 Dec 2025 09:22:19 +0000 Subject: [PATCH 1/2] 8373722: [TESTBUG] compiler/vectorapi/TestVectorOperationsWithPartialSize.java fails intermittently --- .../vectorapi/TestVectorOperationsWithPartialSize.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/hotspot/jtreg/compiler/vectorapi/TestVectorOperationsWithPartialSize.java b/test/hotspot/jtreg/compiler/vectorapi/TestVectorOperationsWithPartialSize.java index 6fd20b7e2fb62..1bcf49d8d363e 100644 --- a/test/hotspot/jtreg/compiler/vectorapi/TestVectorOperationsWithPartialSize.java +++ b/test/hotspot/jtreg/compiler/vectorapi/TestVectorOperationsWithPartialSize.java @@ -76,8 +76,8 @@ public class TestVectorOperationsWithPartialSize { random.fill(random.ints(), ia); random.fill(random.longs(), la); - random.fill(random.floats(), fa); - random.fill(random.doubles(), da); + random.fill(random.uniformFloats(1.0f, 5.0f), fa); + random.fill(random.uniformDoubles(1.0, 5.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 +160,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 +226,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 +242,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) + ")" ); From 433efddc746ea148d0b7ede6c48a86a4b9bf0a1f Mon Sep 17 00:00:00 2001 From: Xiaohong Gong Date: Thu, 25 Dec 2025 06:59:23 +0000 Subject: [PATCH 2/2] Extend the float/double value range --- .../vectorapi/TestVectorOperationsWithPartialSize.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/compiler/vectorapi/TestVectorOperationsWithPartialSize.java b/test/hotspot/jtreg/compiler/vectorapi/TestVectorOperationsWithPartialSize.java index 1bcf49d8d363e..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.uniformFloats(1.0f, 5.0f), fa); - random.fill(random.uniformDoubles(1.0, 5.0), 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;