OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Buffer_Namespace::CpuBuffer Class Reference

#include <CpuBuffer.h>

+ Inheritance diagram for Buffer_Namespace::CpuBuffer:
+ Collaboration diagram for Buffer_Namespace::CpuBuffer:

Public Member Functions

 CpuBuffer (BufferMgr *bm, BufferList::iterator segment_iter, 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 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 device_id)
 
 AbstractBuffer (const int device_id, const SQLTypeInfo sql_type)
 
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 tmp_sql_type)
 
void syncEncoder (const AbstractBuffer *src_buffer)
 

Private Member Functions

void readData (int8_t *const dst, const size_t num_bytes, const size_t offset=0, const MemoryLevel dst_memory_level=CPU_LEVEL, const int dst_device_id=-1) override
 
void writeData (int8_t *const src, const size_t num_bytes, const size_t offset=0, const MemoryLevel src_memory_level=CPU_LEVEL, const int src_device_id=-1) override
 

Private Attributes

CudaMgr_Namespace::CudaMgrcuda_mgr_
 

Additional Inherited Members

- Public Attributes inherited from Data_Namespace::AbstractBuffer
std::unique_ptr< Encoderencoder
 
bool has_encoder
 
SQLTypeInfo sql_type
 
- Protected Attributes inherited from Buffer_Namespace::Buffer
int8_t * mem_
 
- Protected Attributes inherited from Data_Namespace::AbstractBuffer
size_t size_
 
bool is_dirty_
 
bool is_appended_
 
bool is_updated_
 
int device_id_
 

Detailed Description

Definition at line 26 of file CpuBuffer.h.

Constructor & Destructor Documentation

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

Definition at line 27 of file CpuBuffer.cpp.

33  : Buffer(bm, segment_iter, device_id, page_size, num_bytes), cuda_mgr_(cuda_mgr) {}
CudaMgr_Namespace::CudaMgr * cuda_mgr_
Definition: CpuBuffer.h:49
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:36

Member Function Documentation

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

Implements Data_Namespace::AbstractBuffer.

Definition at line 35 of file CpuBuffer.h.

References Data_Namespace::CPU_LEVEL.

void Buffer_Namespace::CpuBuffer::readData ( int8_t *const  dst,
const size_t  num_bytes,
const size_t  offset = 0,
const MemoryLevel  dst_memory_level = CPU_LEVEL,
const int  dst_device_id = -1 
)
overrideprivatevirtual

Implements Buffer_Namespace::Buffer.

Definition at line 35 of file CpuBuffer.cpp.

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

39  {
40  if (dst_memory_level == CPU_LEVEL) {
41  memcpy(dst, mem_ + offset, num_bytes);
42  } else if (dst_memory_level == GPU_LEVEL) {
43  CHECK_GE(dst_device_id, 0);
44  cuda_mgr_->copyHostToDevice(dst, mem_ + offset, num_bytes, dst_device_id);
45  } else {
46  LOG(FATAL) << "Unsupported buffer type";
47  }
48 }
#define LOG(tag)
Definition: Logger.h:185
#define CHECK_GE(x, y)
Definition: Logger.h:203
void copyHostToDevice(int8_t *device_ptr, const int8_t *host_ptr, const size_t num_bytes, const int device_num)
Definition: CudaMgr.cpp:81
CudaMgr_Namespace::CudaMgr * cuda_mgr_
Definition: CpuBuffer.h:49

+ Here is the call graph for this function:

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

Implements Buffer_Namespace::Buffer.

Definition at line 50 of file CpuBuffer.cpp.

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

54  {
55  if (src_memory_level == CPU_LEVEL) {
56  // std::cout << "Writing to CPU from source CPU" << std::endl;
57  memcpy(mem_ + offset, src, num_bytes);
58  } else if (src_memory_level == GPU_LEVEL) {
59  // std::cout << "Writing to CPU from source GPU" << std::endl;
60  CHECK_GE(src_device_id, 0);
61  cuda_mgr_->copyDeviceToHost(mem_ + offset, src, num_bytes, src_device_id);
62  } else {
63  LOG(FATAL) << "Unsupported buffer type";
64  }
65 }
void copyDeviceToHost(int8_t *host_ptr, const int8_t *device_ptr, const size_t num_bytes, const int device_num)
Definition: CudaMgr.cpp:90
#define LOG(tag)
Definition: Logger.h:185
int64_t * src
#define CHECK_GE(x, y)
Definition: Logger.h:203
CudaMgr_Namespace::CudaMgr * cuda_mgr_
Definition: CpuBuffer.h:49

+ Here is the call graph for this function:

Member Data Documentation

CudaMgr_Namespace::CudaMgr* Buffer_Namespace::CpuBuffer::cuda_mgr_
private

Definition at line 49 of file CpuBuffer.h.

Referenced by readData(), and writeData().


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