OmniSciDB  04ee39c94c
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 int8_t * alloc (Data_Namespace::DataMgr *data_mgr, const size_t num_bytes, const int device_id)
 
static Data_Namespace::AbstractBufferallocGpuAbstractBuffer (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

Data_Namespace::DataMgrdata_mgr_
 
int device_id_
 

Detailed Description

Definition at line 43 of file CudaAllocator.h.

Constructor & Destructor Documentation

◆ CudaAllocator()

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

Definition at line 25 of file CudaAllocator.cpp.

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

26  : data_mgr_(data_mgr), device_id_(device_id) {
28 #ifdef HAVE_CUDA
29  const auto cuda_mgr = data_mgr_->getCudaMgr();
30  CHECK(cuda_mgr);
31  cuda_mgr->setContext(device_id);
32 #endif // HAVE_CUDA
33 }
Data_Namespace::DataMgr * data_mgr_
Definition: CudaAllocator.h:80
CudaMgr_Namespace::CudaMgr * getCudaMgr() const
Definition: DataMgr.h:116
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:

◆ ~CudaAllocator()

CudaAllocator::~CudaAllocator ( )
inlineoverride

Definition at line 47 of file CudaAllocator.h.

47 {}

Member Function Documentation

◆ alloc() [1/2]

int8_t * CudaAllocator::alloc ( Data_Namespace::DataMgr data_mgr,
const size_t  num_bytes,
const int  device_id 
)
static

Definition at line 35 of file CudaAllocator.cpp.

References allocGpuAbstractBuffer(), and CHECK.

Referenced by alloc(), ColumnFetcher::getOneTableColumnFragment(), InValuesBitmap::InValuesBitmap(), ResultSet::ResultSet(), and ColumnFetcher::transferColumnIfNeeded().

37  {
38  CHECK(data_mgr);
39  auto ab = CudaAllocator::allocGpuAbstractBuffer(data_mgr, num_bytes, device_id);
40  return ab->getMemoryPtr();
41 }
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:187
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ alloc() [2/2]

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

Implements Allocator.

Definition at line 59 of file CudaAllocator.cpp.

References alloc(), data_mgr_, and device_id_.

59  {
60  return CudaAllocator::alloc(data_mgr_, num_bytes, device_id_);
61 }
Data_Namespace::DataMgr * data_mgr_
Definition: CudaAllocator.h:80
static int8_t * alloc(Data_Namespace::DataMgr *data_mgr, const size_t num_bytes, const int device_id)
+ Here is the call graph for this function:

◆ allocGpuAbstractBuffer()

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

Definition at line 43 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::initHashTableForDevice(), and JoinHashTable::initOneToManyHashTable().

46  {
47  CHECK(data_mgr);
48  auto ab = data_mgr->alloc(Data_Namespace::GPU_LEVEL, device_id, num_bytes);
49  CHECK_EQ(ab->getPinCount(), 1);
50  return ab;
51 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
#define CHECK(condition)
Definition: Logger.h:187
AbstractBuffer * alloc(const MemoryLevel memoryLevel, const int deviceId, const size_t numBytes)
Definition: DataMgr.cpp:374
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyFromDevice()

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

Implements DeviceAllocator.

Definition at line 75 of file CudaAllocator.cpp.

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

77  {
78  const auto cuda_mgr = data_mgr_->getCudaMgr();
79  CHECK(cuda_mgr);
80  cuda_mgr->copyDeviceToHost(host_dst, device_src, num_bytes, device_id_);
81 }
Data_Namespace::DataMgr * data_mgr_
Definition: CudaAllocator.h:80
CudaMgr_Namespace::CudaMgr * getCudaMgr() const
Definition: DataMgr.h:116
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:

◆ copyToDevice()

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

Implements DeviceAllocator.

Definition at line 67 of file CudaAllocator.cpp.

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

69  {
70  const auto cuda_mgr = data_mgr_->getCudaMgr();
71  CHECK(cuda_mgr);
72  cuda_mgr->copyHostToDevice(device_dst, host_src, num_bytes, device_id_);
73 }
Data_Namespace::DataMgr * data_mgr_
Definition: CudaAllocator.h:80
CudaMgr_Namespace::CudaMgr * getCudaMgr() const
Definition: DataMgr.h:116
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:

◆ free()

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

Implements DeviceAllocator.

Definition at line 63 of file CudaAllocator.cpp.

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

63  {
64  data_mgr_->free(ab);
65 }
Data_Namespace::DataMgr * data_mgr_
Definition: CudaAllocator.h:80
void free(AbstractBuffer *buffer)
Definition: DataMgr.cpp:382
+ Here is the call graph for this function:

◆ freeGpuAbstractBuffer()

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

Definition at line 53 of file CudaAllocator.cpp.

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

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

54  {
55  CHECK(data_mgr);
56  data_mgr->free(ab);
57 }
#define CHECK(condition)
Definition: Logger.h:187
void free(AbstractBuffer *buffer)
Definition: DataMgr.cpp:382
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDeviceMem()

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

Implements DeviceAllocator.

Definition at line 89 of file CudaAllocator.cpp.

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

91  {
92  const auto cuda_mgr = data_mgr_->getCudaMgr();
93  CHECK(cuda_mgr);
94  cuda_mgr->setDeviceMem(device_ptr, uc, num_bytes, device_id_);
95 }
Data_Namespace::DataMgr * data_mgr_
Definition: CudaAllocator.h:80
CudaMgr_Namespace::CudaMgr * getCudaMgr() const
Definition: DataMgr.h:116
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:

◆ zeroDeviceMem()

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

Implements DeviceAllocator.

Definition at line 83 of file CudaAllocator.cpp.

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

83  {
84  const auto cuda_mgr = data_mgr_->getCudaMgr();
85  CHECK(cuda_mgr);
86  cuda_mgr->zeroDeviceMem(device_ptr, num_bytes, device_id_);
87 }
Data_Namespace::DataMgr * data_mgr_
Definition: CudaAllocator.h:80
CudaMgr_Namespace::CudaMgr * getCudaMgr() const
Definition: DataMgr.h:116
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:

Member Data Documentation

◆ data_mgr_

Data_Namespace::DataMgr* CudaAllocator::data_mgr_
private

◆ device_id_

int CudaAllocator::device_id_
private

Definition at line 81 of file CudaAllocator.h.

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


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