[vectorIntrinsics] RFR: Remove `byte[]` and `ByteBuffer` access methods.
Paul Sandoz
psandoz at openjdk.java.net
Mon Apr 11 16:09:04 UTC 2022
On Mon, 11 Apr 2022 00:11:19 GMT, Jie Fu <jiefu at openjdk.org> wrote:
>> Hi @PaulSandoz ,
>>
>> Is there any perf number before and after this patch?
>> Also why there is no JBS for this PR?
>
>> Hi @DamonFool, issues are optional for integration into the `panama-vector` repo.
>
> Okay.
>
>>
>> Performance-wise `MemorySegment` is similar to `byte[]` and `ByteBuffer` (heap and direct), which is not too surprising since the `base`/`offset` are extracted from a segment and passed to the `load`/`store` vector intrinsic.
>>
>> There is one performance anomaly I have observed related to using an `int`-based loop and `int` offset. This results in a widening conversion to `long` when passing the `int` value as the `offset` argument to the access method. The memory addressing logic is not efficient, which exacerbates with unrolling. This may be more generally C2 related, but it requires further investigation.
>
> Can you give us a benchmark example whose performance would be improved so that we can learn more from your patch?
> Thanks.
@DamonFool I confirmed what @merykitty described, related to overflow, although I suppose if the loop bound is known then it could be determined if overflow occurs or not. Although, as i understand this area of HotSpot is quite tricky.
If doing a calculation such as `someIntIndex << 2` it is necessary to explicitly cast `someIntIndex` to a `long`, similar to what is required when using `Unsafe` e.g. see [here](https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java#L760). The alternative is to use a `long` based index.
-------------
PR: https://git.openjdk.java.net/panama-vector/pull/190
More information about the panama-dev
mailing list