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

8308817: RISC-V: Support VectorTest node for Vector API #14138

Closed
wants to merge 1 commit into from

Conversation

zifeihan
Copy link
Member

@zifeihan zifeihan commented May 25, 2023

Hi,

we have added VectorTest node, It was implemented by referring to RVV v1.0 [1]. please take a look and have some reviews. Thanks a lot.
We can use the Int256VectorTests.java[2] to print the compilation log, verify and observe the generation of nodes.

For example, we can use the following command to print the compilation log of a jtreg test case:

/home/zifeihan/jdk-tools/jtreg/bin/jtreg \
-v:default \
-concurrency:16 -timeout:50 \
-javaoption:-XX:+UnlockExperimentalVMOptions \
-javaoption:-XX:+UseRVV \
-javaoption:-XX:+PrintOptoAssembly \
-javaoption:-XX:LogFile=/home/zifeihan/jdk-rvv/Int256VectorTests_PrintOptoAssembly_20230525.log \
-jdk:/home/zifeihan/jdk-rvv/build/linux-riscv64-server-fastdebug/jdk \
-compilejdk:/home/zifeihan/jdk-rvv/build/linux-x86_64-server-release/images/jdk \
/home/zifeihan/jdk/test/jdk/jdk/incubator/vector/Int256VectorTests.java

Also here's a more concise test case, VectorTestDemo:

import jdk.incubator.vector.ByteVector;
import jdk.incubator.vector.VectorMask;

public class VectorTestDemo {
    static boolean[] d = new boolean[]{true, false, false, false, false, false, false, false};
    static VectorMask<Byte> avmask = VectorMask.fromArray(ByteVector.SPECIES_64, d, 0);

    public static void main(String[] args) {
        for (int i = 0; i < 300000; i++) {
            
            final boolean alltrue = alltrue();
            if (alltrue != false) {
                throw new RuntimeException("alltrue");
            }
            final boolean anytrue = anytrue();
            if (anytrue != true) {
                throw new RuntimeException("anytrue");
            }
        }
    }

    public static boolean anytrue() {
        return avmask.anyTrue();
    }

    public static boolean alltrue() {
        return avmask.allTrue();
    }
}

We can compile VectorTestDemo.java using javac --add-modules jdk.incubator.vector VectorTestDemo.java, and use ./java -XX:-TieredCompilation -XX:+UnlockExperimentalVMOptions -XX:+UseRVV -XX:+PrintOptoAssembly -XX:+LogCompilation -XX:LogFile=compile.log VectorTestDemo > aaa.log to start the test case, we can observe the specified compilation log compile.log, which contains the VectorTest node for the PR implementation.
Some of the compilation logs of VectorTestDemo#anytrue method are as follows.

