Skip to content

Commit bb33fa5

Browse files
authored
Fix KernelAbstractions for Unified Memory (#316)
1 parent 9a1411e commit bb33fa5

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/MetalKernels.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,20 @@ Adapt.adapt_storage(::KA.CPU, a::MtlArray) = convert(Array, a)
3535

3636
function KA.copyto!(::MetalBackend, A::MtlArray{T}, B::MtlArray{T}) where T
3737
if device(dest) == device(src)
38-
GC.@preserve A B unsafe_copyto!(device(A), pointer(A), pointer(B), length(A); async=true)
38+
GC.@preserve A B copyto!(A, B)
3939
return A
4040
else
4141
error("Copy between different devices not implemented")
4242
end
4343
end
4444

4545
function KA.copyto!(::MetalBackend, A::Array{T}, B::MtlArray{T}) where T
46-
GC.@preserve A B unsafe_copyto!(device(B), pointer(A), pointer(B), length(A); async=true)
46+
GC.@preserve A B copyto!(A, B)
4747
return A
4848
end
4949

5050
function KA.copyto!(::MetalBackend, A::MtlArray{T}, B::Array{T}) where T
51-
GC.@preserve A B unsafe_copyto!(device(A), pointer(A), pointer(B), length(A); async=true)
51+
GC.@preserve A B copyto!(A, B)
5252
return A
5353
end
5454

src/array.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ end
181181

182182
function Base.unsafe_convert(::Type{MtlPointer{T}}, x::MtlArray) where {T}
183183
buf = x.data[]
184-
synchronize()
185184
MtlPointer{T}(buf, x.offset*Base.elsize(x))
186185
end
187186

0 commit comments

Comments
 (0)