Skip to content

Commit

Permalink
Merge pull request #331 from JuliaGPU/tb/int128
Browse files Browse the repository at this point in the history
Don't rely on Int128
  • Loading branch information
maleadt authored Oct 27, 2020
2 parents 60294ff + 03c040d commit 5f97bfb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
11 changes: 3 additions & 8 deletions src/host/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,11 @@ function generic_matmatmul!(C::AnyGPUArray{R}, A::AnyGPUArray{T}, B::AnyGPUArray
return fill!(C, zero(R))
end

# reshape vectors to matrices
A′ = reshape(A, (size(A,1), size(A,2)))
B′ = reshape(B, (size(B,1), size(B,2)))
C′= reshape(C, (size(C,1), size(C,2)))

gpu_call(C′, A′, B′; name="matmatmul!") do ctx, C, A, B
gpu_call(C, A, B; name="matmatmul!") do ctx, C, A, B
idx = @linearidx C
i, j = Tuple(CartesianIndices(C)[idx])
i, j = @inbounds Tuple(CartesianIndices(C)[idx])..., 1

if i <= size(A,1) && j <= size(B,2)
@inbounds if i <= size(A,1) && j <= size(B,2)
z2 = zero(A[i, 1]*B[1, j] + A[i, 1]*B[1, j])
Ctmp = convert(promote_type(R, typeof(z2)), z2)
for k in 1:size(A,2)
Expand Down
14 changes: 8 additions & 6 deletions test/testsuite/mapreduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,21 @@ end
@test compare(A->maximum(A; dims=dims), AT, rand(range, sz))
end
end
OT = isbitstype(widen(ET)) ? widen(ET) : ET
for (sz,red) in [(10,)=>(1,), (10,10)=>(1,1), (10,10,10)=>(1,1,1), (10,10,10)=>(10,10,10),
(10,10,10)=>(1,10,10), (10,10,10)=>(10,1,10), (10,10,10)=>(10,10,1)]
if !(ET <: Complex)
@test compare((A,R)->minimum!(R, A), AT, rand(range, sz), fill(typemax(ET), red))
@test compare((A,R)->maximum!(R, A), AT, rand(range, sz), fill(typemin(ET), red))
end
end
# smaller-scale test to avoid very large values and roundoff issues
for (sz,red) in [(2,)=>(1,), (2,2)=>(1,1), (2,2,2)=>(1,1,1), (2,2,2)=>(2,2,2),
(2,2,2)=>(1,2,2), (2,2,2)=>(2,1,2), (2,2,2)=>(2,2,1)]
@test compare((A,R)->sum!(R, A), AT, rand(range, sz), rand(OT, red))
@test compare((A,R)->prod!(R, A), AT, rand(range, sz), rand(OT, red))
OT = isbitstype(widen(ET)) ? widen(ET) : ET
if OT in supported_eltypes()
# smaller-scale test to avoid very large values and roundoff issues
for (sz,red) in [(2,)=>(1,), (2,2)=>(1,1), (2,2,2)=>(1,1,1), (2,2,2)=>(2,2,2),
(2,2,2)=>(1,2,2), (2,2,2)=>(2,1,2), (2,2,2)=>(2,2,1)]
@test compare((A,R)->sum!(R, A), AT, rand(range, sz), rand(OT, red))
@test compare((A,R)->prod!(R, A), AT, rand(range, sz), rand(OT, red))
end
end
end

Expand Down

0 comments on commit 5f97bfb

Please sign in to comment.