05e lwu R28, [R7, #12] # loadN, compressed ptr, #@loadN ! Field: jdk/internal/vm/vector/VectorSupport$VectorPayload.payload (constant)
062 decode_heap_oop R7, R28 #@decodeHeapOop
066 addi R7, R7, #16 # ptr, #@addP_reg_imm
068 loadV V1, [R7] # vector (rvv)
070 vloadmask V0, V1
078 CMove R10, (vectortest eq V0 V0), zero, one #@cmovI_vtest_anytrue_negate

Some of the compilation logs of the VectorTestDemo#alltrue method are as follows.

05e lwu R28, [R7, #12] # loadN, compressed ptr, #@loadN ! Field: jdk/internal/vm/vector/VectorSupport$VectorPayload.payload (constant)
062 decode_heap_oop R7, R28 #@decodeHeapOop
066 addi R7, R7, #16 # ptr, #@addP_reg_imm
068 loadV V1, [R7] # vector (rvv)
070 vloadmask V0, V1
078 CMove R10, (vectortest ne V0 V0), zero, one #@cmovI_vtest_alltrue_negate

Some of the compilation logs of VectorTest#main method are as follows.

0b2 decode_heap_oop R7, R7 #@decodeHeapOop
0b4 addi R7, R7, #16 # ptr, #@addP_reg_imm
0b6 loadV V1, [R7] # vector (rvv)
0be vloadmask V0, V1
0c6 CMove R28, (vectortest eq V0 V0), zero, one #@cmovI_vtest_anytrue_negate
0d2 beq (vectortest overflow V0, V0) B8 #@vtest_alltrue_branch P=0.000001 C=-1.000000

As comment in the PR in cmovI_vtest_anytrue instruct, cmpOp is negated in CMoveINode::Ideal. So we keep this version for better understanding of the code change.

[1] https://github.com/riscv/riscv-v-spec/blob/v1.0/v-spec.adoc
[2] https://github.com/openjdk/jdk/blob/master/test/jdk/jdk/incubator/vector/Int256VectorTests.java

Testing:

qemu with UseRVV:

  • Tier1 tests (release)
  • Tier2 tests (release)
  • Tier3 tests (release)
  • test/jdk/jdk/incubator/vector (fastdebug)

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-8308817: RISC-V: Support VectorTest node for Vector API

Reviewers

Contributors

  • Dingli Zhang <dingli@iscas.ac.cn>

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14138

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 25, 2023

👋 Welcome back gcao! 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.

@zifeihan
Copy link
Member Author

/contributor add Dingli Zhang dingli@iscas.ac.cn

@openjdk openjdk bot added the rfr Pull request is ready for review label May 25, 2023
@openjdk
Copy link

openjdk bot commented May 25, 2023

@zifeihan
Contributor Dingli Zhang <dingli@iscas.ac.cn> successfully added.

@openjdk
Copy link

openjdk bot commented May 25, 2023

@zifeihan 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 May 25, 2023
@mlbridge
Copy link

mlbridge bot commented May 25, 2023

Webrevs

Copy link
Member

@feilongjiang feilongjiang 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

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.

@openjdk
Copy link

openjdk bot commented May 26, 2023

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

8308817: RISC-V: Support VectorTest node for Vector API

Co-authored-by: Dingli Zhang <dingli@iscas.ac.cn>
Reviewed-by: fjiang, 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 56 new commits pushed to the master branch:

  • 7508d9f: 8308906: Make CIPrintCompilerName a diagnostic flag
  • a4bae3a: 8309060: Compilation Error in javax/swing/event/FocusEventCauseTest.java
  • d73fc70: 8289547: Update javax/swing/Popup/TaskbarPositionTest.java
  • 7cf6eec: 8307488: Incorrect weight of the first ObjectAllocationSample JFR event
  • a5d8d59: 8308930: [JVMCI] TestUncaughtErrorInCompileMethod times out
  • 70130d3: 8306119: Many components respond to a mouse event by requesting focus without supplying the MOUSE_EVENT cause
  • 6360b49: 8308948: Remove unimplemented ThreadLocalAllocBuffer::reset
  • e21f865: 8308915: RISC-V: Improve temporary vector register usage avoiding the use of v0
  • 547a8b4: 8306560: Add TOOLING.jsh load file
  • ca54f4e: 8306428: RunThese30M.java crashed with assert(early->flag() == current->flag() || early->flag() == mtNone)
  • ... and 46 more: https://git.openjdk.org/jdk/compare/1451ac1770aa1fde0a96e475dfe9a92bc76b4eb9...master

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 May 26, 2023
@zifeihan
Copy link
Member Author

@RealFYang @feilongjiang Thanks for the review.
/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label May 30, 2023
@openjdk
Copy link

openjdk bot commented May 30, 2023

@zifeihan
Your change (at version 2ab456f) is now ready to be sponsored by a Committer.

@RealFYang
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented May 30, 2023

Going to push as commit 457e1cb.
Since your change was applied there have been 56 commits pushed to the master branch:

  • 7508d9f: 8308906: Make CIPrintCompilerName a diagnostic flag
  • a4bae3a: 8309060: Compilation Error in javax/swing/event/FocusEventCauseTest.java
  • d73fc70: 8289547: Update javax/swing/Popup/TaskbarPositionTest.java
  • 7cf6eec: 8307488: Incorrect weight of the first ObjectAllocationSample JFR event
  • a5d8d59: 8308930: [JVMCI] TestUncaughtErrorInCompileMethod times out
  • 70130d3: 8306119: Many components respond to a mouse event by requesting focus without supplying the MOUSE_EVENT cause
  • 6360b49: 8308948: Remove unimplemented ThreadLocalAllocBuffer::reset
  • e21f865: 8308915: RISC-V: Improve temporary vector register usage avoiding the use of v0
  • 547a8b4: 8306560: Add TOOLING.jsh load file
  • ca54f4e: 8306428: RunThese30M.java crashed with assert(early->flag() == current->flag() || early->flag() == mtNone)
  • ... and 46 more: https://git.openjdk.org/jdk/compare/1451ac1770aa1fde0a96e475dfe9a92bc76b4eb9...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label May 30, 2023
@openjdk openjdk bot closed this May 30, 2023
@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 May 30, 2023
@openjdk
Copy link

openjdk bot commented May 30, 2023

@RealFYang @zifeihan Pushed as commit 457e1cb.

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

@zifeihan zifeihan deleted the JDK-8308817 branch July 19, 2023 14:56
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
3 participants