![]() |
Block-Structured AMR Software Framework
|
#include <AMReX_TrackedVector.H>
Public Types | |
| enum class | Status { up_to_date , device_dirty , host_dirty } |
| using | value_type = T |
| using | size_type = std::size_t |
| using | device_vector_type = amrex::Gpu::NonManagedDeviceVector< T > |
Public Member Functions | |
| TrackedVector ()=default | |
| TrackedVector (size_type a_size) | |
| TrackedVector (size_type a_size, value_type const &a_value) | |
| TrackedVector (std::initializer_list< T > a_initializer_list) | |
| TrackedVector (std::vector< T > a_vector) | |
| TrackedVector (TrackedVector const &a_vector) | |
| TrackedVector (TrackedVector &&a_vector) noexcept | |
| TrackedVector & | operator= (TrackedVector const &a_vector) |
| TrackedVector & | operator= (TrackedVector &&a_vector) noexcept |
| ~TrackedVector ()=default | |
| Status | status () const |
| std::vector< T > & | host () |
| std::vector< T > const & | host_const () const |
| device_vector_type & | device () |
| device_vector_type const & | device_const () const |
| void | release_gpu () |
Base for element data with dynamic host vectors mirrored lazily to GPU.
Provides lifetimes independent of AMReX initialize/finalize cycles, synchronization tracking, and data release APIs.
This object is primarily for input handling, allowing to initialize data even before AMReX was initialized and enabling workflows crossing AMReX init/finalize cycles. GPU memory will always be bound to an AMReX session, but CPU memory can be allocated and live arbitrarily long.
For AMReX CPU builds, the host and device members point to the same memory and the status will always be up to date.
Usage contract:
release_gpu() anytime, but we will call it during AMReX finalize to invalidate device().host_const, device_const) may trigger a synchronous copy when the opposite side is dirty. They are logically const but not side-effect-free._const variants) must be externally synchronized if used from multiple threads. | using amrex::Gpu::TrackedVector< T >::device_vector_type = amrex::Gpu::NonManagedDeviceVector<T> |
| using amrex::Gpu::TrackedVector< T >::size_type = std::size_t |
| using amrex::Gpu::TrackedVector< T >::value_type = T |
|
strong |
|
default |
|
inlineexplicit |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
Swap data of this and a_vector
|
default |
|
inline |
Return writable device data
If host data is newer, syncs host-to-device first. Marks device as dirty so the next host access will sync back.
|
inline |
Return read-only device data
If host data is newer, syncs host-to-device first.
|
inline |
Return writable host data
If device data is newer, syncs device-to-host first (GPU builds). Marks host as dirty so the next device access will sync back.
|
inline |
Return read-only host data
If device data is newer, syncs device-to-host first (GPU builds).
|
inlinenoexcept |
Swap the data of this and a_vector
|
inline |
Copy data from a_vector
|
inline |
Release GPU memory
If the device side was modified (device_dirty), syncs device data back to the host first so no updates are lost. Host data preserved for reuse until destructor. This enables use outside of and across AMReX init/finalize cycles.
|
inline |