introduced SharedArrays; can we enumerate?

main
Francesco Minnocci 1 year ago
parent f114eeec77
commit 1be9251941
Signed by untrusted user: BachoSeven
GPG Key ID: 2BE4AB7FDAD828A4

@ -2,7 +2,7 @@
using TypedPolynomials using TypedPolynomials
using LinearAlgebra using LinearAlgebra
using Distributed using Distributed
using ClusterManagers using SharedArrays
# Local dependencies # Local dependencies
include("random_poly.jl") include("random_poly.jl")
@ -18,10 +18,7 @@ using .EulerNewton
using .AdaptStep using .AdaptStep
using .Plot using .Plot
# Launch worker processes function compute_root(H, r, maxsteps=1000)
addprocs(SlurmManager(40), N=20, t="01:00:00"))
function compute_root(H, r, maxsteps)
t = 1.0 t = 1.0
step_size = 0.01 step_size = 0.01
x0 = r x0 = r
@ -38,16 +35,17 @@ function compute_root(H, r, maxsteps)
end end
# Main homotopy continuation loop # Main homotopy continuation loop
function solve(F, (G, roots) = start_system(F)) function solve(F, (G, roots)=start_system(F))
H=homotopy(F,G) H = homotopy(F, G)
@distributed for r in roots sols = SharedArray{Complex{Float64}}(length(roots))
(solutions, step_array) = compute_root(H, r, maxsteps = 1000) steps = SharedArray{Int64}(length(roots))
@sync @distributed for (i, r) in enumerate(roots)
(solutions, step_array) = compute_root(H, r)
sols[i] = solutions
steps[i] = step_array
end end
# Gather results from worker processes
sols = fetch(solutions)
steps = fetch(step_array)
return (sols, steps) return (sols, steps)
end end
@ -81,10 +79,10 @@ sR = filter(u -> imag(u[1]) < 0.1 && imag(u[2]) < 0.1, sR)
vars = variables(R) vars = variables(R)
println("solutions: ", sR) println("solutions: ", sR)
println([LinearAlgebra.norm([f(vars=>s) for f in R]) for s in sR]) println([LinearAlgebra.norm([f(vars => s) for f in R]) for s in sR])
# Plotting the system and the real solutions # Plotting the system and the real solutions
ENV["GKSwstype"]="nul" ENV["GKSwstype"] = "nul"
# plot_real(sC, C, 6, 12, "1") # plot_real(sC, C, 6, 12, "1")
# plot_real(sQ, Q, 2, 2, "2") # plot_real(sQ, Q, 2, 2, "2")
# plot_real(sF, F, 4, 4, "3") # plot_real(sF, F, 4, 4, "3")

Loading…
Cancel
Save