Vector::rearrange(Shuffle) allocations
Vladimir Ivanov
vladimir.x.ivanov at oracle.com
Tue Jan 15 19:39:30 UTC 2019
Good catch, Tomasz! That's a bug in the implementation of rearrange:
default implementation (lambda) captures the vector box and it keeps it
from being eliminated.
The following patch should fix the problem:
http://cr.openjdk.java.net/~vlivanov/panama/vector/rearrange/webrev.00/
Best regards,
Vladimir Ivanov
On 14/01/2019 09:56, Tomasz Kowalczewski wrote:
> I have a question about vector rearranges. My recent observation is
> that using IntVector.rearrange causes a lot of allocations (in a JMH
> microbenchmark). Is this expected? I wrote a few simple (but not
> trivial) algorithms and they all did not box vectors into objects and
> all tests were able to run using EpsilonGC. The intrinsic works and
> vpermd instruction is emitted.
>
> There are 64 bytes allocated per benchmark iteration in the following
> code (the addAll is used so that vector does not escape the method):
>
> @Benchmark
> public int rearrange() {
> IntVector input = SPECIES_I256.fromArray(inputArray, 0);
> IntVector rearrangedVector = input.rearrange(SHUFFLE_1);
>
> return rearrangedVector.addAll();
> }
>
> There is no allocation in following code:
>
> @Benchmark
> public int noRearrange() {
> IntVector input = SPECIES_I256.fromArray(inputArray, 0);
>
> return input.addAll();
> }
>
> Output from jmap -histo for first case:
>
> num #instances #bytes class name (module)
> -------------------------------------------------------
> 1: 4122313 198969024 [I (java.base@)
> 2: 4119794 65916704 jdk.incubator.vector.Int256Vector
> (jdk.incubator.vector@)
> 3: 8913 808512 [B (java.base@)
> 4: 1982 222408 java.lang.Class (java.base@)
> 5: 8638 207312 java.lang.String (java.base@)
>
> Any hints will be much appreciated.
>
More information about the panama-dev
mailing list