Skip to content

Commit 35d6a13

Browse files
committed
Update visualize script for new output format
1 parent 3a41d32 commit 35d6a13

File tree

1 file changed

+71
-33
lines changed

1 file changed

+71
-33
lines changed

benchmarks/visualize.jl

Lines changed: 71 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,59 @@
1-
using JLD
1+
using JLD, Serialization
22
using BenchmarkTools
33
using TypedTables
44

5-
res = JLD.load(ARGS[1])
5+
res = if endswith(ARGS[1], ".jld")
6+
JLD.load(ARGS[1])
7+
elseif endswith(ARGS[1], ".jls")
8+
deserialize(ARGS[1])
9+
else
10+
error("Unknown file type")
11+
end
612

7-
serial_results = res["results"]["Serial"]
8-
dagger_results = res["results"]["Dagger"]
13+
serial_results = filter(x->!occursin("dagger", x[1]), res["results"])
14+
@assert length(keys(serial_results)) > 0 "No serial results found"
15+
dagger_results = filter(x->occursin("dagger", x[1]), res["results"])
16+
@assert length(keys(dagger_results)) > 0 "No Dagger results found"
17+
18+
scale_set = sort([key=>parse(Int, lstrip(last(split(key, ':')), ' ')) for key in keys(first(serial_results)[2])]; by=x->x[2])
19+
nw_set = sort([key=>parse(Int, lstrip(last(split(key, ':')), ' ')) for key in keys(first(dagger_results)[2][first(first(scale_set))])]; by=x->x[2])
20+
raw_table = NamedTuple[]
21+
for bset_key in keys(res["results"])
22+
bset = res["results"][bset_key]
23+
if typeof(bset[first(first(scale_set))]) <: BenchmarkGroup
24+
procs = parse(Int, lstrip(last(split(first(first(bset[first(first(scale_set))])), ':')), ' '))
25+
for nw in nw_set
26+
for i in 1:length(scale_set)
27+
set_times = [minimum(bset[scale][nw[1]]).time/(10^9) for scale in first.(scale_set)]
28+
push!(raw_table, (name=bset_key, time=set_times[i], scale=last.(scale_set)[i], procs=nw[2]))
29+
end
30+
end
31+
else
32+
set_times = [minimum(bset[scale]).time/(10^9) for scale in first.(scale_set)]
33+
procs = 8 # default for OpenBLAS
34+
for i in 1:length(set_times)
35+
push!(raw_table, (name=bset_key, time=set_times[i], scale=last.(scale_set)[i], procs=procs))
36+
end
37+
end
38+
end
39+
table = Table(raw_table)
940

10-
scale_set = sort([key=>parse(Int, lstrip(last(split(key, ':')), ' ')) for key in keys(serial_results)]; by=x->x[2])
11-
serial_times = [minimum(serial_results[scale]).time/(10^9) for scale in first.(scale_set)]
12-
nw_set = sort([key=>parse(Int, lstrip(last(split(key, ':')), ' ')) for key in keys(dagger_results[first(first(scale_set))])]; by=x->x[2])
41+
btable = copy(table[map(x->!x, occursin.(Ref("dagger"), table.name))])
42+
dtable = copy(table[occursin.(Ref("dagger"), table.name)])
1343

14-
table = Table(name=[:Base for _ in 1:3], time=serial_times, scale=last.(scale_set), procs=[8 for _ in 1:3])
44+
#table = Table(name=[:Base for _ in 1:3], time=serial_times, scale=last.(scale_set), procs=[8 for _ in 1:3])
1545

16-
btable = copy(table)
46+
#btable = copy(table)
1747

48+
#=
1849
for (nw,nw_val) in nw_set
1950
dagger_times = [minimum(dagger_results[scale][nw]).time/(10^9) for scale in first.(scale_set)]
2051
t = Table(name=[:Dagger for _ in 1:3], time=dagger_times, scale=last.(scale_set), procs=[parse(Int,split(nw, ":")[2]) for _ in 1:3])
2152
append!(table, t)
2253
end
54+
=#
2355

24-
dtable = table[table.name .== :Dagger]
56+
#dtable = table[table.name .== :Dagger]
2557

2658
# Plotting
2759

@@ -45,11 +77,11 @@ legend_names = String[]
4577

4678
scales = unique(dtable.scale)
4779

48-
colors = distinguishable_colors(lenght(scales), ColorSchemes.seaborn_deep.colors)
80+
colors = distinguishable_colors(length(scales), ColorSchemes.seaborn_deep.colors)
4981

5082
for (i, scale) in enumerate(scales)
5183
stable = dtable[dtable.scale .== scale]
52-
t1 = first(stable[stable.procs .== 1].time)
84+
t1 = first(stable[stable.procs .== minimum(dtable.procs)].time)
5385
ss_efficiency = strong_scaling.(t1, stable.time, stable.procs)
5486
push!(line_plots, lines!(ssp, stable.procs, ss_efficiency, linewidth=3.0, color = colors[i]))
5587
push!(legend_names, "scale = $scale")
@@ -65,25 +97,32 @@ save("strong_scaling.png", fig)
6597
# too little data
6698

6799
fig = Figure(resolution = (1200, 800))
68-
weak_scaling(t1, tn) = t1/tn
100+
weak_scaling(t1, tn, p_prime, p) = t1/((p_prime/p)*tn)
69101

70-
dtable = table[table.name .== :Dagger]
71-
wstable = filter(row->row.scale == row.procs, dtable)
72-
wstable = sort(wstable, by=r->r.scale)
73-
t1 = first(wstable).time
102+
t1 = first(dtable[map(row->(row.scale == 10) && (row.procs == 1), dtable)]).time
74103

75104
fig = Figure(resolution = (1200, 800))
76-
perf = fig[1, 1] = Axis(fig, title = "Weak scaling")
77-
perf.xlabel = "nprocs"
78-
perf.ylabel = "Efficiency"
105+
perf = fig[1, 1] = Axis(fig, title = "Weak Scaling")
106+
perf.xlabel = "Number of processes"
107+
perf.ylabel = "Scaling efficiency"
108+
109+
line_plots = Any[]
110+
legend_names = String[]
79111

80-
lines!(perf, wstable.procs, weak_scaling.(t1, wstable.time), linewidth=3.0)
112+
wstable = similar(dtable, 0)
113+
for pair in [(10,1),(35,4),(85,8)]
114+
append!(wstable, dtable[map(row->(row.scale == pair[1]) && (row.procs == pair[2]), rows(dtable))])
115+
end
116+
push!(line_plots, lines!(perf, wstable.procs, weak_scaling.(t1, wstable.time, wstable.procs .* 10, wstable.scale), linewidth=3.0))
117+
push!(legend_names, "cpu+dagger")
118+
119+
legend = fig[1, 2] = Legend(fig, line_plots, legend_names)
81120
save("weak_scaling.png", fig)
82121

83122
# 3. Comparision against Base
84123

85124
fig = Figure(resolution = (1200, 800))
86-
perf = fig[1, 1] = Axis(fig, title = "DaggerArrays vs Base")
125+
perf = fig[1, 1] = Axis(fig, title = "Dagger vs Base")
87126
perf.xlabel = "Scaling factor"
88127
perf.ylabel = "time (s)"
89128

@@ -92,7 +131,7 @@ legend_names = String[]
92131

93132
procs = unique(dtable.procs)
94133

95-
colors = distinguishable_colors(lenght(procs) + 1, ColorSchemes.seaborn_deep.colors)
134+
colors = distinguishable_colors(length(procs) + 1, ColorSchemes.seaborn_deep.colors)
96135

97136
for (i, nproc) in enumerate(procs)
98137
stable = dtable[dtable.procs .== nproc]
@@ -109,23 +148,22 @@ save("raw_timings.png", fig)
109148

110149
# 4. Speedup
111150
fig = Figure(resolution = (1200, 800))
112-
speedup = fig[1, 1] = Axis(fig, title = "DaggerArrays vs Base (8 threads)")
113-
speedup.xlabel = "Scaling factor"
114-
speedup.ylabel = "Speedup Base/Dagger"
151+
speedup = fig[1, 1] = Axis(fig, title = "Speedup vs. 1 processor")
152+
speedup.xlabel = "Number of processors"
153+
speedup.ylabel = "Speedup"
115154

116155
line_plots = Any[]
117156
legend_names = String[]
118157

119158
colors = distinguishable_colors(length(procs), ColorSchemes.seaborn_deep.colors)
120159

121-
sort!(btable, by=r->r.scale)
160+
t1 = sort(dtable[dtable.scale .== 10]; by=r->r.procs)
122161

123-
for (i, nproc) in enumerate(unique(dtable.procs))
124-
nproc < 8 && continue
125-
stable = dtable[dtable.procs .== nproc]
126-
sort!(stable, by=r->r.scale)
127-
push!(line_plots, lines!(speedup, stable.scale, btable.time ./ stable.time, linewidth=3.0, color = colors[i]))
128-
push!(legend_names, "Dagger (nprocs = $nproc)")
162+
for (i, scale) in enumerate(unique(dtable.scale))
163+
stable = dtable[dtable.scale .== scale]
164+
sort!(stable, by=r->r.procs)
165+
push!(line_plots, lines!(speedup, stable.procs, stable.time ./ t1.time, linewidth=3.0, color = colors[i]))
166+
push!(legend_names, "Dagger (scale = $scale)")
129167
end
130168

131169
legend = fig[1, 2] = Legend(fig, line_plots, legend_names)

0 commit comments

Comments
 (0)