Skip to content

Allow variable number of operands in work-group metadata#1726

Merged
MrSidims merged 1 commit intoKhronosGroup:mainfrom
steffenlarsen:steffen/make_work_group_sizes_variable
Nov 22, 2022
Merged

Allow variable number of operands in work-group metadata#1726
MrSidims merged 1 commit intoKhronosGroup:mainfrom
steffenlarsen:steffen/make_work_group_sizes_variable

Conversation

@steffenlarsen
Copy link

@steffenlarsen steffenlarsen commented Nov 21, 2022

The reqd_work_group_size and work_group_size_hint metadata nodes are currently expected to have exactly 3 operands which are in turn translated to the 3 operands of their corresponding SPIR-V execution modes. This commit relaxes this requirement by allowing the metadata to have 1-3 operands, where the missing dimensions are padded with 1's in the corresponding execution mode. Note that the information about the dimensionality of the original metadata is lost after translation, so reverse translation will always result in the metadata having all three operands.

Motivation comes from intel/llvm#7450 where instead of doing the implicit padding during LLVM IR generation we want to simplify the metadata to only have the operands specified. Not only does it relax the requirements, it also lets us preserve information about dimensionality up until it is translated into SPIR-V.

The reqd_work_group_size and work_group_size_hint metadata nodes are
currently expected to have exactly 3 operands which are in turn
translated to the 3 operands of their corresponding SPIR-V execution
modes. This commit relaxes this requirement by allowing the metadata to
have 1-3 operands, where the missing dimensions are padded with 1's in
the corresponding execution mode. Note that the information about the
dimensionality of the original metadata is lost after translation, so
reverse translation will always result in the metadata having all three
operands.

Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Copy link
Contributor

@MrSidims MrSidims left a comment

Choose a reason for hiding this comment

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

LGTM
But please specify, what FE is capable to produce 1-dimentional WG metadata, if I understand correctly, it's not just llvm.org's clang compiling vanilla OpenCL code.

@steffenlarsen
Copy link
Author

steffenlarsen commented Nov 21, 2022

But please specify, what FE is capable to produce 1-dimentional WG metadata, if I understand correctly, it's not just llvm.org's clang compiling vanilla OpenCL code.

Motivation comes from intel/llvm (intel/llvm#7450) where instead of doing the implicit padding during LLVM IR generation we want to simplify the metadata to only have the operands specified. Not only does it relax the requirements, it also lets us preserve information about dimensionality up until it is translated into SPIR-V.

@MrSidims MrSidims merged commit 8d352d8 into KhronosGroup:main Nov 22, 2022
steffenlarsen pushed a commit to intel/llvm that referenced this pull request Nov 24, 2022
)

The reqd_work_group_size and work_group_size_hint metadata nodes are
currently expected to have exactly 3 operands which are in turn
translated to the 3 operands of their corresponding SPIR-V execution
modes. This commit relaxes this requirement by allowing the metadata to
have 1-3 operands, where the missing dimensions are padded with 1's in
the corresponding execution mode. Note that the information about the
dimensionality of the original metadata is lost after translation, so
reverse translation will always result in the metadata having all three
operands.

Motivation comes from #7450 where instead of doing the
implicit padding during LLVM IR generation we want to simplify the
metadata to only have the operands specified. Not only does it relax the
requirements, it also lets us preserve information about dimensionality
up until it is translated into SPIR-V.

NOTE: This is a cherry-pick of
KhronosGroup/SPIRV-LLVM-Translator#1726.
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