RFR: 8311864: Add ArraysSupport.hashCode(int[] a, fromIndex, length, initialValue)

Quan Anh Mai qamai at openjdk.org
Thu Jul 13 09:17:04 UTC 2023


On Thu, 13 Jul 2023 08:44:02 GMT, Pavel Rappo <prappo at openjdk.org> wrote:

>>> For an arbitrary int[], unconditional vectorization might be unwarranted or puzzling.
>> 
>> Could you clarify this statement? Thanks a lot.
>
>> > For an arbitrary int[], unconditional vectorization might be unwarranted or puzzling.
>> 
>> Could you clarify this statement? Thanks a lot.
> 
> My mental model is that Arrays.hashCode is to ArraysSupport.vectorizedHashCode as Arrays.mismatch to ArraysSupport.vectorizedMismatch. In either pair, the first method is applicable to some generic array, whereas the second method is applicable to an array that would definitely benefit from vectorized processing.
> 
> When I see a call to ArraysSupport.vectorizedHashCode, it reads like a statement: this particular computation must be vectorized. Now, was it author's intention, or there simply were no alternatives to compute hash code of an array subrange or with a different initial value?

@pavelrappo Actually I look at the implementation of `ArraySupport.vectorizedHashCode` and it does branching and only uses vector instructions if the length is sufficiently large. Please do benchmarking if you are uncertain with performance characteristics of functions. Thanks.

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

PR Comment: https://git.openjdk.org/jdk/pull/14831#issuecomment-1633867335


More information about the core-libs-dev mailing list