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

Paul Sandoz psandoz at openjdk.java.net
Fri Apr 8 15:59:05 UTC 2022


On Fri, 8 Apr 2022 15:36:05 GMT, Quan Anh Mai <duke at openjdk.java.net> wrote:

>> 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.

@merykitty that's a good point. I have run into that before, and could be a likely cause.

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

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


More information about the panama-dev mailing list