Skip to content

Commit cba0723

Browse files
authored
Merge pull request #2176 from CliMA/gb/common_mpi
Fix CommonSpaces and MPI
2 parents 034e081 + d9957d6 commit cba0723

File tree

4 files changed

+89
-30
lines changed

4 files changed

+89
-30
lines changed

.buildkite/pipeline.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,35 @@ steps:
273273
agents:
274274
slurm_gpus: 1
275275

276+
- label: "Unit: common spaces with CUDA"
277+
key: "gpu_common_cuda_spaces"
278+
command:
279+
- "julia --color=yes --check-bounds=yes --project=.buildkite test/CommonSpaces/unit_common_spaces.jl"
280+
env:
281+
CLIMACOMMS_DEVICE: "CUDA"
282+
agents:
283+
slurm_gpus: 1
284+
285+
- label: "Unit: common spaces with CUDA and MPI"
286+
key: "gpu_common_cuda_mpi_spaces"
287+
command:
288+
- "srun julia --color=yes --check-bounds=yes --project=.buildkite test/CommonSpaces/unit_common_spaces.jl"
289+
env:
290+
CLIMACOMMS_CONTEXT: "MPI"
291+
CLIMACOMMS_DEVICE: "CUDA"
292+
agents:
293+
slurm_gpus: 1
294+
slurm_ntasks: 2
295+
296+
- label: "Unit: common spaces with MPI"
297+
key: "common_cuda_mpi_spaces"
298+
command:
299+
- "srun julia --color=yes --check-bounds=yes --project=.buildkite test/CommonSpaces/unit_common_spaces.jl"
300+
env:
301+
CLIMACOMMS_CONTEXT: "MPI"
302+
agents:
303+
slurm_ntasks: 2
304+
276305
- label: "Unit: distributed cuda spaces"
277306
key: "gpu_distributed_extruded_cuda_spaces"
278307
command:

NEWS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ ClimaCore.jl Release Notes
22
========================
33

44
main
5+
-------
6+
7+
- Prior to this version, `CommonSpaces` could not be created with
8+
`ClimaComms.MPICommContext`. This is now fixed with PR
9+
[2176](https://github.com/CliMA/ClimaCore.jl/pull/2176).
10+
11+
12+
v0.14.24
513
-------
614

715
- A new `Adapt` wrapper was added, `to_device`, which allows users to adapt datalayouts, spaces, fields, and fieldvectors between the cpu and gpu. PR [2159](https://github.com/CliMA/ClimaCore.jl/pull/2159).

src/CommonGrids/CommonGrids.jl

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,10 @@ function ExtrudedCubedSphereGrid(
189189
horizontal_layout_type,
190190
enable_bubble,
191191
)
192-
z_topology = Topologies.IntervalTopology(context, z_mesh)
192+
z_topology = Topologies.IntervalTopology(
193+
ClimaComms.SingletonCommsContext(device),
194+
z_mesh,
195+
)
193196
z_grid = Grids.FiniteDifferenceGrid(z_topology)
194197
return Grids.ExtrudedFiniteDifferenceGrid(
195198
h_grid,
@@ -307,6 +310,7 @@ function ColumnGrid(
307310
),
308311
) where {FT}
309312
@assert ClimaComms.device(context) == device "The given device and context device do not match."
313+
@assert context isa ClimaComms.SingletonCommsContext "Columns can only be created on Singleton contextes."
310314
z_topology = Topologies.IntervalTopology(context, z_mesh)
311315
return Grids.FiniteDifferenceGrid(z_topology)
312316
end
@@ -439,7 +443,10 @@ function Box3DGrid(
439443
horizontal_layout_type,
440444
enable_bubble,
441445
)
442-
z_topology = Topologies.IntervalTopology(context, z_mesh)
446+
z_topology = Topologies.IntervalTopology(
447+
ClimaComms.SingletonCommsContext(device),
448+
z_mesh,
449+
)
443450
z_grid = Grids.FiniteDifferenceGrid(z_topology)
444451
return Grids.ExtrudedFiniteDifferenceGrid(
445452
h_grid,
@@ -542,10 +549,16 @@ function SliceXZGrid(
542549
@assert horizontal_layout_type <: DataLayouts.AbstractData
543550
@assert ClimaComms.device(context) == device "The given device and context device do not match."
544551

545-
h_topology = Topologies.IntervalTopology(context, h_mesh)
552+
h_topology = Topologies.IntervalTopology(
553+
ClimaComms.SingletonCommsContext(device),
554+
h_mesh,
555+
)
546556
h_grid =
547557
Grids.SpectralElementGrid1D(h_topology, quad; horizontal_layout_type)
548-
z_topology = Topologies.IntervalTopology(context, z_mesh)
558+
z_topology = Topologies.IntervalTopology(
559+
ClimaComms.SingletonCommsContext(device),
560+
z_mesh,
561+
)
549562
z_grid = Grids.FiniteDifferenceGrid(z_topology)
550563
return Grids.ExtrudedFiniteDifferenceGrid(
551564
h_grid,

test/CommonSpaces/unit_common_spaces.jl

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ using ClimaCore:
1616
DataLayouts
1717
using Test
1818

19+
# Initialize MPI context
20+
ClimaComms.init(ClimaComms.context())
21+
1922
@testset "Convenience constructors" begin
2023
function warp_surface(coord)
2124
# sin²(x) form ground elevation
@@ -34,7 +37,7 @@ using Test
3437
h_elem = 10,
3538
n_quad_points = 4,
3639
horizontal_layout_type = DataLayouts.IJHF,
37-
staggering = Grids.CellCenter(),
40+
staggering = CellCenter(),
3841
)
3942
grid = Spaces.grid(space)
4043
@test grid isa Grids.ExtrudedFiniteDifferenceGrid
@@ -60,7 +63,7 @@ using Test
6063
h_elem = 10,
6164
n_quad_points = 4,
6265
hypsography_fun,
63-
staggering = Grids.CellCenter(),
66+
staggering = CellCenter(),
6467
)
6568
grid = Spaces.grid(space)
6669
@test grid isa Grids.ExtrudedFiniteDifferenceGrid
@@ -75,14 +78,17 @@ using Test
7578
@test grid isa Grids.SpectralElementGrid2D
7679
@test Grids.topology(grid).mesh isa Meshes.EquiangularCubedSphere
7780

78-
space = ColumnSpace(;
79-
z_elem = 10,
80-
z_min = 0,
81-
z_max = 1,
82-
staggering = Grids.CellCenter(),
83-
)
84-
grid = Spaces.grid(space)
85-
@test grid isa Grids.FiniteDifferenceGrid
81+
# Column spaces are not supported with MPI
82+
if !(ClimaComms.context() isa ClimaComms.MPICommsContext)
83+
space = ColumnSpace(;
84+
z_elem = 10,
85+
z_min = 0,
86+
z_max = 1,
87+
staggering = Grids.CellCenter(),
88+
)
89+
grid = Spaces.grid(space)
90+
@test grid isa Grids.FiniteDifferenceGrid
91+
end
8692

8793
space = Box3DSpace(;
8894
z_elem = 10,
@@ -97,28 +103,31 @@ using Test
97103
n_quad_points = 4,
98104
x_elem = 3,
99105
y_elem = 4,
100-
staggering = Grids.CellCenter(),
106+
staggering = CellCenter(),
101107
)
102108
grid = Spaces.grid(space)
103109
@test grid isa Grids.ExtrudedFiniteDifferenceGrid
104110
@test grid.horizontal_grid isa Grids.SpectralElementGrid2D
105111
@test Grids.topology(grid.horizontal_grid).mesh isa Meshes.RectilinearMesh
106112

107-
space = SliceXZSpace(;
108-
z_elem = 10,
109-
x_min = 0,
110-
x_max = 1,
111-
z_min = 0,
112-
z_max = 1,
113-
periodic_x = false,
114-
n_quad_points = 4,
115-
x_elem = 4,
116-
staggering = Grids.CellCenter(),
117-
)
118-
grid = Spaces.grid(space)
119-
@test grid isa Grids.ExtrudedFiniteDifferenceGrid
120-
@test grid.horizontal_grid isa Grids.SpectralElementGrid1D
121-
@test Grids.topology(grid.horizontal_grid).mesh isa Meshes.IntervalMesh
113+
# Slices are currently not compatible with GPU
114+
if !(ClimaComms.device() isa ClimaComms.CUDADevice)
115+
space = SliceXZSpace(;
116+
z_elem = 10,
117+
x_min = 0,
118+
x_max = 1,
119+
z_min = 0,
120+
z_max = 1,
121+
periodic_x = false,
122+
n_quad_points = 4,
123+
x_elem = 4,
124+
staggering = CellCenter(),
125+
)
126+
grid = Spaces.grid(space)
127+
@test grid isa Grids.ExtrudedFiniteDifferenceGrid
128+
@test grid.horizontal_grid isa Grids.SpectralElementGrid1D
129+
@test Grids.topology(grid.horizontal_grid).mesh isa Meshes.IntervalMesh
130+
end
122131

123132
space = RectangleXYSpace(;
124133
x_min = 0,

0 commit comments

Comments
 (0)