OmniSciDB  5ade3759e0
Buffer_Namespace::GpuCudaBuffer Class Reference

#include <GpuCudaBuffer.h>

+ Inheritance diagram for Buffer_Namespace::GpuCudaBuffer:
+ Collaboration diagram for Buffer_Namespace::GpuCudaBuffer:

Public Member Functions

 GpuCudaBuffer (BufferMgr *bm, BufferList::iterator segIt, const int deviceId, CudaMgr_Namespace::CudaMgr *cudaMgr, const size_t pageSize=512, const size_t numBytes=0)
 
Data_Namespace::MemoryLevel getType () const override
 
- Public Member Functions inherited from Buffer_Namespace::Buffer
 Buffer (BufferMgr *bm, BufferList::iterator segIt, const int deviceId, const size_t pageSize=512, const size_t numBytes=0)
 Constructs a Buffer object. The constructor requires a memory address (provided by BufferMgr), number of pages, and the size in bytes of each page. Additionally, the Buffer can be initialized with an epoch. More...
 
 ~Buffer () override
 Destructor. More...
 
void read (int8_t *const dst, const size_t numBytes, const size_t offset=0, const MemoryLevel dstBufferType=CPU_LEVEL, const int deviceId=-1) override
 Reads (copies) data from the buffer to the destination (dst) memory location. Reads (copies) nbytes of data from the buffer, beginning at the specified byte offset, into the destination (dst) memory location. More...
 
void reserve (const size_t numBytes) override
 
void write (int8_t *src, const size_t numBytes, const size_t offset=0, const MemoryLevel srcBufferType=CPU_LEVEL, const int deviceId=-1) override
 Writes (copies) data from src into the buffer. Writes (copies) nbytes of data into the buffer at the specified byte offset, from the source (src) memory location. More...
 
void append (int8_t *src, const size_t numBytes, const MemoryLevel srcBufferType=CPU_LEVEL, const int deviceId=-1) override
 
int8_t * getMemoryPtr () override
 Returns a raw, constant (read-only) pointer to the underlying buffer. More...
 
size_t size () const override
 
size_t reservedSize () const override
 Returns the total number of bytes allocated for the buffer. More...
 
size_t pageCount () const override
 Returns the number of pages in the buffer. More...
 
size_t pageSize () const override
 Returns the size in bytes of each page in the buffer. More...
 
bool isDirty () const override
 Returns whether or not the buffer has been modified since the last flush/checkpoint. More...
 
int pin () override
 
int unPin () override
 
int getPinCount () override
 
- Public Member Functions inherited from Data_Namespace::AbstractBuffer
 AbstractBuffer (const int deviceId)
 
 AbstractBuffer (const int deviceId, const SQLTypeInfo sqlType)
 
virtual ~AbstractBuffer ()
 
virtual int getDeviceId () const
 
virtual bool isAppended () const
 
virtual bool isUpdated () const
 
virtual void setDirty ()
 
virtual void setUpdated ()
 
virtual void setAppended ()
 
void setSize (const size_t size)
 
void clearDirtyBits ()
 
void initEncoder (const SQLTypeInfo tmpSqlType)
 
void syncEncoder (const AbstractBuffer *srcBuffer)
 

Private Member Functions

void readData (int8_t *const dst, const size_t numBytes, const size_t offset=0, const MemoryLevel dstBufferType=CPU_LEVEL, const int dstDeviceId=-1) override
 
void writeData (int8_t *const src, const size_t numBytes, const size_t offset=0, const MemoryLevel srcBufferType=CPU_LEVEL, const int srcDeviceId=-1) override
 

Private Attributes

CudaMgr_Namespace::CudaMgrcudaMgr_
 

Additional Inherited Members

- Public Attributes inherited from Data_Namespace::AbstractBuffer
std::unique_ptr< Encoderencoder
 
bool hasEncoder
 
SQLTypeInfo sqlType
 
- Protected Attributes inherited from Buffer_Namespace::Buffer
int8_t * mem_
 
- Protected Attributes inherited from Data_Namespace::AbstractBuffer
size_t size_
 
bool isDirty_
 
bool isAppended_
 
bool isUpdated_
 
int deviceId_
 

Detailed Description

Definition at line 27 of file GpuCudaBuffer.h.

Constructor & Destructor Documentation

◆ GpuCudaBuffer()

Buffer_Namespace::GpuCudaBuffer::GpuCudaBuffer ( BufferMgr bm,
BufferList::iterator  segIt,
const int  deviceId,
CudaMgr_Namespace::CudaMgr cudaMgr,
const size_t  pageSize = 512,
const size_t  numBytes = 0 
)

Definition at line 25 of file GpuCudaBuffer.cpp.

31  : Buffer(bm, segIt, deviceId, pageSize, numBytes), cudaMgr_(cudaMgr) {}
Buffer(BufferMgr *bm, BufferList::iterator segIt, const int deviceId, const size_t pageSize=512, const size_t numBytes=0)
Constructs a Buffer object. The constructor requires a memory address (provided by BufferMgr)...
Definition: Buffer.cpp:35
size_t pageSize() const override
Returns the size in bytes of each page in the buffer.
Definition: Buffer.h:129
CudaMgr_Namespace::CudaMgr * cudaMgr_
Definition: GpuCudaBuffer.h:50

Member Function Documentation

◆ getType()

Data_Namespace::MemoryLevel Buffer_Namespace::GpuCudaBuffer::getType ( ) const
inlineoverridevirtual

◆ readData()

void Buffer_Namespace::GpuCudaBuffer::readData ( int8_t *const  dst,
const size_t  numBytes,
const size_t  offset = 0,
const MemoryLevel  dstBufferType = CPU_LEVEL,
const int  dstDeviceId = -1 
)
overrideprivatevirtual

Implements Buffer_Namespace::Buffer.

Definition at line 33 of file GpuCudaBuffer.cpp.

References CudaMgr_Namespace::CudaMgr::copyDeviceToDevice(), CudaMgr_Namespace::CudaMgr::copyDeviceToHost(), Data_Namespace::CPU_LEVEL, cudaMgr_, Data_Namespace::AbstractBuffer::deviceId_, logger::FATAL, Data_Namespace::GPU_LEVEL, LOG, and Buffer_Namespace::Buffer::mem_.

37  {
38  if (dstBufferType == CPU_LEVEL) {
40  dst, mem_ + offset, numBytes, deviceId_); // need to replace 0 with gpu num
41  } else if (dstBufferType == GPU_LEVEL) {
42  //@todo fill this in
43  // CudaUtils::copyGpuToGpu(dst, mem_ + offset, numBytes, 1, dst->getDeviceId());
44  //@todo, populate device id
45  // CudaUtils::copyGpuToGpu(dst, mem_ + offset, numBytes, 1, 0);
46  cudaMgr_->copyDeviceToDevice(dst, mem_ + offset, numBytes, dstDeviceId, deviceId_);
47 
48  } else {
49  LOG(FATAL) << "Unsupported buffer type";
50  }
51 }
void copyDeviceToHost(int8_t *host_ptr, const int8_t *device_ptr, const size_t num_bytes, const int device_num)
Definition: CudaMgr.cpp:80
#define LOG(tag)
Definition: Logger.h:182
void copyDeviceToDevice(int8_t *dest_ptr, int8_t *src_ptr, const size_t num_bytes, const int dest_device_num, const int src_device_num)
Definition: CudaMgr.cpp:89
CudaMgr_Namespace::CudaMgr * cudaMgr_
Definition: GpuCudaBuffer.h:50
+ Here is the call graph for this function:

◆ writeData()

void Buffer_Namespace::GpuCudaBuffer::writeData ( int8_t *const  src,
const size_t  numBytes,
const size_t  offset = 0,
const MemoryLevel  srcBufferType = CPU_LEVEL,
const int  srcDeviceId = -1 
)
overrideprivatevirtual

Implements Buffer_Namespace::Buffer.

Definition at line 53 of file GpuCudaBuffer.cpp.

References CudaMgr_Namespace::CudaMgr::copyDeviceToDevice(), CudaMgr_Namespace::CudaMgr::copyHostToDevice(), Data_Namespace::CPU_LEVEL, cudaMgr_, Data_Namespace::AbstractBuffer::deviceId_, logger::FATAL, Data_Namespace::GPU_LEVEL, LOG, and Buffer_Namespace::Buffer::mem_.

57  {
58  if (srcBufferType == CPU_LEVEL) {
59  // std::cout << "Writing to GPU from source CPU" << std::endl;
60 
62  mem_ + offset, src, numBytes, deviceId_); // need to replace 0 with gpu num
63 
64  } else if (srcBufferType == GPU_LEVEL) {
65  // std::cout << "Writing to GPU from source GPU" << std::endl;
66  assert(srcDeviceId >= 0);
67  cudaMgr_->copyDeviceToDevice(mem_ + offset, src, numBytes, deviceId_, srcDeviceId);
68  // CudaUtils::copyGpuToGpu(mem_ + offset, src, numBytes, 1, deviceId_);
69  //@todo fill this in
70  } else {
71  LOG(FATAL) << "Unsupported buffer type";
72  }
73 }
#define LOG(tag)
Definition: Logger.h:182
int64_t * src
void copyDeviceToDevice(int8_t *dest_ptr, int8_t *src_ptr, const size_t num_bytes, const int dest_device_num, const int src_device_num)
Definition: CudaMgr.cpp:89
void copyHostToDevice(int8_t *device_ptr, const int8_t *host_ptr, const size_t num_bytes, const int device_num)
Definition: CudaMgr.cpp:71
CudaMgr_Namespace::CudaMgr * cudaMgr_
Definition: GpuCudaBuffer.h:50
+ Here is the call graph for this function:

Member Data Documentation

◆ cudaMgr_

CudaMgr_Namespace::CudaMgr* Buffer_Namespace::GpuCudaBuffer::cudaMgr_
private

Definition at line 50 of file GpuCudaBuffer.h.

Referenced by readData(), and writeData().


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