Skip to content

Commit 5e9f368

Browse files
committed
fix: parallel precompile
1 parent 004634d commit 5e9f368

File tree

6 files changed

+30
-28
lines changed

6 files changed

+30
-28
lines changed

lib/BracketingNonlinearSolve/src/BracketingNonlinearSolve.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ end
3535
algs = (Alefeld(), Bisection(), Brent(), Falsi(), ITP(), Ridder())
3636

3737
@compile_workload begin
38-
for alg in algs
39-
CommonSolve.solve(prob_brack, alg; abstol = 1e-6)
38+
@sync for alg in algs
39+
Threads.@spawn CommonSolve.solve(prob_brack, alg; abstol = 1e-6)
4040
end
4141
end
4242
end

lib/NonlinearSolveFirstOrder/src/NonlinearSolveFirstOrder.jl

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,21 @@ include("pseudo_transient.jl")
3535
include("solve.jl")
3636

3737
@setup_workload begin
38-
include(joinpath(
39-
@__DIR__, "..", "..", "..", "common", "nonlinear_problem_workloads.jl"
40-
))
41-
include(joinpath(
42-
@__DIR__, "..", "..", "..", "common", "nlls_problem_workloads.jl"
43-
))
38+
include("../../../common/nonlinear_problem_workloads.jl")
39+
include("../../../common/nlls_problem_workloads.jl")
4440

4541
nlp_algs = [NewtonRaphson(), TrustRegion(), LevenbergMarquardt()]
4642
nlls_algs = [GaussNewton(), TrustRegion(), LevenbergMarquardt()]
4743

4844
@compile_workload begin
49-
for prob in nonlinear_problems, alg in nlp_algs
50-
CommonSolve.solve(prob, alg; abstol = 1e-2, verbose = false)
51-
end
45+
@sync begin
46+
for prob in nonlinear_problems, alg in nlp_algs
47+
Threads.@spawn CommonSolve.solve(prob, alg; abstol = 1e-2, verbose = false)
48+
end
5249

53-
for prob in nlls_problems, alg in nlls_algs
54-
CommonSolve.solve(prob, alg; abstol = 1e-2, verbose = false)
50+
for prob in nlls_problems, alg in nlls_algs
51+
Threads.@spawn CommonSolve.solve(prob, alg; abstol = 1e-2, verbose = false)
52+
end
5553
end
5654
end
5755
end

lib/NonlinearSolveQuasiNewton/src/NonlinearSolveQuasiNewton.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,13 @@ include("klement.jl")
3333
include("solve.jl")
3434

3535
@setup_workload begin
36-
include(joinpath(
37-
@__DIR__, "..", "..", "..", "common", "nonlinear_problem_workloads.jl"
38-
))
36+
include("../../../common/nonlinear_problem_workloads.jl")
3937

4038
algs = [Broyden(), Klement()]
4139

4240
@compile_workload begin
43-
for prob in nonlinear_problems, alg in algs
44-
CommonSolve.solve(prob, alg; abstol = 1e-2, verbose = false)
41+
@sync for prob in nonlinear_problems, alg in algs
42+
Threads.@spawn CommonSolve.solve(prob, alg; abstol = 1e-2, verbose = false)
4543
end
4644
end
4745
end

lib/NonlinearSolveSpectralMethods/src/NonlinearSolveSpectralMethods.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ include("solve.jl")
2323
algs = [DFSane()]
2424

2525
@compile_workload begin
26-
for prob in nonlinear_problems, alg in algs
27-
CommonSolve.solve(prob, alg; abstol = 1e-2, verbose = false)
26+
@sync for prob in nonlinear_problems, alg in algs
27+
Threads.@spawn CommonSolve.solve(prob, alg; abstol = 1e-2, verbose = false)
2828
end
2929
end
3030
end

lib/SimpleNonlinearSolve/src/SimpleNonlinearSolve.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ function solve_adjoint_internal end
148148
#!format: on
149149

150150
@compile_workload begin
151-
for prob in (prob_scalar, prob_iip, prob_oop), alg in algs
152-
CommonSolve.solve(prob, alg; abstol = 1e-2, verbose = false)
151+
@sync for prob in (prob_scalar, prob_iip, prob_oop), alg in algs
152+
Threads.@spawn CommonSolve.solve(prob, alg; abstol = 1e-2, verbose = false)
153153
end
154154
end
155155
end

src/NonlinearSolve.jl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,18 @@ include("default.jl")
5858
include(joinpath(@__DIR__, "..", "common", "nlls_problem_workloads.jl"))
5959

6060
@compile_workload begin
61-
for prob in nonlinear_problems
62-
CommonSolve.solve(prob, nothing; abstol = 1e-2, verbose = false)
63-
end
64-
65-
for prob in nlls_problems
66-
CommonSolve.solve(prob, nothing; abstol = 1e-2, verbose = false)
61+
@sync begin
62+
for prob in nonlinear_problems
63+
Threads.@spawn CommonSolve.solve(
64+
prob, nothing; abstol = 1e-2, verbose = false
65+
)
66+
end
67+
68+
for prob in nlls_problems
69+
Threads.@spawn CommonSolve.solve(
70+
prob, nothing; abstol = 1e-2, verbose = false
71+
)
72+
end
6773
end
6874
end
6975
end

0 commit comments

Comments
 (0)