RFR: 8301012: [vectorapi]: Intrinsify CompressBitsV/ExpandBitsV and add the AArch64 SVE backend implementation

Nick Gasson ngasson at openjdk.org
Mon Feb 13 09:54:27 UTC 2023


On Mon, 6 Feb 2023 17:23:20 GMT, Bhavana Kilambi <bkilambi at openjdk.org> wrote:

> This patch adds mid-end compiler vector IR nodes for the scalar CompressBits and ExpandBits nodes - CompressBitsV and ExpandBitsV and also adds aarch64 backend support for these nodes using SVE2 instructions (included in the svebitperm feature). As there are direct instructions in SVE2 that map to these operations, a huge speed up in performance can be observed and it might significantly benefit all those workloads that extensively run these operations on an SVE2(with svebitperm feature) supporting machine.
> 
> All the JTREG tests under "test/jdk/jdk/incubator/vector" pass successfully with this patch on an SVE2 machine.
> The JMH tests - COMPRESS_BITS and EXPAND_BITS from [1] and [2] were run on a 128-bit vector length, SVE2 and svebitperm supporting aarch64 machine. Following are the gains observed with this patch -
> 
> 
> Benchmark                       (length)  Mode    Cnt   Gain
> IntMaxVector.COMPRESS_BITS      1024      thrpt   15    81.68x
> IntMaxVector.EXPAND_BITS        1024      thrpt   15    85.65x
> LongMaxVector.COMPRESS_BITS     1024      thrpt   15    70.78x
> LongMaxVector.EXPAND_BITS       1024      thrpt   15    76.31x
> 
> 
> The "Gain" column is the ratio between the throughput of benchmark runs with this patch and that of benchmark runs without this patch. This patch does not change the performance of these operations for all other machines that do not support these instructions or when run on a different architecture.
> With this patch, vectorization of CompressBits and ExpandBits operations happens only through vectorapi for aarch64. Autovectorization does not take place as the current JDK source does not contain aarch64 backend implementation for scalar CompressBits and ExpandBits. However, this PR - https://github.com/openjdk/jdk/pull/10537 adds aarch64 backend implementaton for CompressBits and ExpandBits and may lead to autovectorization of these nodes as well eventually but this PR is a standalone one and not dependent on the scalar implementation.
> 
> [1] https://github.com/openjdk/panama-vector/blob/vectorIntrinsics/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/IntMaxVector.java 
> [2] https://github.com/openjdk/panama-vector/blob/vectorIntrinsics/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/LongMaxVector.java

The test and changes under `cpu/aarch64` look OK to me but needs someone else to review the C2 changes.

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

Marked as reviewed by ngasson (Reviewer).

PR: https://git.openjdk.org/jdk/pull/12446


More information about the hotspot-dev mailing list