Skip to content

Commit

Permalink
Fix compare cpu/gpu tests
Browse files Browse the repository at this point in the history
The tests were only comparing the albedo function job
  • Loading branch information
Sbozzolo committed Jun 26, 2024
1 parent 9c2abcd commit eba0471
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
10 changes: 1 addition & 9 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,12 @@ steps:

- group: "CPU/GPU comparisons"
steps:
- label: "Compare GPU bucket with CPU bucket (functional albedo)"
- label: "Compare GPU bucket with CPU bucket"
command: "julia --color=yes --project=.buildkite experiments/standalone/Bucket/compare_gpu_cpu_output.jl"
depends_on:
- "global_bucket_function_cpu"
- "global_bucket_function_gpu"

- label: "Compare GPU bucket with CPU bucket (static map albedo)"
command: "julia --color=yes --project=.buildkite experiments/standalone/Bucket/compare_gpu_cpu_output.jl"
depends_on:
- "global_bucket_staticmap_cpu"
- "global_bucket_staticmap_gpu"

- label: "Compare GPU bucket with CPU bucket (temporal map albedo)"
command: "julia --color=yes --project=.buildkite experiments/standalone/Bucket/compare_gpu_cpu_output.jl"
depends_on:
- "global_bucket_temporalmap_cpu"
- "global_bucket_temporalmap_gpu"
18 changes: 12 additions & 6 deletions experiments/standalone/Bucket/compare_gpu_cpu_output.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ using DelimitedFiles
using Statistics
import ClimaLand
outdir = joinpath(pkgdir(ClimaLand), "experiments/standalone/Bucket/artifacts")
cpu_state = readdlm(joinpath(outdir, "tf_state_cpu.txt"), ',')
gpu_state = readdlm(joinpath(outdir, "tf_state_gpu.txt"), ',')
@show abs(maximum(cpu_state .- gpu_state))
@show abs(median(cpu_state .- gpu_state))
@show abs(mean(cpu_state .- gpu_state))
@assert isapprox(cpu_state, gpu_state)
function check(job)
cpu_state = readdlm(joinpath(outdir, "tf_cpu_$job.txt"), ',')
gpu_state = readdlm(joinpath(outdir, "tf_gpu_$job.txt"), ',')
@show abs(maximum(cpu_state .- gpu_state))
@show abs(median(cpu_state .- gpu_state))
@show abs(mean(cpu_state .- gpu_state))
@assert isapprox(cpu_state, gpu_state)
end

check("function")
check("static")
check("temporal")
2 changes: 1 addition & 1 deletion experiments/standalone/Bucket/global_bucket_function.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,6 @@ T_sfc = Array(Remapping.interpolate(remapper, prob.p.bucket.T_sfc))
device_suffix =
typeof(ClimaComms.context().device) <: ClimaComms.CPUSingleThreaded ?
"cpu" : "gpu"
open(joinpath(outdir, "tf_state_$device_suffix.txt"), "w") do io
open(joinpath(outdir, "tf_$(device_suffix)_function.txt"), "w") do io
writedlm(io, hcat(T_sfc[:], W[:], Ws[:], σS[:]), ',')
end;
2 changes: 1 addition & 1 deletion experiments/standalone/Bucket/global_bucket_staticmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -347,5 +347,5 @@ for (i, (field_ts, field_name)) in enumerate(
end

end
outfile = joinpath(outdir, string("ts_$device_suffix.png"))
outfile = joinpath(outdir, string("ts_($device_suffix)_static.png"))
CairoMakie.save(outfile, fig_ts)
2 changes: 1 addition & 1 deletion experiments/standalone/Bucket/global_bucket_temporalmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -323,5 +323,5 @@ for (i, (field_ts, field_name)) in enumerate(
)
CairoMakie.lines!(ax2, sol.t ./ 3600 ./ 24, [mean(x) for x in field_ts])
end
outfile = joinpath(outdir, string("ts_$device_suffix.png"))
outfile = joinpath(outdir, string("ts_($device_suffix)_temporal.png"))
CairoMakie.save(outfile, fig_ts)

0 comments on commit eba0471

Please sign in to comment.