Skip to content

Commit

Permalink
Formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Jun 16, 2023
1 parent 0a71a5b commit cb09402
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -240,24 +240,23 @@ take ownership of the memory, calling `cudaFree` when the array is no longer ref
function Base.unsafe_wrap(::Union{Type{CuArray},Type{CuArray{T}},Type{CuArray{T,N}}},
ptr::CuPtr{T}, dims::NTuple{N,Int};
own::Bool=false, ctx::CuContext=context()) where {T,N}
buf = _unsafe_wrapped_buff(T, ptr, dims; own, ctx)
buf = _unsafe_wrap(T, ptr, dims; own, ctx)
storage = ArrayStorage(buf, own ? 1 : -1)
CuArray{T, length(dims)}(storage, dims)
end
function Base.unsafe_wrap(::Type{CuArray{T,N,B}},
ptr::CuPtr{T}, dims::NTuple{N,Int};
own::Bool=false, ctx::CuContext=context()) where {T,N,B}
buf = _unsafe_wrapped_buff(T, ptr, dims; own, ctx)
buf = _unsafe_wrap(T, ptr, dims; own, ctx)
if typeof(buf) !== B
error("Declared buffer type does not match inferred buffer type.")
end
storage = ArrayStorage(buf, own ? 1 : -1)
CuArray{T, length(dims)}(storage, dims)
end

function _unsafe_wrapped_buff(::Type{T},
ptr::CuPtr{T}, dims::NTuple{N,Int};
own::Bool=false, ctx::CuContext=context()) where {T,N}
function _unsafe_wrap(::Type{T}, ptr::CuPtr{T}, dims::NTuple{N,Int};
own::Bool=false, ctx::CuContext=context()) where {T,N}
isbitstype(T) || error("Can only unsafe_wrap a pointer to a bits type")
sz = prod(dims) * sizeof(T)

Expand Down

0 comments on commit cb09402

Please sign in to comment.