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

8295948: Support for Zicbop/prefetch instructions on RISC-V #10884

Closed
wants to merge 10 commits into from

Conversation

luhenry
Copy link
Member

@luhenry luhenry commented Oct 27, 2022

The OpenJDK supports generating prefetch instructions on most platforms. RISC-V supports through the Zicbop extension the use of prefetch instructions. We want to make sure we use these instructions whenever they are available.

It passes hotspot:tier1 test suite


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-8295948: Support for Zicbop/prefetch instructions on RISC-V

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10884

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

Using diff file

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

The OpenJDK supports generating prefetch instructions on most platforms.
RISC-V supports through the Zicbop extension the use of prefetch
instructions. We want to make sure we use these instructions whenever
they are available.
@bridgekeeper
Copy link

bridgekeeper bot commented Oct 27, 2022

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

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

@luhenry
Copy link
Member Author

luhenry commented Oct 31, 2022

@RealFYang let me know what you think. Thanks!

@RealFYang
Copy link
Member

@luhenry : Sorry for late reply. I am looking this this now.

@luhenry
Copy link
Member Author

luhenry commented Nov 1, 2022

@RealFYang perfect, thank you

src/hotspot/cpu/riscv/riscv.ad Outdated Show resolved Hide resolved
void (*stub)(const void*, intptr_t) =
(void (*)(const void*, intptr_t))StubRoutines::riscv::prefetch_r();
if (interval >= 0 && stub != NULL) {
stub(loc, interval);
Copy link
Member

@RealFYang RealFYang Nov 2, 2022

Choose a reason for hiding this comment

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

I am not sure if it really worth it to call a stub for read / write here. It looks to me not a big issue for the case the stub tries to catch and resolve. And I see aarch64 simply plant a 'prfm' instruction for prefetching [1]. I guess we might can do the same?

[1] https://github.com/openjdk/jdk/blob/master/src/hotspot/os_cpu/linux_aarch64/prefetch_linux_aarch64.inline.hpp#L34

Copy link
Member Author

@luhenry luhenry Nov 2, 2022

Choose a reason for hiding this comment

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

We would need to check for UseZicbop in any case; the access to a global variable is then required.

It would be the same issue as https://github.com/openjdk/jdk/pull/10884/files/e968f7164124dcf560807c9ff7765e6f82b64cdd#diff-e3c18b8b83898e82b5a3069319df6a47468e91cc2527bf065e704a685a20f26bR5196 without the stub.

I've to admit that the interval naming here is confusing since no implementation ever uses it as an interval but alway as an offset. Also, the callers assume it to be an offset, like ContiguousSpace::prepare_for_compaction for example.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I agree that a check for UseZicbop option would be necessary. But I still don't understand why we should implement this through a stub here. It looks to me that CPP code with inline assembly would also do. At least this could help eliminate the prologue & epilogue cost of calling the stub.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can definitely go with inline assembly here, just not sure that prefetch.r or prefetch.w would be recognized by the assembler. However, given that prefetch.* is an ori under the hood, we can simply use that.

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.

Updated changes looks good except for the indentation issue.

@openjdk
Copy link

openjdk bot commented Nov 4, 2022

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

8295948: Support for Zicbop/prefetch instructions on RISC-V

Reviewed-by: fyang, yadongwang

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 144 new commits pushed to the master branch:

  • f2acdfd: 8296638: RISC-V: NegVI node emits wrong code when vector element basic type is T_BYTE/T_SHORT
  • bfc5816: 8295475: Move non-resource allocation strategies out of ResourceObj
  • e802b12: 8296196: Class.getEnumConstants() throws undocumented ClassCastException and NullPointerException
  • 78a08a0: 8295430: Use cmsDoTransformLineStride instead of cmsDoTransform in the loop
  • f0a6e71: 8295812: Skip the "half float" support in LittleCMS during the build
  • 79c0092: 8285635: javax/swing/JRootPane/DefaultButtonTest.java failed with Default Button not pressed for L&F: com.sun.java.swing.plaf.motif.MotifLookAndFeel
  • 0981bfb: 8296156: [macos] Resize DMG windows and background to fit additional DMG contents
  • 93fed9b: 8296448: RISC-V: Fix temp usages of heapbase register killed by MacroAssembler::en/decode_klass_not_null
  • d6e2d0d: 8296611: Problemlist several sun/security tests until JDK-8295343 is resolved
  • 102b2b3: 8292033: Move jdk.X509Certificate event logic to JCA layer
  • ... and 134 more: https://git.openjdk.org/jdk/compare/628820f47ef9c9ad3cc62e68db9c4dbc7e659154...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 Nov 4, 2022
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.

Still looks good. Thanks.

@luhenry
Copy link
Member Author

luhenry commented Nov 4, 2022

/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

@luhenry
Your change (at version 51725fd) is now ready to be sponsored by a Committer.

@openjdk openjdk bot removed the sponsor Pull request is ready to be sponsored label Nov 8, 2022
@luhenry
Copy link
Member Author

luhenry commented Nov 8, 2022

/integrate

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

openjdk bot commented Nov 8, 2022

@luhenry
Your change (at version 42a61aa) is now ready to be sponsored by a Committer.

@luhenry
Copy link
Member Author

luhenry commented Nov 8, 2022

@RealFYang @yadongw could you please review+sponsor if it looks all good to you? Thanks!

@openjdk openjdk bot removed the sponsor Pull request is ready to be sponsored label Nov 9, 2022
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

@RealFYang
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Nov 10, 2022

@RealFYang The PR has been updated since the change author (@luhenry) issued the integrate command - the author must perform this command again.

@luhenry
Copy link
Member Author

luhenry commented Nov 10, 2022

/integrate

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

openjdk bot commented Nov 10, 2022

@luhenry
Your change (at version 3f70a21) is now ready to be sponsored by a Committer.

@RealFYang
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Nov 10, 2022

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

  • f2acdfd: 8296638: RISC-V: NegVI node emits wrong code when vector element basic type is T_BYTE/T_SHORT
  • bfc5816: 8295475: Move non-resource allocation strategies out of ResourceObj
  • e802b12: 8296196: Class.getEnumConstants() throws undocumented ClassCastException and NullPointerException
  • 78a08a0: 8295430: Use cmsDoTransformLineStride instead of cmsDoTransform in the loop
  • f0a6e71: 8295812: Skip the "half float" support in LittleCMS during the build
  • 79c0092: 8285635: javax/swing/JRootPane/DefaultButtonTest.java failed with Default Button not pressed for L&F: com.sun.java.swing.plaf.motif.MotifLookAndFeel
  • 0981bfb: 8296156: [macos] Resize DMG windows and background to fit additional DMG contents
  • 93fed9b: 8296448: RISC-V: Fix temp usages of heapbase register killed by MacroAssembler::en/decode_klass_not_null
  • d6e2d0d: 8296611: Problemlist several sun/security tests until JDK-8295343 is resolved
  • 102b2b3: 8292033: Move jdk.X509Certificate event logic to JCA layer
  • ... and 134 more: https://git.openjdk.org/jdk/compare/628820f47ef9c9ad3cc62e68db9c4dbc7e659154...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Nov 10, 2022

@RealFYang @luhenry Pushed as commit 4465361.

💡 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