OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Buffer_Namespace::GpuCudaBufferMgr Class Reference

#include <GpuCudaBufferMgr.h>

+ Inheritance diagram for Buffer_Namespace::GpuCudaBufferMgr:
+ Collaboration diagram for Buffer_Namespace::GpuCudaBufferMgr:

Public Member Functions

 GpuCudaBufferMgr (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=0)
 
MgrType getMgrType () override
 
std::string getStringMgrType () override
 
 ~GpuCudaBufferMgr () override
 
- 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
 

Private Member Functions

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

Private Attributes

CudaMgr_Namespace::CudaMgrcuda_mgr_
 

Additional Inherited Members

- 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_
 

Detailed Description

Definition at line 27 of file GpuCudaBufferMgr.h.

Constructor & Destructor Documentation

Buffer_Namespace::GpuCudaBufferMgr::GpuCudaBufferMgr ( 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 = 0 
)

Definition at line 25 of file GpuCudaBufferMgr.cpp.

33  : BufferMgr(device_id,
34  max_buffer_pool_size,
35  min_slab_size,
36  max_slab_size,
37  default_slab_size,
38  page_size,
39  parent_mgr)
40  , cuda_mgr_(cuda_mgr) {}
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_
Buffer_Namespace::GpuCudaBufferMgr::~GpuCudaBufferMgr ( )
override

Definition at line 42 of file GpuCudaBufferMgr.cpp.

References cuda_mgr_, logger::ERROR, freeAllMem(), LOG, and CudaMgr_Namespace::CudaMgr::synchronizeDevices().

42  {
43  try {
45  freeAllMem();
46 #ifdef HAVE_CUDA
47  } catch (const CudaMgr_Namespace::CudaErrorException& e) {
48  if (e.getStatus() == CUDA_ERROR_DEINITIALIZED) {
49  // TODO(adb / asuhan): Verify cuModuleUnload removes the context
50  return;
51  }
52 #endif
53  } catch (const std::runtime_error& e) {
54  LOG(ERROR) << "CUDA Error: " << e.what();
55  }
56 }
#define LOG(tag)
Definition: Logger.h:285
CudaMgr_Namespace::CudaMgr * cuda_mgr_
void synchronizeDevices() const
Definition: CudaMgr.cpp:120

+ Here is the call graph for this function:

Member Function Documentation

void Buffer_Namespace::GpuCudaBufferMgr::addSlab ( const size_t  slab_size)
overrideprivatevirtual

Implements Buffer_Namespace::BufferMgr.

Definition at line 58 of file GpuCudaBufferMgr.cpp.

References CudaMgr_Namespace::CudaMgr::allocateDeviceMem(), cuda_mgr_, Buffer_Namespace::BufferMgr::page_size_, Buffer_Namespace::BufferMgr::slab_segments_, and Buffer_Namespace::BufferMgr::slabs_.

58  {
59  slabs_.resize(slabs_.size() + 1);
60  try {
61  slabs_.back() =
62  cuda_mgr_->allocateDeviceMem(slab_size, device_id_, /* is_slab */ true);
63  } catch (std::runtime_error& error) {
64  slabs_.resize(slabs_.size() - 1);
65  throw FailedToCreateSlab(slab_size);
66  }
67  slab_segments_.resize(slab_segments_.size() + 1);
68  slab_segments_[slab_segments_.size() - 1].push_back(
69  BufferSeg(0, slab_size / page_size_));
70 }
std::vector< BufferList > slab_segments_
Definition: BufferMgr.h:184
CudaMgr_Namespace::CudaMgr * cuda_mgr_
virtual int8_t * allocateDeviceMem(const size_t num_bytes, const int device_num, const bool is_slab=false)
Definition: CudaMgr.cpp:333
std::vector< int8_t * > slabs_
Definition: BufferMgr.h:182

+ Here is the call graph for this function:

void Buffer_Namespace::GpuCudaBufferMgr::allocateBuffer ( BufferList::iterator  seg_it,
const size_t  page_size,
const size_t  initial_size 
)
overrideprivatevirtual

Implements Buffer_Namespace::BufferMgr.

Definition at line 78 of file GpuCudaBufferMgr.cpp.

References cuda_mgr_.

80  {
81  new GpuCudaBuffer(this,
82  seg_it,
83  device_id_,
84  cuda_mgr_,
85  page_size,
86  initial_size); // this line is admittedly a bit weird
87  // but the segment iterator passed into
88  // buffer takes the address of the new
89  // Buffer in its buffer member
90 }
CudaMgr_Namespace::CudaMgr * cuda_mgr_
void Buffer_Namespace::GpuCudaBufferMgr::freeAllMem ( )
overrideprivatevirtual

Implements Buffer_Namespace::BufferMgr.

Definition at line 72 of file GpuCudaBufferMgr.cpp.

References cuda_mgr_, CudaMgr_Namespace::CudaMgr::freeDeviceMem(), and Buffer_Namespace::BufferMgr::slabs_.

Referenced by ~GpuCudaBufferMgr().

72  {
73  for (auto buf_it = slabs_.begin(); buf_it != slabs_.end(); ++buf_it) {
74  cuda_mgr_->freeDeviceMem(*buf_it);
75  }
76 }
void freeDeviceMem(int8_t *device_ptr)
Definition: CudaMgr.cpp:392
CudaMgr_Namespace::CudaMgr * cuda_mgr_
std::vector< int8_t * > slabs_
Definition: BufferMgr.h:182

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

MgrType Buffer_Namespace::GpuCudaBufferMgr::getMgrType ( )
inlineoverride

Definition at line 37 of file GpuCudaBufferMgr.h.

37 { return GPU_MGR; }
std::string Buffer_Namespace::GpuCudaBufferMgr::getStringMgrType ( )
inlineoverride

Definition at line 38 of file GpuCudaBufferMgr.h.

38 { return ToString(GPU_MGR); }

Member Data Documentation

CudaMgr_Namespace::CudaMgr* Buffer_Namespace::GpuCudaBufferMgr::cuda_mgr_
private

Definition at line 47 of file GpuCudaBufferMgr.h.

Referenced by addSlab(), allocateBuffer(), freeAllMem(), and ~GpuCudaBufferMgr().


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