|
23 | 23 |
|
24 | 24 | # Parse the thread list used by the driver to spawn child Julia processes. |
25 | 25 | function parse_thread_list() |
26 | | - raw = get(ENV, "QSIM_THREAD_LIST", "1,2,4,8") |
| 26 | + raw = get(ENV, "QSIM_THREAD_LIST", nothing) |
27 | 27 | values = Int[] |
28 | | - for token in split(raw, ',') |
29 | | - stripped = strip(token) |
30 | | - isempty(stripped) && continue |
31 | | - push!(values, parse(Int, stripped)) |
| 28 | + if raw === nothing |
| 29 | + push!(values, 1) |
| 30 | + max_threads = Threads.nthreads() |
| 31 | + max_threads != 1 && push!(values, max_threads) |
| 32 | + else |
| 33 | + for token in split(raw, ',') |
| 34 | + stripped = strip(token) |
| 35 | + isempty(stripped) && continue |
| 36 | + push!(values, parse(Int, stripped)) |
| 37 | + end |
32 | 38 | end |
33 | 39 | isempty(values) && push!(values, Threads.nthreads()) |
34 | 40 | values = unique(values) |
@@ -61,15 +67,17 @@ function measure_median_seconds(f::Function; repeats::Int, evals::Int) |
61 | 67 | samples = Vector{Float64}(undef, repeats) |
62 | 68 | g = f # capture in stable binding for BenchmarkTools interpolation |
63 | 69 | for idx in 1:repeats |
| 70 | + idx != 1 && print("\r sampling trial $(idx)/$(repeats)...") |
64 | 71 | samples[idx] = @belapsed ($g(); nothing) evals=evals |
65 | 72 | end |
| 73 | + repeats > 1 && println("\r sampling trials complete ") |
66 | 74 | return Statistics.median(samples) |
67 | 75 | end |
68 | 76 |
|
69 | 77 | function worker_main() |
70 | 78 | state_qubits = parse_int_env("QSIM_STATE_QUBITS", "7"; minvalue=2) |
71 | | - density_qubits = parse_int_env("QSIM_DENSITY_QUBITS", "6"; minvalue=2) |
72 | | - repeats = parse_int_env("QSIM_BENCH_REPEATS", "5"; minvalue=1) |
| 79 | + density_qubits = parse_int_env("QSIM_DENSITY_QUBITS", "5"; minvalue=2) |
| 80 | + repeats = parse_int_env("QSIM_BENCH_REPEATS", "3"; minvalue=1) |
73 | 81 | evals = parse_int_env("QSIM_BENCH_EVALS", "1"; minvalue=1) |
74 | 82 | seed = parse_int_env("QSIM_BENCH_SEED", "1234"; minvalue=0) |
75 | 83 |
|
@@ -155,12 +163,16 @@ function driver_main() |
155 | 163 | project_path = Base.active_project() |
156 | 164 | cmd_base = project_path === nothing ? `$(Base.julia_cmd()) $(abspath(@__FILE__))` : `$(Base.julia_cmd()) --project=$(project_path) $(abspath(@__FILE__))` |
157 | 165 |
|
158 | | - for threads in thread_list |
| 166 | + total = length(thread_list) |
| 167 | + for (idx, threads) in enumerate(thread_list) |
| 168 | + println("[$idx/$total] benchmarking with JULIA_NUM_THREADS=$(threads)...") |
| 169 | + flush(stdout) |
159 | 170 | env = copy(ENV) |
160 | 171 | env["JULIA_NUM_THREADS"] = string(threads) |
161 | 172 | env["QSIM_BENCH_WORKER"] = "1" |
162 | 173 | output = read(setenv(cmd_base, env), String) |
163 | 174 | push!(results, parse_result(output)) |
| 175 | + println("[$idx/$total] finished threads=$(threads)") |
164 | 176 | end |
165 | 177 |
|
166 | 178 | isempty(results) && return |
|
0 commit comments