[vectorIntrinsics] RFR: Remove `byte[]` and `ByteBuffer` access methods.

Quan Anh Mai duke at openjdk.java.net
Fri Apr 8 15:40:03 UTC 2022


On Fri, 8 Apr 2022 15:08:56 GMT, Paul Sandoz <psandoz 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.
> 
> 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.

@PaulSandoz  My wild guess of the situation is that you need to widen the offset before scaling (that is doing `(long)index * scale` instead of `(long)(index * scale)`). The former can be reduced to an address mode on x64 while the latter cannot due to possible multiplication overflow. I believe this is a not-easy-to-see caveat and needs a helper method to ensure performing properly.
Thanks.

-------------

PR: https://git.openjdk.java.net/panama-vector/pull/190


More information about the panama-dev mailing list