GEOSX
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
geos::LifoStorageCommon< T, INDEX_TYPE > Class Template Referenceabstract

#include <LifoStorageCommon.hpp>

Inheritance diagram for geos::LifoStorageCommon< T, INDEX_TYPE >:
Inheritance graph
[legend]

Public Member Functions

 LifoStorageCommon (std::string name, size_t elemCnt, int numberOfBuffersToStoreOnHost, int maxNumberOfBuffers)
 
virtual void pushAsync (arrayView1d< T > array)=0
 
virtual void pushWait ()=0
 
virtual void popAsync (arrayView1d< T > array)=0
 
void popAsyncPrelude ()
 
virtual void popWait ()=0
 
bool empty ()
 

Static Public Member Functions

static int computeNumberOfBufferOnHost (int percent, size_t bufferSize, int maxNumberOfBuffers, int numberOfBuffersToStoreOnDevice)
 

Protected Member Functions

void hostToDisk (int id)
 
void diskToHost (int id)
 
bool dirExists (const std::string &dirName)
 
void writeOnDisk (const T *d, int id)
 
void readOnDisk (T *d, int id)
 

Protected Attributes

int m_maxNumberOfBuffers
 number of buffers to be inserted into the LIFO
 
size_t m_bufferSize
 size of one buffer in bytes
 
std::string m_name
 name used to store data on disk
 
FixedSizeDequeWithMutexes< T, INDEX_TYPE > m_hostDeque
 Queue of data stored on host memory.
 
int m_bufferCount
 counter of buffer stored in LIFO
 
int m_bufferToHostCount
 counter of buffer pushed to host
 
int m_bufferToDiskCount
 counter of buffer pushed to disk
 
std::condition_variable m_task_queue_not_empty_cond [2]
 condition used to tell m_worker queue has been filled or processed is stopped.
 
std::mutex m_task_queue_mutex [2]
 mutex to protect access to m_task_queue.
 
std::deque< std::packaged_task< void() > > m_task_queue [2]
 queue of task to be executed by m_worker.
 
std::thread m_worker [2]
 thread to execute tasks.
 
bool m_continue
 boolean to keep m_worker alive.
 
bool m_hasPoppedBefore
 marker to detect first pop
 

Detailed Description

template<typename T, typename INDEX_TYPE>
class geos::LifoStorageCommon< T, INDEX_TYPE >

This class is used to store in a LIFO way buffers, first on device, then on host, then on disk.

Definition at line 49 of file LifoStorageCommon.hpp.

Constructor & Destructor Documentation

◆ LifoStorageCommon()

template<typename T , typename INDEX_TYPE >
geos::LifoStorageCommon< T, INDEX_TYPE >::LifoStorageCommon ( std::string  name,
size_t  elemCnt,
int  numberOfBuffersToStoreOnHost,
int  maxNumberOfBuffers 
)
inline

A LIFO storage will store numberOfBuffersToStoreDevice buffer on deevice, numberOfBuffersToStoreHost on host and the rest on disk.

Parameters
namePrefix of the files used to save the occurenncy of the saved buffer on disk.
elemCntNumber of elments in the LvArray we want to store in the LIFO storage.
numberOfBuffersToStoreOnHostMaximum number of array to store on host memory ( -1 = use 80% of remaining memory ).
maxNumberOfBuffersNumber of arrays expected to be stores in the LIFO.

Definition at line 63 of file LifoStorageCommon.hpp.

Member Function Documentation

◆ computeNumberOfBufferOnHost()

template<typename T , typename INDEX_TYPE >
static int geos::LifoStorageCommon< T, INDEX_TYPE >::computeNumberOfBufferOnHost ( int  percent,
size_t  bufferSize,
int  maxNumberOfBuffers,
int  numberOfBuffersToStoreOnDevice 
)
inlinestatic

Compute the number of arrays that can be stored on host

Parameters
percentPercentage of the remaining device memory that can be dedicated to the LIFO storage.
bufferSizeSize of one buffer
maxNumberOfBuffersMaximum number of buffers to store in the LIFO storage
numberOfBuffersToStoreOnDeviceThe number of buffer that will be stored on device by the LIFO.
Returns
The maximum number of buffer to allocate to fit in the percentage of the available memory.

Definition at line 155 of file LifoStorageCommon.hpp.

◆ dirExists()

template<typename T , typename INDEX_TYPE >
bool geos::LifoStorageCommon< T, INDEX_TYPE >::dirExists ( const std::string &  dirName)
inlineprotected

Checks if a directory exists.

Parameters
dirNameDirectory name to check existence of.
Returns
true is dirName exists and is a directory.

Definition at line 240 of file LifoStorageCommon.hpp.

◆ diskToHost()

template<typename T , typename INDEX_TYPE >
void geos::LifoStorageCommon< T, INDEX_TYPE >::diskToHost ( int  id)
inlineprotected

Copy data from disk to host memory

Parameters
idID of the buffer to read on disk.

Definition at line 223 of file LifoStorageCommon.hpp.

◆ empty()

template<typename T , typename INDEX_TYPE >
bool geos::LifoStorageCommon< T, INDEX_TYPE >::empty ( )
inline

Check if the LIFO is empty

Returns
true if the LIFO does not contain a buffer.

Definition at line 142 of file LifoStorageCommon.hpp.

◆ hostToDisk()

template<typename T , typename INDEX_TYPE >
void geos::LifoStorageCommon< T, INDEX_TYPE >::hostToDisk ( int  id)
inlineprotected

Copy data from host memory to disk

Parameters
idID of the buffer to store on disk.

Definition at line 207 of file LifoStorageCommon.hpp.

◆ popAsync()

template<typename T , typename INDEX_TYPE >
virtual void geos::LifoStorageCommon< T, INDEX_TYPE >::popAsync ( arrayView1d< T >  array)
pure virtual

Asynchroneously copy last data from the LIFO into the LvArray.

Parameters
arrayLvArray to store data from the LIFO into it.

Implemented in geos::LifoStorageHost< T, INDEX_TYPE >, and geos::LifoStorageCuda< T, INDEX_TYPE >.

◆ popAsyncPrelude()

template<typename T , typename INDEX_TYPE >
void geos::LifoStorageCommon< T, INDEX_TYPE >::popAsyncPrelude ( )
inline

Prelude for pop async

Definition at line 107 of file LifoStorageCommon.hpp.

◆ popWait()

template<typename T , typename INDEX_TYPE >
virtual void geos::LifoStorageCommon< T, INDEX_TYPE >::popWait ( )
pure virtual

Waits for last pop to be terminated

Implemented in geos::LifoStorageHost< T, INDEX_TYPE >, and geos::LifoStorageCuda< T, INDEX_TYPE >.

◆ pushAsync()

template<typename T , typename INDEX_TYPE >
virtual void geos::LifoStorageCommon< T, INDEX_TYPE >::pushAsync ( arrayView1d< T >  array)
pure virtual

Asynchroneously push a copy of the given LvArray into the LIFO

Parameters
arrayThe LvArray to store in the LIFO, should match the size of the data used in constructor.

Implemented in geos::LifoStorageCuda< T, INDEX_TYPE >, and geos::LifoStorageHost< T, INDEX_TYPE >.

◆ pushWait()

template<typename T , typename INDEX_TYPE >
virtual void geos::LifoStorageCommon< T, INDEX_TYPE >::pushWait ( )
pure virtual

Waits for last push to be terminated

Implemented in geos::LifoStorageHost< T, INDEX_TYPE >, and geos::LifoStorageCuda< T, INDEX_TYPE >.

◆ readOnDisk()

template<typename T , typename INDEX_TYPE >
void geos::LifoStorageCommon< T, INDEX_TYPE >::readOnDisk ( T *  d,
int  id 
)
inlineprotected

Read data from disk

Parameters
dBuffer to store data read from disk.
idID of the buffer on disk.

Definition at line 276 of file LifoStorageCommon.hpp.

◆ writeOnDisk()

template<typename T , typename INDEX_TYPE >
void geos::LifoStorageCommon< T, INDEX_TYPE >::writeOnDisk ( const T *  d,
int  id 
)
inlineprotected

Write data on disk

Parameters
dData to store on disk.
idID of the buffer to read on disk

Definition at line 252 of file LifoStorageCommon.hpp.


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