You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/array.jl
+12-3Lines changed: 12 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -440,10 +440,19 @@ function Base.unsafe_copyto!(dev::MTLDevice, dest::MtlArray{T}, doffs, src::MtlA
440
440
end
441
441
return dest
442
442
end
443
-
function Base.unsafe_copyto!(::MTLDevice, dest::MtlArray{T,<:Any,Metal.SharedStorage}, doffs, src::MtlArray{T,<:Any,Metal.SharedStorage}, soffs, n) where T
444
-
# these copies are implemented using pure memcpy's, not API calls, so aren't ordered.
443
+
function Base.unsafe_copyto!(dev::MTLDevice, dest::MtlArray{T, <:Any, Metal.SharedStorage}, doffs, src::MtlArray{T, <:Any, Metal.SharedStorage}, soffs, n) where {T}
445
444
synchronize()
446
-
GC.@preserve src dest unsafe_copyto!(pointer(unsafe_wrap(Array,dest), doffs), pointer(unsafe_wrap(Array,src), soffs), n)
445
+
bytes = n * sizeof(T)
446
+
# Use GPU blit for large copies (>32MiB) where it's faster than CPU memcpy.
447
+
# For small copies, CPU memcpy avoids GPU command buffer overhead.
448
+
if bytes >=32*2^20# If changed, also change in tests
449
+
GC.@preserve src dest unsafe_copyto!(dev, pointer(dest, doffs), pointer(src, soffs), n)
450
+
if Base.isbitsunion(T)
451
+
error("Not implemented")
452
+
end
453
+
else
454
+
GC.@preserve src dest unsafe_copyto!(pointer(unsafe_wrap(Array, dest), doffs), pointer(unsafe_wrap(Array, src), soffs), n)
0 commit comments