Skip to content

Commit aba90b6

Browse files
committed
Merge branch 'master' into sd/tuple_brc
2 parents 9016013 + b5a5286 commit aba90b6

File tree

8 files changed

+25
-184
lines changed

8 files changed

+25
-184
lines changed

src/blas.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ end
4242
Base.scale!(s::Real, X::GPUArray) = scale!(X, s)
4343
function Base.scale!(X::GPUArray{T}, s::Real) where T <: BLAS.BlasComplex
4444
R = typeof(real(zero(T)))
45-
buff = reinterpret(R, vec(X))
46-
BLAS.scal!(2*length(X), R(s), buff, 1)
45+
N = 2*length(X)
46+
buff = unsafe_reinterpret(R, X, (N,))
47+
BLAS.scal!(N, R(s), buff, 1)
4748
X
4849
end
4950
function Base.scale!(X::GPUArray{T}, s::Real) where T <: Union{Float32, Float64}

src/broadcast.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,17 @@ function Base.foreach(func, over::GPUArray, Bs...)
104104
end
105105

106106

107-
arg_length(x::Array) = error("No array in GPU Broadcast supported. Try converting it to a gpu array")
107+
function arg_length(x::AbstractArray)
108+
if !Base.datatype_pointerfree(x)
109+
error("Arrays type contains pointer - this doesn't work on the GPU (So arrays that don't contain pointers to memory, e.g. UnitRanges, would work).
110+
Try converting it to a gpu array. Found: $(typeof(x))"
111+
)
112+
end
113+
UInt32.(size(x))
114+
end
108115
arg_length(x::Tuple) = (UInt32(length(x)),)
109116
arg_length(x::GPUArray) = UInt32.(size(x))
110-
arg_length(x) = ()
117+
arg_length(x) = () # Scalar
111118

112119
struct BInfo{Typ, N}
113120
size::NTuple{N, UInt32}

src/construction.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ function convert(AT::Type{<: GPUArray{T, N}}, A::DenseArray{T, N}) where {T, N}
4545
copy!(AT(Base.size(A)), A)
4646
end
4747

48-
function convert(AT::Type{<: GPUArray{T1}}, A::DenseArray{T2}) where {T1, T2}
49-
copy!(similar(AT, T1, size(A)), T1.(A))
48+
function convert(AT::Type{<: GPUArray{T1}}, A::DenseArray{T2, N}) where {T1, T2, N}
49+
copy!(similar(AT, T1, size(A)), convert(Array{T1, N}, A))
5050
end
5151
function convert(AT::Type{<: GPUArray}, A::DenseArray{T2, N}) where {T2, N}
5252
copy!(similar(AT, T2, size(A)), A)

src/jlbackend.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ end
3434
similar(::Type{<: JLArray}, ::Type{T}, size::Base.Dims{N}) where {T, N} = JLArray{T, N}(size)
3535

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

4040
function copy!(

src/testsuite/blas.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ function run_blas(Typ)
99
against_base(*, T, (5, 5), (5, 5))
1010
against_base(*, T, (5, 5), (5,))
1111
against_base(A_mul_Bt, T, (5, 5), (5, 5))
12+
against_base(A_mul_Bt!, T, (10, 32), (10, 60), (32, 60))
1213
against_base(At_mul_B, T, (5, 5), (5, 5))
14+
against_base(At_mul_Bt, T, (10, 15), (1, 10))
15+
against_base(At_mul_B, T, (10, 15), (10,))
16+
against_base(A_mul_B!, T, (15,), (15, 10), (10,))
17+
end
18+
for T in (Complex64, Float32)
19+
@testset "scale! $T" begin
20+
against_base(scale!, Typ{T}, (13, 23), 77f0)
21+
end
1322
end
14-
# for T in (Complex64, Float32)
15-
# @testset "scale!" begin
16-
# against_base(scale!, Typ{T}, (13, 23), 77f0)
17-
# end
18-
# end
1923
end
2024
end

src/testsuite/testsuite.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module TestSuite
88
using Base.Test
99

1010
toarray(T, x::Tuple{X, Vararg{Int}}) where X = fill(first(x), Base.tail(x))
11+
toarray(::Type{T}, x::NTuple{N, Int}) where {T <: Bool, N} = rand(T, x)
1112
toarray(::Type{T}, x::NTuple{N, Int}) where {T <: Integer, N} = rand(T(1):T(10), x)
1213
toarray(T, x::NTuple{N, Int}) where N = rand(T, x)
1314
toarray(T, x) = x

test/convolution.jl

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
using GPUArrays, Colors, FileIO, ImageFiltering
2-
using CLArrays
3-
using GPUArrays: synchronize_threads
4-
import GPUArrays: LocalMemory
5-
using CLArrays
6-
7-
8-
img = RGB{Float32}.(load(homedir()*"/Desktop/backround.jpg"));
9-
10-
a = CLArray(img);
11-
out = similar(a);
12-
k = CLArray(Float32.(collect(Kernel.gaussian(3))));
13-
imgc = similar(img)
141

152
# convolution!(a, out, k);
163
# Array(out)

test/pde.jl

Lines changed: 0 additions & 159 deletions
This file was deleted.

0 commit comments

Comments
 (0)