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

8264109: Add vectorized implementation for VectorMask.andNot() #3211

Closed
wants to merge 2 commits into from

Conversation

@XiaohongGong
Copy link
Contributor

@XiaohongGong XiaohongGong commented Mar 26, 2021

Currently "VectorMask.andNot()" is not vectorized:

    public VectorMask<E> andNot(VectorMask<E> m) {
        // FIXME: Generate good code here.
        return bOp(m, (i, a, b) -> a && !b);
    }

This can be implemented with"and(m.not())"directly. Since "VectorMask.and()/not()" have been vectorized in hotspot, "andNot"
can be vectorized as well by calling them.

The performance gain is >100% for such a simple JMH:

  @Benchmark
  public Object andNot(Blackhole bh) {
    boolean[] mask = fm.apply(SPECIES.length());
    boolean[] r = fmt.apply(SPECIES.length());
    VectorMask<Byte> rm = VectorMask.fromArray(SPECIES, r, 0);

    for (int ic = 0; ic < INVOC_COUNT; ic++) {
      for (int i = 0; i < mask.length; i += SPECIES.length()) {
        VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, i);
          rm = rm.andNot(vmask);
        }
    }
    return rm;
  }

Progress

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

Issue

  • JDK-8264109: Add vectorized implementation for VectorMask.andNot()

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3211

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

Using diff file

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

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Mar 26, 2021

👋 Welcome back xgong! 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 openjdk bot added the rfr label Mar 26, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Mar 26, 2021

@XiaohongGong To determine the appropriate audience for reviewing this pull request, one or more labels corresponding to different subsystems will normally be applied automatically. However, no automatic labelling rule matches the changes in this pull request. In order to have an "RFR" email sent to the correct mailing list, you will need to add one or more applicable labels manually using the /label pull request command.

Applicable Labels
  • 2d
  • awt
  • beans
  • build
  • compiler
  • core-libs
  • hotspot
  • hotspot-compiler
  • hotspot-gc
  • hotspot-jfr
  • hotspot-runtime
  • i18n
  • javadoc
  • jdk
  • jmx
  • kulla
  • net
  • nio
  • security
  • serviceability
  • shenandoah
  • sound
  • swing

Loading

@XiaohongGong
Copy link
Contributor Author

@XiaohongGong XiaohongGong commented Mar 26, 2021

/label hotspot-compiler

Loading

@openjdk
Copy link

@openjdk openjdk bot commented Mar 26, 2021

@XiaohongGong
The hotspot-compiler label was successfully added.

Loading

@mlbridge
Copy link

@mlbridge mlbridge bot commented Mar 26, 2021

Webrevs

Loading

@XiaohongGong
Copy link
Contributor Author

@XiaohongGong XiaohongGong commented Mar 26, 2021

/label core-libs

Loading

@openjdk openjdk bot added the core-libs label Mar 26, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Mar 26, 2021

@XiaohongGong
The core-libs label was successfully added.

Loading

@XiaohongGong
Copy link
Contributor Author

@XiaohongGong XiaohongGong commented Mar 31, 2021

Hi there, could anyone please take a look at this PR? Thanks so much!

Loading

Copy link
Member

@PaulSandoz PaulSandoz left a comment

Would you mind updating the existing AbstractMask.andNot implementation? rather than changing VectorMask.andNot. That fits in with the current implementation pattern.

Loading

…Mask

Change-Id: Ie3ec8f53cb24526c8e1ccc68038355d024910818
CustomizedGitHooks: yes
@XiaohongGong
Copy link
Contributor Author

@XiaohongGong XiaohongGong commented Apr 1, 2021

Would you mind updating the existing AbstractMask.andNot implementation? rather than changing VectorMask.andNot. That fits in with the current implementation pattern.

Hi @PaulSandoz , thanks for looking at this PR. I'v updated the patch according to your comments. Would you mind having look at it again? Thanks so much!

Loading

Copy link
Member

@PaulSandoz PaulSandoz left a comment

Looks good.

Loading

@openjdk
Copy link

@openjdk openjdk bot commented Apr 1, 2021

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

8264109: Add vectorized implementation for VectorMask.andNot()

Reviewed-by: psandoz, njian

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

  • 0935eaa: 8264409: AArch64: generate better code for Vector API allTrue
  • 4793557: 8264502: (fc) FileDispatcherImpl.setDirect0 might return uninitialized variable on some platforms
  • da643cd: 8264526: javax/swing/text/html/parser/Parser/8078268/bug8078268.java timeout
  • 66d9961: 8205502: Make exception message from AnnotationInvocationHandler more informative
  • 5e59d28: 8262046: Clean up parallel class loading code and comments
  • 04f24fe: 8264403: [macos]: App names containing '.' characters results in an error message when launching
  • b953386: 8264609: Number.{byteValue, shortValue} spec should use @implSpec
  • 5858399: 8264285: Clean the modification of ccstr JVM flags
  • 6e0da99: 8263448: CTW: fatal error: meet not symmetric
  • 328e951: 8169629: Annotations with lambda expressions cause AnnotationFormatError
  • ... and 135 more: https://git.openjdk.java.net/jdk/compare/45e1bab87ccebd498d4f927a008dd89a47dd177b...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 (@PaulSandoz, @nsjian) 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).

Loading

@openjdk openjdk bot added the ready label Apr 1, 2021
@XiaohongGong
Copy link
Contributor Author

@XiaohongGong XiaohongGong commented Apr 2, 2021

Thanks for your review @PaulSandoz !

Loading

@XiaohongGong
Copy link
Contributor Author

@XiaohongGong XiaohongGong commented Apr 2, 2021

/integrate

Loading

@openjdk openjdk bot added the sponsor label Apr 2, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Apr 2, 2021

@XiaohongGong
Your change (at version 33ac041) is now ready to be sponsored by a Committer.

Loading

nsjian
nsjian approved these changes Apr 2, 2021
Copy link

@nsjian nsjian left a comment

LGTM

Loading

@nsjian
Copy link

@nsjian nsjian commented Apr 2, 2021

/sponsor

Loading

@openjdk openjdk bot closed this Apr 2, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Apr 2, 2021

@nsjian @XiaohongGong Since your change was applied there have been 145 commits pushed to the master branch:

  • 0935eaa: 8264409: AArch64: generate better code for Vector API allTrue
  • 4793557: 8264502: (fc) FileDispatcherImpl.setDirect0 might return uninitialized variable on some platforms
  • da643cd: 8264526: javax/swing/text/html/parser/Parser/8078268/bug8078268.java timeout
  • 66d9961: 8205502: Make exception message from AnnotationInvocationHandler more informative
  • 5e59d28: 8262046: Clean up parallel class loading code and comments
  • 04f24fe: 8264403: [macos]: App names containing '.' characters results in an error message when launching
  • b953386: 8264609: Number.{byteValue, shortValue} spec should use @implSpec
  • 5858399: 8264285: Clean the modification of ccstr JVM flags
  • 6e0da99: 8263448: CTW: fatal error: meet not symmetric
  • 328e951: 8169629: Annotations with lambda expressions cause AnnotationFormatError
  • ... and 135 more: https://git.openjdk.java.net/jdk/compare/45e1bab87ccebd498d4f927a008dd89a47dd177b...master

Your commit was automatically rebased without conflicts.

Pushed as commit 7d0a0ba.

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

Loading

@XiaohongGong XiaohongGong deleted the JDK-8264109 branch Apr 2, 2021
@XiaohongGong
Copy link
Contributor Author

@XiaohongGong XiaohongGong commented Apr 2, 2021

Thanks for the review @nsjian !

Loading

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