Skip to content

Commit

Permalink
Cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeR227 committed Aug 21, 2024
1 parent 54f1cdb commit 50b0700
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 27 deletions.
2 changes: 1 addition & 1 deletion benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ using DrWatson
@quickactivate :benchmarks
```

which auto-activate the project, enable local path handling from DrWatson and provide several helper functions. Note that `@quickactivate` is only usable from within the `benchmarks` directory.
which auto-activate the project, enable local path handling from DrWatson and provide several helper functions. Note that `@quickactivate :benchmarks` is only usable from within the `benchmarks` directory.

## Establishing Simulation Configurations

Expand Down
4 changes: 2 additions & 2 deletions benchmarks/scripts/post_processing/default_out.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ sims_to_process = collect_mainconfig_simentries(physics)

# TODO: Have meta config information be in a seperate toml
config_data = load_simconfig(first(sims_to_process))
meta_config = get_meta_config_info(config_data)
meta_config = meta_config_info(config_data)
const meta_field_names = split(meta_config["fields"], ",")

# TODO: Meant as a basic data processing pipeline
# Can create multiple scripts to roughly process data in general ways
pretty_results = collect_results(aggdatadir(physics, slurm_id))

median_times = map(stage -> get_benchmark_headername(stage, "Median", "time"), solver_stages())
median_times = map(stage -> benchmark_headername(stage, "Median", "time"), solver_stages())
table_header = vcat(["Task ID", "statsfile", "benchfile"], meta_field_names, median_times, ["nf"])

select!(pretty_results, table_header)
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/src/helpers/data_aggr_helper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ function add_trial_data!(data_row, statistic_name::String, trial_data)
stage_data = trial_data[stage]
for field in fieldnames(typeof(stage_data))
field != :params || continue
push!(data_row, get_benchmark_headername(stage, statistic_name, String(field)) => getfield(stage_data, field))
push!(data_row, benchmark_headername(stage, statistic_name, String(field)) => getfield(stage_data, field))
end
end
end

function get_benchmark_headername(stage::String, statistic_name::String, category::String)
function benchmark_headername(stage::String, statistic_name::String, category::String)
return "$(stage) $(statistic_name) $(category)"
end

Expand Down
8 changes: 4 additions & 4 deletions benchmarks/src/helpers/main_config_helper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using DrWatson
using TOML

export mainsim_config_path, load_main_config, listof_main_physics,
collect_simsfor_physics, has_config_args, get_config_args, get_config_arg
collect_simsfor_physics, has_config_args, config_args, config_arg

mainsim_config_path() = srcdir("main_config.toml")

Expand Down Expand Up @@ -66,19 +66,19 @@ function has_config_args(config_info, snd::SimNameData)
return !isempty(tag_info)
end

function get_config_args(config_info, snd::SimNameData)
function config_args(config_info, snd::SimNameData)
if !(has_config_args(config_info, snd))
error("Arguments for $(snd) were not found in the main configuration or provided architecture $(snd.arch) is invalid")
end
return config_info[snd.physics][snd.arch][snd.tag]
end

function get_config_arg(config_info, snd::SimNameData, arg)
function config_arg(config_info, snd::SimNameData, arg)
if !has_config_args(config_info, snd)
return nothing
end

args = get_config_args(config_info, snd)
args = config_args(config_info, snd)
if !haskey(args, arg)
return nothing
end
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/src/helpers/main_source.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ end

function get_slurm_args(main_config_info, snd::SimNameData)

slurm_args = get_config_arg(main_config_info, snd, "slurm_args")
slurm_args = config_arg(main_config_info, snd, "slurm_args")

if isnothing(slurm_args)
return @match snd.arch begin
Expand All @@ -105,6 +105,6 @@ function get_slurm_args(main_config_info, snd::SimNameData)
end

function get_concur_jobs(main_config_info, snd::SimNameData)
job_arg = get_config_arg(main_config_info, snd, "concur_jobs")
job_arg = config_arg(main_config_info, snd, "concur_jobs")
return isnothing(job_arg) ? DEFAULT_MAXJOBS : job_arg
end
4 changes: 2 additions & 2 deletions benchmarks/src/helpers/paths.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export load_simconfig, simconfig_name, simconfig_path,
load_physicsconfig, physicsconfig_name, physicsconfig_path,
load_statsfile, statsfile_name, statsfile_path,
load_benchfile, benchfile_name, benchfile_path
export simconfig_size, get_meta_config_info
export simconfig_size, meta_config_info

export SimNameData
import Base.show
Expand Down Expand Up @@ -74,4 +74,4 @@ benchfile_path(simdata::SimNameData) = resultsdir(simdata.physics, benchfile_nam

simconfig_size(config_data) = return length(keys(config_data)) - 1 # Don't include meta info

get_meta_config_info(benchmark_config) = return benchmark_config[meta_config_id()]
meta_config_info(benchmark_config) = return benchmark_config[meta_config_id()]
2 changes: 1 addition & 1 deletion benchmarks/src/helpers/physics_config_helper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function load_save_benchmark_data(sim)
end

has_physicsconfig_args(sim) = has_config_args(load_physicsconfig(sim), sim)
physicsconfig_args(sim) = get_config_args(load_physicsconfig(sim), sim)
physicsconfig_args(sim) = config_args(load_physicsconfig(sim), sim)

function process_simulation_config(entry)
received_params = dict_list(entry)
Expand Down
5 changes: 2 additions & 3 deletions benchmarks/src/main_config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[heat]
cpu = ["test"]
cuda = ["test"]
[heat.cpu.test]
[heat.cuda.test]
5 changes: 5 additions & 0 deletions benchmarks/src/physics/heat/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ code_target = "CPUTarget"
float_type = ["Float32", "Float64"]
resolution = [5, 2, 1]

[heat.cpu.test2]
code_target = "CPUTarget"
float_type = "Float64"
resolution = 5

[heat.cuda.test]
code_target = "CUDATarget"
float_type = ["Float32", "Float64"]
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/test/config_gen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ using TOML
init_params = Dict("full_test" => ["a", "b", "c", "d"])
temp_list = process_simulation_config(init_params)
@test simconfig_size(temp_list) == 4
@test get_meta_config_info(temp_list)["fields"] == "full_test"
@test meta_config_info(temp_list)["fields"] == "full_test"
end

@testset "Parameter parsing" begin
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/test/data_aggr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using BenchmarkTools
include(helpersdir("data_aggr_helper.jl"))

@testset "Benchmark names" begin
@test get_benchmark_headername("Solve", "Maximum", "Time") == "Solve Maximum Time"
@test benchmark_headername("Solve", "Maximum", "Time") == "Solve Maximum Time"
end

@testset "Adding debug data" begin
Expand Down Expand Up @@ -44,7 +44,7 @@ end

for stage in solver_stages()
for stat in ["time", "memory", "gctime", "allocs"]
@test get_benchmark_headername(stage, "Median", stat) in keys(data_row_bench)
@test benchmark_headername(stage, "Median", stat) in keys(data_row_bench)
end
end
end
Expand Down
14 changes: 7 additions & 7 deletions benchmarks/test/main_config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ end

hcpa = SimNameData("heat", "cpu", "a")
@test has_config_args(main_config_info, hcpa)
hcpa_args = get_config_args(main_config_info, hcpa)
hcpa_args = config_args(main_config_info, hcpa)
@test hcpa_args["args"] == "test"

@test is_supported_arch("cpu")
Expand All @@ -94,28 +94,28 @@ end

no_entries = SimNameData("heat", "cuda", "c")
@test has_config_args(main_config_info, no_entries) == false
@test_throws "not found in the main config" get_config_args(main_config_info, no_entries)
@test_throws "not found in the main config" config_args(main_config_info, no_entries)

no_tag = SimNameData("heat", "cpu", "badtag")
@test has_config_args(main_config_info, no_tag) == false
@test_throws "not found in the main config" get_config_args(main_config_info, no_tag)
@test_throws "not found in the main config" config_args(main_config_info, no_tag)

no_arch = SimNameData("not_heat", "cpu", "c")
@test has_config_args(main_config_info, no_arch) == false
@test_throws "not found in the main config" get_config_args(main_config_info, no_arch)
@test_throws "not found in the main config" config_args(main_config_info, no_arch)

bad_arch = SimNameData("not_heat", "fake", "c")
@test has_config_args(main_config_info, bad_arch) == false
@test_throws "not found in the main config" get_config_args(main_config_info, bad_arch)
@test_throws "not found in the main config" config_args(main_config_info, bad_arch)

no_physics = SimNameData("brussel", "cuda", "c")
@test has_config_args(main_config_info, no_physics) == false
@test_throws "not found in the main config" get_config_args(main_config_info, no_physics)
@test_throws "not found in the main config" config_args(main_config_info, no_physics)

empty_toml = TOML.parse("")
empty_snd = SimNameData("", "", "")
@test has_config_args(empty_toml, empty_snd) == false
@test_throws "not found in the main configuration" get_config_args(empty_toml, empty_snd)
@test_throws "not found in the main configuration" config_args(empty_toml, empty_snd)
end

end

0 comments on commit 50b0700

Please sign in to comment.