This repository was archived by the owner on Dec 16, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +34
-28
lines changed Expand file tree Collapse file tree 2 files changed +34
-28
lines changed Original file line number Diff line number Diff line change @@ -11,22 +11,30 @@ if Base.USE_GPL_LIBS
1111 include (" linalg_tests.jl" )
1212
1313 # Test multithreaded execution
14- let p, cmd = ` $(Base. julia_cmd ()) --depwarn=error --startup-file=no threads.jl`
14+ @testset " threaded SuiteSparse tests" verbose = true begin
15+ @testset " threads = $(Threads. nthreads ()) " begin
16+ include (" threads.jl" )
17+ end
1518 # test both nthreads==1 and nthreads>1. spawn a process to test whichever
1619 # case we are not running currently.
1720 other_nthreads = Threads. nthreads () == 1 ? 4 : 1
18- p = run (
19- pipeline (
20- setenv (
21- cmd,
22- " JULIA_NUM_THREADS" => other_nthreads,
23- dir= @__DIR__ ()),
24- stdout = stdout ,
25- stderr = stderr ),
26- wait = false )
27- include (" threads.jl" )
28- if ! success (p)
29- error (" SuiteSparse threads test failed with nthreads == $other_nthreads " )
21+ @testset " threads = $other_nthreads " begin
22+ let p, cmd = ` $(Base. julia_cmd ()) --depwarn=error --startup-file=no threads.jl`
23+ p = run (
24+ pipeline (
25+ setenv (
26+ cmd,
27+ " JULIA_NUM_THREADS" => other_nthreads,
28+ dir= @__DIR__ ()),
29+ stdout = stdout ,
30+ stderr = stderr ),
31+ wait = false )
32+ if ! success (p)
33+ error (" SuiteSparse threads test failed with nthreads == $other_nthreads " )
34+ else
35+ @test true # mimic the one @test in threads.jl
36+ end
37+ end
3038 end
3139 end
3240end
Original file line number Diff line number Diff line change 22
33using Test, LinearAlgebra, SparseArrays
44
5- @testset " threaded SuiteSparse tests" begin
6- A = sprandn (200 , 200 , 0.2 )
7- b = rand (200 )
5+ A = sprandn (200 , 200 , 0.2 )
6+ b = rand (200 )
87
9- function test (n:: Integer )
10- _A = A[1 : n, 1 : n]
11- _b = b[1 : n]
12- x = qr (_A) \ _b
13- return norm (x)
14- end
15-
16- res_threads = zeros (100 )
17- Threads. @threads for i in 1 : 100
18- res_threads[i] = test (i + 100 )
19- end
8+ function test (n:: Integer )
9+ _A = A[1 : n, 1 : n]
10+ _b = b[1 : n]
11+ x = qr (_A) \ _b
12+ return norm (x)
13+ end
2014
21- @test res_threads ≈ [test (i + 100 ) for i in 1 : 100 ]
15+ res_threads = zeros (100 )
16+ Threads. @threads for i in 1 : 100
17+ res_threads[i] = test (i + 100 )
2218end
19+
20+ @test res_threads ≈ [test (i + 100 ) for i in 1 : 100 ]
You can’t perform that action at this time.
0 commit comments