Skip to content

8355667: RISC-V: Add backend implementation for unsigned vector Min / Max operations #24909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

RealFYang
Copy link
Member

@RealFYang RealFYang commented Apr 28, 2025

Hi, please review this change.
https://bugs.openjdk.org/browse/JDK-8338021 proposed new vector operators including Unsigned Vector Min / Max.
This intrinsify Unsigned Vector Min / Max operations with RVV extension for RISC-V backend to improve performance.
This also enables some extra IR tests in file test/hotspot/jtreg/compiler/vectorapi/VectorCommutativeOperSharingTest.java.

Testing:

  • make test TEST="jdk_vector" (QEMU / fastdebug)

JMH tested on BPI-F3 SBC (256-bit VLEN) for reference:
Before:

ByteMaxVector.UMAX          1024  thrpt    5  58.657 ± 17.216  ops/ms
ByteMaxVector.UMAXMasked    1024  thrpt    5  45.581 ± 18.164  ops/ms
ByteMaxVector.UMIN          1024  thrpt    5  55.275 ± 15.863  ops/ms
ByteMaxVector.UMINMasked    1024  thrpt    5  44.651 ± 29.209  ops/ms
ShortMaxVector.UMAX          1024  thrpt    5  24.146 ± 7.570  ops/ms
ShortMaxVector.UMAXMasked    1024  thrpt    5  21.506 ± 0.430  ops/ms
ShortMaxVector.UMIN          1024  thrpt    5  24.261 ± 6.993  ops/ms
ShortMaxVector.UMINMasked    1024  thrpt    5  20.980 ± 1.622  ops/ms
IntMaxVector.UMAX          1024  thrpt    5  10.780 ± 0.812  ops/ms
IntMaxVector.UMAXMasked    1024  thrpt    5  10.609 ± 0.851  ops/ms
IntMaxVector.UMIN          1024  thrpt    5  10.845 ± 0.578  ops/ms
IntMaxVector.UMINMasked    1024  thrpt    5  10.705 ± 0.562  ops/ms
LongMaxVector.UMAX          1024  thrpt    5  5.445 ± 0.439  ops/ms
LongMaxVector.UMAXMasked    1024  thrpt    5  5.387 ± 0.285  ops/ms
LongMaxVector.UMIN          1024  thrpt    5  5.379 ± 0.407  ops/ms
LongMaxVector.UMINMasked    1024  thrpt    5  5.373 ± 0.236  ops/ms

After:

ByteMaxVector.UMAX          1024  thrpt    5  2552.161 ±  121.213  ops/ms
ByteMaxVector.UMAXMasked    1024  thrpt    5  2444.001 ±  105.139  ops/ms
ByteMaxVector.UMIN          1024  thrpt    5  2616.963 ±    3.065  ops/ms
ByteMaxVector.UMINMasked    1024  thrpt    5  2367.968 ± 1057.028  ops/ms
ShortMaxVector.UMAX          1024  thrpt    5  1363.676 ±   9.294  ops/ms
ShortMaxVector.UMAXMasked    1024  thrpt    5  1321.759 ± 121.471  ops/ms
ShortMaxVector.UMIN          1024  thrpt    5  1368.598 ±   5.251  ops/ms
ShortMaxVector.UMINMasked    1024  thrpt    5  1337.044 ±   1.434  ops/ms
IntMaxVector.UMAX          1024  thrpt    5  566.509 ±  0.658  ops/ms
IntMaxVector.UMAXMasked    1024  thrpt    5  559.456 ±  0.491  ops/ms
IntMaxVector.UMIN          1024  thrpt    5  569.238 ±  1.309  ops/ms
IntMaxVector.UMINMasked    1024  thrpt    5  535.359 ± 15.765  ops/ms
LongMaxVector.UMAX          1024  thrpt    5  367.765 ±  0.835  ops/ms
LongMaxVector.UMAXMasked    1024  thrpt    5  366.470 ±  1.179  ops/ms
LongMaxVector.UMIN          1024  thrpt    5  365.960 ±  2.007  ops/ms
LongMaxVector.UMINMasked    1024  thrpt    5  268.859 ± 14.090  ops/ms

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8355667: RISC-V: Add backend implementation for unsigned vector Min / Max operations (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24909/head:pull/24909
$ git checkout pull/24909

Update a local copy of the PR:
$ git checkout pull/24909
$ git pull https://git.openjdk.org/jdk.git pull/24909/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 24909

View PR using the GUI difftool:
$ git pr show -t 24909

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24909.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 28, 2025

👋 Welcome back fyang! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Apr 28, 2025

@RealFYang This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8355667: RISC-V: Add backend implementation for unsigned vector Min / Max operations

Reviewed-by: mli, gcao

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Apr 28, 2025

@RealFYang The following label will be automatically applied to this pull request:

  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@RealFYang RealFYang marked this pull request as ready for review April 28, 2025 03:03
@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 28, 2025
@mlbridge
Copy link

mlbridge bot commented Apr 28, 2025

Webrevs

Copy link
Member

@zifeihan zifeihan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link

@Hamlin-Li Hamlin-Li left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
Just one minor question, should we add an assert like below for these instructs? Seems not, but I'm not quite sure.

assert(Matcher::vector_element_basic_type(n) != T_FLOAT &&
            Matcher::vector_element_basic_type(n) != T_DOUBLE);

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 29, 2025
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Apr 29, 2025
@RealFYang
Copy link
Member Author

Looks good. Just one minor question, should we add an assert like below for these instructs? Seems not, but I'm not quite sure.

assert(Matcher::vector_element_basic_type(n) != T_FLOAT &&
            Matcher::vector_element_basic_type(n) != T_DOUBLE);

Good suggestion! I have added following assertion for these instructions just like other CPU ports.
Please take another look. Thanks.

assert(is_integral_type(bt), "unsupported type");

Copy link

@Hamlin-Li Hamlin-Li left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating, still good!

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 29, 2025
@RealFYang
Copy link
Member Author

Thanks for the review! Let's
/integrate

@openjdk
Copy link

openjdk bot commented Apr 29, 2025

Going to push as commit 2ed7ad4.
Since your change was applied there has been 1 commit pushed to the master branch:

  • 9f42ff8: 8355594: Warnings occur when building with clang and enabling ubsan

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Apr 29, 2025
@openjdk openjdk bot closed this Apr 29, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 29, 2025
@openjdk
Copy link

openjdk bot commented Apr 29, 2025

@RealFYang Pushed as commit 2ed7ad4.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler [email protected] integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants