Skip to content

Checkout api - #319

Merged
filoferra merged 2 commits into
JuliaParallel:mainfrom
filoferra:checkout-api
Oct 27, 2026
Merged

filoferra merged 2 commits into
JuliaParallel:mainfrom
filoferra:checkout-api

Conversation

@filoferra

Copy link
Copy Markdown
Collaborator

Two do-block checkouts that hand the arrays back when the block returns or throws.

  • with_local_arrays!(f!, g_fx, l_x) replaces the local_arrays / restore_local_arrays! pair, which left both Vecs checked out if anything threw in between. GPU placement (device arrays, host bounce buffer) is unchanged.
  • with_local_coordinate_array(f, dm) replaces local_coordinate_array, whose array was handed back by a finalizer. That crashed Julia when the DM was destroyed before the GC ran it; the old function now warns and returns a copy.

The old functions still work and warn. The CUDA path isn't exercised here (no GPU in CI or locally); its extension methods are unchanged.

with_local_arrays!(f!, g_fx, l_x) checks out both local arrays, on the device when a GPU extension is loaded, calls f!(fx, lx), and hands them back also when f! throws. local_arrays and restore_local_arrays! now warn: an exception between the two calls left both Vecs checked out.
with_local_coordinate_array(f, dm) calls f with the local coordinates of a DMDA or DMStag, addressed with global indices, and hands the array back when f returns or throws.
local_coordinate_array now warns and returns a copy: its array used to be handed back by a finalizer, which crashed Julia when the DM was destroyed first.
@filoferra
filoferra merged commit 957bc0d into JuliaParallel:main Oct 27, 2026
5 checks passed
@filoferra
filoferra deleted the checkout-api branch October 27, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant