-
Notifications
You must be signed in to change notification settings - Fork 113
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
Add code change workaround for 64-bit reduce_by_segment bug #1791
Changes from 2 commits
49f4f41
ce29407
3e08d9d
c6b254c
558e6b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -351,7 +351,11 @@ __sycl_reduce_by_segment(__internal::__hetero_tag<_BackendTag>, _ExecutionPolicy | |||||||
__seg_reduce_wg_kernel, | ||||||||
#endif | ||||||||
sycl::nd_range<1>{__n_groups * __wgroup_size, __wgroup_size}, [=](sycl::nd_item<1> __item) { | ||||||||
::std::array<__val_type, __vals_per_item> __loc_partials; | ||||||||
auto __identity = unseq_backend::__known_identity<_BinaryOperator, __val_type>; | ||||||||
// TODO: Remove this initialization to the identity when possible. We load real data to __loc_partials | ||||||||
// in the first loop below but this initialization to the identity works around an IGC register | ||||||||
// filling bug. | ||||||||
std::array<__val_type, __vals_per_item> __loc_partials = {__identity}; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this meant to fill the array with the identity value? Because I believe as it is currently written, only the first value in the array would be populated and the rest will be uninitialized. If the intent is for all of the elements to be the identity, then this can be written as:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, it looks like the rest of the elements may be initialized to 0: https://en.cppreference.com/w/c/language/array_initialization. The way the fix was implemented still worked since it does not matter what is loaded into the array as long as it's something. However, I switched to your suggestion to be consistent. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Filling the array after its definition seems to reintroduce the bug. I will see if I can find a better solution. I suppose what we originally had adds a default constructability requirement we do not want. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have reverted the change I made here. My last statement is wrong, the default constructor for each array element is already called when we declare the array, so we are not adding any additional requirements. I have explored some different ways to try to workaround the issue, but this seems to be the only thing that works. I've confirmed that register filling bug is avoided as our tests pass along with internal reproducers where the issue was reported. |
||||||||
|
||||||||
auto __group = __item.get_group(); | ||||||||
::std::size_t __group_id = __item.get_group(0); | ||||||||
|
@@ -368,7 +372,6 @@ __sycl_reduce_by_segment(__internal::__hetero_tag<_BackendTag>, _ExecutionPolicy | |||||||
|
||||||||
::std::size_t __max_end = 0; | ||||||||
::std::size_t __item_segments = 0; | ||||||||
auto __identity = unseq_backend::__known_identity<_BinaryOperator, __val_type>; | ||||||||
|
||||||||
__val_type __accumulator = __identity; | ||||||||
for (::std::size_t __i = __start; __i < __end; ++__i) | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use
__val_type
instead ofauto
- it's will more readable, I think.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done