Skip to content

Commit db5dae0

Browse files
Merge pull request #1899 from CliMA/ck/copyto_bench
Update fill benchmark, add copyto benchmark
2 parents 77c94c6 + e441df0 commit db5dae0

File tree

3 files changed

+75
-10
lines changed

3 files changed

+75
-10
lines changed

.buildkite/pipeline.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,10 @@ steps:
11661166
key: "cpu_datalayouts_fill"
11671167
command: "julia --color=yes --project=.buildkite test/DataLayouts/benchmark_fill.jl"
11681168

1169+
- label: "Perf: DataLayouts copyto!"
1170+
key: "cpu_datalayouts_copyto"
1171+
command: "julia --color=yes --project=.buildkite test/DataLayouts/benchmark_copyto.jl"
1172+
11691173
- label: "Perf: DataLayouts fill"
11701174
key: "gpu_datalayouts_fill"
11711175
command:
@@ -1176,6 +1180,16 @@ steps:
11761180
agents:
11771181
slurm_gpus: 1
11781182

1183+
- label: "Perf: DataLayouts copyto"
1184+
key: "gpu_datalayouts_copyto"
1185+
command:
1186+
- "julia --project=.buildkite -e 'using CUDA; CUDA.versioninfo()'"
1187+
- "julia --color=yes --project=.buildkite test/DataLayouts/benchmark_copyto.jl"
1188+
env:
1189+
CLIMACOMMS_DEVICE: "CUDA"
1190+
agents:
1191+
slurm_gpus: 1
1192+
11791193
- group: "Perf: Fields"
11801194
steps:
11811195

test/DataLayouts/benchmark_copyto.jl

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#=
2+
julia --project
3+
using Revise; include(joinpath("test", "DataLayouts", "benchmark_copyto.jl"))
4+
=#
5+
using Test
6+
using ClimaCore.DataLayouts
7+
using BenchmarkTools
8+
import ClimaComms
9+
@static pkgversion(ClimaComms) >= v"0.6" && ClimaComms.@import_required_backends
10+
11+
function benchmarkcopyto!(device, data, val, name)
12+
println("Benchmarking ClimaCore copyto! for $name DataLayout")
13+
bc = Base.Broadcast.broadcasted(identity, val)
14+
trial = @benchmark ClimaComms.@cuda_sync $device Base.copyto!($data, $bc)
15+
show(stdout, MIME("text/plain"), trial)
16+
println()
17+
println("Benchmarking array copyto! for $name DataLayout")
18+
trial = @benchmark ClimaComms.@cuda_sync $device Base.copyto!(
19+
$(parent(data)),
20+
$bc,
21+
)
22+
show(stdout, MIME("text/plain"), trial)
23+
println()
24+
end
25+
26+
@testset "copyto! with Nf = 1" begin
27+
device = ClimaComms.device()
28+
device_zeros(args...) = ClimaComms.array_type(device)(zeros(args...))
29+
FT = Float64
30+
S = FT
31+
Nf = 1
32+
Nv = 63
33+
Nij = 4
34+
Nh = 30 * 30 * 6
35+
Nk = 6
36+
#! format: off
37+
data = DataF{S}(device_zeros(FT,Nf)); benchmarkcopyto!(device, data, 3, "DataF" ); @test all(parent(data) .== 3)
38+
data = IJFH{S, Nij, Nh}(device_zeros(FT,Nij,Nij,Nf,Nh)); benchmarkcopyto!(device, data, 3, "IJFH" ); @test all(parent(data) .== 3)
39+
data = IFH{S, Nij, Nh}(device_zeros(FT,Nij,Nf,Nh)); benchmarkcopyto!(device, data, 3, "IFH" ); @test all(parent(data) .== 3)
40+
data = IJF{S, Nij}(device_zeros(FT,Nij,Nij,Nf)); benchmarkcopyto!(device, data, 3, "IJF" ); @test all(parent(data) .== 3)
41+
data = IF{S, Nij}(device_zeros(FT,Nij,Nf)); benchmarkcopyto!(device, data, 3, "IF" ); @test all(parent(data) .== 3)
42+
data = VF{S, Nv}(device_zeros(FT,Nv,Nf)); benchmarkcopyto!(device, data, 3, "VF" ); @test all(parent(data) .== 3)
43+
data = VIJFH{S,Nv,Nij,Nh}(device_zeros(FT,Nv,Nij,Nij,Nf,Nh));benchmarkcopyto!(device, data, 3, "VIJFH" ); @test all(parent(data) .== 3)
44+
data = VIFH{S, Nv, Nij, Nh}(device_zeros(FT,Nv,Nij,Nf,Nh)); benchmarkcopyto!(device, data, 3, "VIFH" ); @test all(parent(data) .== 3)
45+
#! format: on
46+
47+
# data = IJKFVH{S}(device_zeros(FT,Nij,Nij,Nk,Nf,Nh)); benchmarkcopyto!(device, data, 3); @test all(parent(data) .== 3) # TODO: test
48+
# data = IH1JH2{S}(device_zeros(FT,Nij,Nij,Nk,Nf,Nh)); benchmarkcopyto!(device, data, 3); @test all(parent(data) .== 3) # TODO: test
49+
end

test/DataLayouts/benchmark_fill.jl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ using BenchmarkTools
88
import ClimaComms
99
@static pkgversion(ClimaComms) >= v"0.6" && ClimaComms.@import_required_backends
1010

11-
function benchmarkfill!(device, data, val)
11+
function benchmarkfill!(device, data, val, name)
12+
println("Benchmarking ClimaCore fill! for $name DataLayout")
1213
trial = @benchmark ClimaComms.@cuda_sync $device fill!($data, $val)
1314
show(stdout, MIME("text/plain"), trial)
1415
println()
16+
println("Benchmarking array fill! for $name DataLayout")
1517
trial =
1618
@benchmark ClimaComms.@cuda_sync $device fill!($(parent(data)), $val)
1719
show(stdout, MIME("text/plain"), trial)
@@ -26,17 +28,17 @@ end
2628
Nf = 1
2729
Nv = 63
2830
Nij = 4
29-
Nh = 30
31+
Nh = 30 * 30 * 6
3032
Nk = 6
3133
#! format: off
32-
data = DataF{S}(device_zeros(FT,Nf)); benchmarkfill!(device, data, 3); @test all(parent(data) .== 3)
33-
data = IJFH{S, Nij, Nh}(device_zeros(FT,Nij,Nij,Nf,Nh)); benchmarkfill!(device, data, 3); @test all(parent(data) .== 3)
34-
data = IFH{S, Nij, Nh}(device_zeros(FT,Nij,Nf,Nh)); benchmarkfill!(device, data, 3); @test all(parent(data) .== 3)
35-
data = IJF{S, Nij}(device_zeros(FT,Nij,Nij,Nf)); benchmarkfill!(device, data, 3); @test all(parent(data) .== 3)
36-
data = IF{S, Nij}(device_zeros(FT,Nij,Nf)); benchmarkfill!(device, data, 3); @test all(parent(data) .== 3)
37-
data = VF{S, Nv}(device_zeros(FT,Nv,Nf)); benchmarkfill!(device, data, 3); @test all(parent(data) .== 3)
38-
data = VIJFH{S,Nv,Nij,Nh}(device_zeros(FT,Nv,Nij,Nij,Nf,Nh));benchmarkfill!(device, data, 3); @test all(parent(data) .== 3)
39-
data = VIFH{S, Nv, Nij, Nh}(device_zeros(FT,Nv,Nij,Nf,Nh)); benchmarkfill!(device, data, 3); @test all(parent(data) .== 3)
34+
data = DataF{S}(device_zeros(FT,Nf)); benchmarkfill!(device, data, 3, "DataF" ); @test all(parent(data) .== 3)
35+
data = IJFH{S, Nij, Nh}(device_zeros(FT,Nij,Nij,Nf,Nh)); benchmarkfill!(device, data, 3, "IJFH" ); @test all(parent(data) .== 3)
36+
data = IFH{S, Nij, Nh}(device_zeros(FT,Nij,Nf,Nh)); benchmarkfill!(device, data, 3, "IFH" ); @test all(parent(data) .== 3)
37+
data = IJF{S, Nij}(device_zeros(FT,Nij,Nij,Nf)); benchmarkfill!(device, data, 3, "IJF" ); @test all(parent(data) .== 3)
38+
data = IF{S, Nij}(device_zeros(FT,Nij,Nf)); benchmarkfill!(device, data, 3, "IF" ); @test all(parent(data) .== 3)
39+
data = VF{S, Nv}(device_zeros(FT,Nv,Nf)); benchmarkfill!(device, data, 3, "VF" ); @test all(parent(data) .== 3)
40+
data = VIJFH{S,Nv,Nij,Nh}(device_zeros(FT,Nv,Nij,Nij,Nf,Nh));benchmarkfill!(device, data, 3, "VIJFH" ); @test all(parent(data) .== 3)
41+
data = VIFH{S, Nv, Nij, Nh}(device_zeros(FT,Nv,Nij,Nf,Nh)); benchmarkfill!(device, data, 3, "VIFH" ); @test all(parent(data) .== 3)
4042
#! format: on
4143

4244
# data = IJKFVH{S}(device_zeros(FT,Nij,Nij,Nk,Nf,Nh)); benchmarkfill!(device, data, 3); @test all(parent(data) .== 3) # TODO: test

0 commit comments

Comments
 (0)