-
Notifications
You must be signed in to change notification settings - Fork 539
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
Fixed an issue when switching streams on device_buffer and host_buffer #358
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f4a8ac5
Fixed an issue when switching streams on MLCommon::device_buffer and …
jirikraus d0dd791
Avoided unnecessary cudaEventRecord + cudaStreamWaitEvent
jirikraus 8245982
Merge branch 'branch-0.7' into bug-ext-buffer_stream
jirikraus 553e35a
Fixed CHANGELOG.md
jirikraus 1734f37
Merge branch 'branch-0.7' into bug-ext-buffer_stream
jirikraus 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
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.
@jirikraus Sorry, I realize that this question is not related to this PR! Do we need this synchronize step? I suppose, as long as the caller adheres to the stream semantics, we should be fine without it, no?
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.
IIRC we already touched on this in a discussion on the PR which introduced this data structure. From my point of view the expectation of a user of
host_buffer
ordevice_buffer
is that it is usable after constructions. Thus the synchronization to avoid surprises. However I agree that given we pass in a stream that surprise of some users is something we can probably live with. Btw. if you want a fully asynchronous construction you can do it with:I am undecided what the better option is. Any other thoughts on this?
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.
host_buffer
can also potentially be directly accessed from CPU code. So, it does make sense to put a sync call there to avoid surprises.However, after a
device_buffer
is constructed, the only way it can be touched is by using a cuda api or a cuda kernel, both of which adhere to stream semantics. Thus, as long as the underlying allocator adheres to the stream semantics, we could live without a sync here. What say?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.
Yes that is a good argument. Only concern I have with that it would be confusing if
host_buffer
anddevice_buffer
have different semantics.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.
Agree that this can be confusing to some folks. May be we could document this difference somewhere so that our devs are aware?
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.
@teju85 that's not what I meant. As I wrote: "I like the guarantee that the memory is immediately valid and available to all streams. I think it probably leads to fewer bugs."
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.
@harrism I was referring to your following statement about RMM:
In fact, even though RMM takes a stream in rmmAlloc(), the returned memory is immediately available for use on any stream!
I was wishing for any custom device allocators people might want to use with
device_buffer
, we could have this a guarantee, atleast for the specific stream in the ctor.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.
You could have a parameter that you set with the allocator. Call cudaStreamSynchronize() (or cudaDeviceSynchronize()) if the allocator is asynchronous, and don't call it if not.
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.
Thanks for all the inputs. I don't think we have come to a conclusion yet. @teju85 what do you think if we move the discussion if the constructor of
device_buffer
should synchronize or not to an issue and move on with this pull request (which as you state initially is unrelated to the open discussion) as it is.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.
Agreed. Doesn't make sense to block this PR for this discussion. Have filed issue #425 and let's migrate this discussion over there.