Commit 4dab9be
Support periodic vertical topologies in eager FD kernel
The eager FD path rewrites vertical FD operators into band-matrix
multiplies, evaluated by row_mul_vec!/row_mul_mat! against the operand
stored in a linear shared-memory buffer. Those reads used a bounds guard
that zero-pads out-of-range neighbors, which is only correct for
non-periodic columns; for periodic columns the seam levels read the
wrap-around neighbor as 0 instead of wrapping to the opposite end.
- column_matrix_helpers.jl: add _banded_vec_entry/_banded_mat_entry and
use them across all 12 row_mul_*! methods. For periodic columns they
wrap the operand index with mod1(ix, blockDim().x) and always
contribute (and skip the output-band truncation); non-periodic columns
keep the existing zero-padding guard. Periodicity is a compile-time
constant threaded in from the vertical topology.
- operators_fd_eager.jl: add has_padding_thread(space) (the unused
last-thread exists only for non-periodic center output, since periodic
center/face have equal nlevels) and gate the v == blockDim().x guards
on it; pass periodic = isperiodic(space) to the row_mul call sites.
- operators_finite_difference.jl: gate the eager launch on !high_resolution
instead of !isperiodic, so both periodic and non-periodic low-resolution
columns use the eager kernel; high-resolution columns still fall back to
copyto_stencil_kernel!.
Validated on an A100 (sb env, Julia 1.10.5): periodic extruded
cubed-sphere CPU-vs-GPU matches for C2F/F2C operators, a nested transport
expression, and a band-matrix product (12/12 tests, Float32 and Float64);
non-periodic large ClimaAtmos-style expressions still pass 26/26.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LHZcz51UUA6zvdMLap8Ns31 parent 90d7f1c commit 4dab9be
3 files changed
Lines changed: 145 additions & 113 deletions
0 commit comments