From 18d847edcc4292d1314d03904077b6e43dff0c11 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Mon, 6 Jan 2020 11:45:42 +0100 Subject: [PATCH] Separate-out unsafe_copy of arrays. --- src/array.jl | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/array.jl b/src/array.jl index 61b39b6d..6fc8d624 100644 --- a/src/array.jl +++ b/src/array.jl @@ -250,7 +250,7 @@ function Base.copyto!(dest::CuArray{T}, doffs::Integer, src::Array{T}, soffs::In @boundscheck checkbounds(dest, doffs+n-1) @boundscheck checkbounds(src, soffs) @boundscheck checkbounds(src, soffs+n-1) - unsafe_copyto!(pointer(dest, doffs), pointer(src, soffs), n) + unsafe_copyto!(dest, doffs, src, soffs, n) return dest end @@ -261,7 +261,7 @@ function Base.copyto!(dest::Array{T}, doffs::Integer, src::CuArray{T}, soffs::In @boundscheck checkbounds(dest, doffs+n-1) @boundscheck checkbounds(src, soffs) @boundscheck checkbounds(src, soffs+n-1) - unsafe_copyto!(pointer(dest, doffs), pointer(src, soffs), n) + unsafe_copyto!(dest, doffs, src, soffs, n) return dest end @@ -272,7 +272,34 @@ function Base.copyto!(dest::CuArray{T}, doffs::Integer, src::CuArray{T}, soffs:: @boundscheck checkbounds(dest, doffs+n-1) @boundscheck checkbounds(src, soffs) @boundscheck checkbounds(src, soffs+n-1) + unsafe_copyto!(dest, doffs, src, soffs, n) + return dest +end + +function Base.unsafe_copyto!(dest::CuArray{T}, doffs, src::Array{T}, soffs, n) where T + unsafe_copyto!(pointer(dest, doffs), pointer(src, soffs), n) + if Base.isbitsunion(T) + # copy selector bytes + error("Not implemented") + end + return dest +end + +function Base.unsafe_copyto!(dest::Array{T}, doffs, src::CuArray{T}, soffs, n) where T + unsafe_copyto!(pointer(dest, doffs), pointer(src, soffs), n) + if Base.isbitsunion(T) + # copy selector bytes + error("Not implemented") + end + return dest +end + +function Base.unsafe_copyto!(dest::CuArray{T}, doffs, src::CuArray{T}, soffs, n) where T unsafe_copyto!(pointer(dest, doffs), pointer(src, soffs), n) + if Base.isbitsunion(T) + # copy selector bytes + error("Not implemented") + end return dest end