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 daa9ded
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 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"
23 changes: 16 additions & 7 deletions experiments/standalone/Bucket/compare_gpu_cpu_output.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
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)
outdir = joinpath(
pkgdir(ClimaLand),
"experiments/standalone/Bucket/artifacts_$job",
)
cpu_state = readdlm(joinpath(outdir, "tf_state_cpu_$job.txt"), ',')
gpu_state = readdlm(joinpath(outdir, "tf_state_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("staticmap")
check("temporalmap")
7 changes: 5 additions & 2 deletions experiments/standalone/Bucket/global_bucket_function.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ anim_plots = false
FT = Float64;
context = ClimaComms.context()
earth_param_set = LP.LandParameters(FT);
outdir = joinpath(pkgdir(ClimaLand), "experiments/standalone/Bucket/artifacts")
outdir = joinpath(
pkgdir(ClimaLand),
"experiments/standalone/Bucket/artifacts_function",
)
!ispath(outdir) && mkpath(outdir)

# Construct simulation domain
Expand Down Expand Up @@ -226,6 +229,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_state_$(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)_staticmap.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)_temporalmap.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 daa9ded

Please sign in to comment.