Skip to content

Commit c5b5c9c

Browse files
committed
Unify DataLayouts and simplify API
1 parent 337f0d1 commit c5b5c9c

70 files changed

Lines changed: 1443 additions & 5995 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.buildkite/pipeline.yml

Lines changed: 3 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -104,30 +104,15 @@ steps:
104104
- group: "Unit: DataLayouts"
105105
steps:
106106

107-
- label: "Unit: data0d"
108-
key: unit_data0d
109-
retry: *retry_policy
110-
command: "julia --color=yes --check-bounds=yes --project=.buildkite test/DataLayouts/data0d.jl"
111-
112-
- label: "Unit: data_fill"
113-
key: unit_data_fill
114-
retry: *retry_policy
115-
command: "julia --color=yes --check-bounds=yes --project=.buildkite test/DataLayouts/unit_fill.jl"
116-
117107
- label: "Unit: data_copyto"
118108
key: unit_data_copyto
119109
retry: *retry_policy
120110
command: "julia --color=yes --check-bounds=yes --project=.buildkite test/DataLayouts/unit_copyto.jl"
121111

122-
- label: "Unit: cartesian_field_index"
123-
key: unit_data_cartesian_field_index
124-
retry: *retry_policy
125-
command: "julia --color=yes --check-bounds=yes --project=.buildkite test/DataLayouts/unit_cartesian_field_index.jl"
126-
127-
- label: "Unit: non_extruded_broadcast"
128-
key: unit_non_extruded_broadcast
112+
- label: "Unit: data_copyto multithreaded"
113+
key: unit_data_copyto
129114
retry: *retry_policy
130-
command: "julia --color=yes --check-bounds=yes --project=.buildkite test/DataLayouts/unit_non_extruded_broadcast.jl"
115+
command: "julia --threads=4 --color=yes --check-bounds=yes --project=.buildkite test/DataLayouts/unit_copyto.jl"
131116

132117
- label: "Unit: mapreduce"
133118
key: unit_data_mapreduce
@@ -139,41 +124,6 @@ steps:
139124
retry: *retry_policy
140125
command: "julia --color=yes --check-bounds=yes --project=.buildkite test/DataLayouts/opt_similar.jl"
141126

142-
- label: "Unit: opt_universal_size"
143-
key: opt_universal_size
144-
retry: *retry_policy
145-
command: "julia --color=yes --check-bounds=yes --project=.buildkite test/DataLayouts/opt_universal_size.jl"
146-
147-
- label: "Unit: data_ndims"
148-
key: unit_data_ndims
149-
retry: *retry_policy
150-
command: "julia --color=yes --check-bounds=yes --project=.buildkite test/DataLayouts/unit_ndims.jl"
151-
152-
- label: "Unit: unit_data2array"
153-
key: unit_data2array
154-
retry: *retry_policy
155-
command: "julia --color=yes --check-bounds=yes --project=.buildkite test/DataLayouts/unit_data2array.jl"
156-
157-
- label: "Unit: data1d"
158-
key: unit_data1d
159-
retry: *retry_policy
160-
command: "julia --color=yes --check-bounds=yes --project=.buildkite test/DataLayouts/data1d.jl"
161-
162-
- label: "Unit: data2d"
163-
key: unit_data2d
164-
retry: *retry_policy
165-
command: "julia --color=yes --check-bounds=yes --project=.buildkite test/DataLayouts/data2d.jl"
166-
167-
- label: "Unit: data1dx"
168-
key: unit_data1dx
169-
retry: *retry_policy
170-
command: "julia --color=yes --check-bounds=yes --project=.buildkite test/DataLayouts/data1dx.jl"
171-
172-
- label: "Unit: data2dx"
173-
key: unit_data2dx
174-
retry: *retry_policy
175-
command: "julia --color=yes --check-bounds=yes --project=.buildkite test/DataLayouts/data2dx.jl"
176-
177127
- label: "Unit: data cuda"
178128
key: unit_data_cuda
179129
retry: *retry_policy
@@ -196,17 +146,6 @@ steps:
196146
agents:
197147
slurm_gpus: 1
198148

199-
- label: "Unit: data fill"
200-
key: gpu_unit_data_fill
201-
retry: *retry_policy
202-
command:
203-
- "julia --project=.buildkite -e 'using CUDA; CUDA.versioninfo()'"
204-
- "julia --color=yes --check-bounds=yes --project=.buildkite test/DataLayouts/unit_fill.jl"
205-
env:
206-
CLIMACOMMS_DEVICE: "CUDA"
207-
agents:
208-
slurm_gpus: 1
209-
210149
- label: "Unit: data mapreduce"
211150
key: gpu_unit_data_mapreduce
212151
retry: *retry_policy
@@ -1624,27 +1563,11 @@ steps:
16241563
- group: "Perf: DataLayouts"
16251564
steps:
16261565

1627-
- label: "Perf: DataLayouts fill"
1628-
key: "cpu_datalayouts_fill"
1629-
retry: *retry_policy
1630-
command: "julia --color=yes --project=.buildkite test/DataLayouts/benchmark_fill.jl"
1631-
16321566
- label: "Perf: DataLayouts copyto!"
16331567
key: "cpu_datalayouts_copyto"
16341568
retry: *retry_policy
16351569
command: "julia --color=yes --project=.buildkite test/DataLayouts/benchmark_copyto.jl"
16361570

1637-
- label: "Perf: DataLayouts fill"
1638-
key: "gpu_datalayouts_fill"
1639-
retry: *retry_policy
1640-
command:
1641-
- "julia --project=.buildkite -e 'using CUDA; CUDA.versioninfo()'"
1642-
- "julia --color=yes --project=.buildkite test/DataLayouts/benchmark_fill.jl"
1643-
env:
1644-
CLIMACOMMS_DEVICE: "CUDA"
1645-
agents:
1646-
slurm_gpus: 1
1647-
16481571
- label: "Perf: DataLayouts copyto"
16491572
key: "gpu_datalayouts_copyto"
16501573
retry: *retry_policy

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ v0.14.6
523523

524524
- ![][badge-✨feature/enhancement] Added `array2field(::Field)` and `field2array(::Field)` convenience functions, to help facilitate use with RRTMGP. PR [#1768](https://github.com/CliMA/ClimaCore.jl/pull/1768)
525525

526-
- ![][badge-🚀performance] `Nv` is now a type parameter in DataLayouts that have vertical levels. As a result, users can use `DataLayouts.nlevels(::AbstractData)` to obtain a compile-time constant for the number of vertical levels.
526+
- ![][badge-🚀performance] `Nv` is now a type parameter in DataLayouts that have vertical levels. As a result, users can use `DataLayouts.nlevels(::DataLayout)` to obtain a compile-time constant for the number of vertical levels.
527527

528528
- ![][badge-✨feature/enhancement] Added `interpolate(field, target_hcoords,
529529
target_zcoord)` convenience function so that the `Remapper` does not have to

benchmarks/scripts/index_swapping.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function custom_kernel_knl_bc_1swap!(y1, bc, us)
106106
if tidx get_N(us)
107107
n = (get_Nij(us), get_Nij(us), 1, get_Nv(us), get_Nh(us))
108108
GCI = CartesianIndices(map(x -> Base.OneTo(x), n))[tidx]
109-
# Perform index swap (as in `getindex(::AbstractData, ::CartesianIndex)`)
109+
# Perform index swap (as in `getindex(::DataLayout, ::CartesianIndex)`)
110110
i, j, _, v, h = GCI.I
111111
CI = CartesianIndex(v, i, j, 1, h)
112112
y1[CI] = bc[CI]
@@ -140,7 +140,7 @@ function custom_kernel_knl_bc_2swap!(y1, bc, us)
140140
(v, i, j, _, h) = CIK.I
141141
GCI = CartesianIndex(i, j, 1, v, h)
142142

143-
# Swap again (in `getindex(::AbstractData, ::CartesianIndex)`)
143+
# Swap again (in `getindex(::DataLayout, ::CartesianIndex)`)
144144
(i, j, _, v, h) = GCI.I
145145
CI = CartesianIndex(v, i, j, 1, h)
146146
y1[CI] = bc[CI]

docs/src/debugging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ parts of the broadcasted object contains NaNs:
250250
```julia
251251
using StructuredPrinting
252252
import ClimaCore: DataLayouts
253-
highlight_nans(x::DataLayouts.AbstractData) = any(y->isnan(y), parent(x));
253+
highlight_nans(x::DataLayouts.DataLayout) = any(y->isnan(y), parent(x));
254254
highlight_nans(_) = false;
255255
bc = Infiltrator.safehouse.args[2]; # we know that argument 2 is the broadcasted object
256256
(; result) = Infiltrator.safehouse; # get the result

docs/src/masks.md

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -169,60 +169,6 @@ operations of mask-aware and mask-unaware:
169169
This was a design implementation detail, users should not generally depend on the results where `mask == 0`, in case this is changed in the future.
170170
- internal array operations (`fill!(parent(field), 0)`) mask-unaware.
171171

172-
## Temporary work-arounds
173-
174-
We can perform mask-aware reductions with the following work-around
175-
176-
```julia
177-
using ClimaComms
178-
ClimaComms.@import_required_backends
179-
import ClimaCore: Spaces, Fields, DataLayouts, Geometry, Operators
180-
using ClimaCore.CommonSpaces
181-
using Test
182-
183-
FT = Float64
184-
ᶜspace = ExtrudedCubedSphereSpace(FT;
185-
z_elem = 10,
186-
z_min = 0,
187-
z_max = 1,
188-
radius = 10,
189-
h_elem = 10,
190-
n_quad_points = 4,
191-
staggering = CellCenter(),
192-
enable_mask = true,
193-
)
194-
ᶠspace = Spaces.face_space(ᶜspace)
195-
ᶠcoords = Fields.coordinate_field(ᶠspace)
196-
197-
# Set the mask
198-
Spaces.set_mask!(ᶜspace) do coords
199-
coords.lat > 0.5
200-
end
201-
202-
# get the mask
203-
mask = Spaces.get_mask(ᶜspace)
204-
205-
# make a field of ones
206-
ᶜf = ones(ᶜspace) # ignores mask
207-
208-
# bitmask spanning datalayout
209-
bm = DataLayouts.full_bitmask(mask, Fields.field_values(ᶜf));
210-
211-
# mask-unaware integral (includes jacobian weighting)
212-
@show sum(ᶜf)
213-
214-
# mask-unaware sum (excludes jacobian weighting)
215-
@show sum(Fields.field_values(ᶜf))
216-
217-
# mask-aware sum (excludes jacobian)
218-
@show sum(parent(ᶜf)[bm])
219-
220-
# level mask
221-
ᶜf_lev = Fields.level(ᶜf, 1);
222-
bm_lev = DataLayouts.full_bitmask(mask, Fields.field_values(ᶜf_lev));
223-
@show sum(parent(ᶜf_lev)[bm_lev])
224-
```
225-
226172
## Developer docs
227173

228174
In order to support masks, we define their types in `DataLayouts`, since

examples/bickleyjet/bickleyjet_cg_invariant_hypervisc.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import ClimaCore:
99
Operators,
1010
Spaces,
1111
Topologies,
12-
Quadratures,
13-
DataLayouts
12+
Quadratures
1413
using OrdinaryDiffEqSSPRK: ODEProblem, solve, SSPRK33
1514

1615
using Logging
@@ -163,7 +162,7 @@ sol_global = []
163162
if usempi
164163
for sol_step in sol.u
165164
sol_step_values_global =
166-
DataLayouts.gather(context, Fields.field_values(sol_step))
165+
ClimaComms.gather(context, Fields.field_values(sol_step))
167166
if ClimaComms.iamroot(context)
168167
sol_step_global = Fields.Field(sol_step_values_global, global_space)
169168
push!(sol_global, sol_step_global)

examples/hybrid/driver.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ any(isnan, sol.u[end]) && error("NaNs found in result.")
197197

198198
if is_distributed # replace sol.u on the root processor with the global sol.u
199199
global_Y_c_1 =
200-
DataLayouts.gather(comms_ctx, Fields.field_values(sol.u[1].c))
200+
ClimaComms.gather(comms_ctx, Fields.field_values(sol.u[1].c))
201201
global_Y_f_1 =
202-
DataLayouts.gather(comms_ctx, Fields.field_values(sol.u[1].f))
202+
ClimaComms.gather(comms_ctx, Fields.field_values(sol.u[1].f))
203203
if ClimaComms.iamroot(comms_ctx)
204204
global_h_space = make_horizontal_space(
205205
horizontal_mesh,
@@ -220,9 +220,9 @@ if is_distributed # replace sol.u on the root processor with the global sol.u
220220
end
221221
for i in 1:length(sol.u)
222222
global_Y_c =
223-
DataLayouts.gather(comms_ctx, Fields.field_values(sol.u[i].c))
223+
ClimaComms.gather(comms_ctx, Fields.field_values(sol.u[i].c))
224224
global_Y_f =
225-
DataLayouts.gather(comms_ctx, Fields.field_values(sol.u[i].f))
225+
ClimaComms.gather(comms_ctx, Fields.field_values(sol.u[i].f))
226226
if ClimaComms.iamroot(comms_ctx)
227227
global_sol_u[i] = Fields.FieldVector(
228228
c = Fields.Field(global_Y_c, global_center_space),

examples/sphere/shallow_water.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import ClimaCore:
1414
Operators,
1515
Spaces,
1616
Quadratures,
17-
Topologies,
18-
DataLayouts
17+
Topologies
1918

2019
import QuadGK
2120
using OrdinaryDiffEqSSPRK: ODEProblem, init, solve!, SSPRK33
@@ -564,7 +563,7 @@ function shallow_water_driver(ARGS, ::Type{FT}) where {FT}
564563
if !usempi
565564
Y0_global = deepcopy(Y)
566565
else
567-
Y0_global_values = DataLayouts.gather(context, Fields.field_values(Y))
566+
Y0_global_values = ClimaComms.gather(context, Fields.field_values(Y))
568567
if ClimaComms.iamroot(context)
569568
Y0_global = Fields.Field(Y0_global_values, global_space)
570569
end
@@ -602,7 +601,7 @@ function shallow_water_driver(ARGS, ::Type{FT}) where {FT}
602601
if usempi
603602
for sol_step in sol.u
604603
sol_step_values_global =
605-
DataLayouts.gather(context, Fields.field_values(sol_step))
604+
ClimaComms.gather(context, Fields.field_values(sol_step))
606605
if ClimaComms.iamroot(context)
607606
sol_step_global =
608607
Fields.Field(sol_step_values_global, global_space)

ext/ClimaCoreCUDAExt.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ using CUDA: threadIdx, blockIdx, blockDim
1212
import StaticArrays: SVector, SMatrix, SArray
1313
import ClimaCore.DebugOnly: call_post_op_callback, post_op_callback
1414
import ClimaCore.DataLayouts: mapreduce_cuda
15-
import ClimaCore.DataLayouts: ToCUDA
1615
import ClimaCore.DataLayouts: NoMask, IJHMask
1716
import ClimaCore.DataLayouts: slab, column
1817
import ClimaCore.Utilities: half, new, cart_ind, linear_ind

ext/cuda/adapt.jl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,3 @@ Adapt.adapt_structure(
5454
lim.rtol,
5555
Limiters.NoConvergenceStats(),
5656
)
57-
58-
Adapt.adapt_structure(to::CUDA.KernelAdaptor, mask::DataLayouts.IJHMask) =
59-
DataLayouts.IJHMask(
60-
Adapt.adapt(to, mask.is_active),
61-
nothing,
62-
Adapt.adapt(to, mask.i_map),
63-
Adapt.adapt(to, mask.j_map),
64-
Adapt.adapt(to, mask.h_map),
65-
)

0 commit comments

Comments
 (0)