Skip to content

Commit

Permalink
output table to file, send to slack
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasloan25 committed Apr 8, 2024
1 parent 7545846 commit f9c3017
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
9 changes: 8 additions & 1 deletion .buildkite/benchmarks/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,17 @@ steps:
- group: "Generate output table"
steps:
- label: "Compare AMIP/aquaplanet with diagnostic EDMF"
key: "compare_slabplanet_albedo_function"
key: "compare_amip_aquaplanet"
command: "julia --color=yes --project=experiments/AMIP/ experiments/AMIP/user_io/benchmarks.jl --cpu_run_name_coupled amip_diagedmf --cpu_run_name_atmos aquaplanet_diagedmf --gpu_run_name_coupled gpu_amip_diagedmf --gpu_run_name_atmos gpu_aquaplanet_diagedmf --mode_name amip"
artifact_paths: "experiments/AMIP/output/compare_amip_aquaplanet/"
depends_on:
- "aquaplanet_diagedmf"
- "amip_diagedmf"
- "gpu_aquaplanet_diagedmf"
- "gpu_amip_diagedmf"

- label: ":envelope: Slack report: CPU/GPU AMIP/aquaplanet table"
depends_on:
- "compare_amip_aquaplanet"
command:
- slack-upload -c "#coupler-report" -f experiments/AMIP/output/compare_amip_aquaplanet/table.txt -m txt -n compare_amip_aquaplanet_table -x "Coupler CPU/GPU Comparison Table"
26 changes: 14 additions & 12 deletions experiments/AMIP/user_io/benchmarks.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using PrettyTables

#=
Our goal here is to output a table displaying some results from benchmark runs
in the coupler. We want to be able to compare between CPU and GPU runs, as well
Expand Down Expand Up @@ -107,7 +105,7 @@ cpu_artifacts_dir_atmos = joinpath(output_dir, cpu_run_name_atmos)
function get_sypd_allocs(artifacts_dir)
# Read in SYPD info
sypd_file = open(joinpath(artifacts_dir, "sypd.txt"), "r")
sypd = read(sypd_file, String)
sypd = round(parse(Float64, read(sypd_file, String)), digits = 4)

# Read in allocations info
allocs_file = open(joinpath(artifacts_dir, "allocations.txt"), "r")
Expand All @@ -122,15 +120,19 @@ cpu_sypd_atmos, cpu_allocs_atmos = get_sypd_allocs(cpu_artifacts_dir_atmos)
gpu_sypd_atmos, gpu_allocs_atmos = get_sypd_allocs(gpu_artifacts_dir_atmos)

# Set up info for PrettyTables.jl
headers = ["", "CPU Run", "GPU Run"]
headers = ["", "", "CPU Run", "GPU Run"]
data = [
["", cpu_run_name_coupled, gpu_run_name_coupled],
["Coupled run", cpu_sypd_coupled, gpu_sypd_coupled],
["", cpu_allocs_coupled, gpu_allocs_coupled],
["", cpu_run_name_atmos, gpu_run_name_atmos],
["Atmos-only", cpu_sypd_atmos, gpu_sypd_atmos],
["", cpu_allocs_atmos, gpu_allocs_atmos],
["" "run name:" cpu_run_name_coupled gpu_run_name_coupled]
["Coupled" "SYPD:" cpu_sypd_coupled gpu_sypd_coupled]
["" "allocations:" cpu_allocs_coupled gpu_allocs_coupled]
["" "run name:" cpu_run_name_atmos gpu_run_name_atmos]
["Atmos-only" "SYPD:" cpu_sypd_atmos gpu_sypd_atmos]
["" "allocations:" cpu_allocs_atmos gpu_allocs_atmos]
]

# Output the table, including lines before and after the header, and after the 4th row
PrettyTables.pretty_table(data, headers, hlines = [0, 1, 4])
# Use the coupled CPU run name for the output dir
table_path = joinpath(output_dir, "compare_amip_aquaplanet", "table.txt")
open(table_path, "w") do f
# Output the table, including lines before and after the header
PrettyTables.pretty_table(f, data, header = headers, hlines = [0, 1, 4, 7])
end
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ else
end

# Specify atmos output directory to be inside the coupler output directory
output_dir = joinpath(pkgdir(ClimaCoupler), "experiments/AMIP/output", config["job_id"])
output_dir = joinpath(pkgdir(ClimaCoupler), "experiments/AMIP/output/aquaplanet", config["job_id"])
!isdir(output_dir) && mkpath(output_dir)
config = merge(config, Dict("output_dir" => output_dir))
atmos_config = CA.AtmosConfig(config)
simulation = CA.get_simulation(atmos_config)
Expand Down

0 comments on commit f9c3017

Please sign in to comment.