OmniSciDB  471d68cefb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{OverlapsJoinHashTable.cpp} Namespace Reference

Classes

struct  HashTableProps
 
struct  TuningState
 
class  BucketSizeTuner
 

Functions

std::vector< double > correct_uninitialized_bucket_sizes_to_thresholds (const std::vector< double > &bucket_sizes, const std::vector< double > &bucket_thresholds, const double initial_value)
 
std::vector< double > compute_bucket_sizes (const std::vector< double > &bucket_thresholds, const Data_Namespace::MemoryLevel effective_memory_level, const JoinColumn &join_column, const JoinColumnTypeInfo &join_column_type, const std::vector< InnerOuter > &inner_outer_pairs, const Executor *executor)
 
std::ostream & operator<< (std::ostream &os, const HashTableProps &props)
 
std::ostream & operator<< (std::ostream &os, const BucketSizeTuner &tuner)
 

Function Documentation

std::vector<double> anonymous_namespace{OverlapsJoinHashTable.cpp}::compute_bucket_sizes ( const std::vector< double > &  bucket_thresholds,
const Data_Namespace::MemoryLevel  effective_memory_level,
const JoinColumn join_column,
const JoinColumnTypeInfo join_column_type,
const std::vector< InnerOuter > &  inner_outer_pairs,
const Executor executor 
)

Definition at line 170 of file OverlapsJoinHashTable.cpp.

References CHECK, CHECK_EQ, compute_bucket_sizes_on_cpu(), compute_bucket_sizes_on_device(), CudaAllocator::copyFromDevice(), correct_uninitialized_bucket_sizes_to_thresholds(), Data_Namespace::CPU_LEVEL, cpu_threads(), to_string(), transfer_flat_object_to_gpu(), transfer_vector_of_flat_objects_to_gpu(), and VLOG.

Referenced by anonymous_namespace{OverlapsJoinHashTable.cpp}::BucketSizeTuner::computeBucketSizes().

176  {
177  // No coalesced keys for overlaps joins yet
178  CHECK_EQ(inner_outer_pairs.size(), 1u);
179 
180  const auto col = inner_outer_pairs[0].first;
181  CHECK(col);
182  const auto col_ti = col->get_type_info();
183  CHECK(col_ti.is_array());
184 
185  // TODO: Compute the number of dimensions for this overlaps key
186  const size_t num_dims{2};
187  const double initial_bin_value{0.0};
188  std::vector<double> bucket_sizes(num_dims, initial_bin_value);
189  CHECK_EQ(bucket_thresholds.size(), num_dims);
190 
191  VLOG(1)
192  << "Computing x and y bucket sizes for overlaps hash join with maximum bucket size "
193  << std::to_string(bucket_thresholds[0]) << ", "
194  << std::to_string(bucket_thresholds[1]);
195 
196  if (effective_memory_level == Data_Namespace::MemoryLevel::CPU_LEVEL) {
197  const int thread_count = cpu_threads();
199  bucket_sizes, join_column, join_column_type, bucket_thresholds, thread_count);
200  }
201 #ifdef HAVE_CUDA
202  else {
203  // Note that we compute the bucket sizes using only a single GPU
204  const int device_id = 0;
205  auto data_mgr = executor->getDataMgr();
206  CudaAllocator allocator(data_mgr, device_id);
207  auto device_bucket_sizes_gpu =
208  transfer_vector_of_flat_objects_to_gpu(bucket_sizes, allocator);
209  auto join_column_gpu = transfer_flat_object_to_gpu(join_column, allocator);
210  auto join_column_type_gpu = transfer_flat_object_to_gpu(join_column_type, allocator);
211  auto device_bucket_thresholds_gpu =
212  transfer_vector_of_flat_objects_to_gpu(bucket_thresholds, allocator);
213 
214  compute_bucket_sizes_on_device(device_bucket_sizes_gpu,
215  join_column_gpu,
216  join_column_type_gpu,
217  device_bucket_thresholds_gpu);
218  allocator.copyFromDevice(reinterpret_cast<int8_t*>(bucket_sizes.data()),
219  reinterpret_cast<int8_t*>(device_bucket_sizes_gpu),
220  bucket_sizes.size() * sizeof(double));
221  }
222 #endif
223  const auto corrected_bucket_sizes = correct_uninitialized_bucket_sizes_to_thresholds(
224  bucket_sizes, bucket_thresholds, initial_bin_value);
225 
226  VLOG(1) << "Computed x and y bucket sizes for overlaps hash join: ("
227  << corrected_bucket_sizes[0] << ", " << corrected_bucket_sizes[1] << ")";
228 
229  return corrected_bucket_sizes;
230 }
#define CHECK_EQ(x, y)
Definition: Logger.h:217
T * transfer_flat_object_to_gpu(const T &object, DeviceAllocator &allocator)
std::string to_string(char const *&&v)
void compute_bucket_sizes_on_device(double *bucket_sizes_buffer, const JoinColumn *join_column, const JoinColumnTypeInfo *type_info, const double *bucket_size_thresholds)
void compute_bucket_sizes_on_cpu(std::vector< double > &bucket_sizes_for_dimension, const JoinColumn &join_column, const JoinColumnTypeInfo &type_info, const std::vector< double > &bucket_size_thresholds, const int thread_count)
std::vector< double > correct_uninitialized_bucket_sizes_to_thresholds(const std::vector< double > &bucket_sizes, const std::vector< double > &bucket_thresholds, const double initial_value)
#define CHECK(condition)
Definition: Logger.h:209
T * transfer_vector_of_flat_objects_to_gpu(const std::vector< T > &vec, DeviceAllocator &allocator)
int cpu_threads()
Definition: thread_count.h:24
#define VLOG(n)
Definition: Logger.h:303

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector<double> anonymous_namespace{OverlapsJoinHashTable.cpp}::correct_uninitialized_bucket_sizes_to_thresholds ( const std::vector< double > &  bucket_sizes,
const std::vector< double > &  bucket_thresholds,
const double  initial_value 
)

