From 74143c2d4e9ad8c9f2d35d5e0772437da24e408a Mon Sep 17 00:00:00 2001 From: Stephan Hilb <stephan@ecshi.net> Date: Sun, 7 Jan 2024 22:14:23 +0100 Subject: [PATCH] update scaling example --- scripts/run_experiments.jl | 21 ++++++++++++--------- scripts/run_parallel_scaling.jl | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 scripts/run_parallel_scaling.jl diff --git a/scripts/run_experiments.jl b/scripts/run_experiments.jl index 148cf55..1c4fb44 100644 --- a/scripts/run_experiments.jl +++ b/scripts/run_experiments.jl @@ -1,13 +1,10 @@ # experiments +using Distributed using Random: MersenneTwister using LinearAlgebra: Diagonal, I, dot, norm, mul!, diagm using Statistics: median -using CSV -using Colors: HSV -using DataFrames -using Distributed @everywhere using DualTVDD @everywhere using DualTVDD: DualTVL1ROFOpProblem, @@ -15,6 +12,10 @@ using Distributed SurrogateAlgorithm, DualTVDDSurrogateAlgorithm, init, step!, fetch, fetch_u, gradient, divergence, normB, energy, residual + +using CSV +using Colors: HSV +using DataFrames using DualTVDD: fetch_u using FFTW using FileIO @@ -270,10 +271,11 @@ function experiment_scaling_opticalflow(ctx) λ = 0.01 β = 0.001 - ninner = 300 - Mdir = 2 * floor(Int, sqrt(nworkers())) # to have enough workers available - M = (Mdir, Mdir) - overlap = (5, 5) + ninner = 500 + #Mdir = 2 * floor(Int, sqrt(nworkers())) # to have enough workers available + Mdir = nworkers() + M = (4, Mdir) + overlap = (10, 10) stopenergy = 130. ntimings = 3 @@ -298,6 +300,7 @@ function experiment_scaling_opticalflow(ctx) tg = timeit(galg) + # divide by 2^2 due to coloring nparallel = prod(M) ÷ 2^2 ws = workers() @assert nparallel <= length(ws) @@ -315,7 +318,7 @@ function experiment_scaling_opticalflow(ctx) CSV.write(joinpath(ctx.outdir, "timings.csv"), df) savedata(joinpath(ctx.outdir, "data.tex"); - lambda=λ, beta=β, Mdir, M=prod(M), + lambda=λ, beta=β, M1=M[1], M2=M[2], M=prod(M), ntimings, stopenergy, ninner, width=size(fo, 2), height=size(fo, 1)) end diff --git a/scripts/run_parallel_scaling.jl b/scripts/run_parallel_scaling.jl new file mode 100644 index 0000000..6266179 --- /dev/null +++ b/scripts/run_parallel_scaling.jl @@ -0,0 +1,20 @@ +# do not use a startup file: `julia --startup-file=no` +# otherwise precompilation will be done over and over again + +using Pkg +Pkg.activate(@__DIR__) +Pkg.instantiate() + +using Distributed +addprocs(8) + +@everywhere using Pkg +@everywhere Pkg.activate(@__DIR__) +@everywhere Pkg.instantiate() + +@everywhere using Revise +includet(joinpath(@__DIR__, "run_experiments.jl")) + +const datapath = joinpath(@__DIR__, "..", "..", "data") +ctx = Util.Context(datapath) +ctx(experiment_scaling_opticalflow, "fd/scaling/opticalflow") -- GitLab