Skip to content

[SYCL] Infer IdT in GroupBroadcast from group type #2115

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
merged 2 commits into from
Jul 16, 2020

Conversation

Pennycook
Copy link
Contributor

  • Work-group => any integral type
  • Sub-group => unsigned 32-bit integer

Signed-off-by: John Pennycook [email protected]


Fixes failing broadcast test in #2049.

- Work-group => any integral type
- Sub-group => unsigned 32-bit integer

Signed-off-by: John Pennycook <[email protected]>
@Pennycook Pennycook requested review from AlexeySachkov and a team as code owners July 14, 2020 18:58
@Pennycook Pennycook requested a review from v-klochkov July 14, 2020 18:58
bader
bader previously approved these changes Jul 14, 2020
GroupBroadcast(T x, IdT local_id) {
using OCLT = detail::ConvertToOpenCLType_t<T>;
using OCLIdT = detail::ConvertToOpenCLType_t<IdT>;
OCLT ocl_x = detail::convertDataToType<T, OCLT>(x);
OCLIdT ocl_id = detail::convertDataToType<IdT, OCLIdT>(local_id);
return __spirv_GroupBroadcast(group_scope<Group>::value, ocl_x, ocl_id);
}
template <typename Group, typename T, typename IdT>
detail::enable_if_t<is_sub_group<Group>::value && std::is_integral<IdT>::value,
Copy link
Contributor

@v-klochkov v-klochkov Jul 14, 2020

Choose a reason for hiding this comment

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

If IdT is uint64_t, then it will silently truncated to uint32_t, right?
Would it be useful here to assert that local_id fits into 32-bits, or throw an exception if local_id does not fit into 32-bit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Truncation is the desired behavior here.

A sub-group's local ID is represented by an id<1> (which is a size_t) but the CPU runtime only accepts a SPIR-V OpGroupBroadcast instruction with Subgroup scope if the LocalId parameter is a uint32_t.

This version of GroupBroadcast can only be called if the Group is a sub-group, so truncating into 32 bits should always be safe.

@v-klochkov
Copy link
Contributor

Fixes failing broadcast test in #2049.

It is Ok not to have a LIT test here if it fixes existing test(s). Which LIT test does it fix? I see a bunch of failed tests in #2049, but they are for all_of, none_of, reduce, etc. I did not find which one is for broadcast.

@bader
Copy link
Contributor

bader commented Jul 14, 2020

Fixes failing broadcast test in #2049.

It is Ok not to have a LIT test here if it fixes existing test(s). Which LIT test does it fix? I see a bunch of failed tests in #2049, but they are for all_of, none_of, reduce, etc. I did not find which one is for broadcast.

It's broadcast.cpp, but you won't see it in CI results as it fails on OpenCL CPU device, which wasn't tested due to failures on Level Zero back-end.

@bader bader merged commit 0c3c763 into intel:sycl Jul 16, 2020
@Pennycook Pennycook deleted the sub-group-broadcast-uint32_t branch July 28, 2020 18:07
jsji pushed a commit that referenced this pull request Aug 11, 2023
Change `auto` to `auto *` when the type is a pointer.  This makes the
code comply with the clang-tidy `llvm-qualified-auto` check.  That
check is already enabled, but the code base wasn't fully compliant
yet.

Original commit:
KhronosGroup/SPIRV-LLVM-Translator@aa9226e
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