[pull] develop from lammps:develop#157
Merged
Merged
Conversation
When running with the KOKKOS package and per-atom data residing on a device (e.g. a GPU), the library function lammps_extract_atom() (and the Python and Fortran wrappers built on it) returned a pointer to host data that could be stale. The host copy is only guaranteed current at output steps and at the end of a run, but extract_atom() may be called at arbitrary times -- e.g. from the LAMMPS GUI (which runs the simulation in a separate thread) or from a "python" command during a run. Make Atom::extract() virtual and override it in AtomKokkos: map the property name to the KOKKOS data mask of the dual view that holds it and sync(Host, mask) before delegating to Atom::extract(). Custom per-atom double vectors/arrays (d_*/d2_*) sync via DVECTOR_MASK. Names whose data is not device-resident fall through unchanged (their host copy is always current). The sync is a no-op when the host copy is already current, and atom->extract() is only called from the library interface, so there is no impact on hot code paths. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Builds on PR #5014. Its custom-data fallback matched "^d2?_" and synced DVECTOR_MASK for both d_ (dvector) and d2_ (darray), which syncs the wrong storage for d2_ and never handles i_/i2_. extract() sees four kinds of custom per-atom data (fix property/atom): i_ (ivector), d_ (dvector), i2_ (iarray), d2_ (darray). The fallback now matches the full "^[id]2?_" pattern (same as Atom::extract) and decodes the prefix to the matching mask: i_ -> IVECTOR_MASK d_ -> DVECTOR_MASK i2_ -> IARRAY_MASK d2_ -> DARRAY_MASK Groups all four custom masks together in atom_masks.h: moves DVECTOR_MASK out of the DPD section into a new "custom per-atom vectors and arrays" section alongside the new IVECTOR_MASK / IARRAY_MASK / DARRAY_MASK, and renumbers so the bit values stay contiguous and gap-free. Only dvector is currently device-resident, so the three new masks are no-ops for now, but using all four means extract() needs no change once that custom data is ported to the device. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Co-Authored-By: Stan Moore <stanmoore1@gmail.com> Claude-Session: https://claude.ai/code/session_01WvmBeBBxFmEGbgGo4eDZxu
KOKKOS: make extract_atom device-aware (sync to host before returning, #3945)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )