RFR: 8346954: [JMH] jdk.incubator.vector.MaskedLogicOpts fails due to IndexOutOfBoundsException [v2]
Nicole Xu
duke at openjdk.org
Wed Feb 26 07:04:58 UTC 2025
> 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.
Nicole Xu has updated the pull request incrementally with two additional commits since the last revision:
- 8346954: [JMH] jdk.incubator.vector.MaskedLogicOpts fails due to IndexOutOfBoundsException
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()`
resulting in the IndexOutOfBoundsException error. On the other hand, the
unified index for 128-bit, 256-bit and 512-bit species might not be
proper since it leaves gaps in between when accessing the data
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.
Hence, we improved the benchmark from several aspects,
1. Used sufficient number of predicated operations within the vector
loop while minimizing the noise due to memory operations.
2. Modified the index computation logic which can now withstand any
ARRAYLEN without resulting in an IOOBE.
3. Removed redundant vector read/writes to instance fields, thus
eliminating significant boxing penalty which translates into throughput
gains.
Change-Id: Ie8a9d495b1ca5e36f1eae069ff70a815a2de00c0
- Revert "8346954: [JMH] jdk.incubator.vector.MaskedLogicOpts fails due to IndexOutOfBoundsException"
This reverts commit 083bedec04d5ab78a420e156e74c1257ce30aee8.
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/22963/files
- new: https://git.openjdk.org/jdk/pull/22963/files/083bedec..896c27ea
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=22963&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=22963&range=00-01
Stats: 147 lines in 1 file changed: 14 ins; 29 del; 104 mod
Patch: https://git.openjdk.org/jdk/pull/22963.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/22963/head:pull/22963
PR: https://git.openjdk.org/jdk/pull/22963
More information about the core-libs-dev
mailing list