Definition at line 157 of file OverlapsJoinHashTable.cpp.

References i.

Referenced by compute_bucket_sizes().

160  {
161  std::vector<double> corrected_bucket_sizes(bucket_sizes);
162  for (size_t i = 0; i != bucket_sizes.size(); ++i) {
163  if (bucket_sizes[i] == initial_value) {
164  corrected_bucket_sizes[i] = bucket_thresholds[i];
165  }
166  }
167  return corrected_bucket_sizes;
168 }

+ Here is the caller graph for this function:

std::ostream& anonymous_namespace{OverlapsJoinHashTable.cpp}::operator<< ( std::ostream &  os,
const HashTableProps &  props 
)

Definition at line 253 of file OverlapsJoinHashTable.cpp.

References anonymous_namespace{OverlapsJoinHashTable.cpp}::HashTableProps::emitted_keys_count, anonymous_namespace{OverlapsJoinHashTable.cpp}::HashTableProps::entry_count, anonymous_namespace{OverlapsJoinHashTable.cpp}::HashTableProps::hash_table_size, and anonymous_namespace{OverlapsJoinHashTable.cpp}::HashTableProps::keys_per_bin.

253  {
254  os << " entry_count: " << props.entry_count << ", emitted_keys "
255  << props.emitted_keys_count << ", hash table size " << props.hash_table_size
256  << ", keys per bin " << props.keys_per_bin;
257  return os;
258 }
std::ostream& anonymous_namespace{OverlapsJoinHashTable.cpp}::operator<< ( std::ostream &  os,
const BucketSizeTuner &  tuner 
)

Definition at line 531 of file OverlapsJoinHashTable.cpp.

References anonymous_namespace{OverlapsJoinHashTable.cpp}::BucketSizeTuner::bucket_thresholds_, anonymous_namespace{OverlapsJoinHashTable.cpp}::BucketSizeTuner::min_threshold_, anonymous_namespace{OverlapsJoinHashTable.cpp}::BucketSizeTuner::num_steps_, and anonymous_namespace{OverlapsJoinHashTable.cpp}::BucketSizeTuner::step_.

531  {
532  os << "Step Num: " << tuner.num_steps_ << ", Threshold: " << std::fixed << "("
533  << tuner.bucket_thresholds_[0] << ", " << tuner.bucket_thresholds_[1] << ")"
534  << ", Step Size: " << std::fixed << tuner.step_ << ", Min: " << std::fixed
535  << tuner.min_threshold_;
536  return os;
537 }