16 #ifndef LIFOSTORAGE_HPP
17 #define LIFOSTORAGE_HPP
22 #include <condition_variable>
23 #include <camp/camp.hpp>
29 #include "common/GEOS_RAJA_Interface.hpp"
31 #include "common/LifoStorageCommon.hpp"
32 #include "common/LifoStorageHost.hpp"
34 #include "common/LifoStorageCuda.hpp"
42 template<
typename T,
typename INDEX_TYPE >
61 LifoStorage(
std::string name,
size_t elemCnt,
int numberOfBuffersToStoreOnDevice,
int numberOfBuffersToStoreOnHost,
int maxNumberOfBuffers ):
62 m_maxNumberOfBuffers( maxNumberOfBuffers ),
63 m_bufferSize( elemCnt*sizeof( T ) ),
66 LIFO_LOG_RANK(
" LIFO : maximum size "<< m_maxNumberOfBuffers <<
" buffers " );
67 double bufferSize = ( ( double ) m_bufferSize ) / ( 1024.0 * 1024.0 );
68 LIFO_LOG_RANK(
" LIFO : buffer size "<< bufferSize <<
"MB" );
69 if( numberOfBuffersToStoreOnDevice < 0 )
74 numberOfBuffersToStoreOnDevice = 0;
77 if( numberOfBuffersToStoreOnHost < 0 )
79 numberOfBuffersToStoreOnHost =
82 LIFO_LOG_RANK(
" LIFO : allocating "<< numberOfBuffersToStoreOnHost <<
" buffers on host" );
83 LIFO_LOG_RANK(
" LIFO : allocating "<< numberOfBuffersToStoreOnDevice <<
" buffers on device" );
85 if( numberOfBuffersToStoreOnDevice > 0 )
87 m_lifo = std::make_unique< LifoStorageCuda< T, INDEX_TYPE > >( name, elemCnt, numberOfBuffersToStoreOnDevice, numberOfBuffersToStoreOnHost, maxNumberOfBuffers );
92 m_lifo = std::make_unique< LifoStorageHost< T, INDEX_TYPE > >( name, elemCnt, numberOfBuffersToStoreOnHost, maxNumberOfBuffers );
107 LifoStorage( name, array.size(), numberOfBuffersToStoreOnDevice, numberOfBuffersToStoreOnHost, maxNumberOfBuffers ) {}
117 m_lifo->pushAsync( array );
149 m_lifo->popAsyncPrelude();
150 m_lifo->popAsync( array );
181 return m_lifo->empty();
186 int m_maxNumberOfBuffers;
193 std::unique_ptr< LifoStorageCommon< T, INDEX_TYPE > > m_lifo;
static int computeNumberOfBufferOnHost(int percent, size_t bufferSize, int maxNumberOfBuffers, int numberOfBuffersToStoreOnDevice)
static int computeNumberOfBufferOnDevice(int percent, size_t bufferSize, int maxNumberOfBuffers)
void push(arrayView1d< T > array)
void pushAsync(arrayView1d< T > array)
LifoStorage(std::string name, arrayView1d< T > array, int numberOfBuffersToStoreOnDevice, int numberOfBuffersToStoreOnHost, int maxNumberOfBuffers)
void pop(arrayView1d< T > array)
void popAsync(arrayView1d< T > array)
LifoStorage(std::string name, size_t elemCnt, int numberOfBuffersToStoreOnDevice, int numberOfBuffersToStoreOnHost, int maxNumberOfBuffers)
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
std::string string
String type.