Skip to content

Commit dc68bc6

Browse files
authored
Merge pull request #49 from JuliaGPU/fbot/deps
Fix deprecations
2 parents 1d61814 + bed4c85 commit dc68bc6

File tree

12 files changed

+67
-67
lines changed

12 files changed

+67
-67
lines changed

src/abstractarray.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const GPUVecOrMat{T} = Union{GPUArray{T, 1}, GPUArray{T, 2}}
1313
# GPU Local Memory
1414
struct LocalMemory{T} <: GPUArray{T, 1}
1515
size::Int
16-
(::Type{LocalMemory{T}})(x::Integer) where T = new{T}(x)
16+
LocalMemory{T}(x::Integer) where T = new{T}(x)
1717
end
1818

1919
#=
@@ -40,11 +40,11 @@ else
4040
error("No Serialization type found. Probably unsupported Julia version")
4141
end
4242

43-
function Base.serialize{T <: GPUArray}(s::BaseSerializer, t::T)
43+
function Base.serialize(s::BaseSerializer, t::T) where T <: GPUArray
4444
Base.serialize_type(s, T)
4545
serialize(s, Array(t))
4646
end
47-
function Base.deserialize{T <: GPUArray}(s::BaseSerializer, ::Type{T})
47+
function Base.deserialize(s::BaseSerializer, ::Type{T}) where T <: GPUArray
4848
A = deserialize(s)
4949
T(A)
5050
end
@@ -88,18 +88,18 @@ for (D, S) in ((GPUArray, AbstractArray), (AbstractArray, GPUArray), (GPUArray,
8888
unpack_buffer(src), soffset, amount
8989
)
9090
end
91-
function copy!{T, N}(
91+
function copy!(
9292
dest::$D{T, N}, rdest::NTuple{N, UnitRange},
9393
src::$S{T, N}, ssrc::NTuple{N, UnitRange},
94-
)
94+
) where {T, N}
9595
drange = crange(start.(rdest), last.(rdest))
9696
srange = crange(start.(ssrc), last.(ssrc))
9797
copy!(dest, drange, src, srange)
9898
end
99-
function copy!{T}(
99+
function copy!(
100100
dest::$D{T}, d_range::CartesianRange{CartesianIndex{1}},
101101
src::$S{T}, s_range::CartesianRange{CartesianIndex{1}},
102-
)
102+
) where T
103103
amount = length(d_range)
104104
if length(s_range) != amount
105105
throw(ArgumentError("Copy range needs same length. Found: dest: $amount, src: $(length(s_range))"))
@@ -109,9 +109,9 @@ for (D, S) in ((GPUArray, AbstractArray), (AbstractArray, GPUArray), (GPUArray,
109109
s_offset = first(s_range)[1]
110110
copy!(dest, d_offset, src, s_offset, amount)
111111
end
112-
function copy!{T, N}(
112+
function copy!(
113113
dest::$D{T, N}, src::$S{T, N}
114-
)
114+
) where {T, N}
115115
len = length(src)
116116
len == 0 && return dest
117117
if length(dest) > len
@@ -134,10 +134,10 @@ function copy_kernel!(state, dest, dest_offsets, src, src_offsets, shape, shape_
134134
return
135135
end
136136

137-
function copy!{T, N}(
137+
function copy!(
138138
dest::GPUArray{T, N}, destcrange::CartesianRange{CartesianIndex{N}},
139139
src::GPUArray{T, N}, srccrange::CartesianRange{CartesianIndex{N}}
140-
)
140+
) where {T, N}
141141
shape = size(destcrange)
142142
if shape != size(srccrange)
143143
throw(DimensionMismatch("Ranges don't match their size. Found: $shape, $(size(srccrange))"))
@@ -155,10 +155,10 @@ function copy!{T, N}(
155155
end
156156

157157

158-
function copy!{T, N}(
158+
function copy!(
159159
dest::GPUArray{T, N}, destcrange::CartesianRange{CartesianIndex{N}},
160160
src::AbstractArray{T, N}, srccrange::CartesianRange{CartesianIndex{N}}
161-
)
161+
) where {T, N}
162162
# Is this efficient? Maybe!
163163
# TODO: compare to a pure intrinsic copy implementation!
164164
# this would mean looping over linear sections of memory and
@@ -170,10 +170,10 @@ function copy!{T, N}(
170170
end
171171

172172

173-
function copy!{T, N}(
173+
function copy!(
174174
dest::AbstractArray{T, N}, destcrange::CartesianRange{CartesianIndex{N}},
175175
src::GPUArray{T, N}, srccrange::CartesianRange{CartesianIndex{N}}
176-
)
176+
) where {T, N}
177177
# Is this efficient? Maybe!
178178
dest_gpu = similar(src, size(destcrange))
179179
nrange = CartesianRange(one(CartesianIndex{N}), CartesianIndex(size(dest_gpu)))

src/base.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,29 +61,29 @@ map!(f, y::GPUArray, x1::GPUArray, x2::GPUArray) =
6161

6262

6363
# Base functions that are sadly not fit for the the GPU yet (they only work for Int64)
64-
@pure @inline function gpu_ind2sub{T}(A::AbstractArray, ind::T)
64+
@pure @inline function gpu_ind2sub(A::AbstractArray, ind::T) where T
6565
_ind2sub(size(A), ind - T(1))
6666
end
67-
@pure @inline function gpu_ind2sub{N, T}(dims::NTuple{N}, ind::T)
67+
@pure @inline function gpu_ind2sub(dims::NTuple{N}, ind::T) where {N, T}
6868
_ind2sub(NTuple{N, T}(dims), ind - T(1))
6969
end
70-
@pure @inline _ind2sub{T}(::Tuple{}, ind::T) = (ind + T(1),)
71-
@pure @inline function _ind2sub{T}(indslast::NTuple{1}, ind::T)
70+
@pure @inline _ind2sub(::Tuple{}, ind::T) where {T} = (ind + T(1),)
71+
@pure @inline function _ind2sub(indslast::NTuple{1}, ind::T) where T
7272
((ind + T(1)),)
7373
end
74-
@pure @inline function _ind2sub{T}(inds, ind::T)
74+
@pure @inline function _ind2sub(inds, ind::T) where T
7575
r1 = inds[1]
7676
indnext = div(ind, r1)
7777
f = T(1); l = r1
7878
(ind-l*indnext+f, _ind2sub(Base.tail(inds), indnext)...)
7979
end
8080

81-
@pure function gpu_sub2ind{N, N2, T}(dims::NTuple{N}, I::NTuple{N2, T})
81+
@pure function gpu_sub2ind(dims::NTuple{N}, I::NTuple{N2, T}) where {N, N2, T}
8282
Base.@_inline_meta
8383
_sub2ind(NTuple{N, T}(dims), T(1), T(1), I...)
8484
end
8585
_sub2ind(x, L, ind) = ind
86-
function _sub2ind{T}(::Tuple{}, L, ind, i::T, I::T...)
86+
function _sub2ind(::Tuple{}, L, ind, i::T, I::T...) where T
8787
Base.@_inline_meta
8888
ind + (i - T(1)) * L
8989
end

src/blas.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ end
2828

2929
for elty in (Float64, Float32)
3030
@eval begin
31-
function Base.BLAS.scal!{N}(
31+
function Base.BLAS.scal!(
3232
n::Integer, DA::$elty,
3333
DX::GPUArray{$elty, N}, incx::Integer
34-
)
34+
) where N
3535
blasmod = blas_module(DX)
3636
blasmod.scal!(n, DA, blasbuffer(DX), incx)
3737
DX

src/broadcast.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ arg_length(x) = ()
111111

112112
abstract type BroadcastDescriptor{Typ} end
113113

114-
immutable BroadcastDescriptorN{Typ, N} <: BroadcastDescriptor{Typ}
114+
struct BroadcastDescriptorN{Typ, N} <: BroadcastDescriptor{Typ}
115115
size::NTuple{N, UInt32}
116116
keep::NTuple{N, UInt32}
117117
idefault::NTuple{N, UInt32}
@@ -208,7 +208,7 @@ for N = 0:10
208208

209209
end
210210

211-
function mapidx{N}(f, A::GPUArray, args::NTuple{N, Any})
211+
function mapidx(f, A::GPUArray, args::NTuple{N, Any}) where N
212212
gpu_call(mapidx_kernel, A, (f, A, UInt32(length(A)), args...))
213213
end
214214

@@ -225,7 +225,7 @@ end
225225
end
226226

227227
# differently shaped arrays
228-
@generated function newindex{N, T}(I, ilin::T, keep::NTuple{N}, Idefault, size)
228+
@generated function newindex(I, ilin::T, keep::NTuple{N}, Idefault, size) where {N, T}
229229
exprs = Expr(:tuple)
230230
for i = 1:N
231231
push!(exprs.args, :(T(Bool(keep[$i]) ? T(I[$i]) : T(Idefault[$i]))))

src/construction.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function fill(X::Type{<: GPUArray}, val::T, dims::NTuple{N, Integer}) where {T,
99
fill!(res, val)
1010
end
1111

12-
function fill!{T, N}(A::GPUArray{T, N}, val)
12+
function fill!(A::GPUArray{T, N}, val) where {T, N}
1313
valconv = T(val)
1414
gpu_call(const_kernel2, A, (A, valconv, UInt32(length(A))))
1515
A

src/convolution.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function convolution!(a, out, k)
7171
out
7272
end
7373

74-
immutable FFTKernel{T}
74+
struct FFTKernel{T}
7575
kernel::T
7676
irfftplan
7777
rfftplan

src/fft.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import CLFFT
99
#const plan_dict = Dict()
1010
import Base: *, plan_ifft!, plan_fft!, plan_fft, plan_ifft, size, plan_bfft, plan_bfft!
1111

12-
immutable CLFFTPlan{Direction, Inplace, T, N} <: Base.FFTW.FFTWPlan{T, Direction, Inplace}
12+
struct CLFFTPlan{Direction, Inplace, T, N} <: Base.FFTW.FFTWPlan{T, Direction, Inplace}
1313
plan::CLFFT.Plan{T}
14-
function (::Type{CLFFTPlan{Direction, Inplace}})(A::CLArray{T, N}) where {T, N, Direction, Inplace}
14+
function CLFFTPlan{Direction, Inplace}(A::CLArray{T, N}) where {T, N, Direction, Inplace}
1515
ctx = context(A)
1616
p = CLFFT.Plan(T, ctx.context, size(A))
1717
CLFFT.set_layout!(p, :interleaved, :interleaved)

src/jlbackend.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ end
1010
"""
1111
Thread group local memory
1212
"""
13-
immutable LocalMem{N, T}
13+
struct LocalMem{N, T}
1414
x::NTuple{N, Vector{T}}
1515
end
1616

@@ -27,7 +27,7 @@ to_blocks(state, x) = x
2727
# unpacks local memory for each block
2828
to_blocks(state, x::LocalMem) = x.x[blockidx_x(state)]
2929

30-
function (::Type{JLArray{T, N}})(size::NTuple{N, Integer}) where {T, N}
30+
function JLArray{T, N}(size::NTuple{N, Integer}) where {T, N}
3131
JLArray{T, N}(Array{T, N}(size), size)
3232
end
3333

@@ -37,23 +37,23 @@ function unsafe_reinterpret(::Type{T}, A::JLArray{ET}, size::NTuple{N, Integer})
3737
JLArray(collect(reshape(reinterpret(T, A.data), size)))
3838
end
3939

40-
function copy!{T}(
40+
function copy!(
4141
dest::Array{T}, d_offset::Integer,
4242
source::JLArray{T}, s_offset::Integer, amount::Integer
43-
)
43+
) where T
4444
copy!(dest, d_offset, source.data, s_offset, amount)
4545
end
46-
function copy!{T}(
46+
function copy!(
4747
dest::JLArray{T}, d_offset::Integer,
4848
source::Array{T}, s_offset::Integer, amount::Integer
49-
)
49+
) where T
5050
copy!(dest.data, d_offset, source, s_offset, amount)
5151
dest
5252
end
53-
function copy!{T}(
53+
function copy!(
5454
dest::JLArray{T}, d_offset::Integer,
5555
source::JLArray{T}, s_offset::Integer, amount::Integer
56-
)
56+
) where T
5757
copy!(dest.data, d_offset, source.data, s_offset, amount)
5858
dest
5959
end
@@ -99,10 +99,10 @@ function LocalMemory(state::JLState, ::Type{T}, ::Val{N}, ::Val{C}) where {T, N,
9999
end
100100
end
101101

102-
function (::Type{AbstractDeviceArray})(ptr::Array, shape::NTuple{N, Integer}) where N
102+
function AbstractDeviceArray(ptr::Array, shape::NTuple{N, Integer}) where N
103103
reshape(ptr, Int.(shape))
104104
end
105-
function (::Type{AbstractDeviceArray})(ptr::Array, shape::Vararg{Integer, N}) where N
105+
function AbstractDeviceArray(ptr::Array, shape::Vararg{Integer, N}) where N
106106
reshape(ptr, Int.(shape))
107107
end
108108

@@ -158,7 +158,7 @@ blasbuffer(A::JLArray) = A.data
158158

159159
import Base: *, plan_ifft!, plan_fft!, plan_fft, plan_ifft, size, plan_bfft, plan_bfft!
160160
# defining our own plan type is the easiest way to pass around the plans in Base interface without ambiguities
161-
immutable FFTPlan{T}
161+
struct FFTPlan{T}
162162
p::T
163163
end
164164
function plan_fft(A::JLArray; kw_args...)

src/linalg.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function transpose_blocks!(
5353
return
5454
end
5555

56-
function transpose!{T}(At::GPUArray{T, 2}, A::GPUArray{T, 2})
56+
function transpose!(At::GPUArray{T, 2}, A::GPUArray{T, 2}) where T
5757
if size(A, 1) == size(A, 2) && all(x-> x % 32 == 0, size(A))
5858
outsize = UInt32.(size(At))
5959
TDIM = UInt32(32); BLOCK_ROWS = UInt32(8)

src/mapreduce.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ startvalue(::typeof(Base.scalarmin), T) = typemax(T)
2020
startvalue(::typeof(Base.scalarmax), T) = typemin(T)
2121

2222
# TODO widen and support Int64 and use Base.r_promote_type
23-
gpu_promote_type{T}(op, ::Type{T}) = T
24-
gpu_promote_type{T<:Base.WidenReduceResult}(op, ::Type{T}) = T
25-
gpu_promote_type{T<:Base.WidenReduceResult}(::typeof(+), ::Type{T}) = T
26-
gpu_promote_type{T<:Base.WidenReduceResult}(::typeof(*), ::Type{T}) = T
27-
gpu_promote_type{T<:Number}(::typeof(+), ::Type{T}) = typeof(zero(T)+zero(T))
28-
gpu_promote_type{T<:Number}(::typeof(*), ::Type{T}) = typeof(one(T)*one(T))
29-
gpu_promote_type{T<:Base.WidenReduceResult}(::typeof(Base.scalarmax), ::Type{T}) = T
30-
gpu_promote_type{T<:Base.WidenReduceResult}(::typeof(Base.scalarmin), ::Type{T}) = T
31-
gpu_promote_type{T<:Base.WidenReduceResult}(::typeof(max), ::Type{T}) = T
32-
gpu_promote_type{T<:Base.WidenReduceResult}(::typeof(min), ::Type{T}) = T
23+
gpu_promote_type(op, ::Type{T}) where {T} = T
24+
gpu_promote_type(op, ::Type{T}) where {T<:Base.WidenReduceResult} = T
25+
gpu_promote_type(::typeof(+), ::Type{T}) where {T<:Base.WidenReduceResult} = T
26+
gpu_promote_type(::typeof(*), ::Type{T}) where {T<:Base.WidenReduceResult} = T
27+
gpu_promote_type(::typeof(+), ::Type{T}) where {T<:Number} = typeof(zero(T)+zero(T))
28+
gpu_promote_type(::typeof(*), ::Type{T}) where {T<:Number} = typeof(one(T)*one(T))
29+
gpu_promote_type(::typeof(Base.scalarmax), ::Type{T}) where {T<:Base.WidenReduceResult} = T
30+
gpu_promote_type(::typeof(Base.scalarmin), ::Type{T}) where {T<:Base.WidenReduceResult} = T
31+
gpu_promote_type(::typeof(max), ::Type{T}) where {T<:Base.WidenReduceResult} = T
32+
gpu_promote_type(::typeof(min), ::Type{T}) where {T<:Base.WidenReduceResult} = T
3333

34-
function Base.mapreduce{T, N}(f::Function, op::Function, A::GPUArray{T, N})
34+
function Base.mapreduce(f::Function, op::Function, A::GPUArray{T, N}) where {T, N}
3535
OT = gpu_promote_type(op, T)
3636
v0 = startvalue(op, OT) # TODO do this better
3737
mapreduce(f, op, v0, A)
@@ -117,9 +117,9 @@ end
117117
to_cpu(x) = x
118118
to_cpu(x::GPUArray) = Array(x)
119119

120-
function acc_mapreduce{T, OT, N}(
120+
function acc_mapreduce(
121121
f, op, v0::OT, A::GPUArray{T, N}, rest::Tuple
122-
)
122+
) where {T, OT, N}
123123
dev = device(A)
124124
blocksize = 80
125125
threads = 256

0 commit comments

Comments
 (0)