Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
m-fila committed Aug 14, 2024
1 parent 74f680b commit 7f7bda7
Show file tree
Hide file tree
Showing 30 changed files with 282 additions and 250 deletions.
4 changes: 2 additions & 2 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ include("suite/cpu_crunching.jl")

if abspath(PROGRAM_FILE) == @__FILE__
@info "tuning benchmark suite"
tune!(SUITE, verbose=true)
tune!(SUITE, verbose = true)
@info "running benchmark suite"
results = run(SUITE, verbose=true)
results = run(SUITE, verbose = true)
@info "running benchmark suite" results
for processor in result_processors
processor(results)
Expand Down
36 changes: 19 additions & 17 deletions benchmark/suite/cpu_crunching.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ import Printf
SUITE["cpu_crunching"] = BenchmarkGroup(["cpu_crunching"])

SUITE["cpu_crunching"]["find_primes"] = BenchmarkGroup(["find_primes"])
for i in exp10.(range(0, stop=6, length=10))
for i in exp10.(range(0, stop = 6, length = 10))
n = ceil(Int, i)
SUITE["cpu_crunching"]["find_primes"][n] = @benchmarkable FrameworkDemo.find_primes($n) evals = 1 samples = 1
SUITE["cpu_crunching"]["find_primes"][n] = @benchmarkable FrameworkDemo.find_primes($n) evals=1 samples=1
end

SUITE["cpu_crunching"]["crunch_for_seconds"] = BenchmarkGroup(["crunch_for_seconds"])
coef = FrameworkDemo.calculate_coefficients()
for i in exp10.(range(-6, stop=1.5, length=10))
SUITE["cpu_crunching"]["crunch_for_seconds"][i] = @benchmarkable FrameworkDemo.crunch_for_seconds($i, $coef) evals = 1 samples = 1
for i in exp10.(range(-6, stop = 1.5, length = 10))
SUITE["cpu_crunching"]["crunch_for_seconds"][i] = @benchmarkable FrameworkDemo.crunch_for_seconds($i,
$coef) evals=1 samples=1
end

function log_ticks(range)
Expand All @@ -21,14 +22,14 @@ function log_ticks(range)
end

function plot_find_primes(results::BenchmarkGroup)
primes_r = sort(collect(results["cpu_crunching"]["find_primes"]), by=first)
primes_r = sort(collect(results["cpu_crunching"]["find_primes"]), by = first)
x = first.(primes_r)
y = primes_r .|> last .|> minimum .|> time |> x -> x * 1e-9
p = plot(x, y, xaxis=:log10, yaxis=:log10, xlabel="n", ylabel="time [s]",
title="find_primes(n)", label="find_primes",
marker=(:circle, 5), linewidth=3,
xticks=log_ticks(x), yticks=log_ticks(y),
xguidefonthalign=:right, yguidefontvalign=:top, legend=:topleft)
p = plot(x, y, xaxis = :log10, yaxis = :log10, xlabel = "n", ylabel = "time [s]",
title = "find_primes(n)", label = "find_primes",
marker = (:circle, 5), linewidth = 3,
xticks = log_ticks(x), yticks = log_ticks(y),
xguidefonthalign = :right, yguidefontvalign = :top, legend = :topleft)
filename = "bench_find_primes.png"
savefig(p, filename)
@info "Results of benchmark cpu_crunching/find_primes written to $filename"
Expand All @@ -37,15 +38,16 @@ end
push!(result_processors, plot_find_primes)

function plot_crunch_for_seconds(results::BenchmarkGroup)
crunch_r = sort(collect(results["cpu_crunching"]["crunch_for_seconds"]), by=first)
crunch_r = sort(collect(results["cpu_crunching"]["crunch_for_seconds"]), by = first)
x = first.(crunch_r)
y = crunch_r .|> last .|> minimum .|> time |> x -> x * 1e-9
p = plot(x, (y - x) ./ x, xaxis=:log10, xlabel="t [s]", ylabel="Time relative error",
yformatter=x -> Printf.@sprintf("%.1f%%", 100 * x),
xticks=log_ticks(x),
title="crunch_for_seconds(t)", label="crunch_for_seconds",
marker=(:circle, 5), linewidth=3,
xguidefonthalign=:right, yguidefontvalign=:top, legend=:bottomright)
p = plot(x, (y - x) ./ x, xaxis = :log10, xlabel = "t [s]",
ylabel = "Time relative error",
yformatter = x -> Printf.@sprintf("%.1f%%", 100*x),
xticks = log_ticks(x),
title = "crunch_for_seconds(t)", label = "crunch_for_seconds",
marker = (:circle, 5), linewidth = 3,
xguidefonthalign = :right, yguidefontvalign = :top, legend = :bottomright)
filename = "bench_crunch_for_seconds.png"
savefig(p, filename)
@info "Results of benchmark cpu_crunching/crunch_for_seconds written to $filename"
Expand Down
15 changes: 6 additions & 9 deletions bin/schedule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ function parse_args()
"--fast"
help = "Execute algorithms immediately skipping algorithm runtime information and crunching"
action = :store_true

end

return ArgParse.parse_args(s)
Expand All @@ -46,15 +45,14 @@ function main()
end

graph = FrameworkDemo.parse_graphml(args["data-flow"])
event_count=args["event-count"]
max_concurrent=args["max-concurrent"]
fast=args["fast"]
event_count = args["event-count"]
max_concurrent = args["max-concurrent"]
fast = args["fast"]

@time "Pipeline execution" FrameworkDemo.run_events(graph;
event_count=event_count,
max_concurrent=max_concurrent,
fast=fast
)
event_count = event_count,
max_concurrent = max_concurrent,
fast = fast)

if !isnothing(args["dot-trace"])
logs = Dagger.fetch_logs!()
Expand All @@ -65,7 +63,6 @@ function main()
end
end


if abspath(PROGRAM_FILE) == @__FILE__
main()
rmprocs!(Dagger.Sch.eager_context(), workers())
Expand Down
1 change: 0 additions & 1 deletion examples/dummy_tasks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,3 @@ function modernAPI_graph_setup(time_to_sleep)

return f
end

11 changes: 5 additions & 6 deletions examples/logging/getting_logs/enable_logging.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
include("../../dummy_tasks.jl") # here Dagger is imported as well

Dagger.enable_logging!(tasknames=true, # Here we can choose the consumers to use. Check source code for more.
taskdeps=true,
taskargs=true,
taskargmoves=true,
)
Dagger.enable_logging!(tasknames = true, # Here we can choose the consumers to use. Check source code for more.
taskdeps = true,
taskargs = true,
taskargmoves = true)

t = modernAPI_graph_setup(1) # Can also be the old API
fetch(t)

logs = Dagger.fetch_logs!()
println("\n\nRaw logs:")
println(logs) # <- That should be a Dictionary of the form: {worker_id -> {consumer_symbol -> [list of the events on that worker after being processed by a consumer corresponding to this symbol]}}
println(logs) # <- That should be a Dictionary of the form: {worker_id -> {consumer_symbol -> [list of the events on that worker after being processed by a consumer corresponding to this symbol]}}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ end

function configure_MultiEventLog()
Dagger.enable_logging!(timeline = true, # Some example configuration
tasknames=true,
taskdeps=true,
taskargs=true,
taskargmoves=true,
)
tasknames = true,
taskdeps = true,
taskargs = true,
taskargmoves = true)
Dagger.Sch.eager_context().log_sink[:full] = Dagger.TimespanLogging.Events.FullMetrics()
end

Expand All @@ -49,4 +48,6 @@ open(log_file_name, "w") do io
# FrameworkDemo.Dagger.show_logs(graph_thunk, logs, :graphviz_simple) # Returns the string representation of the graph
end

FrameworkDemo.dot_to_png(log_file_name, FrameworkDemo.timestamp_string(FILENAME_TEMPLATE) * ".png", 2000, 2000)
FrameworkDemo.dot_to_png(log_file_name,
FrameworkDemo.timestamp_string(FILENAME_TEMPLATE) * ".png", 2000,
2000)
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ end

function configure_MultiEventLog()
Dagger.enable_logging!(timeline = true, # Some example configuration
tasknames=true,
taskdeps=true,
taskargs=true,
taskargmoves=true,
)
tasknames = true,
taskdeps = true,
taskargs = true,
taskargmoves = true)
Dagger.Sch.eager_context().log_sink[:full] = Dagger.TimespanLogging.Events.FullMetrics()
end

Expand All @@ -51,4 +50,6 @@ open(log_file_name, "w") do io
# FrameworkDemo.Dagger.show_logs(graph_thunk, logs, :graphviz_simple) # Returns the string representation of the graph
end

FrameworkDemo.dot_to_png(log_file_name, FrameworkDemo.timestamp_string(FILENAME_TEMPLATE) * ".png", 2000, 2000)
FrameworkDemo.dot_to_png(log_file_name,
FrameworkDemo.timestamp_string(FILENAME_TEMPLATE) * ".png", 2000,
2000)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ println(collect(ctx, graph_thunk)) # Wait for the graph execution and fetch the
log_file_name = FrameworkDemo.timestamp_string(FILENAME_TEMPLATE) * ".dot"
open(log_file_name, "w") do io
#FrameworkDemo.ModGraphVizSimple.show_logs(io, graph_thunk, Dagger.fetch_logs!(), :graphviz_simple)
FrameworkDemo.ModGraphVizSimple.show_logs(graph_thunk, Dagger.fetch_logs!(), :graphviz_simple)
FrameworkDemo.ModGraphVizSimple.show_logs(graph_thunk, Dagger.fetch_logs!(),
:graphviz_simple)
end

FrameworkDemo.dot_to_png(log_file_name, FrameworkDemo.timestamp_string(FILENAME_TEMPLATE) * ".png", 700, 700)
FrameworkDemo.dot_to_png(log_file_name,
FrameworkDemo.timestamp_string(FILENAME_TEMPLATE) * ".png", 700,
700)
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ open(log_file_name, "w") do io
# or FrameworkDemo.ModGraphVizSimple.show_logs(io, graph_thunk, :graphviz_simple) # Dagger.show_logs(io, graph_thunk, :graphviz_simple) after the bug fix in the package
end

FrameworkDemo.dot_to_png(log_file_name, FrameworkDemo.timestamp_string(FILENAME_TEMPLATE) * ".png", 2000, 2000)
FrameworkDemo.dot_to_png(log_file_name,
FrameworkDemo.timestamp_string(FILENAME_TEMPLATE) * ".png", 2000,
2000)
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ spans = Dagger.TimespanLogging.build_timespans(vcat(values(events_logs)...)).com
timespan_logs = convert(Vector{Dagger.TimespanLogging.Timespan}, spans)
log_file_name = FrameworkDemo.timestamp_string(FILENAME_TEMPLATE) * ".dot"
open(log_file_name, "w") do io
FrameworkDemo.ModGraphVizSimple.show_logs(io, graph_thunk, timespan_logs, :graphviz_simple) # Dagger.show_logs(io, graph_thunk, timespan_logs, :graphviz_simple) after the bug fix in the package
FrameworkDemo.ModGraphVizSimple.show_logs(io, graph_thunk, timespan_logs,
:graphviz_simple) # Dagger.show_logs(io, graph_thunk, timespan_logs, :graphviz_simple) after the bug fix in the package
# or FrameworkDemo.ModGraphVizSimpleExt.show_logs(io, timespan_logs, :graphviz_simple) # Dagger.show_logs(io, timespan_logs, :graphviz_simple) after the bug fix in the package
# or FrameworkDemo.ModGraphVizSimpleExt.show_logs(io, graph_thunk, :graphviz_simple) # Dagger.show_logs(io, graph_thunk, :graphviz_simple) after the bug fix in the package
end

FrameworkDemo.dot_to_png(log_file_name, FrameworkDemo.timestamp_string(FILENAME_TEMPLATE) * ".png", 2000, 2000)
FrameworkDemo.dot_to_png(log_file_name,
FrameworkDemo.timestamp_string(FILENAME_TEMPLATE) * ".png", 2000,
2000)
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ open(log_file_name, "w") do io
# or ModGraphVizSimpleExt.show_logs(io, graph_thunk, :graphviz_simple) # Dagger.show_logs(io, graph_thunk, :graphviz_simple) after the bug fix in the package
end

FrameworkDemo.dot_to_png(log_file_name, FrameworkDemo.timestamp_string(FILENAME_TEMPLATE) * ".png", 2000, 2000)
FrameworkDemo.dot_to_png(log_file_name,
FrameworkDemo.timestamp_string(FILENAME_TEMPLATE) * ".png", 2000,
2000)
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ spans = Dagger.TimespanLogging.build_timespans(vcat(values(events_logs)...)).com
timespan_logs = convert(Vector{Dagger.TimespanLogging.Timespan}, spans)
log_file_name = FrameworkDemo.timestamp_string(FILENAME_TEMPLATE) * ".dot"
open(log_file_name, "w") do io
FrameworkDemo.ModGraphVizSimple.show_logs(io, graph_thunk, timespan_logs, :graphviz_simple) # Dagger.show_logs(io, graph_thunk, timespan_logs, :graphviz_simple) after the bug fix in the package
FrameworkDemo.ModGraphVizSimple.show_logs(io, graph_thunk, timespan_logs,
:graphviz_simple) # Dagger.show_logs(io, graph_thunk, timespan_logs, :graphviz_simple) after the bug fix in the package
# or ModGraphVizSimpleExt.show_logs(io, timespan_logs, :graphviz_simple) # Dagger.show_logs(io, timespan_logs, :graphviz_simple) after the bug fix in the package
# or ModGraphVizSimpleExt.show_logs(io, graph_thunk, :graphviz_simple) # Dagger.show_logs(io, graph_thunk, :graphviz_simple) after the bug fix in the package
end

