Skip to content

Conversation

@gctony
Copy link
Contributor

@gctony gctony commented Aug 4, 2023

Small improvement of the MD5 intrinsic when the Zbb extension is available. Performance comparison (with thanks again to @robehn for this!):

before:

MessageDigests.digest                   md5        64     DEFAULT  avgt    6    1835.246 ±  252.071  ns/op
MessageDigests.digest                   md5     16384     DEFAULT  avgt    6  145386.522 ±  444.446  ns/op
MessageDigests.getAndDigest             md5        64     DEFAULT  avgt    6    2555.515 ±  639.491  ns/op
MessageDigests.getAndDigest             md5     16384     DEFAULT  avgt    6  149045.631 ± 6658.545  ns/op

after:

MessageDigests.digest                   md5        64     DEFAULT  avgt    6    1779.637 ±  207.869  ns/op
MessageDigests.digest                   md5     16384     DEFAULT  avgt    6  137147.179 ±  706.396  ns/op
MessageDigests.getAndDigest             md5        64     DEFAULT  avgt    6    2645.354 ± 1245.318  ns/op
MessageDigests.getAndDigest             md5     16384     DEFAULT  avgt    6  141306.966 ± 7000.576  ns/op

(only line 3 is not an improvement, but it has higher variation)

It seems to save around 5% of executed instructions.


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-8313779: RISC-V: use andn / orn in the MD5 instrinsic (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 15156

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 4, 2023

👋 Welcome back tonyp! 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 Aug 4, 2023
@openjdk
Copy link

openjdk bot commented Aug 4, 2023

@gctony 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 Aug 4, 2023
@mlbridge
Copy link

mlbridge bot commented Aug 4, 2023

Webrevs

@gctony
Copy link
Contributor Author

gctony commented Aug 4, 2023

Was not sure how to differentiate between the andn and orn in the assembler and the macro assembler. I added an r suffix. If there's a better way, let me know!

@gctony
Copy link
Contributor Author

gctony commented Aug 4, 2023

correctness testing:

test/jdk/java/security/MessageDigest
test/hotspot/jtreg/compiler/intrinsics/sha/sanity

with -UseZbb and +UseZbb

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.
BTW: I noticed that two li are used in your previous PR to implement MD5 intrinsic:

./stubGenerator_riscv.cpp:    __ li(rtmp2, t);
./stubGenerator_riscv.cpp:    __ li(rmask32, MASK_32);

I think It should be more consistent if you use 'mv' instead as we did in other places when moving an immediate into register.

template<typename T, ENABLE_IF(std::is_integral<T>::value)>
inline void mv(Register Rd, T o)                    { li(Rd, (int64_t)o); }

@openjdk
Copy link

openjdk bot commented Aug 6, 2023

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

8313779: RISC-V: use andn / orn in the MD5 instrinsic

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

  • bbbfa21: 8313880: Incorrect copyright header in jdk/java/foreign/TestFree.java after JDK-8310643
  • 0bb6af3: 8313791: Fix just zPage.inline.hpp and xPage.inline.hpp
  • 4b192a8: 8313676: Amend TestLoadIndexedMismatch test to target intrinsic directly
  • 0b4387e: 8310643: Misformatted copyright messages in FFM
  • 538f955: 8313701: GHA: RISC-V should use the official repository for bootstrap
  • 226cdc6: 8312585: Rename DisableTHPStackMitigation flag to THPStackMitigation
  • dc01604: 8305636: Expand and clean up predicate classes and move them into separate files
  • a38fdaf: 8166900: If you wrap a JTable in a JLayer, the cursor is moved to the last row of table by you press the page down key.
  • c1f4595: 8311160: [macOS, Accessibility] VoiceOver: No announcements on JRadioButtonMenuItem and JCheckBoxMenuItem
  • 90d795a: 8313141: Missing check for os_thread type in os_windows.cpp
  • ... and 33 more: https://git.openjdk.org/jdk/compare/b093880acd89d8d0bccd4b8b260b721f4dcfc161...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.

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

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 6, 2023
@gctony
Copy link
Contributor Author

gctony commented Aug 7, 2023

I think It should be more consistent if you use 'mv' instead as we did in other places when moving an immediate into register.

Thanks for the suggestion @RealFYang ! I thought mv was for register to register copy. But I'll change li to mv in those two places. I'll integrate the change as soon as I retest.

@gctony
Copy link
Contributor Author

gctony commented Aug 7, 2023

Tests pass (with both -UseZbb and +UseZbb) with the li -> mv change. I also confirmed that the generated code is the same.

@gctony
Copy link
Contributor Author

gctony commented Aug 7, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Aug 7, 2023

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

  • bbbfa21: 8313880: Incorrect copyright header in jdk/java/foreign/TestFree.java after JDK-8310643
  • 0bb6af3: 8313791: Fix just zPage.inline.hpp and xPage.inline.hpp
  • 4b192a8: 8313676: Amend TestLoadIndexedMismatch test to target intrinsic directly
  • 0b4387e: 8310643: Misformatted copyright messages in FFM
  • 538f955: 8313701: GHA: RISC-V should use the official repository for bootstrap
  • 226cdc6: 8312585: Rename DisableTHPStackMitigation flag to THPStackMitigation
  • dc01604: 8305636: Expand and clean up predicate classes and move them into separate files
  • a38fdaf: 8166900: If you wrap a JTable in a JLayer, the cursor is moved to the last row of table by you press the page down key.
  • c1f4595: 8311160: [macOS, Accessibility] VoiceOver: No announcements on JRadioButtonMenuItem and JCheckBoxMenuItem
  • 90d795a: 8313141: Missing check for os_thread type in os_windows.cpp
  • ... and 33 more: https://git.openjdk.org/jdk/compare/b093880acd89d8d0bccd4b8b260b721f4dcfc161...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Aug 7, 2023

@gctony Pushed as commit 4726960.

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

@gctony gctony deleted the gctony_8313779_Md5IntrinsicZbb branch August 7, 2023 14:20
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

Development

Successfully merging this pull request may close these issues.

3 participants