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

8269559: AArch64: Implement string_compare intrinsic in SVE #5129

Closed
wants to merge 4 commits into from

Conversation

tatwaichong
Copy link
Contributor

@tatwaichong tatwaichong commented Aug 16, 2021

This patch implements string_compare intrinsic in SVE.
It supports all LL, LU, UL and UU comparisons.

As we haven't found an existing benchmark to measure performance impact,
we created a benchmark derived from the test [1] for this evaluation.
This benchmark is attached to this patch.

Besides, remove the unused temporary register vtmp3 from the existing
match rules for StrCmp.

The result below shows all varients can be benefited largely.
Command: make exploded-test TEST="micro:StringCompareToDifferentLength"

Benchmark (size) Mode Cnt Score Speedup Units
compareToLL 24 avgt 10 1.0x ms/op
compareToLL 36 avgt 10 1.0x ms/op
compareToLL 72 avgt 10 1.0x ms/op
compareToLL 128 avgt 10 1.4x ms/op
compareToLL 256 avgt 10 1.8x ms/op
compareToLL 512 avgt 10 2.7x ms/op
compareToLU 24 avgt 10 1.6x ms/op
compareToLU 36 avgt 10 1.8x ms/op
compareToLU 72 avgt 10 2.3x ms/op
compareToLU 128 avgt 10 3.8x ms/op
compareToLU 256 avgt 10 4.7x ms/op
compareToLU 512 avgt 10 6.3x ms/op
compareToUL 24 avgt 10 1.6x ms/op
compareToUL 36 avgt 10 1.7x ms/op
compareToUL 72 avgt 10 2.2x ms/op
compareToUL 128 avgt 10 3.3x ms/op
compareToUL 256 avgt 10 4.4x ms/op
compareToUL 512 avgt 10 6.1x ms/op
compareToUU 24 avgt 10 1.0x ms/op
compareToUU 36 avgt 10 1.0x ms/op
compareToUU 72 avgt 10 1.4x ms/op
compareToUU 128 avgt 10 2.2x ms/op
compareToUU 256 avgt 10 2.6x ms/op
compareToUU 512 avgt 10 3.7x ms/op

[1] https://github.com/openjdk/jdk/blob/master/test/hotspot/jtreg/compiler/intrinsics/string/TestStringCompareToDifferentLength.java


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8269559: AArch64: Implement string_compare intrinsic in SVE

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5129/head:pull/5129
$ git checkout pull/5129

Update a local copy of the PR:
$ git checkout pull/5129
$ git pull https://git.openjdk.java.net/jdk pull/5129/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5129

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5129.diff

This patch implements string_compare intrinsic in SVE.
It supports all LL, LU, UL and UU comparisons.

As we haven't found an existing benchmark to measure performance impact,
we created a benchmark derived from the test [1] for this evaluation.
This benchmark is attached to this patch.

Besides, remove the unused temporary register `vtmp3` from the existing
match rules for StrCmp.

The result below shows all varients can be benefited largely.
Command: make exploded-test TEST="micro:StringCompareToDifferentLength"

Benchmark    (size)  Mode  Cnt   Score Speedup Units
compareToLL      24  avgt   10      1.0x       ms/op
compareToLL      36  avgt   10      1.0x       ms/op
compareToLL      72  avgt   10      1.0x       ms/op
compareToLL     128  avgt   10      1.4x       ms/op
compareToLL     256  avgt   10      1.8x       ms/op
compareToLL     512  avgt   10      2.7x       ms/op
compareToLU      24  avgt   10      1.6x       ms/op
compareToLU      36  avgt   10      1.8x       ms/op
compareToLU      72  avgt   10      2.3x       ms/op
compareToLU     128  avgt   10      3.8x       ms/op
compareToLU     256  avgt   10      4.7x       ms/op
compareToLU     512  avgt   10      6.3x       ms/op
compareToUL      24  avgt   10      1.6x       ms/op
compareToUL      36  avgt   10      1.7x       ms/op
compareToUL      72  avgt   10      2.2x       ms/op
compareToUL     128  avgt   10      3.3x       ms/op
compareToUL     256  avgt   10      4.4x       ms/op
compareToUL     512  avgt   10      6.1x       ms/op
compareToUU      24  avgt   10      1.0x       ms/op
compareToUU      36  avgt   10      1.0x       ms/op
compareToUU      72  avgt   10      1.4x       ms/op
compareToUU     128  avgt   10      2.2x       ms/op
compareToUU     256  avgt   10      2.6x       ms/op
compareToUU     512  avgt   10      3.7x       ms/op

[1] https://github.com/openjdk/jdk/blob/master/test/hotspot/jtreg/compiler/intrinsics/string/TestStringCompareToDifferentLength.java
@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Aug 16, 2021

👋 Welcome back tatwaichong! 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 label Aug 16, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Aug 16, 2021

@tatwaichong The following labels will be automatically applied to this pull request:

  • core-libs
  • hotspot-compiler

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.

@openjdk openjdk bot added hotspot-compiler core-libs labels Aug 16, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Aug 16, 2021

Webrevs

%}
ins_pipe(pipe_class_memory);
%}

instruct string_compareUL(iRegP_R1 str1, iRegI_R2 cnt1, iRegP_R3 str2, iRegI_R4 cnt2,
iRegI_R0 result, iRegP_R10 tmp1, iRegL_R11 tmp2,
vRegD_V0 vtmp1, vRegD_V1 vtmp2, vRegD_V2 vtmp3, rFlagsReg cr)
Copy link
Member

@nick-arm nick-arm Aug 17, 2021

Choose a reason for hiding this comment

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

I think vtmp3 (=V2) is still used by the non-SVE compare-long-strings stub? (see generate_compare_long_string_different_encoding)

Copy link
Contributor Author

@tatwaichong tatwaichong Aug 23, 2021

Choose a reason for hiding this comment

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

Thanks, Nick.
Yes. I remove this vtmp3 from input arguments wrongly. I roll back this mistake in the following patch.

… compare-long-strings stub.

And remove the assertion in `string_compare` since it won't help as the registers
used in the stub are fixed.
Copy link
Member

@nick-arm nick-arm left a comment

This looks ok to me now but please wait to see if @theRealAph has any comments. I suppose the the short-string comparison code which is expanded at the call site could also benefit from SVE, if only to make it shorter.

@openjdk
Copy link

@openjdk openjdk bot commented Aug 24, 2021

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

8269559: AArch64: Implement string_compare intrinsic in SVE

Reviewed-by: ngasson, aph

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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential 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 (@nick-arm, @theRealAph) 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 label Aug 24, 2021
@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Sep 21, 2021

@tatwaichong This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@tatwaichong
Copy link
Contributor Author

@tatwaichong tatwaichong commented Sep 28, 2021

@theRealAph Hello, Andrew. I'm wondering are you interested in reviewing this patch? I believe your feedback and comment are useful to it.

@openjdk
Copy link

@openjdk openjdk bot commented Sep 30, 2021

@tatwaichong this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout sve_compareto
git fetch https://git.openjdk.java.net/jdk master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added merge-conflict and removed ready labels Sep 30, 2021
@openjdk openjdk bot added ready and removed merge-conflict labels Oct 13, 2021
@tatwaichong
Copy link
Contributor Author

@tatwaichong tatwaichong commented Oct 14, 2021

/integrate

@openjdk openjdk bot added the sponsor label Oct 14, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Oct 14, 2021

@tatwaichong
Your change (at version 7799f93) is now ready to be sponsored by a Committer.

@nick-arm
Copy link
Member

@nick-arm nick-arm commented Oct 14, 2021

/sponsor

@openjdk
Copy link

@openjdk openjdk bot commented Oct 14, 2021

Going to push as commit 8b1b6f9.

@openjdk openjdk bot closed this Oct 14, 2021
@openjdk openjdk bot added the integrated label Oct 14, 2021
@openjdk openjdk bot removed ready rfr sponsor labels Oct 14, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Oct 14, 2021

@nick-arm @tatwaichong Pushed as commit 8b1b6f9.

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

@mlbridge
Copy link

@mlbridge mlbridge bot commented Oct 14, 2021

Mailing list message from David Holmes on core-libs-dev:

We are seeing a large number of Aarch64 test failures in our CI after
this push. Somewhat bizarre failure modes:
- truncated classfiles
- unexpected EOF encountered
- illegal state reading a stream

I think we will need to back this change out while this is investigated
further.

David
-----

On 14/10/2021 3:30 pm, TatWai Chong wrote:

@nick-arm
Copy link
Member

@nick-arm nick-arm commented Oct 14, 2021

Hm, I didn't see anything like that when we tested this patch internally. I'll create another PR to revert it for now.

@mlbridge
Copy link

@mlbridge mlbridge bot commented Oct 14, 2021

Mailing list message from David Holmes on core-libs-dev:

On 14/10/2021 4:28 pm, Nick Gasson wrote:

On Thu, 14 Oct 2021 01:17:17 GMT, TatWai Chong <duke at openjdk.java.net> wrote:

This patch implements string_compare intrinsic in SVE.
It supports all LL, LU, UL and UU comparisons.

As we haven't found an existing benchmark to measure performance impact,
we created a benchmark derived from the test [1] for this evaluation.
This benchmark is attached to this patch.

Besides, remove the unused temporary register `vtmp3` from the existing
match rules for StrCmp.

The result below shows all varients can be benefited largely.
Command: make exploded-test TEST="micro:StringCompareToDifferentLength"

Benchmark (size) Mode Cnt Score Speedup Units
compareToLL 24 avgt 10 1.0x ms/op
compareToLL 36 avgt 10 1.0x ms/op
compareToLL 72 avgt 10 1.0x ms/op
compareToLL 128 avgt 10 1.4x ms/op
compareToLL 256 avgt 10 1.8x ms/op
compareToLL 512 avgt 10 2.7x ms/op
compareToLU 24 avgt 10 1.6x ms/op
compareToLU 36 avgt 10 1.8x ms/op
compareToLU 72 avgt 10 2.3x ms/op
compareToLU 128 avgt 10 3.8x ms/op
compareToLU 256 avgt 10 4.7x ms/op
compareToLU 512 avgt 10 6.3x ms/op
compareToUL 24 avgt 10 1.6x ms/op
compareToUL 36 avgt 10 1.7x ms/op
compareToUL 72 avgt 10 2.2x ms/op
compareToUL 128 avgt 10 3.3x ms/op
compareToUL 256 avgt 10 4.4x ms/op
compareToUL 512 avgt 10 6.1x ms/op
compareToUU 24 avgt 10 1.0x ms/op
compareToUU 36 avgt 10 1.0x ms/op
compareToUU 72 avgt 10 1.4x ms/op
compareToUU 128 avgt 10 2.2x ms/op
compareToUU 256 avgt 10 2.6x ms/op
compareToUU 512 avgt 10 3.7x ms/op

[1] https://github.com/openjdk/jdk/blob/master/test/hotspot/jtreg/compiler/intrinsics/string/TestStringCompareToDifferentLength.java

TatWai Chong has updated the pull request incrementally with one additional commit since the last revision:

Replace `sve_cmpne` with up-to-date `sve_cmp`.

Hm, I didn't see anything like that when we tested this patch internally. I'll create another PR to revert it for now.

Filed: https://bugs.openjdk.java.net/browse/JDK-8275263

If a backout is needed then it should be converted to a "backout" issue per:

https://openjdk.java.net/guide/index.html#backing-out-a-change

Thanks,
David

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs hotspot-compiler integrated
3 participants