Vectorized vs. unvectorized array access
Vladimir Kozlov
vladimir.kozlov at oracle.com
Mon Aug 22 20:09:48 UTC 2016
Hi Nassim
It is due to complexity of index expressions because they have hidden a shift (multiply by element size) operation to calculate address of array elements. You can try byte[] array which does not have
a shift to see if it is true.
Regards,
Vladimir
On 8/17/16 10:22 AM, Nassim Halli wrote:
>
> Hi everyone,
>
> I have a basic kernel with a "per bloc" access pattern. Only one of the following implementations is vectorized by C2 (java 1.8.0_51).
>
> Does anyone know the reason why ? What Is the rule to avoid those vectorization barriers ?
>
> The code loops linearly over the primitive arrays a & b by packet of size PACKET_SIZE (here the per-bloc access is useless but simplifies the code).
>
> Loop constants are in capital letters.
>
> *Vectorized*
>
> |for| |(||int| |ibeg||=||0||; |||ibeg|||<(NB_PACKETS*PACKET_SIZE); |||ibeg|||+=PACKET_SIZE)|
> |||for| |(||int| |i=|||ibeg|||; i<(|||ibeg|||+PACKET_SIZE); ++i)|
> |||a[i] += b[i];
>
> |*Unvectorized
>
> *
> |for| |(||int| |ibeg||=||0||; |||ibeg|||<(NB_PACKETS*PACKET_SIZE); |||ibeg|||+=PACKET_SIZE)|
> |||for| |(||int| |off||=||0||; off<PACKET_SIZE; ++off)|
> |||a[|||ibeg|||+off] += b[|||ibeg|||+off];|
> *
>
> **Unvectorized*
>
> |for| |(||int| |packet=||0||; packet<NB_PACKETS; ++packet)|
> |||for| |(||int| |off||=||0||; off<PACKET_SIZE; ++off)|
> |||a[(packet*PACKET_SIZE)+off] += b[(packet_id*PACKET_SIZE)+off];|
>
>
> Thanks a lot,
> Nassim.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20160822/219f7623/attachment.html>
More information about the hotspot-compiler-dev
mailing list