FrameworkDemo.dot_to_png(log_file_name, FrameworkDemo.timestamp_string(FILENAME_TEMPLATE) * ".png", 2000, 2000)
FrameworkDemo.dot_to_png(log_file_name,
FrameworkDemo.timestamp_string(FILENAME_TEMPLATE) * ".png", 2000,
2000)
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ MAX_GRAPHS_RUN = 3
function execution(graphs_map)
graphs_being_run = Set{Int}()
graphs_dict = Dict{Int, String}()
graphs_tasks = Dict{Int,Dagger.DTask}()
graphs = FrameworkDemo.parse_graphs(graphs_map, OUTPUT_GRAPH_PATH, OUTPUT_GRAPH_IMAGE_PATH)
notifications = RemoteChannel(()->Channel{Int}(32))
graphs_tasks = Dict{Int, Dagger.DTask}()
graphs = FrameworkDemo.parse_graphs(graphs_map, OUTPUT_GRAPH_PATH,
OUTPUT_GRAPH_IMAGE_PATH)
notifications = RemoteChannel(() -> Channel{Int}(32))
# notifications = Channel{Int}(32)
for (i, (g_name, g)) in enumerate(graphs)
graphs_dict[i] = g_name
Expand All @@ -38,7 +39,8 @@ function execution(graphs_map)
delete!(graphs_tasks, i)
println("Dispatcher: graph finished - $finished_graph_id: $(graphs_dict[finished_graph_id])")
end
graphs_tasks[i] = FrameworkDemo.schedule_graph_with_notify(g, notifications, g_name, i)
graphs_tasks[i] = FrameworkDemo.schedule_graph_with_notify(g, notifications, g_name,
i)
push!(graphs_being_run, i)
println("Dispatcher: scheduled graph $i: $g_name")
end
Expand All @@ -64,29 +66,28 @@ function execution(graphs_map)
end

function main(graphs_map)
Dagger.enable_logging!(tasknames=true,
taskdeps=true,
taskargs=true,
taskargmoves=true,
)
Dagger.enable_logging!(tasknames = true,
taskdeps = true,
taskargs = true,
taskargmoves = true)

@time execution(graphs_map)

graph = Dagger.render_logs(Dagger.fetch_logs!(), :graphviz, disconnected=true, color_by=:proc)
graph = Dagger.render_logs(Dagger.fetch_logs!(), :graphviz, disconnected = true,
color_by = :proc)
surface = Cairo.CairoSVGSurface(IOBuffer(), 7000, 2000)
context = Cairo.CairoContext(surface)
GraphViz.render(context, graph)
img_name = FrameworkDemo.timestamp_string("$output_dir/render_graphviz_complex") * ".png"
img_name = FrameworkDemo.timestamp_string("$output_dir/render_graphviz_complex") *
".png"
write_to_png(surface, img_name)
end

graphs_map = Dict{String, String}(
"graph1" => graph1_path,
"graph2" => graph2_path,
"graph3" => graph1_path,
"graph4" => graph2_path
)
graphs_map = Dict{String, String}("graph1" => graph1_path,
"graph2" => graph2_path,
"graph3" => graph1_path,
"graph4" => graph2_path)

main(graphs_map)
rmprocs!(Dagger.Sch.eager_context(), workers())
rmprocs(workers())
rmprocs(workers())
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ include("../../../dummy_tasks.jl")
output_dir = "examples/results"
mkpath(output_dir)

Dagger.enable_logging!(tasknames=true,
taskdeps=true,
taskargs=true,
taskargmoves=true,
)
Dagger.enable_logging!(tasknames = true,
taskdeps = true,
taskargs = true,
taskargmoves = true)

a = modernAPI_graph_setup(0.1)

ctx = Dagger.Sch.eager_context()
println(fetch(a))

graph = Dagger.render_logs(Dagger.fetch_logs!(), :graphviz, disconnected=true, color_by=:proc)
graph = Dagger.render_logs(Dagger.fetch_logs!(), :graphviz, disconnected = true,
color_by = :proc)

surface = Cairo.CairoSVGSurface(IOBuffer(), 7000, 2000)
context = Cairo.CairoContext(surface)
Expand Down
Loading

0 comments on commit 7f7bda7

Please sign in to comment.