[vectorIntrinsics] RFR: 8287289: Gather/Scatter with Index Vector

Joshua Zhu jzhu at openjdk.java.net
Thu Jun 9 19:04:42 UTC 2022


On Wed, 25 May 2022 08:35:53 GMT, Joshua Zhu <jzhu at openjdk.org> wrote:

> When I assist engineers to apply VectorAPI in real business scenarios, I realize that Gather/Scatter APIs depend on indexMap residing in memory.
> 
> When an index map is acquired by vector operations, it is represented by IntVector. To do Gather/Scatter operations, an extra integer array must be introduced and an explicit vector store is also required ahead of each Gather/Scatter. Furthermore, the redundant memory store may cause a performance penalty.
> 
> Hence I submit this change for discussion. I propose to provide Gather/Scatter API supporting index vector. This patch only includes the change for Gather API.
> It passed the jtreg tests for VectorAPI.

John Rose, thanks for your reply:-)

Yes, based on ease-of-use considerations, more APIs have to be introduced to support all these choices.
In my opinion, letting users build these capabilities on top of the combination of fundamental APIs looks more elegant and reasonable if they could be optimized well by JIT.
Hence this requires the fundamental API could meet different requirements in diverse scenarios, such as removing the memory assumption for indexMap in this case.

As you suggest, as the first step, I will implement the fundamental Gather/Scatter API looks like this:

    LongVector fromMemorySegment(VectorSpecies<Long> species,
                                 MemorySegment ms,
                                 Vector<Integer> indexVector,
                                 ByteOrder bo);

    LongVector fromMemorySegment(VectorSpecies<Long> species,
                                 MemorySegment ms,
                                 Vector<Long> indexVector,
                                 ByteOrder bo);

I agree with your choice of offset-mode.
Non-scaled offsets are more suitable for index in memory segments version.
Support of scaled indexes could be extended base on it.
Thanks a lot for your suggestion on it.

If we decide to add more capabilities at API level, we could build them on top of fundamental APIs as you told us.

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

PR: https://git.openjdk.org/panama-vector/pull/201


More information about the panama-dev mailing list