OmniSciDB  04ee39c94c
Buffer_Namespace::CpuBufferMgr Class Reference

#include <CpuBufferMgr.h>

+ Inheritance diagram for Buffer_Namespace::CpuBufferMgr:
+ Collaboration diagram for Buffer_Namespace::CpuBufferMgr:

Public Member Functions

 CpuBufferMgr (const int deviceId, const size_t maxBufferSize, CudaMgr_Namespace::CudaMgr *cudaMgr, const size_t bufferAllocIncrement=2147483648, const size_t pageSize=512, AbstractBufferMgr *parentMgr=0)
 
MgrType getMgrType () override
 
std::string getStringMgrType () override
 
 ~CpuBufferMgr () override
 
- Public Member Functions inherited from Buffer_Namespace::BufferMgr
 BufferMgr (const int deviceId, const size_t maxBufferSize, const size_t maxSlabSize=2147483648, const size_t pageSize=512, AbstractBufferMgr *parentMgr=0)
 Constructs a BufferMgr object that allocates memSize bytes. More...
 
 ~BufferMgr () override
 Destructor. More...
 
void reinit ()
 
void clear ()
 
std::string printSlab (size_t slabNum)
 
std::string printSlabs () override
 
void clearSlabs () override
 
std::string printMap ()
 
void printSegs ()
 
std::string printSeg (BufferList::iterator &segIt)
 
std::string keyToString (const ChunkKey &key)
 
size_t getInUseSize () override
 
size_t getMaxSize () override
 
size_t getAllocated () override
 
size_t getMaxBufferSize ()
 
size_t getMaxSlabSize ()
 
size_t getPageSize ()
 
bool isAllocationCapped () override
 
const std::vector< BufferList > & getSlabSegments ()
 
AbstractBuffercreateBuffer (const ChunkKey &key, const size_t pageSize=0, const size_t initialSize=0) override
 Creates a chunk with the specified key and page size. More...
 
void deleteBuffer (const ChunkKey &key, const bool purge=true) override
 Deletes the chunk with the specified key. More...
 
void deleteBuffersWithPrefix (const ChunkKey &keyPrefix, const bool purge=true) override
 
AbstractBuffergetBuffer (const ChunkKey &key, const size_t numBytes=0) override
 Returns the a pointer to the chunk with the specified key. More...
 
bool isBufferOnDevice (const ChunkKey &key) override
 Puts the contents of d into the Buffer with ChunkKey key. More...
 
void fetchBuffer (const ChunkKey &key, AbstractBuffer *destBuffer, const size_t numBytes=0) override
 
AbstractBufferputBuffer (const ChunkKey &key, AbstractBuffer *d, const size_t numBytes=0) override
 
void checkpoint () override
 
void checkpoint (const int db_id, const int tb_id) override
 
AbstractBufferalloc (const size_t numBytes=0) override
 client is responsible for deleting memory allocated for b->mem_ More...
 
void free (AbstractBuffer *buffer) override
 
size_t size ()
 Returns the total number of bytes allocated. More...
 
size_t getNumChunks () override
 
BufferList::iterator reserveBuffer (BufferList::iterator &segIt, const size_t numBytes)
 
void getChunkMetadataVec (std::vector< std::pair< ChunkKey, ChunkMetadata >> &chunkMetadataVec) override
 
void getChunkMetadataVecForKeyPrefix (std::vector< std::pair< ChunkKey, ChunkMetadata >> &chunkMetadataVec, const ChunkKey &keyPrefix) override
 

Private Member Functions

void addSlab (const size_t slabSize) override
 
void freeAllMem () override
 
void allocateBuffer (BufferList::iterator segIt, const size_t pageSize, const size_t initialSize) override
 

Private Attributes

CudaMgr_Namespace::CudaMgrcudaMgr_
 

Additional Inherited Members

- Protected Attributes inherited from Buffer_Namespace::BufferMgr
std::vector< int8_t * > slabs_
 
std::vector< BufferListslabSegments_
 
size_t pageSize_
 

Detailed Description

Definition at line 28 of file CpuBufferMgr.h.

Constructor & Destructor Documentation

◆ CpuBufferMgr()

Buffer_Namespace::CpuBufferMgr::CpuBufferMgr ( const int  deviceId,
const size_t  maxBufferSize,
CudaMgr_Namespace::CudaMgr cudaMgr,
const size_t  bufferAllocIncrement = 2147483648,
const size_t  pageSize = 512,
AbstractBufferMgr parentMgr = 0 
)

