OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PerfectHashTable Class Reference

#include <PerfectHashTable.h>

+ Inheritance diagram for PerfectHashTable:
+ Collaboration diagram for PerfectHashTable:

Public Member Functions

 PerfectHashTable (const ExecutorDeviceType device_type, PerfectHashTableEntryInfo hash_table_entry_info, Data_Namespace::DataMgr *data_mgr=nullptr, const int device_id=-1)
 
 ~PerfectHashTable () override
 
void allocateGpuMemory (const size_t num_entries)
 
size_t getHashTableBufferSize (const ExecutorDeviceType device_type) const override
 
HashType getLayout () const override
 
int8_t * getCpuBuffer () override
 
int8_t * getGpuBuffer () const override
 
size_t getEntryCount () const override
 
size_t getEmittedKeysCount () const override
 
size_t getRowIdSize () const override
 
void setHashEntryInfo (BucketizedHashEntryInfo &hash_entry_info)
 
void setColumnNumElems (size_t elem)
 
BucketizedHashEntryInfo getHashEntryInfo () const
 
size_t getColumnNumElems () const
 
PerfectHashTableEntryInfo getHashTableEntryInfo () const
 
void printInitLog (ExecutorDeviceType device_type)
 
- Public Member Functions inherited from HashTable
virtual ~HashTable ()
 

Private Attributes

Data_Namespace::AbstractBuffergpu_hash_table_buff_ {nullptr}
 
std::unique_ptr< int32_t[]> cpu_hash_table_buff_ {nullptr}
 
PerfectHashTableEntryInfo hash_table_entry_info_
 
BucketizedHashEntryInfo hash_entry_info_
 
size_t column_num_elems_
 
Data_Namespace::DataMgrdata_mgr_
 
int device_id_
 

Additional Inherited Members

- Static Public Member Functions inherited from HashTable
static DecodedJoinHashBufferSet toSet (size_t key_component_count, size_t key_component_width, size_t entry_count, const int8_t *ptr1, const int8_t *ptr2, const int8_t *ptr3, const int8_t *ptr4, size_t buffer_size)
 Decode hash table into a std::set for easy inspection and validation. More...
 
static std::string toString (const std::string &type, const std::string &layout_type, size_t key_component_count, size_t key_component_width, size_t entry_count, const int8_t *ptr1, const int8_t *ptr2, const int8_t *ptr3, const int8_t *ptr4, size_t buffer_size, bool raw=false)
 Decode hash table into a human-readable string. More...
 

Detailed Description

Definition at line 50 of file PerfectHashTable.h.

Constructor & Destructor Documentation

PerfectHashTable::PerfectHashTable ( const ExecutorDeviceType  device_type,
PerfectHashTableEntryInfo  hash_table_entry_info,
Data_Namespace::DataMgr data_mgr = nullptr,
const int  device_id = -1 
)
inline

Definition at line 53 of file PerfectHashTable.h.

References PerfectHashTableEntryInfo::computeTotalNumSlots(), CPU, cpu_hash_table_buff_, and printInitLog().

57  : hash_table_entry_info_(hash_table_entry_info)
58  , data_mgr_(data_mgr)
59  , device_id_(device_id) {
60  if (device_type == ExecutorDeviceType::CPU) {
62  new int32_t[hash_table_entry_info.computeTotalNumSlots()]);
63  printInitLog(device_type);
64  }
65  }
std::unique_ptr< int32_t[]> cpu_hash_table_buff_
PerfectHashTableEntryInfo hash_table_entry_info_
size_t computeTotalNumSlots() const override
void printInitLog(ExecutorDeviceType device_type)
Data_Namespace::DataMgr * data_mgr_

+ Here is the call graph for this function:

PerfectHashTable::~PerfectHashTable ( )
inlineoverride

Definition at line 67 of file PerfectHashTable.h.

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

67  {
68 #ifdef HAVE_CUDA
72  }
73 #endif
74  }
Data_Namespace::AbstractBuffer * gpu_hash_table_buff_
#define CHECK(condition)
Definition: Logger.h:291
void free(AbstractBuffer *buffer)
Definition: DataMgr.cpp:614
Data_Namespace::DataMgr * data_mgr_

+ Here is the call graph for this function:

Member Function Documentation

void PerfectHashTable::allocateGpuMemory ( const size_t  num_entries)
inline

Definition at line 76 of file PerfectHashTable.h.

References CudaAllocator::allocGpuAbstractBuffer(), CHECK, CHECK_GE, cpu_hash_table_buff_, data_mgr_, device_id_, HashTableEntryInfo::getRowIdSizeInBytes(), GPU, gpu_hash_table_buff_, hash_table_entry_info_, printInitLog(), and VLOG.

76  {
77  CHECK_GE(device_id_, 0);
80  auto const buf_size = num_entries * hash_table_entry_info_.getRowIdSizeInBytes();
84  VLOG(1) << "Allocate " << buf_size
85  << " bytes buffer on GPU to keep the hash table copied from CPU";
86  } else {
88  }
89  }
std::unique_ptr< int32_t[]> cpu_hash_table_buff_
#define CHECK_GE(x, y)
Definition: Logger.h:306
Data_Namespace::AbstractBuffer * gpu_hash_table_buff_
PerfectHashTableEntryInfo hash_table_entry_info_
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:291
void printInitLog(ExecutorDeviceType device_type)
size_t getRowIdSizeInBytes() const
Definition: HashTable.h:52
Data_Namespace::DataMgr * data_mgr_
#define VLOG(n)
Definition: Logger.h:388

+ Here is the call graph for this function:

size_t PerfectHashTable::getColumnNumElems ( ) const
inline

Definition at line 135 of file PerfectHashTable.h.

References column_num_elems_.

135  {
136  return column_num_elems_;
137  }
int8_t* PerfectHashTable::getCpuBuffer ( )
inlineoverridevirtual

Implements HashTable.

Definition at line 103 of file PerfectHashTable.h.

References cpu_hash_table_buff_.

103  {
104  return reinterpret_cast<int8_t*>(cpu_hash_table_buff_.get());
105  }
std::unique_ptr< int32_t[]> cpu_hash_table_buff_
size_t PerfectHashTable::getEmittedKeysCount ( ) const
inlineoverridevirtual

Implements HashTable.

Definition at line 115 of file PerfectHashTable.h.

References HashTableEntryInfo::getNumKeys(), and hash_table_entry_info_.

115  {
117  }
PerfectHashTableEntryInfo hash_table_entry_info_
size_t getNumKeys() const
Definition: HashTable.h:51

+ Here is the call graph for this function:

size_t PerfectHashTable::getEntryCount ( ) const
inlineoverridevirtual

Implements HashTable.

Definition at line 111 of file PerfectHashTable.h.

References HashTableEntryInfo::getNumHashEntries(), and hash_table_entry_info_.

111  {
113  }
size_t getNumHashEntries() const
Definition: HashTable.h:50
PerfectHashTableEntryInfo hash_table_entry_info_

+ Here is the call graph for this function:

int8_t* PerfectHashTable::getGpuBuffer ( ) const
inlineoverridevirtual

Implements HashTable.

Definition at line 107 of file PerfectHashTable.h.

References Data_Namespace::AbstractBuffer::getMemoryPtr(), and gpu_hash_table_buff_.

107  {
109  }
virtual int8_t * getMemoryPtr()=0
Data_Namespace::AbstractBuffer * gpu_hash_table_buff_

+ Here is the call graph for this function:

BucketizedHashEntryInfo PerfectHashTable::getHashEntryInfo ( ) const
inline

Definition at line 131 of file PerfectHashTable.h.

References hash_entry_info_.

131  {
132  return hash_entry_info_;
133  }
BucketizedHashEntryInfo hash_entry_info_
size_t PerfectHashTable::getHashTableBufferSize ( const ExecutorDeviceType  device_type) const
inlineoverridevirtual

Implements HashTable.

Definition at line 91 of file PerfectHashTable.h.

References PerfectHashTableEntryInfo::computeHashTableSize(), CPU, gpu_hash_table_buff_, hash_table_entry_info_, and Data_Namespace::AbstractBuffer::reservedSize().

91  {
92  if (device_type == ExecutorDeviceType::CPU) {
94  } else {
96  }
97  }
virtual size_t reservedSize() const =0
Data_Namespace::AbstractBuffer * gpu_hash_table_buff_
PerfectHashTableEntryInfo hash_table_entry_info_
size_t computeHashTableSize() const override

+ Here is the call graph for this function:

PerfectHashTableEntryInfo PerfectHashTable::getHashTableEntryInfo ( ) const
inline

Definition at line 139 of file PerfectHashTable.h.

References hash_table_entry_info_.

139  {
140  return hash_table_entry_info_;
141  }
PerfectHashTableEntryInfo hash_table_entry_info_
HashType PerfectHashTable::getLayout ( ) const
inlineoverridevirtual

Implements HashTable.

Definition at line 99 of file PerfectHashTable.h.

References HashTableEntryInfo::getHashTableLayout(), and hash_table_entry_info_.

99  {
101  }
HashType getHashTableLayout() const
Definition: HashTable.h:53
PerfectHashTableEntryInfo hash_table_entry_info_

+ Here is the call graph for this function:

size_t PerfectHashTable::getRowIdSize ( ) const
inlineoverridevirtual

Implements HashTable.

Definition at line 119 of file PerfectHashTable.h.

References HashTableEntryInfo::getRowIdSizeInBytes(), and hash_table_entry_info_.

119  {
121  }
PerfectHashTableEntryInfo hash_table_entry_info_
size_t getRowIdSizeInBytes() const
Definition: HashTable.h:52

+ Here is the call graph for this function:

void PerfectHashTable::printInitLog ( ExecutorDeviceType  device_type)
inline

Definition at line 143 of file PerfectHashTable.h.

References PerfectHashTableEntryInfo::computeHashTableSize(), CPU, device_id_, HashTableEntryInfo::getHashTableLayout(), HashTableEntryInfo::getNumHashEntries(), HashTableEntryInfo::getNumKeys(), GPU, hash_table_entry_info_, OneToOne, and VLOG.

Referenced by allocateGpuMemory(), and PerfectHashTable().

143  {
144  std::string device_str = device_type == ExecutorDeviceType::CPU ? "CPU" : "GPU";
145  std::string layout_str =
147  : "OneToMany";
148  std::ostringstream oss;
149  oss << "Initialize a " << device_type << " perfect join hash table";
150  if (device_type == ExecutorDeviceType::GPU) {
151  oss << " for device " << device_id_;
152  }
153  oss << ", join type " << layout_str
154  << ", # hash entries: " << hash_table_entry_info_.getNumHashEntries()
155  << ", # entries stored in the payload buffer: "
157  << ", hash table size : " << hash_table_entry_info_.computeHashTableSize()
158  << " Bytes";
159  VLOG(1) << oss.str();
160  }
HashType getHashTableLayout() const
Definition: HashTable.h:53
size_t getNumHashEntries() const
Definition: HashTable.h:50
PerfectHashTableEntryInfo hash_table_entry_info_
size_t getNumKeys() const
Definition: HashTable.h:51
size_t computeHashTableSize() const override
#define VLOG(n)
Definition: Logger.h:388

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void PerfectHashTable::setColumnNumElems ( size_t  elem)
inline

Definition at line 127 of file PerfectHashTable.h.

References column_num_elems_.

127  {
128  column_num_elems_ = elem;
129  }
void PerfectHashTable::setHashEntryInfo ( BucketizedHashEntryInfo hash_entry_info)
inline

Definition at line 123 of file PerfectHashTable.h.

References hash_entry_info_.

123  {
124  hash_entry_info_ = hash_entry_info;
125  }
BucketizedHashEntryInfo hash_entry_info_

Member Data Documentation

size_t PerfectHashTable::column_num_elems_
private

Definition at line 167 of file PerfectHashTable.h.

Referenced by getColumnNumElems(), and setColumnNumElems().

std::unique_ptr<int32_t[]> PerfectHashTable::cpu_hash_table_buff_ {nullptr}
private

Definition at line 164 of file PerfectHashTable.h.

Referenced by allocateGpuMemory(), getCpuBuffer(), and PerfectHashTable().

Data_Namespace::DataMgr* PerfectHashTable::data_mgr_
private

Definition at line 168 of file PerfectHashTable.h.

Referenced by allocateGpuMemory(), and ~PerfectHashTable().

int PerfectHashTable::device_id_
private

Definition at line 169 of file PerfectHashTable.h.

Referenced by allocateGpuMemory(), and printInitLog().

Data_Namespace::AbstractBuffer* PerfectHashTable::gpu_hash_table_buff_ {nullptr}
private
BucketizedHashEntryInfo PerfectHashTable::hash_entry_info_
private

Definition at line 166 of file PerfectHashTable.h.

Referenced by getHashEntryInfo(), and setHashEntryInfo().


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