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

8268154: Add masking support for vector load intrinsics #90

Closed

Conversation

XiaohongGong
Copy link
Collaborator

@XiaohongGong XiaohongGong commented Jun 7, 2021

This patch adds the predicate support for masked load vector operation, including the Vector API java implementation and hotspot intrinsics changes. The main changes contain:

  • Adding a new hotspot intrinsic method (loadMasked), which can transform the vector mask class and value to hotspot. It is called by the masked "fromArray" API in JAVA level. The compiler will generate the masked vector load node if the current platform supports the predicate feature and backend has implemented it. Otherwise, the vector blend pattern will be generated like before.
  • Adding the similar masked support for load/store boolean/char array.

Note that the intrinsification when there is the array range bailout is not implemented in this patch. We are considering making it vectorized with predicate feature for SVE/AVX-512 as well, and will create a separate patch for it in future.

Also note that this patch doesn't contain any backend changes.


Progress

  • Change must not contain extraneous whitespace
  • Change must be properly reviewed

Issue

  • JDK-8268154: Add masking support for vector load intrinsics

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/panama-vector pull/90/head:pull/90
$ git checkout pull/90

Update a local copy of the PR:
$ git checkout pull/90
$ git pull https://git.openjdk.java.net/panama-vector pull/90/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 90

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/panama-vector/pull/90.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 7, 2021

👋 Welcome back xgong! A progress list of the required criteria for merging this PR into vectorIntrinsics+mask 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 Jun 7, 2021
@mlbridge
Copy link

mlbridge bot commented Jun 7, 2021

Webrevs

@XiaohongGong
Copy link
Collaborator Author

Hi @PaulSandoz , @sviswa7 , could you please take a look at the java side of this PR? Thanks so much!

Hi @iwanowww , could you please take a look at the compiler side of this PR? Thanks so much! Regarding to your feedback!

Best Regards,
Xiaohong

Copy link
Member

@jatin-bhateja jatin-bhateja left a comment

Choose a reason for hiding this comment

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

Currently there following assertion check in both LoadVectorMaskedNode and StoreVectorMaskedNode

assert(mask->bottom_type()->is_vectmask(), "sanity");

This should be relaxed since mask argument will be VectorUnboxNode until macro expansion.

I added following static routine in VectorNode class to get over it in my local sandbox, and adjusted the assertion to use it. If suitable maybe we can integrate it in this patch.

bool VectorNode::is_vector_mask(Node* n) {
  if (n->bottom_type()->is_vectmask()) {
    return true;
  }
  if (n->Opcode() == Op_VectorUnbox) {
    const TypeInstPtr* vector_klass_from = n->as_VectorUnbox()->obj()->bottom_type()->isa_instptr();
    ciKlass* vbox_klass_from = vector_klass_from->const_oop()->as_instance()->java_lang_Class_klass();
    return vbox_klass_from->is_subclass_of(ciEnv::current()->vector_VectorMask_klass());
  }
  return false;
}

src/hotspot/share/opto/vectorIntrinsics.cpp Outdated Show resolved Hide resolved
@jatin-bhateja
Copy link
Member

Over all patch looks good to me.

Copy link
Member

@PaulSandoz PaulSandoz left a comment

Choose a reason for hiding this comment

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

Java changes look good. No need for me to re-review to resolve the comment i made.

@openjdk
Copy link

openjdk bot commented Jun 9, 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:

8268154: Add masking support for vector load intrinsics

Reviewed-by: jbhateja, psandoz

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 vectorIntrinsics+mask 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.

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

@openjdk openjdk bot added the ready label Jun 9, 2021
@XiaohongGong
Copy link
Collaborator Author

Currently there following assertion check in both LoadVectorMaskedNode and StoreVectorMaskedNode

assert(mask->bottom_type()->is_vectmask(), "sanity");

This should be relaxed since mask argument will be VectorUnboxNode until macro expansion.

I added following static routine in VectorNode class to get over it in my local sandbox, and adjusted the assertion to use it. If suitable maybe we can integrate it in this patch.

bool VectorNode::is_vector_mask(Node* n) {
  if (n->bottom_type()->is_vectmask()) {
    return true;
  }
  if (n->Opcode() == Op_VectorUnbox) {
    const TypeInstPtr* vector_klass_from = n->as_VectorUnbox()->obj()->bottom_type()->isa_instptr();
    ciKlass* vbox_klass_from = vector_klass_from->const_oop()->as_instance()->java_lang_Class_klass();
    return vbox_klass_from->is_subclass_of(ciEnv::current()->vector_VectorMask_klass());
  }
  return false;
}

Thanks so for your suggestion @jatin-bhateja ! This looks ok to me. So that I can also revert the type changes to VectorBox/VectorUnbox in PR #78.

@XiaohongGong
Copy link
Collaborator Author

Currently there following assertion check in both LoadVectorMaskedNode and StoreVectorMaskedNode
assert(mask->bottom_type()->is_vectmask(), "sanity");
This should be relaxed since mask argument will be VectorUnboxNode until macro expansion.
I added following static routine in VectorNode class to get over it in my local sandbox, and adjusted the assertion to use it. If suitable maybe we can integrate it in this patch.

bool VectorNode::is_vector_mask(Node* n) {
  if (n->bottom_type()->is_vectmask()) {
    return true;
  }
  if (n->Opcode() == Op_VectorUnbox) {
    const TypeInstPtr* vector_klass_from = n->as_VectorUnbox()->obj()->bottom_type()->isa_instptr();
    ciKlass* vbox_klass_from = vector_klass_from->const_oop()->as_instance()->java_lang_Class_klass();
    return vbox_klass_from->is_subclass_of(ciEnv::current()->vector_VectorMask_klass());
  }
  return false;
}

Thanks so for your suggestion @jatin-bhateja ! This looks ok to me. So that I can also revert the type changes to VectorBox/VectorUnbox in PR #78.

Regarding to merge it, do you think it's better to fix it in #78 instead of this PR? One reason is that there are other mask IRs that also contains the same assertion, we can update them together. Another one is that I can revert the type changes for VectorBox/VectorUnbox and have a test together. Thanks!

@XiaohongGong
Copy link
Collaborator Author

Hi @PaulSandoz @jatin-bhateja , the latest commit have addressed your comments. Thanks!

@jatin-bhateja
Copy link
Member

Thanks!, changes looks good to me.

@XiaohongGong
Copy link
Collaborator Author

Thanks for the review @jatin-bhateja @PaulSandoz !

@jatin-bhateja
Copy link
Member

Hi @XiaohongGong , can you kindly push these common IR changes

@XiaohongGong
Copy link
Collaborator Author

Hi @XiaohongGong , can you kindly push these common IR changes

Sure. I was intending to wait for the feedback from @iwanowww . Maybe it's better to integrate these changes first to make sure the masking feature support is not blocked. Thanks so much for the advice and review!

@iwanowww , I'd like to integrate this PR first. If there are any comments or feedback, please feel free to contact me and we can revisit them with a followed-up patch. Thanks so much!

@XiaohongGong
Copy link
Collaborator Author

/integrate

@openjdk
Copy link

openjdk bot commented Jun 24, 2021

Going to push as commit 1c91304.
Since your change was applied there have been 409 commits pushed to the vectorIntrinsics+mask branch:

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jun 24, 2021

@XiaohongGong Pushed as commit 1c91304.

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

@XiaohongGong XiaohongGong deleted the JDK-8268154 branch June 24, 2021 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants