OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QueryMemoryInitializer.cpp File Reference
+ Include dependency graph for QueryMemoryInitializer.cpp:

Go to the source code of this file.

Classes

struct  anonymous_namespace{QueryMemoryInitializer.cpp}::AddNbytes
 

Namespaces

 anonymous_namespace{QueryMemoryInitializer.cpp}
 

Macros

#define MAX_BUFFER_SIZE   0x100000000000ll
 

Functions

void anonymous_namespace{QueryMemoryInitializer.cpp}::check_total_bitmap_memory (const QueryMemoryDescriptor &query_mem_desc)
 
std::pair< int64_t *, bool > anonymous_namespace{QueryMemoryInitializer.cpp}::alloc_group_by_buffer (const size_t numBytes, RenderAllocatorMap *render_allocator_map, const size_t thread_idx, RowSetMemoryOwner *mem_owner, const bool reuse_existing_buffer_for_thread)
 
int64_t anonymous_namespace{QueryMemoryInitializer.cpp}::get_consistent_frag_size (const std::vector< uint64_t > &frag_offsets)
 
std::vector< int64_t > anonymous_namespace{QueryMemoryInitializer.cpp}::get_consistent_frags_sizes (const std::vector< std::vector< uint64_t >> &frag_offsets)
 
std::vector< int64_t > anonymous_namespace{QueryMemoryInitializer.cpp}::get_consistent_frags_sizes (const std::vector< Analyzer::Expr * > &target_exprs, const std::vector< int64_t > &table_frag_sizes)
 
std::vector< std::vector
< int64_t > > 
anonymous_namespace{QueryMemoryInitializer.cpp}::get_col_frag_offsets (const std::vector< Analyzer::Expr * > &target_exprs, const std::vector< std::vector< uint64_t >> &table_frag_offsets)
 
int anonymous_namespace{QueryMemoryInitializer.cpp}::get_input_idx (RelAlgExecutionUnit const &ra_exe_unit, const shared::TableKey &outer_table_key)
 
void anonymous_namespace{QueryMemoryInitializer.cpp}::check_count_distinct_expr_metadata (const QueryMemoryDescriptor &query_mem_desc, const RelAlgExecutionUnit &ra_exe_unit)
 
QueryMemoryInitializer::TargetAggOpsMetadata anonymous_namespace{QueryMemoryInitializer.cpp}::collect_target_expr_metadata (const QueryMemoryDescriptor &query_mem_desc, const RelAlgExecutionUnit &ra_exe_unit)
 
 num_buffers_ (1)
 
 varlen_output_buffer_ (0)
 
 varlen_output_buffer_host_ptr_ (nullptr)
 
 count_distinct_bitmap_device_mem_ptr_ (0)
 
 count_distinct_bitmap_mem_size_ (0)
 
 count_distinct_bitmap_host_crt_ptr_ (nullptr)
 
 count_distinct_bitmap_host_mem_ptr_ (nullptr)
 
 device_allocator_ (device_allocator)
 
 thread_idx_ (0)
 
template<typename T >
int8_t * anonymous_namespace{QueryMemoryInitializer.cpp}::initColumnarBuffer (T *buffer_ptr, const T init_val, const uint32_t entry_count)
 
void anonymous_namespace{QueryMemoryInitializer.cpp}::compact_projection_buffer_for_cpu_columnar (const QueryMemoryDescriptor &query_mem_desc, int8_t *projection_buffer, const size_t projection_count)
 

Variables

int64_t g_bitmap_memory_limit {8LL * 1000 * 1000 * 1000}
 
 query_mem_desc
 

Macro Definition Documentation

#define MAX_BUFFER_SIZE   0x100000000000ll

Function Documentation

count_distinct_bitmap_device_mem_ptr_ ( )
count_distinct_bitmap_host_crt_ptr_ ( nullptr  )
count_distinct_bitmap_host_mem_ptr_ ( nullptr  )
count_distinct_bitmap_mem_size_ ( )
device_allocator_ ( device_allocator  )
num_buffers_ ( )

Referenced by thread_idx_().

+ Here is the caller graph for this function:

thread_idx_ ( )

Definition at line 488 of file QueryMemoryInitializer.cpp.

References align_to_int64(), anonymous_namespace{QueryMemoryInitializer.cpp}::alloc_group_by_buffer(), CHECK, CHECK_EQ, anonymous_namespace{QueryMemoryInitializer.cpp}::get_col_frag_offsets(), anonymous_namespace{QueryMemoryInitializer.cpp}::get_consistent_frags_sizes(), MAX_BUFFER_SIZE, num_buffers_(), query_mem_desc, and target_exprs_to_infos().

Referenced by ResultSet::getThreadIdx().

