Skip to content
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

8297549: RISC-V: Add support for Vector API vector load const operation #11344

Closed
wants to merge 1 commit into from

Conversation

DingliZhang
Copy link
Member

@DingliZhang DingliZhang commented Nov 24, 2022

The instruction which is matched VectorLoadConst will create index starting from 0 and incremented by 1. In detail, the instruction populates the destination vector by setting the first element to 0 and monotonically incrementing the value by 1 for each subsequent element.

We can add support of VectorLoadConst for RISC-V by vid.v . It was implemented by referring to RVV v1.0 [1].

We can use the JMH test from #10332. Tests are performed on qemu with parameter -cpu rv64,v=true,vlen=256,vext_spec=v1.0. By adding the -XX:+PrintAssembly, the compilation log of floatIndexVector is as follows:

120     vloadcon V2	# generate iota indices
12c     vfmul.vv V1, V2, V1	#@vmulF
134     vfmv.v.f  V2, F8	#@replicateF
13c     vfadd.vv V1, V2, V1	#@vaddF

The above nodes match the logic of Compute indexes with "vec + iota * scale" in #10332, which is the operation corresponding to addIndex in benchmark:

@Benchmark
public void floatIndexVector() {
for (int i = 0; i < size; i += fspecies.length()) {
((FloatVector) fspecies.broadcast(0).addIndex(i % 5)).intoArray(fa, i);
}
}

At the same time, the following assembly code will be generated when running the floatIndexVector case, there will be one more instruction than intIndexVector:

 0x000000401443cc9c:   .4byte	0x10072d7
 0x000000401443cca0:   .4byte	0x5208a157
 0x000000401443cca4:   .4byte	0x4a219157

0x10072d7/0x5208a157 is the machine code for vsetvli/vid.v and 0x4a219157 is the additional machine code for vfcvt.f.x.v, which are the opcodes generated by is_floating_point_type(bt):

    if (is_floating_point_type(bt)) {
      __ vfcvt_f_x_v(as_VectorRegister($dst$$reg), as_VectorRegister($dst$$reg));
    }

After we implement these nodes, by using -XX:+UseRVV, the number of assembly instructions is reduced by about ~50% because of the different execution paths with the number of loops, similar to AddTest [3].

[1] https://github.com/riscv/riscv-v-spec/blob/v1.0/v-spec.adoc
[2] https://github.com/openjdk/jdk/blob/857b0f9b05bc711f3282a0da85fcff131fffab91/test/micro/org/openjdk/bench/jdk/incubator/vector/IndexVectorBenchmark.java
[3] https://github.com/zifeihan/vector-api-test-rvv/blob/master/vector-api-rvv-performance.md

Please take a look and have some reviews. Thanks a lot.

Testing:

  • hotspot and jdk tier1 without new failures (release with UseRVV on QEMU)
  • hotspot, jdk and langtools tier2 without new failures (release with UseRVV on QEMU)
  • test/jdk/jdk/incubator/vector/* (fastdebug/release with UseRVV on QEMU)

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-8297549: RISC-V: Add support for Vector API vector load const operation

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11344

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

Using diff file

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

@DingliZhang DingliZhang changed the title 8297549: RISC-V: Support vloadcon instructions for Vector API 8297549: RISC-V: Support vloadcon instruction for Vector API Nov 24, 2022
@bridgekeeper
Copy link

bridgekeeper bot commented Nov 24, 2022

👋 Welcome back dzhang! 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 openjdk bot added the rfr Pull request is ready for review label Nov 24, 2022
@openjdk
Copy link

openjdk bot commented Nov 24, 2022

@DingliZhang 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.

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Nov 24, 2022
@mlbridge
Copy link

mlbridge bot commented Nov 24, 2022

Webrevs

@DingliZhang DingliZhang changed the title 8297549: RISC-V: Support vloadcon instruction for Vector API 8297549: RISC-V: Add support for Vector API vector load const operation Nov 25, 2022
@VladimirKempik
Copy link

Can you also run whole tier2 please ?

@DingliZhang
Copy link
Member Author

Can you also run whole tier2 please ?

Thank you for your suggestion, of course! I will add the results of whole tier2 later.

@openjdk
Copy link

openjdk bot commented Nov 29, 2022

@DingliZhang 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:

8297549: RISC-V: Add support for Vector API vector load const operation

Reviewed-by: fyang, 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 136 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@RealFYang) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 29, 2022
@DingliZhang
Copy link
Member Author

Can you also run whole tier2 please ?

Hi @VladimirKempik I've run tier2 and updated the test status at the top of the page.

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, thanks

@DingliZhang
Copy link
Member Author

@VladimirKempik @RealFYang @zifeihan Thanks for the review!
/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Dec 2, 2022
@openjdk
Copy link

openjdk bot commented Dec 2, 2022

@DingliZhang
Your change (at version 77f7607) is now ready to be sponsored by a Committer.

@RealFYang
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Dec 2, 2022

Going to push as commit 687fd71.
Since your change was applied there have been 137 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Dec 2, 2022
@openjdk openjdk bot closed this Dec 2, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Dec 2, 2022
@openjdk
Copy link

openjdk bot commented Dec 2, 2022

@RealFYang @DingliZhang Pushed as commit 687fd71.

💡 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 hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants