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

Commit

Permalink
Fix deprecated inner-constructor syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Feb 13, 2017
1 parent 17d2ea9 commit b5560de
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
11 changes: 5 additions & 6 deletions src/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export

## construction

type CuArray{T,N} <: AbstractArray{T,N}
@compat type CuArray{T,N} <: AbstractArray{T,N}
devptr::DevicePtr{T}
shape::NTuple{N,Int}

function CuArray(shape::NTuple{N,Int})
function (::Type{CuArray{T,N}}){T,N}(shape::NTuple{N,Int})
if !isbits(T)
# non-isbits types results in an array with references to CPU objects
throw(ArgumentError("CuArray with non-bit element type not supported"))
Expand All @@ -21,15 +21,14 @@ type CuArray{T,N} <: AbstractArray{T,N}
len = prod(shape)
devptr = Mem.alloc(T, len)

obj = new(devptr, shape)
obj = new{T,N}(devptr, shape)
block_finalizer(obj, devptr.ctx)
finalizer(obj, finalize)
return obj
end

function CuArray(shape::NTuple{N,Int}, devptr::DevicePtr{T})
new(devptr, shape)
end
(::Type{CuArray{T,N}}){T,N}(shape::NTuple{N,Int}, devptr::DevicePtr{T}) =
new{T,N}(devptr, shape)
end

(::Type{CuArray{T}}){T,N}(shape::NTuple{N,Int}) = CuArray{T,N}(shape)
Expand Down
6 changes: 3 additions & 3 deletions src/module/global.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ export
CuGlobal, get, set


immutable CuGlobal{T}
@compat immutable CuGlobal{T}
# TODO: typed pointer
devptr::DevicePtr{Void}
nbytes::Cssize_t

function CuGlobal(mod::CuModule, name::String)
function (::Type{CuGlobal{T}}){T}(mod::CuModule, name::String)
ptr_ref = Ref{Ptr{Void}}()
nbytes_ref = Ref{Cssize_t}()
@apicall(:cuModuleGetGlobal, (Ptr{Ptr{Void}}, Ptr{Cssize_t}, CuModule_t, Ptr{Cchar}),
Expand All @@ -19,7 +19,7 @@ immutable CuGlobal{T}
end
@assert nbytes_ref[] == sizeof(T)

return new(DevicePtr{Void}(ptr_ref[], CuCurrentContext()), nbytes_ref[])
return new{T}(DevicePtr{Void}(ptr_ref[], CuCurrentContext()), nbytes_ref[])
end
end

Expand Down
4 changes: 2 additions & 2 deletions src/pointer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ export
# It also keep track of the associated context, preventing it from getting freed while
# there's still a pointer from that context live.

immutable DevicePtr{T}
@compat immutable DevicePtr{T}
ptr::Ptr{T}
ctx::CuContext

DevicePtr(ptr::Ptr{T}, ctx::CuContext) = new(ptr,ctx)
(::Type{DevicePtr{T}}){T}(ptr::Ptr{T}, ctx::CuContext) = new{T}(ptr,ctx)
end

function Base.:(==)(a::DevicePtr, b::DevicePtr)
Expand Down

0 comments on commit b5560de

Please sign in to comment.