Skip to content

Commit 412a3da

Browse files
committed
add append_table_data func [skip ci]
1 parent 26f39c2 commit 412a3da

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

experiments/ClimaEarth/user_io/benchmarks.jl

+23-7
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,35 @@ headers = [build_id_str, "Horiz. res.: 30 elems", "CPU Run [64 processes]", "GPU
138138
data = [
139139
["" "Vert. res.: 63 levels" "" ""]
140140
["" "dt: 120secs" "" ""]
141-
["" "job ID:" cpu_job_id_coupled gpu_job_id_coupled]
142-
["Coupled" "SYPD:" cpu_sypd_coupled gpu_sypd_coupled]
143-
["" "CPU max RSS allocs:" cpu_allocs_coupled gpu_cpu_allocs_coupled]
144-
["" "job ID:" cpu_job_id_atmos gpu_job_id_atmos]
145-
["Atmos-only" "SYPD:" cpu_sypd_atmos gpu_sypd_atmos]
146-
["" "CPU max RSS allocs:" cpu_allocs_atmos gpu_cpu_allocs_atmos]
147141
]
148142

143+
"""
144+
append_table_data!(table_data, setup_id, cpu_job_id, gpu_job_id, cpu_artifacts_dir, gpu_artifacts_dir)
145+
146+
Append data for a given setup to the table data.
147+
"""
148+
function append_table_data!(table_data, setup_id, cpu_job_id, gpu_job_id, cpu_artifacts_dir, gpu_artifacts_dir)
149+
# Get SYPD and allocation info for both input runs
150+
cpu_sypd, cpu_allocs = get_sypd_allocs(cpu_artifacts_dir)
151+
gpu_sypd, gpu_cpu_allocs = get_sypd_allocs(gpu_artifacts_dir)
152+
153+
# Create rows containing data for these runs
154+
new_table_data = [
155+
["" "job ID:" cpu_job_id gpu_job_id]
156+
[setup_id "SYPD:" cpu_sypd gpu_sypd]
157+
["" "CPU max RSS allocs:" cpu_allocs gpu_cpu_allocs]
158+
]
159+
table_data = vcat(table_data, new_table_data)
160+
end
161+
162+
append_table_data!(data, "Coupled", cpu_job_id_coupled, gpu_job_id_coupled, cpu_artifacts_dir_coupled, gpu_artifacts_dir_coupled)
163+
append_table_data!(data, "Atmos with diag. EDMF", cpu_job_id_atmos, gpu_job_id_atmos, cpu_artifacts_dir_atmos, gpu_artifacts_dir_atmos)
164+
149165
# Use the coupled CPU job ID for the output dir
150166
table_output_dir = joinpath(output_dir, "compare_$(mode_name)_$(mode_name_atmos)_$(cpu_job_id_coupled)")
151167
!isdir(table_output_dir) && mkdir(table_output_dir)
152168
table_path = joinpath(table_output_dir, "table.txt")
153169
open(table_path, "w") do f
154170
# Output the table, including lines before and after the header
155-
PrettyTables.pretty_table(f, data, header = headers, hlines = [0, 3, 6, 9])
171+
PrettyTables.pretty_table(f, data, header = headers, hlines = [0, 3, 6, 9]) # TODO don't hardcode hlines
156172
end

0 commit comments

Comments
 (0)