Add sycl_khr_group_interface extension#638
Conversation
This extension introduces an alternative interface for groups of work-items, offering several improvements over the SYCL 2020 interface: - Shorter names for member functions, dropping the get_ prefix. - Cleaner separation between properties of a group (e.g., a group id) and properties of the calling work-item (e.g., its id within a group). - Clearer distinction between "group" concept and "work_group" class. - New work_item class to represent a single work-item within a specific parent group. This class also satisfies the group concept, modeling a group containing a single work-item.
dc92d73 to
93e784e
Compare
khr::work_item is not templated on dimensions.
The synopsis previously assumed that the extents would be one dimensional, but it must match the ParentGroup. There is no suitable shorthand alias or exposition-only description for this case defined by mdspan, so replace the type with a comment.
|
I like the usage of namespace. Few questions (sorry, trying to understand this new khr mechanism), should it be :
|
I don't think so. When vendors introduce extensions they use The way I see it, although putting something in the |
|
Adding the 2 rank functions from |
rank(), rank_dynamic() and static_extent() are all exposed as static member functions in mdspan, so we follow that precedent here.
Good idea. I've added |
25b35fe to
d59ccb9
Compare
The name __group__ is consistent with the names of the swizzle classes.
Co-authored-by: Greg Lueck <gregory.m.lueck@intel.com>
The previous "not user constructible" wording was based on the description of existing group types. The new wording explains why khr::group, khr::sub_group, and khr::work_item have limited constructors and also points to functions that can be used to acquire instances of these types.
I was thinking about this when I was reviewing this again just now, we could potentially change this to |
I've requested to put this on the agenda for next week's meeting. |
|
WG discussed, and converged on |
Intended to avoid confusion between sycl::item and khr::member_item.
|
CTS tests are implemented in KhronosGroup/SYCL-CTS#1024. The DPC++ implementation that passes the CTS tests is under review in intel/llvm#17595. |
The change in dc1c0f5 missed a few instances of constexpr, resulting in inconsistencies between header and function synopses. This commit fixes that such that size() is only constexpr for member_item.
|
@illuhad : I think we are waiting for your input on this. Do you agree that this is implementable? |
|
I've prototyped this extension in SimSYCL and I've noticed some most likely unintended behaviour in GCC -- see this minimal example: https://godbolt.org/z/zosojE1zG Curiously, Clang and MSVC completely ignore this issue. I wasn't able to find exactly what GCC is basing this decision on in a quick search of the current C++ standard, but on the other hand, I think it's pretty clear that this isn't great (and even if it was, GCC is an important compiler target). As such, I think it might be better if the relevant parts of the code in the spec were adjusted to nip this problem in the bud. This just requires a pretty simple spelling change of types in 4 lines of code, i.e. |
Interesting find. This is weird! After a little bit of searching I eventually found this: https://bugs.llvm.org/show_bug.cgi?id=15559 -- the text in the specification has changed so I can't find this exactly, but it looks like both GCC and Clang are correct...
I'm going to stick this on the agenda for Thursday's WG meeting. Not because I'm opposed to the proposed fix, but because I want to make sure there isn't another solution before I make the change. It's also not clear to me whether there's a precedent for something like this already in the specification, or whether it's an implementation issue rather than a specification one. |
Within the scope of a group definition, sycl::id<> and sycl::range<> are types, whereas id() and range() are functions. Some compilers issue a diagnostic when the same name is used like this, but others do not; adding sycl:: ensures that the header is valid code across all compilers.
|
WG approved to merge |
gmlueck
left a comment
There was a problem hiding this comment.
Sorry for the late comment. Our recent discussion about passing queue by value vs. by reference got me thinking about similar issues with this KHR.
| }; | ||
|
|
||
| template <typename Group> | ||
| member_item<Group> get_member_item(Group g) noexcept; |
There was a problem hiding this comment.
Should this instead be:
| member_item<Group> get_member_item(Group g) noexcept; | |
| member_item<Group> get_member_item(const Group& g) noexcept; |
Likewise for all the other functions in this KHR that take a Group, group, or sub_group parameter by value.
There was a problem hiding this comment.
I'm not opposed to this direction (and I've made the change in 985a67a), but one thing we should give some thought to is if we can also fix the existing group algorithms that take a group by value.
Having overloads for both Group g and const Group& g defined for the same function would lead to ambiguity, so I think the only way to fix this would be to say that the functions in SYCL 2020 take Group and the same functions in SYCL-Next take const Group&. It wouldn't make sense to deprecate these functions in between, because we're not actually removing anything.
I think all implementations of the group algorithms are header-only because they accept user-defined types, so this shouldn't be an ABI break concern. I also think that the vast majority of user would continue to work, because const Group& is less restrictive than Group (but I'm not prepared to rule out that there might be some weird corner cases that require some adjustment).
Could we make this change in SYCL-Next, or are we stuck?
There was a problem hiding this comment.
Yes, I think we need to reexamine all the APIs in the core SYCL spec that take objects by value. It probably does make sense to change them in SYCL-Next even if it does cause some weird corner cases to break. If there are cases like this, users will need to adjust in order to compile applications in SYCL-Next mode.
I'm much more concerned about retaining ABI compatibility between SYCL 2020 and SYCL-Next. It would be a major pain if vendors needed to ship two versions of every library that uses SYCL.
AerialMantis
left a comment
There was a problem hiding this comment.
Looks good! I still have a couple of comments open, but neither of them are blockers to merging the PR.
@tomdeakin: I did not merge this because 985a67a was made after the WG approved. If you would like this merged prior to the next WG meeting, please add another comment saying so. Otherwise, we can call for it to be merged again at the next meeting. |
|
WG approved to merge (again) |
Add sycl_khr_group_interface extension (cherry picked from commit d903d2f)
This extension introduces an alternative interface for groups of work-items, offering several improvements over the SYCL 2020 interface:
Shorter names for member functions, dropping the get_ prefix.
Cleaner separation between properties of a group (e.g., a group id) and properties of the calling work-item (e.g., its id within a group).
Clearer distinction between "group" concept and "work_group" class.
New work_item class to represent a single work-item within a specific parent group. This class also satisfies the group concept, modeling a group containing a single work-item.