OmniSciDB  95562058bd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CudaAllocator Class Reference

#include <CudaAllocator.h>

+ Inheritance diagram for CudaAllocator:
+ Collaboration diagram for CudaAllocator:

Public Member Functions

 CudaAllocator (Data_Namespace::DataMgr *data_mgr, const int device_id)
 
 ~CudaAllocator () override
 
int8_t * alloc (const size_t num_bytes) override
 
void free (Data_Namespace::AbstractBuffer *ab) const override
 
void copyToDevice (int8_t *device_dst, const int8_t *host_src, const size_t num_bytes) const override
 
void copyFromDevice (int8_t *host_dst, const int8_t *device_src, const size_t num_bytes) const override
 
void zeroDeviceMem (int8_t *device_ptr, const size_t num_bytes) const override
 
void setDeviceMem (int8_t *device_ptr, unsigned char uc, const size_t num_bytes) const override
 
- Public Member Functions inherited from Allocator
 Allocator ()
 
virtual ~Allocator ()
 

Static Public Member Functions

static
Data_Namespace::AbstractBuffer
allocGpuAbstractBuffer (Data_Namespace::DataMgr *data_mgr, const size_t num_bytes, const int device_id)
 
static void freeGpuAbstractBuffer (Data_Namespace::DataMgr *data_mgr, Data_Namespace::AbstractBuffer *ab)
 

Private Attributes

std::vector
< Data_Namespace::AbstractBuffer * > 
owned_buffers_
 
Data_Namespace::DataMgrdata_mgr_
 
int device_id_
 

Detailed Description

Definition at line 43 of file CudaAllocator.h.

Constructor & Destructor Documentation

CudaAllocator::CudaAllocator ( Data_Namespace::DataMgr data_mgr,
const int  device_id 
)

Definition at line 24 of file CudaAllocator.cpp.

References CHECK, data_mgr_, and Data_Namespace::DataMgr::getCudaMgr().

25  : data_mgr_(data_mgr), device_id_(device_id) {
27 #ifdef HAVE_CUDA
28  const auto cuda_mgr = data_mgr_->getCudaMgr();
29  CHECK(cuda_mgr);
30  cuda_mgr->setContext(device_id);
31 #endif // HAVE_CUDA
32 }
CudaMgr_Namespace::CudaMgr * getCudaMgr() const
Definition: DataMgr.h:208
Data_Namespace::DataMgr * data_mgr_
Definition: CudaAllocator.h:78
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the call graph for this function:

CudaAllocator::~CudaAllocator ( )
override

Definition at line 34 of file CudaAllocator.cpp.

References CHECK, data_mgr_, Data_Namespace::DataMgr::free(), and owned_buffers_.

34  {
36  for (auto& buffer_ptr : owned_buffers_) {
37  data_mgr_->free(buffer_ptr);
38  }
39 }
Data_Namespace::DataMgr * data_mgr_
Definition: CudaAllocator.h:78
std::vector< Data_Namespace::AbstractBuffer * > owned_buffers_
Definition: CudaAllocator.h:76
#define CHECK(condition)
Definition: Logger.h:197
void free(AbstractBuffer *buffer)
Definition: DataMgr.cpp:461

+ Here is the call graph for this function:

Member Function Documentation

int8_t * CudaAllocator::alloc ( const size_t  num_bytes)
overridevirtual

Implements Allocator.

Definition at line 57 of file CudaAllocator.cpp.

References allocGpuAbstractBuffer(), CHECK, data_mgr_, device_id_, and owned_buffers_.

Referenced by OverlapsJoinHashTable::approximateTupleCount(), BaselineJoinHashTable::approximateTupleCount(), anonymous_namespace{TableFunctionExecutionContext.cpp}::create_literal_buffer(), OverlapsJoinHashTable::initHashTableOnGpu(), BaselineJoinHashTable::initHashTableOnGpu(), transfer_flat_object_to_gpu(), and transfer_vector_of_flat_objects_to_gpu().

