OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 device_id, const size_t max_buffer_pool_size, CudaMgr_Namespace::CudaMgr *cuda_mgr, const size_t min_slab_size, const size_t max_slab_size, const size_t default_slab_size, const size_t page_size, AbstractBufferMgr *parent_mgr=nullptr)
 
 ~CpuBufferMgr () override
 
MgrType getMgrType () override
 
std::string getStringMgrType () override
 
void setAllocator (std::unique_ptr< DramArena > allocator)
 
- Public Member Functions inherited from Buffer_Namespace::BufferMgr
 BufferMgr (const int device_id, const size_t max_buffer_size, const size_t min_slab_size, const size_t max_slab_size, const size_t default_slab_size, const size_t page_size, AbstractBufferMgr *parent_mgr=0)
 Constructs a BufferMgr object that allocates memSize bytes. More...
 
 ~BufferMgr () override
 Destructor. More...
 
std::string printSlab (size_t slab_num)
 
std::string printSlabs () override
 
void clearSlabs ()
 
std::string printMap ()
 
void printSegs ()
 
std::string printSeg (BufferList::iterator &seg_it)
 
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 page_size=0, const size_t initial_size=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 &key_prefix, const bool purge=true) override
 
AbstractBuffergetBuffer (const ChunkKey &key, const size_t num_bytes=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 *dest_buffer, const size_t num_bytes=0) override
 
AbstractBufferputBuffer (const ChunkKey &key, AbstractBuffer *d, const size_t num_bytes=0) override
 
void checkpoint () override
 
void checkpoint (const int db_id, const int tb_id) override
 
void removeTableRelatedDS (const int db_id, const int table_id) override
 
AbstractBufferalloc (const size_t num_bytes=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 &seg_it, const size_t num_bytes)
 
void getChunkMetadataVecForKeyPrefix (ChunkMetadataVector &chunk_metadata_vec, const ChunkKey &key_prefix) override
 

Protected Member Functions

void addSlab (const size_t slab_size) override
 
void freeAllMem () override
 
void allocateBuffer (BufferList::iterator segment_iter, const size_t page_size, const size_t initial_size) override
 
virtual void initializeMem ()
 

Protected Attributes

CudaMgr_Namespace::CudaMgrcuda_mgr_
 
- Protected Attributes inherited from Buffer_Namespace::BufferMgr
const size_t max_buffer_pool_size_
 
const size_t min_slab_size_
 max number of bytes allocated for the buffer pool More...
 
const size_t max_slab_size_
 
const size_t default_slab_size_
 
const size_t page_size_
 
std::vector< int8_t * > slabs_
 
std::vector< BufferListslab_segments_
 

Private Attributes

std::unique_ptr< DramArenaallocator_
 

Detailed Description

Definition at line 29 of file CpuBufferMgr.h.

Constructor & Destructor Documentation

Buffer_Namespace::CpuBufferMgr::CpuBufferMgr ( const int  device_id,
const size_t  max_buffer_pool_size,
CudaMgr_Namespace::CudaMgr cuda_mgr,
const size_t  min_slab_size,
const size_t  max_slab_size,
const size_t  default_slab_size,
const size_t  page_size,
AbstractBufferMgr parent_mgr = nullptr 
)
inline

Definition at line 31 of file CpuBufferMgr.h.

References initializeMem().

39  : BufferMgr(device_id,
40  max_buffer_pool_size,
41  min_slab_size,
42  max_slab_size,
43  default_slab_size,
44  page_size,
45  parent_mgr)
46  , cuda_mgr_(cuda_mgr) {
47  initializeMem();
48  }
BufferMgr(const int device_id, const size_t max_buffer_size, const size_t min_slab_size, const size_t max_slab_size, const size_t default_slab_size, const size_t page_size, AbstractBufferMgr *parent_mgr=0)
Constructs a BufferMgr object that allocates memSize bytes.
Definition: BufferMgr.cpp:47
CudaMgr_Namespace::CudaMgr * cuda_mgr_
Definition: CpuBufferMgr.h:70

+ Here is the call graph for this function:

Buffer_Namespace::CpuBufferMgr::~CpuBufferMgr ( )
inlineoverride

Definition at line 50 of file CpuBufferMgr.h.

50  {
51  /* the destruction of the allocator automatically frees all memory */
52  }

Member Function Documentation

void Buffer_Namespace::CpuBufferMgr::addSlab ( const size_t  slab_size)
overrideprotectedvirtual

Implements Buffer_Namespace::BufferMgr.

Reimplemented in Buffer_Namespace::TieredCpuBufferMgr.

Definition at line 25 of file CpuBufferMgr.cpp.

References allocator_, CHECK, Buffer_Namespace::BufferMgr::page_size_, Buffer_Namespace::BufferMgr::slab_segments_, and Buffer_Namespace::BufferMgr::slabs_.

25  {
27  slabs_.resize(slabs_.size() + 1);
28  try {
29  slabs_.back() = reinterpret_cast<int8_t*>(allocator_->allocate(slab_size));
30  } catch (std::bad_alloc&) {
31  slabs_.resize(slabs_.size() - 1);
32  throw FailedToCreateSlab(slab_size);
33  }
34  slab_segments_.resize(slab_segments_.size() + 1);
35  slab_segments_[slab_segments_.size() - 1].push_back(
36  BufferSeg(0, slab_size / page_size_));
37 }
std::unique_ptr< DramArena > allocator_
Definition: CpuBufferMgr.h:73
std::vector< BufferList > slab_segments_
Definition: BufferMgr.h:184
#define CHECK(condition)
Definition: Logger.h:291
std::vector< int8_t * > slabs_
Definition: BufferMgr.h:182
void Buffer_Namespace::CpuBufferMgr::allocateBuffer ( BufferList::iterator  segment_iter,
const size_t  page_size,
const size_t  initial_size 
)
overrideprotectedvirtual

Implements Buffer_Namespace::BufferMgr.

Definition at line 44 of file CpuBufferMgr.cpp.

References cuda_mgr_.

46  {
47  new CpuBuffer(this,
48  seg_it,
49  device_id_,
50  cuda_mgr_,
51  page_size,
52  initial_size); // this line is admittedly a bit weird but
53  // the segment iterator passed into buffer
54  // takes the address of the new Buffer in its
55  // buffer member
56 }
CudaMgr_Namespace::CudaMgr * cuda_mgr_
Definition: CpuBufferMgr.h:70
void Buffer_Namespace::CpuBufferMgr::freeAllMem ( )
overrideprotectedvirtual

Implements Buffer_Namespace::BufferMgr.

Reimplemented in Buffer_Namespace::TieredCpuBufferMgr.

Definition at line 39 of file CpuBufferMgr.cpp.

References allocator_, CHECK, and initializeMem().

39  {
41  initializeMem();
42 }
std::unique_ptr< DramArena > allocator_
Definition: CpuBufferMgr.h:73
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

MgrType Buffer_Namespace::CpuBufferMgr::getMgrType ( )
inlineoverride

Definition at line 54 of file CpuBufferMgr.h.

54 { return CPU_MGR; }
std::string Buffer_Namespace::CpuBufferMgr::getStringMgrType ( )
inlineoverride

Definition at line 55 of file CpuBufferMgr.h.

55 { return ToString(CPU_MGR); }
void Buffer_Namespace::CpuBufferMgr::initializeMem ( )
protectedvirtual

Reimplemented in Buffer_Namespace::TieredCpuBufferMgr.

Definition at line 58 of file CpuBufferMgr.cpp.

References allocator_, Buffer_Namespace::BufferMgr::default_slab_size_, and kArenaBlockOverhead.

Referenced by CpuBufferMgr(), and freeAllMem().

58  {
60 }
constexpr size_t kArenaBlockOverhead
std::unique_ptr< DramArena > allocator_
Definition: CpuBufferMgr.h:73
const size_t default_slab_size_
Definition: BufferMgr.h:179

+ Here is the caller graph for this function:

void Buffer_Namespace::CpuBufferMgr::setAllocator ( std::unique_ptr< DramArena allocator)
inline

Definition at line 58 of file CpuBufferMgr.h.

References allocator_.

58  {
59  allocator_ = std::move(allocator);
60  }
std::unique_ptr< DramArena > allocator_
Definition: CpuBufferMgr.h:73

Member Data Documentation

std::unique_ptr<DramArena> Buffer_Namespace::CpuBufferMgr::allocator_
private

Definition at line 73 of file CpuBufferMgr.h.

Referenced by addSlab(), freeAllMem(), initializeMem(), and setAllocator().

CudaMgr_Namespace::CudaMgr* Buffer_Namespace::CpuBufferMgr::cuda_mgr_
protected

Definition at line 70 of file CpuBufferMgr.h.

Referenced by allocateBuffer().


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