16 #ifndef LIFOSTORAGEHOST_HPP
17 #define LIFOSTORAGEHOST_HPP
22 #include <condition_variable>
23 #include <camp/camp.hpp>
29 #include "common/GEOS_RAJA_Interface.hpp"
31 #include "common/LifoStorageCommon.hpp"
38 template<
typename T,
typename INDEX_TYPE >
56 LifoStorageCommon< T, INDEX_TYPE >( name, elemCnt, numberOfBuffersToStoreOnHost, maxNumberOfBuffers ),
57 m_pushToHostFutures( maxNumberOfBuffers ),
58 m_popFromHostFutures( maxNumberOfBuffers )
72 "Cannot save on a Lifo without host storage (please set lifoSize, lifoOnDevice and lifoOnHost in xml file)" );
74 std::packaged_task< void() > task( std::bind( [
this ] (
int pushId,
arrayView1d< T > pushedArray ) {
79 LIFO_MARK_SCOPE( geos::lifoStorage::pushAddTasks );
89 m_pushToHostFutures[id] = task.get_future();
117 std::packaged_task< void() > task( std::bind ( [
this ] (
arrayView1d< T > poppedArray ) {
122 LIFO_MARK_SCOPE( geos::LifoStorageHost::popAddTasks );
132 m_popFromHostFutures[id] = task.get_future();
167 std::vector< std::future< void > > m_pushToHostFutures;
169 std::vector< std::future< void > > m_popFromHostFutures;
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
#define GEOS_ERROR_IF(EXP, msg)
Conditionally raise a hard error and terminate the program.
int m_bufferCount
counter of buffer stored in LIFO
int m_bufferToDiskCount
counter of buffer pushed to disk
FixedSizeDequeWithMutexes< T, INDEX_TYPE > m_hostDeque
Queue of data stored on host memory.
std::deque< std::packaged_task< void() > > m_task_queue[2]
queue of task to be executed by m_worker.
std::mutex m_task_queue_mutex[2]
mutex to protect access to m_task_queue.
std::condition_variable m_task_queue_not_empty_cond[2]
condition used to tell m_worker queue has been filled or processed is stopped.
int m_maxNumberOfBuffers
number of buffers to be inserted into the LIFO
static int computeNumberOfBufferOnDevice(int percent, size_t bufferSize, int maxNumberOfBuffers)
LifoStorageHost(std::string name, size_t elemCnt, int numberOfBuffersToStoreOnHost, int maxNumberOfBuffers)
void popAsync(arrayView1d< T > array) override final
void pushAsync(arrayView1d< T > array) override final
void pushWait() override final
void popWait() override final
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
std::string string
String type.