-
Notifications
You must be signed in to change notification settings - Fork 234
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
Remove eager synchronization with HtoD copies. #2625
Conversation
We assumed unpinned memory would always synchronize, but that does not seem to be the case. For some copy sizes (and potentially on some, e.g. coherent, memory architectures) the copy is fully asynchronous. This optimization was made to make `CuRef` of a scalar fully async. I considered making the `CuRef` ctor call `memset` instead, which is always asynchronous by virtue of passing the memory by value, however that does not support 64-bits floats while `memcpy` of 64 bits is still executed fully asynchronously.
# the copy below may block in `libcuda`, so it'd be good to perform a nonblocking | ||
# synchronization here, but the exact cases are hard to know and detect (e.g., unpinned | ||
# memory normally blocks, but not for all sizes, and not on all memory architectures). |
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.
# the copy below may block in `libcuda`, so it'd be good to perform a nonblocking | |
# synchronization here, but the exact cases are hard to know and detect (e.g., unpinned | |
# memory normally blocks, but not for all sizes, and not on all memory architectures). | |
# the copy below may block in `libcuda`, so it'd be good to perform a nonblocking | |
# synchronization here, but the exact cases are hard to know and detect (e.g., unpinned | |
# memory normally blocks, but not for all sizes, and not on all memory architectures). |
is_pinned(pointer(dest)) || synchronize() | ||
end | ||
|
||
# the copy below may block in `libcuda`; see the note above. |
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.
# the copy below may block in `libcuda`; see the note above. | |
# the copy below may block in `libcuda`; see the note above. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2625 +/- ##
==========================================
- Coverage 73.60% 73.59% -0.01%
==========================================
Files 157 157
Lines 15230 15226 -4
==========================================
- Hits 11210 11206 -4
Misses 4020 4020 ☔ View full report in Codecov by Sentry. |
We assumed unpinned memory would always synchronize, but that does not seem to be the case. For some copy sizes (and potentially on some, e.g. coherent, memory architectures) the copy is fully asynchronous.
This optimization was made to make
CuRef
of a scalar fully async. I considered making theCuRef
ctor callmemset
instead, which is always asynchronous by virtue of passing the memory by value, however that does not support 64-bits floats whilememcpy
of 64 bits is still executed fully asynchronously.Demo script:
Before:
After: