RFR: 8346954: [JMH] jdk.incubator.vector.MaskedLogicOpts fails due to IndexOutOfBoundsException
Jatin Bhateja
jbhateja at openjdk.org
Thu Feb 13 12:15:19 UTC 2025
On Wed, 8 Jan 2025 09:04:47 GMT, Nicole Xu <duke at openjdk.org> wrote:
> Suite MaskedLogicOpts.maskedLogicOperationsLong512() failed on both x86 and AArch64 with the following error:
>
>
> java.lang.IndexOutOfBoundsException: Index 252 out of bounds for length 249
>
>
> The variable `long256_arr_idx` is misused when indexing 'LongVector l2, l3, l4, l5' in function `maskedLogicOperationsLongKernel()`. 'long256_arr_idx' increases by 4 every time the benchmark runs and ensures the incremented value remains within the bounds of the array. However, for `LongVector.SPECIES_512`, it loads 8 numbers from the array each time the benchmark runs, resulting in an out-of-range indexing issue.
>
> Hence, we revised the index variables from `long256_arr_idx` to `long512_arr_idx`, which has a stride of 8, to ensure that the loaded vector is inside of the array boundary for all vector species. This is also consistent with other kernel functions.
>
> Additionally, some defined but unused variables have been removed.
test/micro/org/openjdk/bench/jdk/incubator/vector/MaskedLogicOpts.java line 122:
> 120: @Setup(Level.Invocation)
> 121: public void init_per_invoc() {
> 122: int512_arr_idx = (int512_arr_idx + 16) & (ARRAYLEN-1);
Benchmark assumes that ARRAYLEN is a POT value, thus it will also be good to use the modulous operator for rounding here, it will be expensive but will not impact the performance of the Benchmarking kernels.
test/micro/org/openjdk/bench/jdk/incubator/vector/MaskedLogicOpts.java line 126:
> 124: }
> 125:
> 126: @CompilerControl(CompilerControl.Mode.INLINE)
By making the index hop over 16 ints or 8 longs we may leave gaps in between for 128-bit and 256-bit species, this will unnecessarily include the noise due to cache misses or (on some targets) prefetching additional cache lines which are not usable, thereby impacting the crispness of microbenchmark.
test/micro/org/openjdk/bench/jdk/incubator/vector/MaskedLogicOpts.java line 234:
> 232: }
> 233:
> 234: @CompilerControl(CompilerControl.Mode.INLINE)
Benchmarking kernels are forced inlined, so passing a species specific index value may help.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22963#discussion_r1954379708
PR Review Comment: https://git.openjdk.org/jdk/pull/22963#discussion_r1954358833
PR Review Comment: https://git.openjdk.org/jdk/pull/22963#discussion_r1954385898
More information about the hotspot-compiler-dev
mailing list