Skip to content

Add SPV_INTEL_masked_gather_scatter extension #1580

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

Merged

Conversation

MrSidims
Copy link
Contributor

This extension allows TypeVector to have a Physical Pointer Type
Component Type and introduces gather/scatter instructions.
It will be useful for explicitly vectorized kernels.

Spec: intel/llvm#6613

Signed-off-by: Sidorov, Dmitry dmitry.sidorov@intel.com

@MrSidims
Copy link
Contributor Author

@asudarsa @vmaksimo @jcranmer-intel please take a look

Type *BaseTy =
BaseSPVTy->isTypeVector()
? transType(
BaseSPVTy->getVectorComponentType()->getPointerElementType())
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this logic be safely moved inside getPointerElementType?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a very good suggestion. But after some considering I'd say: no.

The reasoning, that it's safe to move it now, but I can imagine, that in the future some vendor, which is not aware or interested in our extension, can add another instructions, that are operating over pointers. The change you are suggesting would implicitly allow vector of pointers to be used by those instruction, which is incorrect.

And may be it's already the case.

if (DestTy->getScalarType()->getNonOpaquePointerElementType() !=
SrcTy->getScalarType()->getNonOpaquePointerElementType()) {
Type *InterTy = PointerType::getWithSamePointeeType(
cast<PointerType>(DestTy), SrcTy->getPointerAddressSpace());
Copy link
Contributor

@asudarsa asudarsa Sep 1, 2022

Choose a reason for hiding this comment

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

cast PointerType for SrcTy?

Copy link
Contributor Author

@MrSidims MrSidims Sep 1, 2022

Choose a reason for hiding this comment

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

Not sure if I get the question/suggestion.

Copy link
Contributor Author

@MrSidims MrSidims Sep 5, 2022

Choose a reason for hiding this comment

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

Probably got it and added.

@@ -3824,6 +3843,47 @@ SPIRVValue *LLVMToSPIRVBase::transIntrinsicInst(IntrinsicInst *II,
}
return Op;
}
case Intrinsic::masked_gather: {
if (BM->isAllowedToUseExtension(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have to check this again? Is there a possibility that we would not have called transType for FixedVectorType before this?

Copy link
Contributor Author

@MrSidims MrSidims Sep 1, 2022

Choose a reason for hiding this comment

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

That's unlikely, but it will explicitly say to the one, who is reading this code next, that these instructions are only supported as a part of the appropriate extension. For the sake of performance I can rewrite these lines in the following way:

if (notSupported)
   error_out
   return
do_translation

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with the argument that it makes the code readable.

@asudarsa
Copy link
Contributor

asudarsa commented Sep 1, 2022

Added some comments. Also added a coupe of comments in the doc PR.
Overall looks good to me. Just some minor questions/issues.
Thanks

This extension allows TypeVector to have a Physical Pointer Type
Component Type and introduces gather/scatter instructions.
It will be useful for explicitly vectorized kernels.

Spec: intel/llvm#6613

Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
@MrSidims MrSidims force-pushed the private/MrSidims/VectorOfPointerImpl branch from 2992af3 to b6d9830 Compare September 1, 2022 13:38
Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
Copy link
Contributor

@jcranmer-intel jcranmer-intel left a comment

Choose a reason for hiding this comment

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

I haven't looked too closely at the code in lib/SPIRV/libSPIRV, but otherwise, this looks good.

@MrSidims MrSidims requested a review from asudarsa September 7, 2022 15:54
Copy link
Contributor

@asudarsa asudarsa left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the comments. LGTM

@MrSidims MrSidims merged commit 49b08e8 into KhronosGroup:main Sep 8, 2022
MrSidims added a commit that referenced this pull request Nov 8, 2022
#1695)

This extension allows TypeVector to have a Physical Pointer Type
Component Type and introduces gather/scatter instructions.
It will be useful for explicitly vectorized kernels.

Spec: intel/llvm#6613

Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com

Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com
Co-authored-by: Dmitry Sidorov <dmitry.sidorov@intel.com>
MrSidims added a commit that referenced this pull request Nov 9, 2022
#1691)

This extension allows TypeVector to have a Physical Pointer Type
Component Type and introduces gather/scatter instructions.
It will be useful for explicitly vectorized kernels.

Spec: intel/llvm#6613

Co-authored-by: Dmitry Sidorov <dmitry.sidorov@intel.com>
MrSidims added a commit that referenced this pull request Nov 10, 2022
…#1689)

This extension allows TypeVector to have a Physical Pointer Type
Component Type and introduces gather/scatter instructions.
It will be useful for explicitly vectorized kernels.

Spec: intel/llvm#6613

Co-authored-by: Dmitry Sidorov <dmitry.sidorov@intel.com>
MrSidims added a commit that referenced this pull request Nov 10, 2022
…#1688)

This extension allows TypeVector to have a Physical Pointer Type
Component Type and introduces gather/scatter instructions.
It will be useful for explicitly vectorized kernels.

Spec: intel/llvm#6613

Co-authored-by: Dmitry Sidorov <dmitry.sidorov@intel.com>
MrSidims added a commit that referenced this pull request Nov 10, 2022
#1692)

This extension allows TypeVector to have a Physical Pointer Type
Component Type and introduces gather/scatter instructions.
It will be useful for explicitly vectorized kernels.

Spec: intel/llvm#6613

Co-authored-by: Dmitry Sidorov <dmitry.sidorov@intel.com>
MrSidims added a commit that referenced this pull request Nov 11, 2022
#1690)

This extension allows TypeVector to have a Physical Pointer Type
Component Type and introduces gather/scatter instructions.
It will be useful for explicitly vectorized kernels.

Spec: intel/llvm#6613

Co-authored-by: Dmitry Sidorov <dmitry.sidorov@intel.com>
MrSidims added a commit that referenced this pull request Nov 12, 2022
#1694)

This extension allows TypeVector to have a Physical Pointer Type
Component Type and introduces gather/scatter instructions.
It will be useful for explicitly vectorized kernels.

Spec: intel/llvm#6613

Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com

Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com
Co-authored-by: Dmitry Sidorov <dmitry.sidorov@intel.com>
MrSidims added a commit that referenced this pull request Nov 12, 2022
#1693)

This extension allows TypeVector to have a Physical Pointer Type
Component Type and introduces gather/scatter instructions.
It will be useful for explicitly vectorized kernels.

Spec: intel/llvm#6613

Co-authored-by: Dmitry Sidorov <dmitry.sidorov@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants