@@ -9,17 +9,13 @@ import ClimaCore.Utilities
9
9
# #### Boundary helpers
10
10
# ####
11
11
12
- @inline function has_left_boundary (space, op)
13
- lloc = Operators. LeftBoundaryWindow {Spaces.left_boundary_name(space)} ()
14
- return Operators. has_boundary (op, lloc)
15
- end
16
- @inline function has_right_boundary (space, op)
17
- rloc = Operators. RightBoundaryWindow {Spaces.right_boundary_name(space)} ()
18
- return Operators. has_boundary (op, rloc)
19
- end
12
+ @inline has_left_boundary (space, op) =
13
+ Operators. has_boundary (op, Operators. left_boundary_window (space))
14
+ @inline has_right_boundary (space, op) =
15
+ Operators. has_boundary (op, Operators. right_boundary_window (space))
20
16
21
- @inline on_boundary (space, op, loc, idx ) =
22
- Operators . has_boundary (op, loc) && on_boundary (idx, space)
17
+ @inline on_boundary (idx, space, op ) =
18
+ on_left_boundary (idx, space, op) || on_right_boundary (idx, space, op )
23
19
24
20
@inline on_left_boundary (idx, space, op) =
25
21
has_left_boundary (space, op) && on_left_boundary (idx, space)
92
88
op,
93
89
args... ,
94
90
)
95
- lloc = Operators. LeftBoundaryWindow {Spaces.left_boundary_name(space)} ()
96
- Operators. should_call_left_boundary (idx, space, lloc, op, args... ) ||
91
+ Operators. should_call_left_boundary (idx, space, op, args... ) ||
97
92
in_left_boundary_window_range (idx, bc_bds)
98
93
end
99
94
104
99
op,
105
100
args... ,
106
101
)
107
- rloc = Operators. RightBoundaryWindow {Spaces.right_boundary_name(space)} ()
108
- Operators. should_call_right_boundary (idx, space, rloc, op, args... ) ||
102
+ Operators. should_call_right_boundary (idx, space, op, args... ) ||
109
103
in_right_boundary_window_range (idx, bc_bds)
110
104
end
111
105
146
140
op,
147
141
args... ,
148
142
)
149
- lloc = Operators. LeftBoundaryWindow {Spaces.left_boundary_name(space)} ()
150
- Operators. should_call_left_boundary (idx, space, lloc, op, args... ) ||
143
+ Operators. should_call_left_boundary (idx, space, op, args... ) ||
151
144
in_left_boundary_window_range (idx, bc_bds)
152
145
end
153
146
158
151
op,
159
152
args... ,
160
153
)
161
- rloc = Operators. RightBoundaryWindow {Spaces.right_boundary_name(space)} ()
162
154
ᶜspace = Spaces. center_space (space)
163
155
idx > Spaces. nlevels (ᶜspace) && return false # short-circuit if
164
- Operators. should_call_right_boundary (idx, space, rloc, op, args... ) ||
156
+ Operators. should_call_right_boundary (idx, space, op, args... ) ||
165
157
in_right_boundary_window_range (idx, bc_bds)
166
158
end
167
159
172
164
Base. @propagate_inbounds function getidx (
173
165
parent_space,
174
166
bc:: StencilBroadcasted{CUDAWithShmemColumnStencilStyle} ,
175
- loc:: Interior ,
176
- idx,
177
- hidx,
178
- )
179
- space = axes (bc)
180
- if Operators. fd_shmem_is_supported (bc)
181
- return fd_operator_evaluate (
182
- bc. op,
183
- bc. work,
184
- loc,
185
- space,
186
- idx,
187
- hidx,
188
- bc. args... ,
189
- )
190
- end
191
- Operators. stencil_interior (bc. op, loc, space, idx, hidx, bc. args... )
192
- end
193
-
194
-
195
- Base. @propagate_inbounds function getidx (
196
- parent_space,
197
- bc:: StencilBroadcasted{CUDAWithShmemColumnStencilStyle} ,
198
- loc:: Operators.LeftBoundaryWindow ,
199
167
idx,
200
168
hidx,
201
169
)
@@ -204,63 +172,34 @@ Base.@propagate_inbounds function getidx(
204
172
return fd_operator_evaluate (
205
173
bc. op,
206
174
bc. work,
207
- loc,
208
175
space,
209
176
idx,
210
177
hidx,
211
178
bc. args... ,
212
179
)
213
180
end
214
181
op = bc. op
215
- if Operators. should_call_left_boundary (idx, space, loc, bc. op, bc. args... )
182
+ if Operators. should_call_left_boundary (idx, space, bc. op, bc. args... )
216
183
Operators. stencil_left_boundary (
217
184
op,
218
- Operators. get_boundary (op, loc),
219
- loc,
220
- space,
221
- idx,
222
- hidx,
223
- bc. args... ,
224
- )
225
- else
226
- # fallback to interior stencil
227
- Operators. stencil_interior (op, loc, space, idx, hidx, bc. args... )
228
- end
229
- end
230
-
231
- Base. @propagate_inbounds function getidx (
232
- parent_space,
233
- bc:: StencilBroadcasted{CUDAWithShmemColumnStencilStyle} ,
234
- loc:: Operators.RightBoundaryWindow ,
235
- idx,
236
- hidx,
237
- )
238
- space = axes (bc)
239
- if Operators. fd_shmem_is_supported (bc)
240
- return fd_operator_evaluate (
241
- bc. op,
242
- bc. work,
243
- loc,
185
+ Operators. get_boundary (op, Operators. left_boundary_window (space)),
244
186
space,
245
187
idx,
246
188
hidx,
247
189
bc. args... ,
248
190
)
249
- end
250
- op = bc. op
251
- if Operators. should_call_right_boundary (idx, space, loc, bc. op, bc. args... )
191
+ elseif Operators. should_call_right_boundary (idx, space, bc. op, bc. args... )
252
192
Operators. stencil_right_boundary (
253
193
op,
254
- Operators. get_boundary (op, loc),
255
- loc,
194
+ Operators. get_boundary (op, Operators. right_boundary_window (space)),
256
195
space,
257
196
idx,
258
197
hidx,
259
198
bc. args... ,
260
199
)
261
200
else
262
201
# fallback to interior stencil
263
- Operators. stencil_interior (op, loc, space, idx, hidx, bc. args... )
202
+ Operators. stencil_interior (op, space, idx, hidx, bc. args... )
264
203
end
265
204
end
266
205
@@ -375,9 +314,6 @@ Base.@propagate_inbounds function fd_resolve_shmem!(
375
314
)
376
315
(li, lw, rw, ri) = bds
377
316
space = axes (sbc)
378
-
379
- ᶜspace = Spaces. center_space (space)
380
- ᶠspace = Spaces. face_space (space)
381
317
arg_space = get_arg_space (sbc, sbc. args)
382
318
ᶜidx = get_cent_idx (idx)
383
319
ᶠidx = get_face_idx (idx)
@@ -387,13 +323,6 @@ Base.@propagate_inbounds function fd_resolve_shmem!(
387
323
# After recursion, check if shmem is supported for this operator
388
324
Operators. fd_shmem_is_supported (sbc) || return nothing
389
325
390
- (; op) = sbc
391
- lloc = Operators. LeftBoundaryWindow {Spaces.left_boundary_name(space)} ()
392
- rloc = Operators. RightBoundaryWindow {Spaces.right_boundary_name(space)} ()
393
- iloc = Operators. Interior ()
394
-
395
- IP = Topologies. isperiodic (Spaces. vertical_topology (space))
396
-
397
326
# There are `Nf` threads, where `Nf` is the number of face levels. So,
398
327
# each thread is responsible for filling shared memory at its cell center
399
328
# (if the broadcasted argument lives on cell centers)
@@ -403,52 +332,18 @@ Base.@propagate_inbounds function fd_resolve_shmem!(
403
332
# (the space of all broadcasted arguments must all match, so using the first is valid).
404
333
405
334
bc_bds = Operators. window_bounds (space, sbc)
406
- (bc_li, bc_lw, bc_rw, bc_ri) = bc_bds
407
335
ᵃidx = arg_space isa Operators. AllFaceFiniteDifferenceSpace ? ᶠidx : ᶜidx
408
336
409
- if in_interior (ᵃidx, arg_space, bc_bds, sbc. op, sbc. args... )
410
- fd_operator_fill_shmem! (
411
- sbc. op,
412
- sbc. work,
413
- iloc,
414
- bc_bds,
415
- arg_space,
416
- space,
417
- ᵃidx,
418
- hidx,
419
- sbc. args... ,
420
- )
421
- elseif in_left_boundary_window (ᵃidx, arg_space, bc_bds, sbc. op, sbc. args... )
422
- fd_operator_fill_shmem! (
423
- sbc. op,
424
- sbc. work,
425
- lloc,
426
- bc_bds,
427
- arg_space,
428
- space,
429
- ᵃidx,
430
- hidx,
431
- sbc. args... ,
432
- )
433
- elseif in_right_boundary_window (
434
- ᵃidx,
435
- arg_space,
436
- bc_bds,
337
+ fd_operator_fill_shmem! (
437
338
sbc. op,
339
+ sbc. work,
340
+ bc_bds,
341
+ arg_space,
342
+ space,
343
+ ᵃidx,
344
+ hidx,
438
345
sbc. args... ,
439
346
)
440
- fd_operator_fill_shmem! (
441
- sbc. op,
442
- sbc. work,
443
- rloc,
444
- bc_bds,
445
- arg_space,
446
- space,
447
- ᵃidx,
448
- hidx,
449
- sbc. args... ,
450
- )
451
- end
452
347
CUDA. sync_threads ()
453
348
return nothing
454
349
end
0 commit comments