Definition at line 23 of file CpuBufferMgr.cpp.

29  : BufferMgr(deviceId, maxBufferSize, bufferAllocIncrement, pageSize, parentMgr)
30  , cudaMgr_(cudaMgr) {}
CudaMgr_Namespace::CudaMgr * cudaMgr_
Definition: CpuBufferMgr.h:46
BufferMgr(const int deviceId, const size_t maxBufferSize, const size_t maxSlabSize=2147483648, const size_t pageSize=512, AbstractBufferMgr *parentMgr=0)
Constructs a BufferMgr object that allocates memSize bytes.
Definition: BufferMgr.cpp:46

◆ ~CpuBufferMgr()

Buffer_Namespace::CpuBufferMgr::~CpuBufferMgr ( )
override

Definition at line 32 of file CpuBufferMgr.cpp.

References freeAllMem().

32  {
33  freeAllMem();
34 }
+ Here is the call graph for this function:

Member Function Documentation

◆ addSlab()

void Buffer_Namespace::CpuBufferMgr::addSlab ( const size_t  slabSize)
overrideprivatevirtual

Implements Buffer_Namespace::BufferMgr.

Definition at line 36 of file CpuBufferMgr.cpp.

References Buffer_Namespace::BufferMgr::pageSize_, Buffer_Namespace::BufferMgr::slabs_, and Buffer_Namespace::BufferMgr::slabSegments_.

36  {
37  slabs_.resize(slabs_.size() + 1);
38  try {
39  slabs_.back() = new int8_t[slabSize];
40  } catch (std::bad_alloc&) {
41  slabs_.resize(slabs_.size() - 1);
42  throw FailedToCreateSlab(slabSize);
43  }
44  slabSegments_.resize(slabSegments_.size() + 1);
45  slabSegments_[slabSegments_.size() - 1].push_back(BufferSeg(0, slabSize / pageSize_));
46 }
std::vector< int8_t * > slabs_
Definition: BufferMgr.h:176
std::vector< BufferList > slabSegments_
Definition: BufferMgr.h:178

◆ allocateBuffer()

void Buffer_Namespace::CpuBufferMgr::allocateBuffer ( BufferList::iterator  segIt,
const size_t  pageSize,
const size_t  initialSize 
)
overrideprivatevirtual

Implements Buffer_Namespace::BufferMgr.

Definition at line 54 of file CpuBufferMgr.cpp.

References cudaMgr_.

56  {
57  new CpuBuffer(this,
58  segIt,
59  deviceId_,
60  cudaMgr_,
61  pageSize,
62  initialSize); // this line is admittedly a bit weird but
63  // the segment iterator passed into buffer
64  // takes the address of the new Buffer in its
65  // buffer member
66 }
CudaMgr_Namespace::CudaMgr * cudaMgr_
Definition: CpuBufferMgr.h:46

◆ freeAllMem()

void Buffer_Namespace::CpuBufferMgr::freeAllMem ( )
overrideprivatevirtual

Implements Buffer_Namespace::BufferMgr.

Definition at line 48 of file CpuBufferMgr.cpp.

References Buffer_Namespace::BufferMgr::slabs_.

Referenced by ~CpuBufferMgr().

48  {
49  for (auto bufIt = slabs_.begin(); bufIt != slabs_.end(); ++bufIt) {
50  delete[] * bufIt;
51  }
52 }
std::vector< int8_t * > slabs_
Definition: BufferMgr.h:176
+ Here is the caller graph for this function:

◆ getMgrType()

MgrType Buffer_Namespace::CpuBufferMgr::getMgrType ( )
inlineoverride

Definition at line 36 of file CpuBufferMgr.h.

36 { return CPU_MGR; }

◆ getStringMgrType()

std::string Buffer_Namespace::CpuBufferMgr::getStringMgrType ( )
inlineoverride

Definition at line 37 of file CpuBufferMgr.h.

37 { return ToString(CPU_MGR); }

Member Data Documentation

◆ cudaMgr_

CudaMgr_Namespace::CudaMgr* Buffer_Namespace::CpuBufferMgr::cudaMgr_
private

Definition at line 46 of file CpuBufferMgr.h.

Referenced by allocateBuffer().


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