57  {
59  owned_buffers_.emplace_back(
61  return owned_buffers_.back()->getMemoryPtr();
62 }
Data_Namespace::DataMgr * data_mgr_
Definition: CudaAllocator.h:78
std::vector< Data_Namespace::AbstractBuffer * > owned_buffers_
Definition: CudaAllocator.h:76
static Data_Namespace::AbstractBuffer * allocGpuAbstractBuffer(Data_Namespace::DataMgr *data_mgr, const size_t num_bytes, const int device_id)
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Data_Namespace::AbstractBuffer * CudaAllocator::allocGpuAbstractBuffer ( Data_Namespace::DataMgr data_mgr,
const size_t  num_bytes,
const int  device_id 
)
static

Definition at line 41 of file CudaAllocator.cpp.

References Data_Namespace::DataMgr::alloc(), CHECK, CHECK_EQ, and Data_Namespace::GPU_LEVEL.

Referenced by alloc(), ThrustAllocator::allocate(), ThrustAllocator::allocateScopedBuffer(), BaselineJoinHashTable::initHashTableForDevice(), JoinHashTable::initOneToManyHashTable(), JoinHashTable::initOneToOneHashTable(), and InValuesBitmap::InValuesBitmap().

44  {
45  CHECK(data_mgr);
46  auto ab = data_mgr->alloc(Data_Namespace::GPU_LEVEL, device_id, num_bytes);
47  CHECK_EQ(ab->getPinCount(), 1);
48  return ab;
49 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
#define CHECK(condition)
Definition: Logger.h:197
AbstractBuffer * alloc(const MemoryLevel memoryLevel, const int deviceId, const size_t numBytes)
Definition: DataMgr.cpp:452

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CudaAllocator::copyFromDevice ( int8_t *  host_dst,
const int8_t *  device_src,
const size_t  num_bytes 
) const
overridevirtual

Implements DeviceAllocator.

Definition at line 76 of file CudaAllocator.cpp.

References CHECK, data_mgr_, device_id_, and Data_Namespace::DataMgr::getCudaMgr().

Referenced by OverlapsJoinHashTable::computeBucketSizes().

78  {
79  const auto cuda_mgr = data_mgr_->getCudaMgr();
80  CHECK(cuda_mgr);
81  cuda_mgr->copyDeviceToHost(host_dst, device_src, num_bytes, device_id_);
82 }
CudaMgr_Namespace::CudaMgr * getCudaMgr() const
Definition: DataMgr.h:208
Data_Namespace::DataMgr * data_mgr_
Definition: CudaAllocator.h:78
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CudaAllocator::copyToDevice ( int8_t *  device_dst,
const int8_t *  host_src,
const size_t  num_bytes 
) const
overridevirtual

Implements DeviceAllocator.

Definition at line 68 of file CudaAllocator.cpp.

References CHECK, data_mgr_, device_id_, and Data_Namespace::DataMgr::getCudaMgr().

Referenced by anonymous_namespace{TableFunctionExecutionContext.cpp}::create_literal_buffer(), transfer_flat_object_to_gpu(), and transfer_vector_of_flat_objects_to_gpu().

70  {
71  const auto cuda_mgr = data_mgr_->getCudaMgr();
72  CHECK(cuda_mgr);
73  cuda_mgr->copyHostToDevice(device_dst, host_src, num_bytes, device_id_);
74 }
CudaMgr_Namespace::CudaMgr * getCudaMgr() const
Definition: DataMgr.h:208
Data_Namespace::DataMgr * data_mgr_
Definition: CudaAllocator.h:78
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CudaAllocator::free ( Data_Namespace::AbstractBuffer ab) const
overridevirtual

Implements DeviceAllocator.

Definition at line 64 of file CudaAllocator.cpp.

References data_mgr_, and Data_Namespace::DataMgr::free().

64  {
65  data_mgr_->free(ab);
66 }
Data_Namespace::DataMgr * data_mgr_
Definition: CudaAllocator.h:78
void free(AbstractBuffer *buffer)
Definition: DataMgr.cpp:461

+ Here is the call graph for this function:

void CudaAllocator::freeGpuAbstractBuffer ( Data_Namespace::DataMgr data_mgr,
Data_Namespace::AbstractBuffer ab 
)
static

Definition at line 51 of file CudaAllocator.cpp.

References CHECK, and Data_Namespace::DataMgr::free().

Referenced by JoinHashTable::freeHashBufferGpuMemory(), and BaselineJoinHashTable::freeHashBufferGpuMemory().

52  {
53  CHECK(data_mgr);
54  data_mgr->free(ab);
55 }
#define CHECK(condition)
Definition: Logger.h:197
void free(AbstractBuffer *buffer)
Definition: DataMgr.cpp:461

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CudaAllocator::setDeviceMem ( int8_t *  device_ptr,
unsigned char  uc,
const size_t  num_bytes 
) const
overridevirtual

Implements DeviceAllocator.

Definition at line 90 of file CudaAllocator.cpp.

References CHECK, data_mgr_, device_id_, and Data_Namespace::DataMgr::getCudaMgr().

92  {
93  const auto cuda_mgr = data_mgr_->getCudaMgr();
94  CHECK(cuda_mgr);
95  cuda_mgr->setDeviceMem(device_ptr, uc, num_bytes, device_id_);
96 }
CudaMgr_Namespace::CudaMgr * getCudaMgr() const
Definition: DataMgr.h:208
Data_Namespace::DataMgr * data_mgr_
Definition: CudaAllocator.h:78
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the call graph for this function:

void CudaAllocator::zeroDeviceMem ( int8_t *  device_ptr,
const size_t  num_bytes 
) const
overridevirtual

Implements DeviceAllocator.

Definition at line 84 of file CudaAllocator.cpp.

References CHECK, data_mgr_, device_id_, and Data_Namespace::DataMgr::getCudaMgr().

84  {
85  const auto cuda_mgr = data_mgr_->getCudaMgr();
86  CHECK(cuda_mgr);
87  cuda_mgr->zeroDeviceMem(device_ptr, num_bytes, device_id_);
88 }
CudaMgr_Namespace::CudaMgr * getCudaMgr() const
Definition: DataMgr.h:208
Data_Namespace::DataMgr * data_mgr_
Definition: CudaAllocator.h:78
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the call graph for this function:

Member Data Documentation

Data_Namespace::DataMgr* CudaAllocator::data_mgr_
private
int CudaAllocator::device_id_
private

Definition at line 79 of file CudaAllocator.h.

Referenced by alloc(), copyFromDevice(), copyToDevice(), setDeviceMem(), and zeroDeviceMem().

std::vector<Data_Namespace::AbstractBuffer*> CudaAllocator::owned_buffers_
private

Definition at line 76 of file CudaAllocator.h.

Referenced by alloc(), and ~CudaAllocator().


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