Skip to content

[pull] develop from lammps:develop#157

Merged
pull[bot] merged 4 commits into
comphy-lab:developfrom
lammps:develop
Jun 26, 2026
Merged

[pull] develop from lammps:develop#157
pull[bot] merged 4 commits into
comphy-lab:developfrom
lammps:develop

Conversation

@pull

@pull pull Bot commented Jun 26, 2026

Copy link
Copy Markdown

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 : )

akohlmey and others added 4 commits June 3, 2026 11:32
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)
@pull pull Bot locked and limited conversation to collaborators Jun 26, 2026
@pull pull Bot added the ⤵️ pull label Jun 26, 2026
@pull pull Bot merged commit adc4296 into comphy-lab:develop Jun 26, 2026
1 check passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants