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

8295967: RISC-V: Support negVI/negVL instructions for Vector API #10880

Closed
wants to merge 1 commit into from

Conversation

DingliZhang
Copy link
Member

@DingliZhang DingliZhang commented Oct 27, 2022

Hi,

This patch will add support of NegVI, NegVL for RISC-V and was implemented by referring to riscv-v-spec v1.0 [1].

Tests are performed on qemu with parameter -cpu rv64,v=true,vlen=256,vext_spec=v1.0. By adding the -XX:+PrintAssembly -Xcomp -XX:-TieredCompilation -XX:+LogCompilation -XX:LogFile=compile.log parameter when executing the test cases[2] [3] , the compilation log is as follows:

100     B16: #	out( B37 B17 ) <- in( B15 )  Freq: 77.0109
100     # castII of R9, #@castII
100     addw  R29, R9, zr	#@convI2L_reg_reg
104     slli  R29, R29, (#2 & 0x3f)	#@lShiftL_reg_imm
108     add R12, R30, R29	# ptr, #@addP_reg_reg
10c     addi  R12, R12, #16	# ptr, #@addP_reg_imm
110     vle V1, [R12]	#@loadV
118     vrsub.vx V1, V1, V1	#@vnegI
120     bgeu  R9, R10, B37	#@cmpU_branch  P=0.000001 C=-1.000000

At the same time, the following assembly code will be generated:

  0x000000400ccfa618:   .4byte	0x10072d7
  0x000000400ccfa61c:   .4byte	0xe1040d7                   ;*invokestatic unaryOp {reexecute=0 rethrow=0 return_oop=0}
                                                            ; - jdk.incubator.vector.IntVector::lanewiseTemplate@91 (line 684)
                                                            ; - jdk.incubator.vector.Int256Vector::lanewise@2 (line 273)
                                                            ; - jdk.incubator.vector.Int256Vector::lanewise@2 (line 41)
                                                            ; - Int256VectorTests::NEGInt256VectorTests@73 (line 5216)

PS: 0x10072d7/0xe1040d7 are the machine code for vsetvli/vrsub.

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 [4].

In the meantime, I also add an assembly pseudoinstruction vneg.v in macroAssembler_riscv.

[1] https://github.com/riscv/riscv-v-spec/blob/v1.0/v-spec.adoc#111-vector-single-width-integer-add-and-subtract
[2] https://github.com/openjdk/jdk/tree/master/test/jdk/jdk/incubator/vector/Int256VectorTests.java
[3] https://github.com/openjdk/jdk/tree/master/test/jdk/jdk/incubator/vector/Long256VectorTests.java
[4] 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 on unmatched board without new failures
  • test/jdk/jdk/incubator/vector/Int256VectorTests.java with fastdebug on qemu
  • test/jdk/jdk/incubator/vector/Long256VectorTests.java with fastdebug 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-8295967: RISC-V: Support negVI/negVL instructions for Vector API

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10880

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 27, 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 Oct 27, 2022
@openjdk
Copy link

openjdk bot commented Oct 27, 2022

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

  • hotspot

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 hotspot-dev@openjdk.org label Oct 27, 2022
@mlbridge
Copy link

mlbridge bot commented Oct 27, 2022

Webrevs

Copy link
Contributor

@yadongw yadongw 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
Member

@RealFYang RealFYang 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. Thanks.

@openjdk
Copy link

openjdk bot commented Nov 4, 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:

8295967: RISC-V: Support negVI/negVL instructions for Vector API

Reviewed-by: yadongwang, fyang

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 82 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 4, 2022
@DingliZhang
Copy link
Member Author

@yadongw @RealFYang Thanks for the review!
/integrate

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

openjdk bot commented Nov 4, 2022

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

@RealFYang
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Nov 4, 2022

Going to push as commit c116ae7.
Since your change was applied there have been 82 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 Nov 4, 2022
@openjdk openjdk bot closed this Nov 4, 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 Nov 4, 2022
@openjdk
Copy link

openjdk bot commented Nov 4, 2022

@RealFYang @DingliZhang Pushed as commit c116ae7.

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