OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
QueryMemoryInitializer.cpp File Reference
#include "QueryMemoryInitializer.h"
#include "Execute.h"
#include "GpuInitGroups.h"
#include "GpuMemUtils.h"
#include "OutputBufferInitialization.h"
#include "ResultSet.h"
#include "Shared/Logger.h"
#include "StreamingTopN.h"
#include <Shared/checked_alloc.h>
+ Include dependency graph for QueryMemoryInitializer.cpp:

Go to the source code of this file.

Namespaces

 anonymous_namespace{QueryMemoryInitializer.cpp}
 

Functions

void anonymous_namespace{QueryMemoryInitializer.cpp}::check_total_bitmap_memory (const QueryMemoryDescriptor &query_mem_desc)
 
int64_t * anonymous_namespace{QueryMemoryInitializer.cpp}::alloc_group_by_buffer (const size_t numBytes, RenderAllocatorMap *render_allocator_map)
 
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)
 
 num_buffers_ (1)
 
 count_distinct_bitmap_mem_ (0)
 
 count_distinct_bitmap_mem_bytes_ (0)
 
 count_distinct_bitmap_crt_ptr_ (nullptr)
 
 count_distinct_bitmap_host_mem_ (nullptr)
 
 device_allocator_ (device_allocator)
 
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

 query_mem_desc
 

Function Documentation

count_distinct_bitmap_crt_ptr_ ( nullptr  )
count_distinct_bitmap_host_mem_ ( nullptr  )
count_distinct_bitmap_mem_ ( )
count_distinct_bitmap_mem_bytes_ ( )
device_allocator_ ( device_allocator  )

Definition at line 331 of file QueryMemoryInitializer.cpp.

References anonymous_namespace{QueryMemoryInitializer.cpp}::alloc_group_by_buffer(), CHECK_EQ, CHECK_GE, checked_malloc(), anonymous_namespace{QueryMemoryInitializer.cpp}::get_col_frag_offsets(), anonymous_namespace{QueryMemoryInitializer.cpp}::get_consistent_frags_sizes(), GPU, num_buffers_(), query_mem_desc, and target_exprs_to_infos().

Referenced by QueryMemoryInitializer::allocateCountDistinctGpuMem().

331  {
332  // Table functions output columnar, basically treat this as a projection
333 
334  const auto& consistent_frag_sizes = get_consistent_frags_sizes(frag_offsets);
335  if (consistent_frag_sizes.empty()) {
336  // No fragments in the input, no underlying buffers will be needed.
337  return;
338  }
339 
340  size_t group_buffer_size{0};
341  // TODO(adb): this is going to give us an index buffer and then the target buffers. this
342  // might not be desireable -- revisit
343  group_buffer_size = query_mem_desc.getBufferSizeBytes(device_type, num_rows_);
344  CHECK_GE(group_buffer_size, size_t(0));
345 
346  std::unique_ptr<int64_t, CheckedAllocDeleter> group_by_buffer_template;
347  if (!query_mem_desc.lazyInitGroups(device_type)) {
348  group_by_buffer_template.reset(
349  static_cast<int64_t*>(checked_malloc(group_buffer_size)));
350  initColumnarGroups(
351  query_mem_desc, group_by_buffer_template.get(), init_agg_vals_, executor);
352  }
353 
354  const auto index_buffer_qw =
355  device_type == ExecutorDeviceType::GPU && query_mem_desc.hasKeylessHash()
356  ? query_mem_desc.getEntryCount()
357  : size_t(0);
358  const auto actual_group_buffer_size =
359  group_buffer_size + index_buffer_qw * sizeof(int64_t);
360  CHECK_GE(actual_group_buffer_size, group_buffer_size);
361 
362  CHECK_EQ(num_buffers_, size_t(1));
363  auto group_by_buffer = alloc_group_by_buffer(actual_group_buffer_size, nullptr);
364  if (!query_mem_desc.lazyInitGroups(device_type)) {
365  memcpy(group_by_buffer + index_buffer_qw,
366  group_by_buffer_template.get(),
367  group_buffer_size);
368  }
369  group_by_buffers_.push_back(group_by_buffer);
370  row_set_mem_owner_->addGroupByBuffer(group_by_buffer);
371 
372  const auto column_frag_offsets =
373  get_col_frag_offsets(exe_unit.target_exprs, frag_offsets);
374  const auto column_frag_sizes =
375  get_consistent_frags_sizes(exe_unit.target_exprs, consistent_frag_sizes);
376  result_sets_.emplace_back(
377  new ResultSet(target_exprs_to_infos(exe_unit.target_exprs, query_mem_desc),
378  {},
379  col_buffers,
380  column_frag_offsets,
381  column_frag_sizes,
382  device_type,
383  device_id,
385  row_set_mem_owner_,
386  executor));
387  result_sets_.back()->allocateStorage(reinterpret_cast<int8_t*>(group_by_buffer),
388  init_agg_vals_);
389 }
#define CHECK_EQ(x, y)
Definition: Logger.h:198
int64_t * alloc_group_by_buffer(const size_t numBytes, RenderAllocatorMap *render_allocator_map)
#define CHECK_GE(x, y)
Definition: Logger.h:203
num_buffers_(1)
void * checked_malloc(const size_t size)
Definition: checked_alloc.h:40
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:452
std::vector< TargetInfo > target_exprs_to_infos(const std::vector< Analyzer::Expr * > &targets, const QueryMemoryDescriptor &query_mem_desc)
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:

num_buffers_ ( )

Referenced by device_allocator_().

+ Here is the caller graph for this function:

Variable Documentation