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 a7193e4
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 @@ -305,7 +305,7 @@ sw_forcing = [
];

# save prognostic state to CSV - for comparison between GPU and CPU output
open(joinpath(outdir, "tf_state_$device_suffix.txt"), "w") do io
open(joinpath(outdir, "tf_state_$(device_suffix)_static.txt"), "w") do io
writedlm(io, hcat(T_sfc[end][:], W[end][:], Ws[end][:], σS[end][:]), ',')
end;
# animation settings
Expand Down
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 @@ -277,7 +277,7 @@ F_sfc = [
];

# save prognostic state to CSV - for comparison between GPU and CPU output
open(joinpath(outdir, "tf_state_$device_suffix.txt"), "w") do io
open(joinpath(outdir, "tf_state_$(device_suffix)_temporal.txt"), "w") do io
writedlm(io, hcat(T_sfc[end][:], W[end][:], Ws[end][:], σS[end][:]), ',')
end;
# animation settings
Expand Down

0 comments on commit a7193e4

Please sign in to comment.