This repository has been archived by the owner on Mar 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 448
Fix overflow in reduce #592
Merged
gevtushenko
merged 2 commits into
NVIDIA:main
from
gevtushenko:fix-main/github/reduce_overflow
Nov 25, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
To clarify my assumptions: is it always true that
even_share.block_end <= even_share.block_offset
? Can they be equal?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.
I am not happy, that we transform the condition differently here and below. I like @canonizer suggestion below
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.
@miscco, @canonizer suggestion doesn't change the fact that this line, or the line below has to be changed.
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.
@canonizer, for segmented reduce
block_offset
is always less thanblock_end
. For reduce the number of blocks is aboutRoundUp(num_items, tile_size)
, whileblock_offset
is justblock_id * TILE_ITEMS
andblock_end
isnum_items
. The case ofnum_items == 0
is treated differently, so I don't thinkblock_end
can be equal toblock_offset
. Could you elaborate on why it's relevant here?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.
I am wondering whether the whole algorithm would be simpler if we used
int valid_items = even_share.block_end - even_share.block_offset;
as the main variable instead of repeatedly computing the remaining number of items.That said, the change is definitely correct and a large scale refactor is a bit too much right now