From 50b0700a257c9d2cd9ad610c5be7def153be1871 Mon Sep 17 00:00:00 2001 From: GeorgeR227 Date: Wed, 21 Aug 2024 12:15:47 -0400 Subject: [PATCH] Cleaning up --- benchmarks/README.md | 2 +- benchmarks/scripts/post_processing/default_out.jl | 4 ++-- benchmarks/src/helpers/data_aggr_helper.jl | 4 ++-- benchmarks/src/helpers/main_config_helper.jl | 8 ++++---- benchmarks/src/helpers/main_source.jl | 4 ++-- benchmarks/src/helpers/paths.jl | 4 ++-- benchmarks/src/helpers/physics_config_helper.jl | 2 +- benchmarks/src/main_config.toml | 5 ++--- benchmarks/src/physics/heat/config.toml | 5 +++++ benchmarks/test/config_gen.jl | 2 +- benchmarks/test/data_aggr.jl | 4 ++-- benchmarks/test/main_config.jl | 14 +++++++------- 12 files changed, 31 insertions(+), 27 deletions(-) diff --git a/benchmarks/README.md b/benchmarks/README.md index 07d0b291..03d0baff 100644 --- a/benchmarks/README.md +++ b/benchmarks/README.md @@ -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 diff --git a/benchmarks/scripts/post_processing/default_out.jl b/benchmarks/scripts/post_processing/default_out.jl index afd861db..70dd5b9f 100644 --- a/benchmarks/scripts/post_processing/default_out.jl +++ b/benchmarks/scripts/post_processing/default_out.jl @@ -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) diff --git a/benchmarks/src/helpers/data_aggr_helper.jl b/benchmarks/src/helpers/data_aggr_helper.jl index b304bfc3..813983dc 100644 --- a/benchmarks/src/helpers/data_aggr_helper.jl +++ b/benchmarks/src/helpers/data_aggr_helper.jl @@ -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 diff --git a/benchmarks/src/helpers/main_config_helper.jl b/benchmarks/src/helpers/main_config_helper.jl index 6e9d6daf..94e32821 100644 --- a/benchmarks/src/helpers/main_config_helper.jl +++ b/benchmarks/src/helpers/main_config_helper.jl @@ -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") @@ -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 diff --git a/benchmarks/src/helpers/main_source.jl b/benchmarks/src/helpers/main_source.jl index df0b3236..06445599 100644 --- a/benchmarks/src/helpers/main_source.jl +++ b/benchmarks/src/helpers/main_source.jl @@ -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 @@ -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 diff --git a/benchmarks/src/helpers/paths.jl b/benchmarks/src/helpers/paths.jl index 562a120a..065529ce 100644 --- a/benchmarks/src/helpers/paths.jl +++ b/benchmarks/src/helpers/paths.jl @@ -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 @@ -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()] diff --git a/benchmarks/src/helpers/physics_config_helper.jl b/benchmarks/src/helpers/physics_config_helper.jl index fc2ba1a3..fb6ea0ff 100644 --- a/benchmarks/src/helpers/physics_config_helper.jl +++ b/benchmarks/src/helpers/physics_config_helper.jl @@ -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) diff --git a/benchmarks/src/main_config.toml b/benchmarks/src/main_config.toml index 3b02d573..54619c6b 100644 --- a/benchmarks/src/main_config.toml +++ b/benchmarks/src/main_config.toml @@ -1,3 +1,2 @@ -[heat] -cpu = ["test"] -cuda = ["test"] \ No newline at end of file +[heat.cpu.test] +[heat.cuda.test] \ No newline at end of file diff --git a/benchmarks/src/physics/heat/config.toml b/benchmarks/src/physics/heat/config.toml index 2f4a68aa..7c041459 100644 --- a/benchmarks/src/physics/heat/config.toml +++ b/benchmarks/src/physics/heat/config.toml @@ -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"] diff --git a/benchmarks/test/config_gen.jl b/benchmarks/test/config_gen.jl index fd54c36d..c3bc6fdc 100644 --- a/benchmarks/test/config_gen.jl +++ b/benchmarks/test/config_gen.jl @@ -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 diff --git a/benchmarks/test/data_aggr.jl b/benchmarks/test/data_aggr.jl index e690e8a0..e00e2153 100644 --- a/benchmarks/test/data_aggr.jl +++ b/benchmarks/test/data_aggr.jl @@ -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 @@ -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 diff --git a/benchmarks/test/main_config.jl b/benchmarks/test/main_config.jl index 6c496469..c7175533 100644 --- a/benchmarks/test/main_config.jl +++ b/benchmarks/test/main_config.jl @@ -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") @@ -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