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

Classes

struct  BucketSizeTuner
 

Functions

void compute_bucket_sizes (std::vector< double > &bucket_sizes_for_dimension, const double bucket_threshold, 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 BucketSizeTuner &tuner)
 

Function Documentation

void anonymous_namespace{OverlapsJoinHashTable.cpp}::compute_bucket_sizes ( std::vector< double > &  bucket_sizes_for_dimension,
const double  bucket_threshold,
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 127 of file OverlapsJoinHashTable.cpp.

References CHECK, CHECK_EQ, compute_bucket_sizes_on_cpu(), compute_bucket_sizes_on_device(), CudaAllocator::copyFromDevice(), 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().

133  {
134  // No coalesced keys for overlaps joins yet
135  CHECK_EQ(inner_outer_pairs.size(), 1u);
136 
137  const auto col = inner_outer_pairs[0].first;
138  CHECK(col);
139  const auto col_ti = col->get_type_info();
140  CHECK(col_ti.is_array());
141 
142  // TODO: Compute the number of dimensions for this overlaps key
143  const int num_dims = 2;
144  std::vector<double> local_bucket_sizes(num_dims, std::numeric_limits<double>::max());
145 
146  VLOG(1)
147  << "Computing x and y bucket sizes for overlaps hash join with minimum bucket size "
148  << std::to_string(bucket_threshold);
149 
150  if (effective_memory_level == Data_Namespace::MemoryLevel::CPU_LEVEL) {
151  const int thread_count = cpu_threads();
152  compute_bucket_sizes_on_cpu(local_bucket_sizes,
153  join_column,
154  join_column_type,
155  bucket_threshold,
156  thread_count);
157  }
158 #ifdef HAVE_CUDA
159  else {
160  // Note that we compute the bucket sizes using only a single GPU
161  const int device_id = 0;
162  auto& data_mgr = executor->getCatalog()->getDataMgr();
163  CudaAllocator allocator(&data_mgr, device_id);
164  auto device_bucket_sizes_gpu =
165  transfer_vector_of_flat_objects_to_gpu(local_bucket_sizes, allocator);
166  auto join_column_gpu = transfer_flat_object_to_gpu(join_column, allocator);
167  auto join_column_type_gpu = transfer_flat_object_to_gpu(join_column_type, allocator);
168 
170  device_bucket_sizes_gpu, join_column_gpu, join_column_type_gpu, bucket_threshold);
171  allocator.copyFromDevice(reinterpret_cast<int8_t*>(local_bucket_sizes.data()),
172  reinterpret_cast<int8_t*>(device_bucket_sizes_gpu),
173  local_bucket_sizes.size() * sizeof(double));
174  }
175 #endif
176 
177  size_t ctr = 0;
178  for (auto& bucket_sz : local_bucket_sizes) {
179  VLOG(1) << "Computed bucket size for dim[" << ctr++ << "]: " << bucket_sz;
180  bucket_sizes_for_dimension.push_back(1.0 / bucket_sz);
181  }
182 
183  return;
184 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
std::string to_string(char const *&&v)
T * transfer_flat_object_to_gpu(const T &object, CudaAllocator &allocator)
void compute_bucket_sizes_on_cpu(std::vector< double > &bucket_sizes_for_dimension, const JoinColumn &join_column, const JoinColumnTypeInfo &type_info, const double bucket_size_threshold, const int thread_count)
#define CHECK(condition)
Definition: Logger.h:197
T * transfer_vector_of_flat_objects_to_gpu(const std::vector< T > &vec, CudaAllocator &allocator)
void compute_bucket_sizes_on_device(double *bucket_sizes_buffer, const JoinColumn *join_column, const JoinColumnTypeInfo *type_info, const double bucket_sz_threshold)
int cpu_threads()
Definition: thread_count.h:24
#define VLOG(n)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 237 of file OverlapsJoinHashTable.cpp.

References anonymous_namespace{OverlapsJoinHashTable.cpp}::BucketSizeTuner::bucket_threshold, anonymous_namespace{OverlapsJoinHashTable.cpp}::BucketSizeTuner::min_threshold, anonymous_namespace{OverlapsJoinHashTable.cpp}::BucketSizeTuner::num_steps, and anonymous_namespace{OverlapsJoinHashTable.cpp}::BucketSizeTuner::step.

237  {
238  os << "Step Num: " << tuner.num_steps << ", Threshold: " << std::fixed
239  << tuner.bucket_threshold << ", Step Size: " << std::fixed << tuner.step
240  << ", Min: " << std::fixed << tuner.min_threshold;
241  return os;
242 }