488  {
489  // Table functions output columnar, basically treat this as a projection
490  const auto& consistent_frag_sizes = get_consistent_frags_sizes(frag_offsets);
491  if (consistent_frag_sizes.empty()) {
492  // No fragments in the input, no underlying buffers will be needed.
493  return;
494  }
495 
496  const size_t num_columns =
497  query_mem_desc.getBufferColSlotCount(); // shouldn't we use getColCount() ???
498  size_t total_group_by_buffer_size{0};
499  for (size_t i = 0; i < num_columns; ++i) {
500  auto ti = exe_unit.target_exprs[i]->get_type_info();
501  if (ti.usesFlatBuffer()) {
502  // See TableFunctionManager.h for info regarding flatbuffer
503  // memory managment.
504  auto slot_idx = query_mem_desc.getSlotIndexForSingleSlotCol(i);
505  CHECK(query_mem_desc.checkSlotUsesFlatBufferFormat(slot_idx));
506  checked_int64_t flatbuffer_size = query_mem_desc.getFlatBufferSize(slot_idx);
507  try {
508  total_group_by_buffer_size = align_to_int64(
509  static_cast<int64_t>(total_group_by_buffer_size + flatbuffer_size));
510  } catch (...) {
511  throw OutOfHostMemory(std::numeric_limits<int64_t>::max() / 8);
512  }
513  } else {
514  const checked_int64_t col_width = ti.get_size();
515  try {
516  const checked_int64_t group_buffer_size = col_width * num_rows_;
517  total_group_by_buffer_size = align_to_int64(
518  static_cast<int64_t>(group_buffer_size + total_group_by_buffer_size));
519  } catch (...) {
520  throw OutOfHostMemory(std::numeric_limits<int64_t>::max() / 8);
521  }
522  }
523  }
524 
525 #ifdef __SANITIZE_ADDRESS__
526  // AddressSanitizer will reject allocation sizes above 1 TiB
527 #define MAX_BUFFER_SIZE 0x10000000000ll
528 #else
529  // otherwise, we'll set the limit to 16 TiB, feel free to increase
530  // the limit if needed
531 #define MAX_BUFFER_SIZE 0x100000000000ll
532 #endif
533 
534  if (total_group_by_buffer_size >= MAX_BUFFER_SIZE) {
535  throw OutOfHostMemory(total_group_by_buffer_size);
536  }
537 
538  CHECK_EQ(num_buffers_, size_t(1));
539  auto group_by_buffer = alloc_group_by_buffer(total_group_by_buffer_size,
540  nullptr,
541  thread_idx_,
542  row_set_mem_owner.get(),
543  false)
544  .first;
545  group_by_buffers_.push_back(group_by_buffer);
546 
547  const auto column_frag_offsets =
548  get_col_frag_offsets(exe_unit.target_exprs, frag_offsets);
549  const auto column_frag_sizes =
550  get_consistent_frags_sizes(exe_unit.target_exprs, consistent_frag_sizes);
551  result_sets_.emplace_back(
552  new ResultSet(target_exprs_to_infos(exe_unit.target_exprs, query_mem_desc),
553  /*col_lazy_fetch_info=*/{},
554  col_buffers,
555  column_frag_offsets,
556  column_frag_sizes,
557  device_type,
558  device_id,
559  -1, /*thread_idx*/
561  row_set_mem_owner_,
562  executor->blockSize(),
563  executor->gridSize()));
564  result_sets_.back()->allocateStorage(reinterpret_cast<int8_t*>(group_by_buffer),
565  init_agg_vals_);
566 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 64, 64, boost::multiprecision::signed_magnitude, boost::multiprecision::checked, void >> checked_int64_t
num_buffers_(1)
std::pair< int64_t *, bool > alloc_group_by_buffer(const size_t numBytes, RenderAllocatorMap *render_allocator_map, const size_t thread_idx, RowSetMemoryOwner *mem_owner, const bool reuse_existing_buffer_for_thread)
std::vector< int64_t > get_consistent_frags_sizes(const std::vector< std::vector< uint64_t >> &frag_offsets)
static QueryMemoryDescriptor fixupQueryMemoryDescriptor(const QueryMemoryDescriptor &)
Definition: ResultSet.cpp:766
#define MAX_BUFFER_SIZE
#define CHECK(condition)
Definition: Logger.h:291
std::vector< TargetInfo > target_exprs_to_infos(const std::vector< Analyzer::Expr * > &targets, const QueryMemoryDescriptor &query_mem_desc)
FORCE_INLINE HOST DEVICE T align_to_int64(T addr)
std::vector< std::vector< int64_t > > get_col_frag_offsets(const std::vector< Analyzer::Expr * > &target_exprs, const std::vector< std::vector< uint64_t >> &table_frag_offsets)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

varlen_output_buffer_ ( )
varlen_output_buffer_host_ptr_ ( nullptr  )

Variable Documentation