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

Commit

Permalink
Merge pull request #551 from JuliaGPU/tb/context
Browse files Browse the repository at this point in the history
Use the CUDAnative context getter.
  • Loading branch information
maleadt authored Jan 6, 2020
2 parents 01be4f4 + 1e909dd commit 6bd1799
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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

0 comments on commit 6bd1799

Please sign in to comment.