Skip to content

Commit 58b293a

Browse files
Merge pull request #2100 from CliMA/sk/swap_grid_dims
Swap CUDA grid dimensions for some partitions
2 parents 988bda5 + 6e99830 commit 58b293a

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

.buildkite/pipeline.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ steps:
266266
- "julia --project=.buildkite -e 'using CUDA; CUDA.versioninfo()'"
267267
- "srun julia --color=yes --check-bounds=yes --project=.buildkite test/Spaces/unit_spaces.jl"
268268
- "srun julia --color=yes --check-bounds=yes --project=.buildkite test/Spaces/opt_spaces.jl"
269+
- "julia --color=yes --check-bounds=yes --project=.buildkite test/Spaces/high_resolution_space.jl"
269270
env:
270271
CLIMACOMMS_DEVICE: "CUDA"
271272
agents:

ext/cuda/data_layouts_threadblock.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ function is_valid_index end
5555
Nv_thread = min(Int(fld(n_max_threads, Nij * Nij)), Nv)
5656
Nv_blocks = cld(Nv, Nv_thread)
5757
@assert prod((Nv_thread, Nij, Nij)) n_max_threads "threads,n_max_threads=($(prod((Nv_thread, Nij, Nij))),$n_max_threads)"
58-
return (; threads = (Nv_thread, Nij, Nij), blocks = (Nv_blocks, Nh))
58+
return (; threads = (Nv_thread, Nij, Nij), blocks = (Nh, Nv_blocks))
5959
end
6060
@inline function universal_index(::Union{DataLayouts.VIJFH, DataLayouts.VIJHF})
6161
(tv, i, j) = CUDA.threadIdx()
62-
(bv, h) = CUDA.blockIdx()
62+
(h, bv) = CUDA.blockIdx()
6363
v = tv + (bv - 1) * CUDA.blockDim().x
6464
return CartesianIndex((i, j, 1, v, h))
6565
end
@@ -152,11 +152,11 @@ end
152152
Nv_thread = min(Int(fld(n_max_threads, Ni)), Nv)
153153
Nv_blocks = cld(Nv, Nv_thread)
154154
@assert prod((Nv_thread, Ni)) n_max_threads "threads,n_max_threads=($(prod((Nv_thread, Ni))),$n_max_threads)"
155-
return (; threads = (Nv_thread, Ni), blocks = (Nv_blocks, Nh))
155+
return (; threads = (Nv_thread, Ni), blocks = (Nh, Nv_blocks))
156156
end
157157
@inline function universal_index(::Union{DataLayouts.VIFH, DataLayouts.VIHF})
158158
(tv, i) = CUDA.threadIdx()
159-
(bv, h) = CUDA.blockIdx()
159+
(h, bv) = CUDA.blockIdx()
160160
v = tv + (bv - 1) * CUDA.blockDim().x
161161
return CartesianIndex((i, 1, 1, v, h))
162162
end

test/Spaces/high_resolution_space.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Test
2+
import ClimaComms
3+
ClimaComms.@import_required_backends
4+
import ClimaCore
5+
@testset "Construct high resolution space on GPU" begin
6+
result = try
7+
ClimaCore.CommonSpaces.ExtrudedCubedSphereSpace(
8+
Float32;
9+
radius = 1.0,
10+
h_elem = 105,
11+
z_elem = 10,
12+
z_min = 1.0,
13+
z_max = 2.0,
14+
n_quad_points = 4,
15+
staggering = ClimaCore.Grids.CellCenter(),
16+
)
17+
catch
18+
println("unable to create center space")
19+
false
20+
end
21+
@test result isa ClimaCore.Spaces.CenterExtrudedFiniteDifferenceSpace
22+
end

0 commit comments

Comments
 (0)