OmniSciDB  95562058bd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 seg_it, const int device_id, CudaMgr_Namespace::CudaMgr *cuda_mgr, const size_t page_size=512, const size_t num_bytes=0)
 
Data_Namespace::MemoryLevel getType () const override
 
- Public Member Functions inherited from Buffer_Namespace::Buffer
 Buffer (BufferMgr *bm, BufferList::iterator seg_it, const int device_id, const size_t page_size=512, const size_t num_bytes=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 num_bytes, const size_t offset=0, const MemoryLevel dst_buffer_type=CPU_LEVEL, const int device_id=-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 num_bytes) override
 
void write (int8_t *src, const size_t num_bytes, const size_t offset=0, const MemoryLevel src_buffer_type=CPU_LEVEL, const int device_id=-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 num_bytes, const MemoryLevel src_buffer_type=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 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...
 
int pin () override
 
int unPin () override
 
int getPinCount () override
 
- Public Member Functions inherited from Data_Namespace::AbstractBuffer
 AbstractBuffer (const int device_id)
 
 AbstractBuffer (const int device_id, const SQLTypeInfo sql_type)
 
virtual ~AbstractBuffer ()
 
size_t size () const
 
int getDeviceId () const
 
bool isDirty () const
 
bool isAppended () const
 
bool isUpdated () const
 
bool hasEncoder () const
 
SQLTypeInfo getSqlType () const
 
void setSqlType (const SQLTypeInfo &sql_type)
 
EncodergetEncoder () const
 
void setDirty ()
 
void setUpdated ()
 
void setAppended ()
 
void setSize (const size_t size)
 
void clearDirtyBits ()
 
void initEncoder (const SQLTypeInfo &tmp_sql_type)
 
void syncEncoder (const AbstractBuffer *src_buffer)
 
void copyTo (AbstractBuffer *destination_buffer, const size_t num_bytes=0)
 
void resetToEmpty ()
 

Private Member Functions

void readData (int8_t *const dst, const size_t num_bytes, const size_t offset=0, const MemoryLevel dst_buffer_type=CPU_LEVEL, const int dst_devic_id=-1) override
 
void writeData (int8_t *const src, const size_t num_bytes, const size_t offset=0, const MemoryLevel src_buffer_type=CPU_LEVEL, const int src_device_id=-1) override
 

Private Attributes

CudaMgr_Namespace::CudaMgrcuda_mgr_
 

Additional Inherited Members

- Protected Attributes inherited from Buffer_Namespace::Buffer
int8_t * mem_
 
- Protected Attributes inherited from Data_Namespace::AbstractBuffer
std::unique_ptr< Encoderencoder_
 
SQLTypeInfo sql_type_
 
size_t size_
 
int device_id_
 

Detailed Description

Definition at line 26 of file GpuCudaBuffer.h.

Constructor & Destructor Documentation

Buffer_Namespace::GpuCudaBuffer::GpuCudaBuffer ( BufferMgr bm,
BufferList::iterator  seg_it,
const int  device_id,
CudaMgr_Namespace::CudaMgr cuda_mgr,
const size_t  page_size = 512,
const size_t  num_bytes = 0 
)

Definition at line 26 of file GpuCudaBuffer.cpp.

32  : Buffer(bm, seg_it, device_id, page_size, num_bytes), cuda_mgr_(cuda_mgr) {}
Buffer(BufferMgr *bm, BufferList::iterator seg_it, const int device_id, const size_t page_size=512, const size_t num_bytes=0)
Constructs a Buffer object. The constructor requires a memory address (provided by BufferMgr)...
Definition: Buffer.cpp:27
CudaMgr_Namespace::CudaMgr * cuda_mgr_
Definition: GpuCudaBuffer.h:48

Member Function Documentation

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

Implements Data_Namespace::AbstractBuffer.

Definition at line 34 of file GpuCudaBuffer.h.

References Data_Namespace::GPU_LEVEL.

void Buffer_Namespace::GpuCudaBuffer::readData ( int8_t *const  dst,
const size_t  num_bytes,
const size_t  offset = 0,
const MemoryLevel  dst_buffer_type = CPU_LEVEL,
const int  dst_devic_id = -1 
)
overrideprivatevirtual

Implements Buffer_Namespace::Buffer.

Definition at line 34 of file GpuCudaBuffer.cpp.

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

38  {
39  if (dst_buffer_type == CPU_LEVEL) {
41  dst, mem_ + offset, num_bytes, device_id_); // need to replace 0 with gpu num
42  } else if (dst_buffer_type == GPU_LEVEL) {
44  dst, mem_ + offset, num_bytes, dst_device_id, device_id_);
45 
46  } else {
47  LOG(FATAL) << "Unsupported buffer type";
48  }
49 }
void copyDeviceToHost(int8_t *host_ptr, const int8_t *device_ptr, const size_t num_bytes, const int device_num)
Definition: CudaMgr.cpp:118
#define LOG(tag)
Definition: Logger.h:188
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:127
CudaMgr_Namespace::CudaMgr * cuda_mgr_
Definition: GpuCudaBuffer.h:48

+ Here is the call graph for this function:

void Buffer_Namespace::GpuCudaBuffer::writeData ( int8_t *const  src,
const size_t  num_bytes,
const size_t  offset = 0,
const MemoryLevel  src_buffer_type = CPU_LEVEL,
const int  src_device_id = -1 
)
overrideprivatevirtual

Implements Buffer_Namespace::Buffer.

Definition at line 51 of file GpuCudaBuffer.cpp.

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

55  {
56  if (src_buffer_type == CPU_LEVEL) {
57  // std::cout << "Writing to GPU from source CPU" << std::endl;
58 
60  mem_ + offset, src, num_bytes, device_id_); // need to replace 0 with gpu num
61 
62  } else if (src_buffer_type == GPU_LEVEL) {
63  // std::cout << "Writing to GPU from source GPU" << std::endl;
64  CHECK_GE(src_device_id, 0);
66  mem_ + offset, src, num_bytes, device_id_, src_device_id);
67  } else {
68  LOG(FATAL) << "Unsupported buffer type";
69  }
70 }
int64_t * src
#define LOG(tag)
Definition: Logger.h:188
#define CHECK_GE(x, y)
Definition: Logger.h:210
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:127
void copyHostToDevice(int8_t *device_ptr, const int8_t *host_ptr, const size_t num_bytes, const int device_num)
Definition: CudaMgr.cpp:109
CudaMgr_Namespace::CudaMgr * cuda_mgr_
Definition: GpuCudaBuffer.h:48

+ Here is the call graph for this function:

Member Data Documentation

CudaMgr_Namespace::CudaMgr* Buffer_Namespace::GpuCudaBuffer::cuda_mgr_
private

Definition at line 48 of file GpuCudaBuffer.h.

Referenced by readData(), and writeData().


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