Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

Use the CUDAnative context getter. #551

Merged
merged 1 commit into from
Jan 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ end

# primary array
function CuArray{T,N}(ptr::CuPtr{T}, dims::Dims{N}, pooled::Bool=true;
ctx=CuCurrentContext()) where {T,N}
ctx=context()) where {T,N}
self = CuArray{T,N,Nothing}(ptr, dims, nothing, pooled, ctx)
retain(self)
finalizer(unsafe_free!, self)
Expand Down Expand Up @@ -123,7 +123,7 @@ Base.similar(a::CuArray, ::Type{T}, dims::Base.Dims{N}) where {T,N} = CuArray{T,


"""
unsafe_wrap(::CuArray, ptr::CuPtr{T}, dims; own=false, ctx=CuCurrentContext())
unsafe_wrap(::CuArray, ptr::CuPtr{T}, dims; own=false, ctx=context())

Wrap a `CuArray` object around the data at the address given by `ptr`. The pointer
element type `T` determines the array element type. `dims` is either an integer (for a 1d
Expand All @@ -133,7 +133,7 @@ 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}}},
p::CuPtr{T}, dims::NTuple{N,Int};
own::Bool=false, ctx::CuContext=CuCurrentContext()) where {T,N}
own::Bool=false, ctx::CuContext=context()) where {T,N}
xs = CuArray{T, length(dims)}(p, dims, false; ctx=ctx)
if own
base = convert(CuPtr{Cvoid}, p)
Expand All @@ -149,7 +149,7 @@ end

function Base.unsafe_wrap(Atype::Union{Type{CuArray},Type{CuArray{T}},Type{CuArray{T,1}}},
p::CuPtr{T}, dim::Integer;
own::Bool=false, ctx::CuContext=CuCurrentContext()) where {T}
own::Bool=false, ctx::CuContext=context()) where {T}
unsafe_wrap(Atype, p, (dim,); own=own, ctx=ctx)
end

Expand Down
2 changes: 1 addition & 1 deletion src/rand/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mutable struct RNG <: Random.AbstractRNG
handle_ref = Ref{curandGenerator_t}()
@allocates curandCreateGenerator(handle_ref, typ)

obj = new(handle_ref[], CuCurrentContext(), typ)
obj = new(handle_ref[], context(), typ)
finalizer(unsafe_destroy!, obj)
return obj
end
Expand Down