OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{BoundingBoxIntersectJoinHashTable.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{BoundingBoxIntersectJoinHashTable.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 177 of file BoundingBoxIntersectJoinHashTable.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(), getQueryEngineCudaStreamForDevice(), to_string(), transfer_flat_object_to_gpu(), transfer_vector_of_flat_objects_to_gpu(), and VLOG.

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

183  {
184  // No coalesced keys for bounding box intersection yet
185  CHECK_EQ(inner_outer_pairs.size(), 1u);
186 
187  const auto col = inner_outer_pairs[0].first;
188  CHECK(col);
189  const auto col_ti = col->get_type_info();
190  CHECK(col_ti.is_array());
191 
192  // TODO: Compute the number of dimensions for keys used to perform bounding box
193  // intersection
194  const size_t num_dims{2};
195  const double initial_bin_value{0.0};
196  std::vector<double> bucket_sizes(num_dims, initial_bin_value);
197  CHECK_EQ(bucket_thresholds.size(), num_dims);
198 
199  VLOG(1) << "Computing x and y bucket sizes for bounding box intersection with maximum "
200  "bucket size "
201  << std::to_string(bucket_thresholds[0]) << ", "
202  << std::to_string(bucket_thresholds[1]);
203 
204  if (effective_memory_level == Data_Namespace::MemoryLevel::CPU_LEVEL) {
205  const int thread_count = cpu_threads();
207  bucket_sizes, join_column, join_column_type, bucket_thresholds, thread_count);
208  }
209 #ifdef HAVE_CUDA
210  else {
211  // Note that we compute the bucket sizes using only a single GPU
212  const int device_id = 0;
213  auto data_mgr = executor->getDataMgr();
214  CudaAllocator allocator(
215  data_mgr, device_id, getQueryEngineCudaStreamForDevice(device_id));
216  auto device_bucket_sizes_gpu =
217  transfer_vector_of_flat_objects_to_gpu(bucket_sizes, allocator);
218  auto join_column_gpu = transfer_flat_object_to_gpu(join_column, allocator);
219  auto join_column_type_gpu = transfer_flat_object_to_gpu(join_column_type, allocator);
220  auto device_bucket_thresholds_gpu =
221  transfer_vector_of_flat_objects_to_gpu(bucket_thresholds, allocator);
222 
223  compute_bucket_sizes_on_device(device_bucket_sizes_gpu,
224  join_column_gpu,
225  join_column_type_gpu,
226  device_bucket_thresholds_gpu);
227  allocator.copyFromDevice(reinterpret_cast<int8_t*>(bucket_sizes.data()),
228  reinterpret_cast<int8_t*>(device_bucket_sizes_gpu),
229  bucket_sizes.size() * sizeof(double));
230  }
231 #endif
232  const auto corrected_bucket_sizes = correct_uninitialized_bucket_sizes_to_thresholds(
233  bucket_sizes, bucket_thresholds, initial_bin_value);
234 
235  VLOG(1) << "Computed x and y bucket sizes for bounding box intersection: ("
236  << corrected_bucket_sizes[0] << ", " << corrected_bucket_sizes[1] << ")";
237 
238  return corrected_bucket_sizes;
239 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
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)
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)
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)
CUstream getQueryEngineCudaStreamForDevice(int device_num)
Definition: QueryEngine.cpp:7
#define CHECK(condition)
Definition: Logger.h:291
T * transfer_vector_of_flat_objects_to_gpu(const std::vector< T > &vec, DeviceAllocator &allocator)
int cpu_threads()
Definition: thread_count.h:25
#define VLOG(n)
Definition: Logger.h:388

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector<double> anonymous_namespace{BoundingBoxIntersectJoinHashTable.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 164 of file BoundingBoxIntersectJoinHashTable.cpp.

Referenced by compute_bucket_sizes().

167  {
168  std::vector<double> corrected_bucket_sizes(bucket_sizes);
169  for (size_t i = 0; i != bucket_sizes.size(); ++i) {
170  if (bucket_sizes[i] == initial_value) {
171  corrected_bucket_sizes[i] = bucket_thresholds[i];
172  }
173  }
174  return corrected_bucket_sizes;
175 }

+ Here is the caller graph for this function:

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

Definition at line 262 of file BoundingBoxIntersectJoinHashTable.cpp.

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

262  {
263  os << " entry_count: " << props.entry_count << ", emitted_keys "
264  << props.emitted_keys_count << ", hash table size " << props.hash_table_size
265  << ", keys per bin " << props.keys_per_bin;
266  return os;
267 }
std::ostream& anonymous_namespace{BoundingBoxIntersectJoinHashTable.cpp}::operator<< ( std::ostream &  os,
const BucketSizeTuner &  tuner 
)

Definition at line 543 of file BoundingBoxIntersectJoinHashTable.cpp.

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

543  {
544  os << "Step Num: " << tuner.num_steps_ << ", Threshold: " << std::fixed << "("
545  << tuner.bucket_thresholds_[0] << ", " << tuner.bucket_thresholds_[1] << ")"
546  << ", Step Size: " << std::fixed << tuner.step_ << ", Min: " << std::fixed
547  << tuner.min_threshold_;
548  return os;
549 }