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

8267190: Optimize Vector API test operations #4039

Closed
wants to merge 3 commits into from

Conversation

@sviswa7
Copy link

@sviswa7 sviswa7 commented May 14, 2021

Vector API test operations (IS_DEFAULT, IS_FINITE, IS_INFINITE, IS_NAN and IS_NEGATIVE) are computed in three steps:

  1. reinterpreting the floating point vectors as integral vectors (int/long)
  2. perform the test in integer domain to get a int/long mask
  3. reinterpret the int/long mask as float/double mask
    Step 3) currently is very slow. It can be optimized by modifying the Java code to utilize the existing reinterpret intrinsic.

For the VectorTestPerf attached to the JBS for JDK-8267190, the performance improves as follows:

Base:
Benchmark (size) Mode Cnt Score Error Units
VectorTestPerf.IS_DEFAULT 1024 thrpt 5 223.156 ± 90.452 ops/ms
VectorTestPerf.IS_FINITE 1024 thrpt 5 223.841 ± 91.685 ops/ms
VectorTestPerf.IS_INFINITE 1024 thrpt 5 224.561 ± 83.890 ops/ms
VectorTestPerf.IS_NAN 1024 thrpt 5 223.777 ± 70.629 ops/ms
VectorTestPerf.IS_NEGATIVE 1024 thrpt 5 218.392 ± 79.806 ops/ms

With patch:
Benchmark (size) Mode Cnt Score Error Units
VectorTestPerf.IS_DEFAULT 1024 thrpt 5 8812.357 ± 40.477 ops/ms
VectorTestPerf.IS_FINITE 1024 thrpt 5 7425.739 ± 296.622 ops/ms
VectorTestPerf.IS_INFINITE 1024 thrpt 5 8932.730 ± 269.988 ops/ms
VectorTestPerf.IS_NAN 1024 thrpt 5 8574.872 ± 498.649 ops/ms
VectorTestPerf.IS_NEGATIVE 1024 thrpt 5 8838.400 ± 11.849 ops/ms

Best Regards,
Sandhya


Progress

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

Issue

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 4039

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

Using diff file

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

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented May 14, 2021

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

Loading

@openjdk
Copy link

@openjdk openjdk bot commented May 15, 2021

@sviswa7 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.

Loading

@sviswa7
Copy link
Author

@sviswa7 sviswa7 commented May 15, 2021

/label core-libs

Loading

@openjdk openjdk bot added the core-libs label May 15, 2021
@openjdk
Copy link

@openjdk openjdk bot commented May 15, 2021

@sviswa7
The core-libs label was successfully added.

Loading

@sviswa7 sviswa7 marked this pull request as ready for review May 15, 2021
@openjdk openjdk bot added the rfr label May 15, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented May 15, 2021

Webrevs

Loading

Copy link
Member

@PaulSandoz PaulSandoz left a comment

Changes look good, some minor comments. I shall run it through tier 1 to 3 tests and report back.

Loading

