Mundy: Multibody Nonlocal Dynamics Version of the Day
Loading...
Searching...
No Matches
mundy::NgpPoolT< DataType, MemorySpace, SizeType > Class Template Reference

NgpPoolT is a Kokkos-compatible pool of default constructible objects.

#include <NgpPool.hpp>

Inheritance diagram for mundy::NgpPoolT< DataType, MemorySpace, SizeType >:
[legend]

Public Types

using memory_space = MemorySpace
using execution_space = typename MemorySpace::execution_space
using pool_vector_t = std::vector<DataType>
using pool_view_t = NgpViewT<DataType*, MemorySpace>
using value_type = DataType
using our_size_t = SizeType

Public Member Functions

 NgpPoolT ()
 NgpPoolT (our_size_t capacity)
 ~NgpPoolT ()=default
 NgpPoolT (const NgpPoolT &)=default
NgpPoolToperator= (const NgpPoolT &)=default
 NgpPoolT (NgpPoolT &&)=default
NgpPoolToperator= (NgpPoolT &&)=default
Accessors
our_size_t capacity () const
our_size_t capacity_host () const
our_size_t size () const
our_size_t size_host () const
void reserve (our_size_t requested_capacity)
value_type acquire () const
 Acquire a value from the pool. Returns by move. Modifies on device but does not mark as modified. It's up to you to mark the pool as modified on the device after using this.
value_type acquire_host () const
 Acquire a value from the pool. Returns by move. Modifies on host but does not mark as modified. It's up to you to mark the pool as modified on the host after using this.
void add (value_type p) const
 Add an object into the pool. Modifies on device but does not mark as modified.
void add_host (value_type p) const
 Add an object into the pool. Modifies on host but does not mark as modified.
pool_view_t batch_acquire (our_size_t n)
 Acquire N objects from the pool. Returns by move. Modifies on device and marks as modified. Results are returned in an NgpViewT<ValueType, MemorySpace>.
pool_vector_t batch_acquire_host (our_size_t n)
 Acquire N objects from the pool. Returns by move. Modifies on host and marks as modified. Results are returned in an std::vector<ValueType>.
void batch_add (pool_view_t p)
 Add N objects into the pool. Modifies on device and marks as modified.
void batch_add_host (pool_vector_t p)
 Add N objects into the pool. Modifies on host and marks as modified.
Ngp interface
void modify_on_host ()
 Mark the host pool as modified.
void modify_on_device ()
 Mark the device pool as modified.
template<typename Space>
void modify_on ()
 Abstract method for marking the pool as modified.
void sync_to_host ()
 Synchronize the host pool to the device pool if needed.
void sync_to_device ()
 Synchronize the device pool to the host pool if needed.
template<typename Space>
void sync_to ()
 Abstract method for synchronizing the pool.
bool need_sync_to_host () const
 Return if we need to sync to the host.
bool need_sync_to_device () const
 Return if we need to sync to the device.
template<typename Space>
bool need_sync_to () const
 Abstract method for checking if we need to sync.

Member Typedef Documentation

◆ memory_space

template<class DataType, typename MemorySpace, typename SizeType = size_t>
using mundy::NgpPoolT< DataType, MemorySpace, SizeType >::memory_space = MemorySpace

◆ execution_space

template<class DataType, typename MemorySpace, typename SizeType = size_t>
using mundy::NgpPoolT< DataType, MemorySpace, SizeType >::execution_space = typename MemorySpace::execution_space

◆ pool_vector_t

template<class DataType, typename MemorySpace, typename SizeType = size_t>
using mundy::NgpPoolT< DataType, MemorySpace, SizeType >::pool_vector_t = std::vector<DataType>

◆ pool_view_t

template<class DataType, typename MemorySpace, typename SizeType = size_t>
using mundy::NgpPoolT< DataType, MemorySpace, SizeType >::pool_view_t = NgpViewT<DataType*, MemorySpace>

◆ value_type

template<class DataType, typename MemorySpace, typename SizeType = size_t>
using mundy::NgpPoolT< DataType, MemorySpace, SizeType >::value_type = DataType

◆ our_size_t

template<class DataType, typename MemorySpace, typename SizeType = size_t>
using mundy::NgpPoolT< DataType, MemorySpace, SizeType >::our_size_t = SizeType

Constructor & Destructor Documentation

◆ NgpPoolT() [1/4]

template<class DataType, typename MemorySpace, typename SizeType = size_t>
mundy::NgpPoolT< DataType, MemorySpace, SizeType >::NgpPoolT ( )
inline

◆ NgpPoolT() [2/4]

template<class DataType, typename MemorySpace, typename SizeType = size_t>
mundy::NgpPoolT< DataType, MemorySpace, SizeType >::NgpPoolT ( our_size_t capacity)
inline

◆ ~NgpPoolT()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
mundy::NgpPoolT< DataType, MemorySpace, SizeType >::~NgpPoolT ( )
default

◆ NgpPoolT() [3/4]

template<class DataType, typename MemorySpace, typename SizeType = size_t>
mundy::NgpPoolT< DataType, MemorySpace, SizeType >::NgpPoolT ( const NgpPoolT< DataType, MemorySpace, SizeType > & )
default

◆ NgpPoolT() [4/4]

template<class DataType, typename MemorySpace, typename SizeType = size_t>
mundy::NgpPoolT< DataType, MemorySpace, SizeType >::NgpPoolT ( NgpPoolT< DataType, MemorySpace, SizeType > && )
default

Member Function Documentation

◆ operator=() [1/2]

template<class DataType, typename MemorySpace, typename SizeType = size_t>
NgpPoolT & mundy::NgpPoolT< DataType, MemorySpace, SizeType >::operator= ( const NgpPoolT< DataType, MemorySpace, SizeType > & )
default

◆ operator=() [2/2]

template<class DataType, typename MemorySpace, typename SizeType = size_t>
NgpPoolT & mundy::NgpPoolT< DataType, MemorySpace, SizeType >::operator= ( NgpPoolT< DataType, MemorySpace, SizeType > && )
default

◆ capacity()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
our_size_t mundy::NgpPoolT< DataType, MemorySpace, SizeType >::capacity ( ) const
inline

◆ capacity_host()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
our_size_t mundy::NgpPoolT< DataType, MemorySpace, SizeType >::capacity_host ( ) const
inline

◆ size()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
our_size_t mundy::NgpPoolT< DataType, MemorySpace, SizeType >::size ( ) const
inline

◆ size_host()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
our_size_t mundy::NgpPoolT< DataType, MemorySpace, SizeType >::size_host ( ) const
inline

◆ reserve()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
void mundy::NgpPoolT< DataType, MemorySpace, SizeType >::reserve ( our_size_t requested_capacity)
inline

◆ acquire()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
value_type mundy::NgpPoolT< DataType, MemorySpace, SizeType >::acquire ( ) const
inline

Something to be aware of: This function is const because a KOKKOS_LAMBDA will const capture this class making acquire on the device impossible otherwise. This is why we mark size, capacity, and our internal pool as mutable.

◆ acquire_host()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
value_type mundy::NgpPoolT< DataType, MemorySpace, SizeType >::acquire_host ( ) const
inline

◆ add()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
void mundy::NgpPoolT< DataType, MemorySpace, SizeType >::add ( value_type p) const
inline

◆ add_host()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
void mundy::NgpPoolT< DataType, MemorySpace, SizeType >::add_host ( value_type p) const
inline

◆ batch_acquire()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
pool_view_t mundy::NgpPoolT< DataType, MemorySpace, SizeType >::batch_acquire ( our_size_t n)
inline

◆ batch_acquire_host()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
pool_vector_t mundy::NgpPoolT< DataType, MemorySpace, SizeType >::batch_acquire_host ( our_size_t n)
inline

◆ batch_add()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
void mundy::NgpPoolT< DataType, MemorySpace, SizeType >::batch_add ( pool_view_t p)
inline

◆ batch_add_host()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
void mundy::NgpPoolT< DataType, MemorySpace, SizeType >::batch_add_host ( pool_vector_t p)
inline

◆ modify_on_host()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
void mundy::NgpPoolT< DataType, MemorySpace, SizeType >::modify_on_host ( )
inline

Call this method after updating the host pool so that the NgpPoolT is aware that the device pool may now be out of date.

◆ modify_on_device()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
void mundy::NgpPoolT< DataType, MemorySpace, SizeType >::modify_on_device ( )
inline

Call this method after updating the device pool so that the NgpPoolT is aware that the host pool may now be out of date.

◆ modify_on()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
template<typename Space>
void mundy::NgpPoolT< DataType, MemorySpace, SizeType >::modify_on ( )
inline

◆ sync_to_host()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
void mundy::NgpPoolT< DataType, MemorySpace, SizeType >::sync_to_host ( )
inline

If the device pool has been modified more recently than the host pool, this function performs a deep copy from the device pool to the host pool.

◆ sync_to_device()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
void mundy::NgpPoolT< DataType, MemorySpace, SizeType >::sync_to_device ( )
inline

If the host pool has been modified more recently than the device pool, this function performs a deep copy from the host pool to the device pool.

◆ sync_to()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
template<typename Space>
void mundy::NgpPoolT< DataType, MemorySpace, SizeType >::sync_to ( )
inline

◆ need_sync_to_host()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
bool mundy::NgpPoolT< DataType, MemorySpace, SizeType >::need_sync_to_host ( ) const
inline

◆ need_sync_to_device()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
bool mundy::NgpPoolT< DataType, MemorySpace, SizeType >::need_sync_to_device ( ) const
inline

◆ need_sync_to()

template<class DataType, typename MemorySpace, typename SizeType = size_t>
template<typename Space>
bool mundy::NgpPoolT< DataType, MemorySpace, SizeType >::need_sync_to ( ) const
inline