14 #ifndef LIFOSTORAGEHOST_HPP
15 #define LIFOSTORAGEHOST_HPP
20 #include <condition_variable>
21 #include <camp/camp.hpp>
27 #include "common/GEOS_RAJA_Interface.hpp"
29 #include "common/LifoStorageCommon.hpp"
36 template<
typename T,
typename INDEX_TYPE >
54 LifoStorageCommon< T, INDEX_TYPE >( name, elemCnt, numberOfBuffersToStoreOnHost, maxNumberOfBuffers ),
55 m_pushToHostFutures( maxNumberOfBuffers ),
56 m_popFromHostFutures( maxNumberOfBuffers )
70 "Cannot save on a Lifo without host storage (please set lifoSize, lifoOnDevice and lifoOnHost in xml file)" );
72 std::packaged_task< void() > task( std::bind( [
this ] (
int pushId,
arrayView1d< T > pushedArray ) {
77 LIFO_MARK_SCOPE( geosx::lifoStorage::pushAddTasks );
87 m_pushToHostFutures[id] = task.get_future();
115 std::packaged_task< void() > task( std::bind ( [
this ] (
arrayView1d< T > poppedArray ) {
120 LIFO_MARK_SCOPE( geosx::LifoStorageHost::popAddTasks );
130 m_popFromHostFutures[id] = task.get_future();
165 std::vector< std::future< void > > m_pushToHostFutures;
167 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.