public <E> VectorMask<E> cast(VectorSpecies<E> s) {
AbstractSpecies<E> species = (AbstractSpecies<E>) s;
final <E>
VectorMask<E> defaultMaskReinterpret(VectorSpecies<E> dsp) {
Copy link
Member

@PaulSandoz PaulSandoz May 18, 2021

Choose a reason for hiding this comment

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

Since this method is only called by cast we can make this method private and accept an argument of AbstractSpecies<E>. Further, the length check is duplicated by cast so we could turn it into an assert. Extra bonus points for converting the statement switch into an expression switch.

Loading

@openjdk
Copy link

@openjdk openjdk bot commented May 18, 2021

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

8267190: Optimize Vector API test operations

Reviewed-by: psandoz, kvn

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

  • 83b3607: 8266642: improve ResolvedMethodTable hash function
  • 1c7a131: 8267350: Archived old interface extends interface with default method causes crash
  • 005d8a7: 8256372: [macos] Unexpected symbol was displayed on JTextField with Monospaced font
  • 81f39ed: 8261205: AssertionError: Cannot add metadata to an intersection type
  • 7b98400: 8267348: Rewrite gc/epsilon/TestClasses.java to use Metaspace with less classes
  • ca93399: 8267235: [macos_aarch64] InterpreterRuntime::throw_pending_exception messing up LR results in crash
  • b7b6acd: 8267481: Make sure table row has correct number of cells
  • f67847f: 8267396: Avoid recording "pc" in unhandled oops detector for better performance
  • 878d1b3: 8267434: Remove LinkOutput[Impl]
  • fc7f0a3: 8267480: Explicitly problemlist all runtime/os/TestTracePageSizes.java tests on linux-aarch64 to reduce noise
  • ... and 79 more: https://git.openjdk.java.net/jdk/compare/7ab6dc83df2e19a57ff0dcdc87598c54cd949a7c...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.

Loading

@openjdk openjdk bot added the ready label May 18, 2021
Copy link
Contributor

@vnkozlov vnkozlov left a comment

Change in vectorIntrinsics.cpp seems fine. I did not look on Java code.

Loading

@PaulSandoz
Copy link
Member

@PaulSandoz PaulSandoz commented May 19, 2021

Tier 1 to 3 tests pass on supported platforms

Loading

@sviswa7
Copy link
Author

@sviswa7 sviswa7 commented May 20, 2021

@PaulSandoz @vnkozlov Thanks a lot for the review.
Paul, I have implemented your review comments. I also changed the switch to switch expression. Please take a look.

Loading

Copy link
Member

@PaulSandoz PaulSandoz left a comment

Java changes are good, some minor comments if you choose to accept them, no need for me to review further.

Loading

@ForceInline
private final <E>
VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
boolean[] maskArray = toArray();
Copy link
Member

@PaulSandoz PaulSandoz May 20, 2021

Choose a reason for hiding this comment

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

Can you add an assert length() != species.laneCount()?

Loading

VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
boolean[] maskArray = toArray();
// enum-switches don't optimize properly JDK-8161245
return (
Copy link
Member

@PaulSandoz PaulSandoz May 20, 2021

Choose a reason for hiding this comment

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

Minor syntactic quibble: you don't need the '(and)` surrounding the switch expressions e.g.:

   return switch (dsp.laneType.switchKey) {
       case ...
   }

Loading

@sviswa7
Copy link
Author

@sviswa7 sviswa7 commented May 20, 2021

Thanks Paul. I have implemented these two suggestions as well.

If no objections from any one else, I plan to integrate this tomorrow, Friday May 21.

Loading

@sviswa7
Copy link
Author

@sviswa7 sviswa7 commented May 21, 2021

/integrate

Loading

@openjdk openjdk bot closed this May 21, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels May 21, 2021
@openjdk
Copy link

@openjdk openjdk bot commented May 21, 2021

@sviswa7 Since your change was applied there have been 98 commits pushed to the master branch:

  • 94cfeb9: 8256155: Allow multiple large page sizes to be used on Linux
  • ec8a809: 8267119: switch expressions lack support for deferred type-checking
  • 4ba7613: 8267332: xor value should handle bounded values
  • ee2651b: 8203359: Container level resources events
  • b5d32bb: 8260690: JConsole User Guide Link from the Help menu is not accessible by keyboard
  • e48d7d6: 8264218: Public method javax.swing.JMenu.setComponentOrientation() has no spec
  • 9eaa4af: 8267056: tools/jpackage/share/RuntimePackageTest.java fails with NoSuchFileException
  • e094f3f: 8266856: Make element void
  • 7a63ff7: 8267370: [Vector API] Fix several crashes after JDK-8256973
  • 83b3607: 8266642: improve ResolvedMethodTable hash function
  • ... and 88 more: https://git.openjdk.java.net/jdk/compare/7ab6dc83df2e19a57ff0dcdc87598c54cd949a7c...master

Your commit was automatically rebased without conflicts.

Pushed as commit 8f10c5a.

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

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants