https://mooseframework.inl.gov
Public Member Functions | Private Attributes | List of all members
Moose::Kokkos::MemoryChunk< T > Class Template Reference

A temporary object returned by the Kokkos memory pool during memory chunk allocation. More...

#include <KokkosMemoryPool.h>

Public Member Functions

KOKKOS_FUNCTION MemoryChunk (const ::Kokkos::MemoryPool< MemSpace > &pool, dof_id_type size)
 Constructor. More...
 
KOKKOS_FUNCTION ~MemoryChunk ()
 Destructor. More...
 
KOKKOS_FUNCTION T * get () const
 Get the pointer to the chunk. More...
 

Private Attributes

const ::Kokkos::MemoryPool< MemSpace > & _pool
 Reference of the Kokkos memory pool. More...
 
const dof_id_type _size
 Memory chunk size in the number of bytes. More...
 
T * _ptr
 Pointer to the memory chunk. More...
 

Detailed Description

template<typename T>
class Moose::Kokkos::MemoryChunk< T >

A temporary object returned by the Kokkos memory pool during memory chunk allocation.

The instances of this class are expected to be only created by the Kokkos memory pool. This object holds the size and pointer to the memory chunk and allocates and deallocates the memory chunk upon its construction and destruction by interacting with the underlying memory pool. Therefore, the instance of this class returned by the Kokkos memory pool should be alive while the memory chunk is used.

Definition at line 31 of file KokkosMemoryPool.h.

Constructor & Destructor Documentation

◆ MemoryChunk()

template<typename T>
KOKKOS_FUNCTION Moose::Kokkos::MemoryChunk< T >::MemoryChunk ( const ::Kokkos::MemoryPool< MemSpace > &  pool,
dof_id_type  size 
)
inline

Constructor.

Parameters
poolThe Kokkos memory pool
sizeThe memory chunk size in the number of bytes

Definition at line 39 of file KokkosMemoryPool.h.

40  : _pool(pool), _size(size)
41  {
42  auto ptr = pool.allocate(size);
43 
44  KOKKOS_ASSERT(ptr);
45 
46  _ptr = static_cast<T *>(ptr);
47  }
T * _ptr
Pointer to the memory chunk.
const ::Kokkos::MemoryPool< MemSpace > & _pool
Reference of the Kokkos memory pool.
const dof_id_type _size
Memory chunk size in the number of bytes.

◆ ~MemoryChunk()

template<typename T>
KOKKOS_FUNCTION Moose::Kokkos::MemoryChunk< T >::~MemoryChunk ( )
inline

Destructor.

Definition at line 51 of file KokkosMemoryPool.h.

51 { _pool.deallocate(_ptr, _size); }
T * _ptr
Pointer to the memory chunk.
const ::Kokkos::MemoryPool< MemSpace > & _pool
Reference of the Kokkos memory pool.
const dof_id_type _size
Memory chunk size in the number of bytes.

Member Function Documentation

◆ get()

template<typename T>
KOKKOS_FUNCTION T* Moose::Kokkos::MemoryChunk< T >::get ( ) const
inline

Get the pointer to the chunk.

Returns
The pointer to the chunk

Definition at line 56 of file KokkosMemoryPool.h.

56 { return _ptr; }
T * _ptr
Pointer to the memory chunk.

Member Data Documentation

◆ _pool

template<typename T>
const ::Kokkos::MemoryPool<MemSpace>& Moose::Kokkos::MemoryChunk< T >::_pool
private

Reference of the Kokkos memory pool.

Definition at line 62 of file KokkosMemoryPool.h.

Referenced by Moose::Kokkos::MemoryChunk< T >::~MemoryChunk().

◆ _ptr

template<typename T>
T* Moose::Kokkos::MemoryChunk< T >::_ptr
private

◆ _size

template<typename T>
const dof_id_type Moose::Kokkos::MemoryChunk< T >::_size
private

Memory chunk size in the number of bytes.

Definition at line 66 of file KokkosMemoryPool.h.

Referenced by Moose::Kokkos::MemoryChunk< T >::~MemoryChunk().


The documentation for this class was generated from the following file: