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 #711 from JuliaGPU/tb/threaded_testset
Browse files Browse the repository at this point in the history
Perform threaded test in lock.
  • Loading branch information
maleadt authored May 8, 2020
2 parents 7b1e0f0 + a41dcfe commit 770e4db
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions test/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -413,18 +413,27 @@ end
@testset "threading" begin
CuArrays.disable_timings() # FIXME

test_lock = ReentrantLock()
Threads.@threads for i in 1:Threads.nthreads()*100
# uses libraries (rand, gemm) to test library handles
# allocates and uses unsafe_free to cover the allocator
a = CuArrays.rand(64, 64)
b = CuArrays.rand(64, 64)
da = CuArrays.rand(64, 64)
db = CuArrays.rand(64, 64)
yield()
c = a * b
dc = da * db
yield()
@test Array(c) Array(a) * Array(b)

# @testset is not thread safe
a = Array(da)
b = Array(db)
c = Array(dc)
lock(test_lock) do
@test c a * b
end

yield()
CuArrays.unsafe_free!(a)
CuArrays.unsafe_free!(b)
CuArrays.unsafe_free!(da)
CuArrays.unsafe_free!(db)
end

CuArrays.enable_timings() # FIXME
Expand Down

0 comments on commit 770e4db

Please sign in to comment.