Skip to content

Commit a4a9166

Browse files
authored
Add a comment on asynchronous HtoD copies.
[ci skip]
1 parent 6bccad6 commit a4a9166

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/array.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,10 @@ function Base.unsafe_copyto!(dest::Array{T}, doffs,
552552
end
553553

554554
GC.@preserve src dest begin
555+
# semantically, it is not safe for this operation to execute asynchronously, because
556+
# the Array may be collected before the copy starts executing. However, when using
557+
# unpinned memory, CUDA first stages a copy to a pinned buffer that will outlive
558+
# the source array, making this operation safe.
555559
unsafe_copyto!(pointer(dest, doffs), pointer(src, soffs), n; async=true)
556560
if Base.isbitsunion(T)
557561
unsafe_copyto!(typetagdata(dest, doffs), typetagdata(src, soffs), n; async=true)

0 commit comments

Comments
 (0)