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
8275167: x86 intrinsic for unsignedMultiplyHigh #5933
Conversation
Hi @vamsi-parasa, welcome to this OpenJDK project and thanks for contributing! We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user vamsi-parasa" as summary for the issue. If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing |
/covered |
@vamsi-parasa The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
Thank you! Please allow for a few business days to verify that your employer has signed the OCA. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated! |
/label hotspot-compiler |
@vamsi-parasa |
Webrevs
|
The |
src/hotspot/share/opto/mulnode.cpp
Outdated
// It is not worth trying to constant fold this stuff! | ||
return TypeLong::LONG; | ||
} | ||
|
||
//============================================================================= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MulHiLNode::Value() and UMulHiLNode::Value() seem to be identical. Perhaps some refactoring would be in order, maybe make a common shared routine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, will do the refactoring to use a shared routine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed the refactored code to use a common routine for MulHiLNode::Value() and UMulHiLNode::Value(). Please review...
public long unsignedMultiplyHighLongLong() { | ||
return Math.unsignedMultiplyHigh(long747, long13); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, the JMH overhead dominates when trying to measure the latency of events in the nanosecond range. unsignedMultiplyHigh
should have a latency of maybe 1.5-2ns. Is that what you saw?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the JMH overhead was dominating the measurement of latency. The latency observed for unsignedMultiplyHigh
was 2.3ns with the intrinsic enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How you verified correctness of results?
I suggest to extend test/jdk//java/lang/Math/MultiplicationTests.java
test to cover unsigned method.
Tests for unsignedMultiplyHigh were already added in test/jdk//java/lang/Math/MultiplicationTests.java (in July 2021 by Brian Burkhalter). Used that test to verify the correctness of the results. |
Good. It seems I have old version of the test. |
The tests were not run with -Xcomp. Looked at the generated x86 code using the disassembler (hsdis) and verified that that correct instruction (mul) instead of (imul, without the intrinsic) was being generated. |
…UMulHiLNode and MulHiLNode
I have verified that the intrinsic is being used by looking at the x86 assembly code generated by using perfasm profiler. |
The patch looks good to me. |
@vnkozlov if the patch looks ok to you, could you please run this through your testing? |
|
@vamsi-parasa This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
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 116 new commits pushed to the
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 (@vnkozlov, @sviswa7) but any other Committer may sponsor as well.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. And I submitted testing.
Tests passed. You can integrate changes. |
Thanks Vladimir! What are the next steps to integrate the change? |
/integrate |
@vamsi-parasa |
/sponsor |
Going to push as commit af7c56b.
Your commit was automatically rebased without conflicts. |
@sviswa7 @vamsi-parasa Pushed as commit af7c56b. |
@@ -1390,6 +1390,7 @@ public static long multiplyHigh(long x, long y) { | |||
* @see #multiplyHigh | |||
* @since 18 | |||
*/ | |||
@IntrinsicCandidate | |||
public static long unsignedMultiplyHigh(long x, long y) { | |||
// Compute via multiplyHigh() to leverage the intrinsic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ijuma, thanks for making a comment in an OpenJDK project!
All comments and discussions in the OpenJDK Community must be made available under the OpenJDK Terms of Use. If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please Use "Add GitHub user ijuma for the summary.
If you are not an OpenJDK Author, Committer or Reviewer, simply check the box below to accept the OpenJDK Terms of Use for your comments.
- I agree to the OpenJDK Terms of Use for all comments I make in a project in the OpenJDK GitHub organization.
Your comment will be automatically restored once you have accepted the OpenJDK Terms of Use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for spotting the stale comment. It will removed in another related commit that will be pushed soon...
Optimize the new Math.unsignedMultiplyHigh using the x86 mul instruction. This change show 1.87X improvement on a micro benchmark.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5933/head:pull/5933
$ git checkout pull/5933
Update a local copy of the PR:
$ git checkout pull/5933
$ git pull https://git.openjdk.java.net/jdk pull/5933/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 5933
View PR using the GUI difftool:
$ git pr show -t 5933
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5933.diff