OmniSciDB  8fa3bf436f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
QueryMemoryDescriptor Class Reference

#include <QueryMemoryDescriptor.h>

+ Collaboration diagram for QueryMemoryDescriptor:

Public Member Functions

 QueryMemoryDescriptor ()
 
 QueryMemoryDescriptor (const Executor *executor, const RelAlgExecutionUnit &ra_exe_unit, const std::vector< InputTableInfo > &query_infos, const bool allow_multifrag, const bool keyless_hash, const bool interleaved_bins_on_gpu, const int32_t idx_target_as_key, const ColRangeInfo &col_range_info, const ColSlotContext &col_slot_context, const std::vector< int8_t > &group_col_widths, const int8_t group_col_compact_width, const std::vector< int64_t > &target_groupby_indices, const size_t entry_count, const CountDistinctDescriptors count_distinct_descriptors, const bool sort_on_gpu_hint, const bool output_columnar, const bool render_output, const bool must_use_baseline_sort, const bool use_streaming_top_n)
 
 QueryMemoryDescriptor (const Executor *executor, const size_t entry_count, const QueryDescriptionType query_desc_type, const bool is_table_function)
 
 QueryMemoryDescriptor (const QueryDescriptionType query_desc_type, const int64_t min_val, const int64_t max_val, const bool has_nulls, const std::vector< int8_t > &group_col_widths)
 
 QueryMemoryDescriptor (const TResultSetBufferDescriptor &thrift_query_memory_descriptor)
 
bool operator== (const QueryMemoryDescriptor &other) const
 
std::unique_ptr
< QueryExecutionContext
getQueryExecutionContext (const RelAlgExecutionUnit &, const Executor *executor, const ExecutorDeviceType device_type, const ExecutorDispatchMode dispatch_mode, const int device_id, const int64_t num_rows, const std::vector< std::vector< const int8_t * >> &col_buffers, const std::vector< std::vector< uint64_t >> &frag_offsets, std::shared_ptr< RowSetMemoryOwner >, const bool output_columnar, const bool sort_on_gpu, const size_t thread_idx, RenderInfo *) const
 
bool countDistinctDescriptorsLogicallyEmpty () const
 
const ExecutorgetExecutor () const
 
QueryDescriptionType getQueryDescriptionType () const
 
void setQueryDescriptionType (const QueryDescriptionType val)
 
bool isSingleColumnGroupByWithPerfectHash () const
 
bool hasKeylessHash () const
 
void setHasKeylessHash (const bool val)
 
bool hasInterleavedBinsOnGpu () const
 
void setHasInterleavedBinsOnGpu (const bool val)
 
int32_t getTargetIdxForKey () const
 
void setTargetIdxForKey (const int32_t val)
 
int8_t groupColWidth (const size_t key_idx) const
 
size_t getPrependedGroupColOffInBytes (const size_t group_idx) const
 
size_t getPrependedGroupBufferSizeInBytes () const
 
const auto groupColWidthsBegin () const
 
const auto groupColWidthsEnd () const
 
void clearGroupColWidths ()
 
bool isGroupBy () const
 
void setGroupColCompactWidth (const int8_t val)
 
size_t getColCount () const
 
size_t getSlotCount () const
 
const int8_t getPaddedSlotWidthBytes (const size_t slot_idx) const
 
const int8_t getLogicalSlotWidthBytes (const size_t slot_idx) const
 
const int8_t getSlotIndexForSingleSlotCol (const size_t col_idx) const
 
size_t getPaddedColWidthForRange (const size_t offset, const size_t range) const
 
void useConsistentSlotWidthSize (const int8_t slot_width_size)
 
size_t getRowWidth () const
 
int8_t updateActualMinByteWidth (const int8_t actual_min_byte_width) const
 
void addColSlotInfo (const std::vector< std::tuple< int8_t, int8_t >> &slots_for_col)
 
void clearSlotInfo ()
 
void alignPaddedSlots ()
 
int64_t getTargetGroupbyIndex (const size_t target_idx) const
 
void setAllTargetGroupbyIndices (std::vector< int64_t > group_by_indices)
 
size_t targetGroupbyIndicesSize () const
 
size_t targetGroupbyNegativeIndicesSize () const
 
void clearTargetGroupbyIndices ()
 
size_t getEntryCount () const
 
void setEntryCount (const size_t val)
 
int64_t getMinVal () const
 
int64_t getMaxVal () const
 
int64_t getBucket () const
 
bool hasNulls () const
 
const CountDistinctDescriptorgetCountDistinctDescriptor (const size_t idx) const
 
size_t getCountDistinctDescriptorsSize () const
 
bool sortOnGpu () const
 
bool canOutputColumnar () const
 
bool didOutputColumnar () const
 
void setOutputColumnar (const bool val)
 
bool useStreamingTopN () const
 
bool isLogicalSizedColumnsAllowed () const
 
bool mustUseBaselineSort () const
 
bool forceFourByteFloat () const
 
void setForceFourByteFloat (const bool val)
 
size_t getGroupbyColCount () const
 
size_t getKeyCount () const
 
size_t getBufferColSlotCount () const
 
size_t getBufferSizeBytes (const RelAlgExecutionUnit &ra_exe_unit, const unsigned thread_count, const ExecutorDeviceType device_type) const
 
size_t getBufferSizeBytes (const ExecutorDeviceType device_type) const
 
size_t getBufferSizeBytes (const ExecutorDeviceType device_type, const size_t override_entry_count) const
 
const ColSlotContextgetColSlotContext () const
 
bool usesGetGroupValueFast () const
 
bool blocksShareMemory () const
 
bool threadsShareMemory () const
 
bool lazyInitGroups (const ExecutorDeviceType) const
 
bool interleavedBins (const ExecutorDeviceType) const
 
size_t getColOffInBytes (const size_t col_idx) const
 
size_t getColOffInBytesInNextBin (const size_t col_idx) const
 
size_t getNextColOffInBytes (const int8_t *col_ptr, const size_t bin, const size_t col_idx) const
 
size_t getNextColOffInBytesRowOnly (const int8_t *col_ptr, const size_t col_idx) const
 
size_t getColOnlyOffInBytes (const size_t col_idx) const
 
size_t getRowSize () const
 
size_t getColsSize () const
 
size_t getWarpCount () const
 
size_t getCompactByteWidth () const
 
size_t getEffectiveKeyWidth () const
 
bool isWarpSyncRequired (const ExecutorDeviceType) const
 
std::string queryDescTypeToString () const
 
std::string toString () const
 
std::string reductionKey () const
 

Static Public Member Functions

static TResultSetBufferDescriptor toThrift (const QueryMemoryDescriptor &)
 
static std::unique_ptr
< QueryMemoryDescriptor
init (const Executor *executor, const RelAlgExecutionUnit &ra_exe_unit, const std::vector< InputTableInfo > &query_infos, const ColRangeInfo &col_range_info, const KeylessInfo &keyless_info, const bool allow_multifrag, const ExecutorDeviceType device_type, const int8_t crt_min_byte_width, const bool sort_on_gpu_hint, const size_t shard_count, const size_t max_groups_buffer_entry_count, RenderInfo *render_info, const CountDistinctDescriptors count_distinct_descriptors, const bool must_use_baseline_sort, const bool output_columnar_hint, const bool streaming_top_n_hint)
 
static bool many_entries (const int64_t max_val, const int64_t min_val, const int64_t bucket)
 
static bool countDescriptorsLogicallyEmpty (const CountDistinctDescriptors &count_distinct_descriptors)
 
static int8_t pick_target_compact_width (const RelAlgExecutionUnit &ra_exe_unit, const std::vector< InputTableInfo > &query_infos, const int8_t crt_min_byte_width)
 

Protected Member Functions

void resetGroupColWidths (const std::vector< int8_t > &new_group_col_widths)
 

Private Member Functions

size_t getTotalBytesOfColumnarBuffers () const
 
size_t getTotalBytesOfColumnarBuffers (const size_t num_entries_per_column) const
 
size_t getTotalBytesOfColumnarProjections (const size_t projection_count) const
 

Private Attributes

const Executorexecutor_
 
bool allow_multifrag_
 
QueryDescriptionType query_desc_type_
 
bool keyless_hash_
 
bool interleaved_bins_on_gpu_
 
int32_t idx_target_as_key_
 
std::vector< int8_t > group_col_widths_
 
int8_t group_col_compact_width_
 
std::vector< int64_t > target_groupby_indices_
 
size_t entry_count_
 
int64_t min_val_
 
int64_t max_val_
 
int64_t bucket_
 
bool has_nulls_
 
CountDistinctDescriptors count_distinct_descriptors_
 
bool sort_on_gpu_
 
bool output_columnar_
 
bool render_output_
 
bool must_use_baseline_sort_
 
bool is_table_function_
 
bool use_streaming_top_n_
 
bool force_4byte_float_
 
ColSlotContext col_slot_context_
 

Friends

class ResultSet
 
class QueryExecutionContext
 

Detailed Description

Definition at line 68 of file QueryMemoryDescriptor.h.

Constructor & Destructor Documentation

QueryMemoryDescriptor::QueryMemoryDescriptor ( )

Definition at line 527 of file QueryMemoryDescriptor.cpp.

References Projection.

528  : executor_(nullptr)
529  , allow_multifrag_(false)
531  , keyless_hash_(false)
532  , interleaved_bins_on_gpu_(false)
533  , idx_target_as_key_(0)
535  , entry_count_(0)
536  , min_val_(0)
537  , max_val_(0)
538  , bucket_(0)
539  , has_nulls_(false)
540  , sort_on_gpu_(false)
541  , output_columnar_(false)
542  , render_output_(false)
543  , must_use_baseline_sort_(false)
544  , is_table_function_(false)
545  , use_streaming_top_n_(false)
546  , force_4byte_float_(false) {}
QueryDescriptionType query_desc_type_
QueryMemoryDescriptor::QueryMemoryDescriptor ( const Executor executor,
const RelAlgExecutionUnit ra_exe_unit,
const std::vector< InputTableInfo > &  query_infos,
const bool  allow_multifrag,
const bool  keyless_hash,
const bool  interleaved_bins_on_gpu,
const int32_t  idx_target_as_key,
const ColRangeInfo col_range_info,
const ColSlotContext col_slot_context,
const std::vector< int8_t > &  group_col_widths,
const int8_t  group_col_compact_width,
const std::vector< int64_t > &  target_groupby_indices,
const size_t  entry_count,
const CountDistinctDescriptors  count_distinct_descriptors,
const bool  sort_on_gpu_hint,
const bool  output_columnar,
const bool  render_output,
const bool  must_use_baseline_sort,
const bool  use_streaming_top_n 
)

Definition at line 430 of file QueryMemoryDescriptor.cpp.

References anonymous_namespace{QueryMemoryDescriptor.cpp}::anyOf(), canOutputColumnar(), CHECK, col_slot_context_, count_distinct_descriptors_, countDescriptorsLogicallyEmpty(), executor_, streaming_top_n::get_heap_size(), getEntryCount(), getRowSize(), GroupByBaselineHash, GroupByPerfectHash, isLogicalSizedColumnsAllowed(), kAPPROX_MEDIAN, keyless_hash_, NonGroupedAggregate, output_columnar_, Projection, query_desc_type_, ColSlotContext::setAllSlotsPaddedSizeToLogicalSize(), ColSlotContext::setAllUnsetSlotsPaddedSize(), sort_on_gpu_, RelAlgExecutionUnit::target_exprs, RelAlgExecutionUnit::use_bump_allocator, use_streaming_top_n_, and ColSlotContext::validate().

450  : executor_(executor)
451  , allow_multifrag_(allow_multifrag)
452  , query_desc_type_(col_range_info.hash_type_)
453  , keyless_hash_(keyless_hash)
454  , interleaved_bins_on_gpu_(interleaved_bins_on_gpu)
455  , idx_target_as_key_(idx_target_as_key)
456  , group_col_widths_(group_col_widths)
457  , group_col_compact_width_(group_col_compact_width)
458  , target_groupby_indices_(target_groupby_indices)
459  , entry_count_(entry_count)
460  , min_val_(col_range_info.min)
461  , max_val_(col_range_info.max)
462  , bucket_(col_range_info.bucket)
463  , has_nulls_(col_range_info.has_nulls)
464  , count_distinct_descriptors_(count_distinct_descriptors)
465  , output_columnar_(false)
466  , render_output_(render_output)
467  , must_use_baseline_sort_(must_use_baseline_sort)
468  , is_table_function_(false)
470  , force_4byte_float_(false)
471  , col_slot_context_(col_slot_context) {
474 
475  sort_on_gpu_ = sort_on_gpu_hint && canOutputColumnar() && !keyless_hash_;
476 
477  if (sort_on_gpu_) {
478  CHECK(!ra_exe_unit.use_bump_allocator);
479  output_columnar_ = true;
480  } else {
481  switch (query_desc_type_) {
483  output_columnar_ = output_columnar_hint;
484  break;
486  output_columnar_ = output_columnar_hint &&
489  !anyOf(ra_exe_unit.target_exprs, kAPPROX_MEDIAN);
490  break;
492  output_columnar_ = output_columnar_hint;
493  break;
495  output_columnar_ = output_columnar_hint &&
498  !anyOf(ra_exe_unit.target_exprs, kAPPROX_MEDIAN);
499  break;
500  default:
501  output_columnar_ = false;
502  break;
503  }
504  }
505 
507  // TODO(adb): Ensure fixed size buffer allocations are correct with all logical column
508  // sizes
509  CHECK(!ra_exe_unit.use_bump_allocator);
512  }
513 
514 #ifdef HAVE_CUDA
515  // Check Streaming Top N heap usage, bail if > max slab size, CUDA ONLY
516  if (use_streaming_top_n_ && executor->catalog_->getDataMgr().gpusPresent()) {
517  const auto thread_count = executor->blockSize() * executor->gridSize();
518  const auto total_buff_size =
520  if (total_buff_size > executor_->maxGpuSlabSize()) {
521  throw StreamingTopNOOM(total_buff_size);
522  }
523  }
524 #endif
525 }
std::vector< Analyzer::Expr * > target_exprs
bool isLogicalSizedColumnsAllowed() const
QueryDescriptionType hash_type_
bool use_streaming_top_n(const RelAlgExecutionUnit &ra_exe_unit, const bool output_columnar)
std::vector< int64_t > target_groupby_indices_
CountDistinctDescriptors count_distinct_descriptors_
void validate() const
bool anyOf(std::vector< Analyzer::Expr * > const &target_exprs, SQLAgg const agg_kind)
QueryDescriptionType query_desc_type_
size_t get_heap_size(const size_t row_size, const size_t n, const size_t thread_count)
void setAllSlotsPaddedSizeToLogicalSize()
#define CHECK(condition)
Definition: Logger.h:203
std::vector< int8_t > group_col_widths_
static bool countDescriptorsLogicallyEmpty(const CountDistinctDescriptors &count_distinct_descriptors)
void setAllUnsetSlotsPaddedSize(const int8_t padded_size)

+ Here is the call graph for this function:

QueryMemoryDescriptor::QueryMemoryDescriptor ( const Executor executor,
const size_t  entry_count,
const QueryDescriptionType  query_desc_type,
const bool  is_table_function 
)

Definition at line 548 of file QueryMemoryDescriptor.cpp.

552  : executor_(executor)
553  , allow_multifrag_(false)
554  , query_desc_type_(query_desc_type)
555  , keyless_hash_(false)
556  , interleaved_bins_on_gpu_(false)
557  , idx_target_as_key_(0)
559  , entry_count_(entry_count)
560  , min_val_(0)
561  , max_val_(0)
562  , bucket_(0)
563  , has_nulls_(false)
564  , sort_on_gpu_(false)
565  , output_columnar_(false)
566  , render_output_(false)
567  , must_use_baseline_sort_(false)
568  , is_table_function_(is_table_function)
569  , use_streaming_top_n_(false)
570  , force_4byte_float_(false) {}
QueryDescriptionType query_desc_type_
QueryMemoryDescriptor::QueryMemoryDescriptor ( const QueryDescriptionType  query_desc_type,
const int64_t  min_val,
const int64_t  max_val,
const bool  has_nulls,
const std::vector< int8_t > &  group_col_widths 
)

Definition at line 572 of file QueryMemoryDescriptor.cpp.

577  : executor_(nullptr)
578  , allow_multifrag_(false)
579  , query_desc_type_(query_desc_type)
580  , keyless_hash_(false)
581  , interleaved_bins_on_gpu_(false)
582  , idx_target_as_key_(0)
583  , group_col_widths_(group_col_widths)
585  , entry_count_(0)
586  , min_val_(min_val)
587  , max_val_(max_val)
588  , bucket_(0)
589  , has_nulls_(false)
590  , sort_on_gpu_(false)
591  , output_columnar_(false)
592  , render_output_(false)
593  , must_use_baseline_sort_(false)
594  , is_table_function_(false)
595  , use_streaming_top_n_(false)
596  , force_4byte_float_(false) {}
QueryDescriptionType query_desc_type_
std::vector< int8_t > group_col_widths_
QueryMemoryDescriptor::QueryMemoryDescriptor ( const TResultSetBufferDescriptor &  thrift_query_memory_descriptor)

Member Function Documentation

void QueryMemoryDescriptor::addColSlotInfo ( const std::vector< std::tuple< int8_t, int8_t >> &  slots_for_col)

Definition at line 1145 of file QueryMemoryDescriptor.cpp.

References ColSlotContext::addColumn(), and col_slot_context_.

Referenced by ResultSetLogicalValuesBuilder::create(), TableFunctionExecutionContext::launchCpuCode(), and TableFunctionExecutionContext::launchGpuCode().

1146  {
1147  col_slot_context_.addColumn(slots_for_col);
1148 }
void addColumn(const std::vector< std::tuple< int8_t, int8_t >> &slots_for_col)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QueryMemoryDescriptor::alignPaddedSlots ( )

Definition at line 1154 of file QueryMemoryDescriptor.cpp.

References ColSlotContext::alignPaddedSlots(), col_slot_context_, and sortOnGpu().

1154  {
1156 }
void alignPaddedSlots(const bool sort_on_gpu)

+ Here is the call graph for this function:

bool QueryMemoryDescriptor::blocksShareMemory ( ) const

Definition at line 1068 of file QueryMemoryDescriptor.cpp.

References bucket_, count_distinct_descriptors_, countDescriptorsLogicallyEmpty(), executor_, g_cluster, getGroupbyColCount(), GroupByBaselineHash, GroupByPerfectHash, is_table_function_, many_entries(), max_val_, min_val_, Projection, query_desc_type_, and render_output_.

Referenced by canOutputColumnar(), ResultSetReductionJIT::codegen(), QueryMemoryInitializer::computeNumberOfBuffers(), copy_group_by_buffers_from_gpu(), create_dev_group_by_buffers(), and toString().

1068  {
1069  if (g_cluster || is_table_function_) {
1070  return true;
1071  }
1073  return true;
1074  }
1075  if (executor_->isCPUOnly() || render_output_ ||
1079  getGroupbyColCount() > 1)) {
1080  return true;
1081  }
1084 }
static bool many_entries(const int64_t max_val, const int64_t min_val, const int64_t bucket)
size_t getGroupbyColCount() const
CountDistinctDescriptors count_distinct_descriptors_
QueryDescriptionType query_desc_type_
bool g_cluster
static bool countDescriptorsLogicallyEmpty(const CountDistinctDescriptors &count_distinct_descriptors)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool QueryMemoryDescriptor::canOutputColumnar ( ) const

Definition at line 1158 of file QueryMemoryDescriptor.cpp.

References blocksShareMemory(), count_distinct_descriptors_, countDescriptorsLogicallyEmpty(), GPU, interleavedBins(), threadsShareMemory(), and usesGetGroupValueFast().

Referenced by QueryMemoryDescriptor().

1158  {
1162 }
CountDistinctDescriptors count_distinct_descriptors_
bool interleavedBins(const ExecutorDeviceType) const
static bool countDescriptorsLogicallyEmpty(const CountDistinctDescriptors &count_distinct_descriptors)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QueryMemoryDescriptor::clearGroupColWidths ( )
inline

Definition at line 194 of file QueryMemoryDescriptor.h.

References group_col_widths_.

194 { group_col_widths_.clear(); }
std::vector< int8_t > group_col_widths_
void QueryMemoryDescriptor::clearSlotInfo ( )

Definition at line 1150 of file QueryMemoryDescriptor.cpp.

References ColSlotContext::clear(), and col_slot_context_.

1150  {
1152 }

+ Here is the call graph for this function:

void QueryMemoryDescriptor::clearTargetGroupbyIndices ( )
inline

Definition at line 243 of file QueryMemoryDescriptor.h.

References target_groupby_indices_.

243 { target_groupby_indices_.clear(); }
std::vector< int64_t > target_groupby_indices_
static bool QueryMemoryDescriptor::countDescriptorsLogicallyEmpty ( const CountDistinctDescriptors count_distinct_descriptors)
inlinestatic

Definition at line 149 of file QueryMemoryDescriptor.h.

References Invalid.

Referenced by blocksShareMemory(), canOutputColumnar(), countDistinctDescriptorsLogicallyEmpty(), lazyInitGroups(), and QueryMemoryDescriptor().

150  {
151  return std::all_of(count_distinct_descriptors.begin(),
152  count_distinct_descriptors.end(),
153  [](const CountDistinctDescriptor& desc) {
154  return desc.impl_type_ == CountDistinctImplType::Invalid;
155  });
156  }

+ Here is the caller graph for this function:

bool QueryMemoryDescriptor::countDistinctDescriptorsLogicallyEmpty ( ) const
inline

Definition at line 158 of file QueryMemoryDescriptor.h.

References count_distinct_descriptors_, and countDescriptorsLogicallyEmpty().

Referenced by QueryMemoryInitializer::allocateCountDistinctGpuMem().

158  {
160  }
CountDistinctDescriptors count_distinct_descriptors_
static bool countDescriptorsLogicallyEmpty(const CountDistinctDescriptors &count_distinct_descriptors)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool QueryMemoryDescriptor::didOutputColumnar ( ) const
inline

Definition at line 265 of file QueryMemoryDescriptor.h.

References output_columnar_.

Referenced by ResultSetStorage::binSearchRowCount(), TargetExprCodegen::codegen(), ResultSetReductionJIT::codegen(), GroupByAndAggregate::codegen(), GroupByAndAggregate::codegenAggCalls(), GroupByAndAggregate::codegenAggColumnPtr(), TargetExprCodegen::codegenAggregate(), GroupByAndAggregate::codegenGroupBy(), GroupByAndAggregate::codegenMultiColumnBaselineHash(), GroupByAndAggregate::codegenMultiColumnPerfectHash(), GroupByAndAggregate::codegenOutputSlot(), GroupByAndAggregate::codegenSingleColumnPerfectHash(), GroupByAndAggregate::codegenWindowRowPointer(), copy_projection_buffer_from_gpu_columnar(), ResultSetStorage::copyKeyColWise(), ResultSet::createComparator(), ResultSet::didOutputColumnar(), anonymous_namespace{ResultSetReduction.cpp}::fill_slots(), ResultSetStorage::fillOneEntryColWise(), ResultSetStorage::fillOneEntryRowWise(), ResultSet::fixupQueryMemoryDescriptor(), get_cols_ptr(), ResultSet::getTargetValueFromBufferColwise(), GpuReductionHelperJIT::GpuReductionHelperJIT(), GpuSharedMemCodeBuilder::GpuSharedMemCodeBuilder(), ResultSetStorage::initializeBaselineValueSlots(), anonymous_namespace{TargetExprBuilder.cpp}::is_columnar_projection(), ResultSetReductionJIT::isEmpty(), ResultSetStorage::isEmptyEntry(), ResultSetStorage::isEmptyEntryColumnar(), QueryExecutionContext::launchCpuCode(), QueryExecutionContext::launchGpuCode(), ResultSet::makeGeoTargetValue(), ResultSetStorage::moveOneEntryToBuffer(), ResultSetStorage::reduce(), ResultSetStorage::reduceOneEntryBaseline(), ResultSetReductionJIT::reduceOneEntryBaselineIdx(), ResultSetStorage::reduceOneEntrySlotsBaseline(), ResultSetStorage::reduceOneSlotBaseline(), ResultSetStorage::reduceSingleRow(), and ResultSetStorage::rewriteAggregateBufferOffsets().

+ Here is the caller graph for this function:

bool QueryMemoryDescriptor::forceFourByteFloat ( ) const
inline

Definition at line 276 of file QueryMemoryDescriptor.h.

References force_4byte_float_.

Referenced by ResultSet::makeTargetValue().

+ Here is the caller graph for this function:

int64_t QueryMemoryDescriptor::getBucket ( ) const
inline

Definition at line 250 of file QueryMemoryDescriptor.h.

References bucket_.

Referenced by GroupByAndAggregate::codegenGroupBy(), and GroupByAndAggregate::codegenSingleColumnPerfectHash().

250 { return bucket_; }

+ Here is the caller graph for this function:

size_t QueryMemoryDescriptor::getBufferColSlotCount ( ) const

Definition at line 1048 of file QueryMemoryDescriptor.cpp.

References col_slot_context_, ColSlotContext::getSlotCount(), i, and target_groupby_indices_.

Referenced by anonymous_namespace{ResultSetIteration.cpp}::advance_col_buff_to_slot(), anonymous_namespace{ResultSetReduction.cpp}::fill_slots(), ResultSetStorage::fillOneEntryColWise(), and ResultSetStorage::fillOneEntryRowWise().

1048  {
1049  size_t total_slot_count = col_slot_context_.getSlotCount();
1050 
1051  if (target_groupby_indices_.empty()) {
1052  return total_slot_count;
1053  }
1054  return total_slot_count - std::count_if(target_groupby_indices_.begin(),
1056  [](const int64_t i) { return i >= 0; });
1057 }
std::vector< int64_t > target_groupby_indices_
size_t getSlotCount() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t QueryMemoryDescriptor::getBufferSizeBytes ( const RelAlgExecutionUnit ra_exe_unit,
const unsigned  thread_count,
const ExecutorDeviceType  device_type 
) const

Definition at line 979 of file QueryMemoryDescriptor.cpp.

References entry_count_, streaming_top_n::get_heap_size(), getRowSize(), SortInfo::limit, SortInfo::offset, RelAlgExecutionUnit::sort_info, and use_streaming_top_n_.

Referenced by QueryMemoryInitializer::applyStreamingTopNOffsetCpu(), QueryMemoryInitializer::copyGroupByBuffersFromGpu(), create_dev_group_by_buffers(), getBufferSizeBytes(), and QueryMemoryInitializer::QueryMemoryInitializer().

982  {
983  if (use_streaming_top_n_) {
984  const size_t n = ra_exe_unit.sort_info.offset + ra_exe_unit.sort_info.limit;
985  return streaming_top_n::get_heap_size(getRowSize(), n, thread_count);
986  }
987  return getBufferSizeBytes(device_type, entry_count_);
988 }
size_t getBufferSizeBytes(const RelAlgExecutionUnit &ra_exe_unit, const unsigned thread_count, const ExecutorDeviceType device_type) const
const size_t limit
const SortInfo sort_info
size_t get_heap_size(const size_t row_size, const size_t n, const size_t thread_count)
const size_t offset

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t QueryMemoryDescriptor::getBufferSizeBytes ( const ExecutorDeviceType  device_type) const

Definition at line 1025 of file QueryMemoryDescriptor.cpp.

References entry_count_, and getBufferSizeBytes().

1026  {
1027  return getBufferSizeBytes(device_type, entry_count_);
1028 }
size_t getBufferSizeBytes(const RelAlgExecutionUnit &ra_exe_unit, const unsigned thread_count, const ExecutorDeviceType device_type) const

+ Here is the call graph for this function:

size_t QueryMemoryDescriptor::getBufferSizeBytes ( const ExecutorDeviceType  device_type,
const size_t  entry_count 
) const

Returns total amount of output buffer memory for each device (CPU/GPU)

Columnar: if projection: it returns index buffer + columnar buffer (all non-lazy columns) if group by: it returns the amount required for each group column (assumes 64-bit per group) + columnar buffer (all involved agg columns)

Row-wise: returns required memory per row multiplied by number of entries

Definition at line 1001 of file QueryMemoryDescriptor.cpp.

References align_to_int64(), CHECK_GE, executor_, getColsSize(), getRowSize(), getTotalBytesOfColumnarBuffers(), group_col_widths_, interleavedBins(), keyless_hash_, output_columnar_, Projection, and query_desc_type_.

1002  {
1003  if (keyless_hash_ && !output_columnar_) {
1004  CHECK_GE(group_col_widths_.size(), size_t(1));
1005  auto row_bytes = align_to_int64(getColsSize());
1006 
1007  return (interleavedBins(device_type) ? executor_->warpSize() : 1) * entry_count *
1008  row_bytes;
1009  }
1010 
1011  constexpr size_t row_index_width = sizeof(int64_t);
1012  size_t total_bytes{0};
1013  if (output_columnar_) {
1015  ? row_index_width * entry_count
1016  : sizeof(int64_t) * group_col_widths_.size() * entry_count) +
1018  } else {
1019  total_bytes = getRowSize() * entry_count;
1020  }
1021 
1022  return total_bytes;
1023 }
#define CHECK_GE(x, y)
Definition: Logger.h:216
size_t getTotalBytesOfColumnarBuffers() const
QueryDescriptionType query_desc_type_
bool interleavedBins(const ExecutorDeviceType) const
std::vector< int8_t > group_col_widths_
FORCE_INLINE HOST DEVICE T align_to_int64(T addr)

+ Here is the call graph for this function:

size_t QueryMemoryDescriptor::getColCount ( ) const

Definition at line 1107 of file QueryMemoryDescriptor.cpp.

References col_slot_context_, and ColSlotContext::getColCount().

1107  {
1108  return col_slot_context_.getColCount();
1109 }
size_t getColCount() const

+ Here is the call graph for this function:

size_t QueryMemoryDescriptor::getColOffInBytes ( const size_t  col_idx) const

Definition at line 858 of file QueryMemoryDescriptor.cpp.

References align_to_int64(), CHECK, CHECK_EQ, entry_count_, getColOnlyOffInBytes(), getEffectiveKeyWidth(), getPaddedSlotWidthBytes(), getPrependedGroupBufferSizeInBytes(), getWarpCount(), group_col_widths_, GroupByPerfectHash, keyless_hash_, output_columnar_, and query_desc_type_.

Referenced by TargetExprCodegen::codegen(), GroupByAndAggregate::codegenAggColumnPtr(), GroupByAndAggregate::codegenOutputSlot(), anonymous_namespace{QueryMemoryInitializer.cpp}::compact_projection_buffer_for_cpu_columnar(), copy_projection_buffer_from_gpu_columnar(), get_cols_ptr(), QueryExecutionContext::groupBufferToDeinterleavedResults(), QueryMemoryInitializer::initRowGroups(), inplace_sort_gpu(), and anonymous_namespace{Execute.cpp}::permute_storage_columnar().

858  {
859  const auto warp_count = getWarpCount();
860  if (output_columnar_) {
861  CHECK_EQ(size_t(1), warp_count);
862  size_t offset{0};
863  if (!keyless_hash_) {
865  }
866  for (size_t index = 0; index < col_idx; ++index) {
868  }
869  return offset;
870  }
871 
872  size_t offset{0};
873  if (keyless_hash_) {
874  // ignore, there's no group column in the output buffer
876  } else {
877  offset += group_col_widths_.size() * getEffectiveKeyWidth();
878  offset = align_to_int64(offset);
879  }
880  offset += getColOnlyOffInBytes(col_idx);
881  return offset;
882 }
#define CHECK_EQ(x, y)
Definition: Logger.h:211
size_t getEffectiveKeyWidth() const
size_t getColOnlyOffInBytes(const size_t col_idx) const
size_t getPrependedGroupBufferSizeInBytes() const
const int8_t getPaddedSlotWidthBytes(const size_t slot_idx) const
QueryDescriptionType query_desc_type_
#define CHECK(condition)
Definition: Logger.h:203
std::vector< int8_t > group_col_widths_
FORCE_INLINE HOST DEVICE T align_to_int64(T addr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t QueryMemoryDescriptor::getColOffInBytesInNextBin ( const size_t  col_idx) const

Definition at line 917 of file QueryMemoryDescriptor.cpp.

References CHECK_EQ, getPaddedSlotWidthBytes(), getRowSize(), getWarpCount(), group_col_widths_, and output_columnar_.

Referenced by QueryExecutionContext::groupBufferToDeinterleavedResults().

917  {
918  auto warp_count = getWarpCount();
919  if (output_columnar_) {
920  CHECK_EQ(size_t(1), group_col_widths_.size());
921  CHECK_EQ(size_t(1), warp_count);
922  return getPaddedSlotWidthBytes(col_idx);
923  }
924 
925  return warp_count * getRowSize();
926 }
#define CHECK_EQ(x, y)
Definition: Logger.h:211
const int8_t getPaddedSlotWidthBytes(const size_t slot_idx) const
std::vector< int8_t > group_col_widths_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t QueryMemoryDescriptor::getColOnlyOffInBytes ( const size_t  col_idx) const

Definition at line 845 of file QueryMemoryDescriptor.cpp.

References col_slot_context_, and ColSlotContext::getColOnlyOffInBytes().

Referenced by TargetExprCodegen::codegen(), GroupByAndAggregate::codegenAggColumnPtr(), TargetExprCodegen::codegenAggregate(), getColOffInBytes(), and ResultSetStorage::reduceSingleRow().

845  {
846  return col_slot_context_.getColOnlyOffInBytes(col_idx);
847 }
size_t getColOnlyOffInBytes(const size_t slot_idx) const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const ColSlotContext& QueryMemoryDescriptor::getColSlotContext ( ) const
inline

Definition at line 291 of file QueryMemoryDescriptor.h.

References col_slot_context_.

Referenced by ResultSetStorage::reduceEntriesNoCollisionsColWise(), and ResultSetReductionJIT::reduceOneEntryTargetsNoCollisions().

291 { return col_slot_context_; }

+ Here is the caller graph for this function:

size_t QueryMemoryDescriptor::getColsSize ( ) const

Definition at line 784 of file QueryMemoryDescriptor.cpp.

References col_slot_context_, and ColSlotContext::getAllSlotsAlignedPaddedSize().

Referenced by getBufferSizeBytes(), getRowSize(), and QueryExecutionContext::launchCpuCode().

784  {
786 }
size_t getAllSlotsAlignedPaddedSize() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t QueryMemoryDescriptor::getCompactByteWidth ( ) const

Definition at line 806 of file QueryMemoryDescriptor.cpp.

References col_slot_context_, and ColSlotContext::getCompactByteWidth().

Referenced by anonymous_namespace{TargetExprBuilder.cpp}::get_initial_agg_val(), and init_agg_val_vec().

806  {
808 }
size_t getCompactByteWidth() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const CountDistinctDescriptor& QueryMemoryDescriptor::getCountDistinctDescriptor ( const size_t  idx) const
inline
size_t QueryMemoryDescriptor::getCountDistinctDescriptorsSize ( ) const
inline

Definition at line 258 of file QueryMemoryDescriptor.h.

References count_distinct_descriptors_.

Referenced by QueryMemoryInitializer::allocateCountDistinctGpuMem(), anonymous_namespace{QueryMemoryInitializer.cpp}::check_total_bitmap_memory(), ResultSetReductionJIT::reduceOneApproxMedianSlot(), ResultSetStorage::reduceOneApproxMedianSlot(), ResultSetReductionJIT::reduceOneCountDistinctSlot(), and ResultSetStorage::reduceOneCountDistinctSlot().

258  {
259  return count_distinct_descriptors_.size();
260  }
CountDistinctDescriptors count_distinct_descriptors_

+ Here is the caller graph for this function:

size_t QueryMemoryDescriptor::getEntryCount ( ) const
inline

Definition at line 245 of file QueryMemoryDescriptor.h.

References entry_count_.

Referenced by advance_to_next_columnar_target_buff(), QueryMemoryInitializer::allocateCountDistinctGpuMem(), QueryMemoryInitializer::applyStreamingTopNOffsetCpu(), QueryMemoryInitializer::applyStreamingTopNOffsetGpu(), ResultSetStorage::binSearchRowCount(), anonymous_namespace{QueryMemoryInitializer.cpp}::check_total_bitmap_memory(), ResultSetReductionJIT::codegen(), GroupByAndAggregate::codegenMultiColumnBaselineHash(), GroupByAndAggregate::codegenMultiColumnPerfectHash(), GroupByAndAggregate::codegenOutputSlot(), GpuSharedMemCodeBuilder::codegenReduction(), GroupByAndAggregate::codegenWindowRowPointer(), anonymous_namespace{QueryMemoryInitializer.cpp}::compact_projection_buffer_for_cpu_columnar(), QueryMemoryInitializer::compactProjectionBuffersCpu(), QueryMemoryInitializer::compactProjectionBuffersGpu(), copy_group_by_buffers_from_gpu(), create_dev_group_by_buffers(), Executor::createKernels(), ResultSet::entryCount(), Executor::executePlanWithGroupBy(), ResultSetStorage::fillOneEntryColWise(), ResultSetStorage::fillOneEntryRowWise(), anonymous_namespace{ResultSetReduction.cpp}::get_matching_group_value_reduction(), ResultSetStorage::getEntryCount(), getPrependedGroupBufferSizeInBytes(), getPrependedGroupColOffInBytes(), ResultSet::getTargetValueFromBufferColwise(), QueryMemoryInitializer::initColumnarGroups(), QueryMemoryInitializer::initGroupByBuffer(), ResultSetStorage::initializeBaselineValueSlots(), ResultSetStorage::initializeColWise(), ResultSetStorage::initializeRowWise(), Executor::inlineHoistedLiterals(), inplace_sort_gpu(), QueryExecutionContext::launchGpuCode(), ResultSetStorage::moveEntriesToBuffer(), ResultSetStorage::moveOneEntryToBuffer(), QueryMemoryDescriptor(), QueryMemoryInitializer::QueryMemoryInitializer(), ResultSetStorage::reduce(), ResultSetStorage::reduceOneEntryBaseline(), ResultSetStorage::reduceOneEntrySlotsBaseline(), ResultSetStorage::reduceOneSlotBaseline(), and ResultSetStorage::rewriteAggregateBufferOffsets().

245 { return entry_count_; }

+ Here is the caller graph for this function:

const Executor* QueryMemoryDescriptor::getExecutor ( ) const
inline

Definition at line 167 of file QueryMemoryDescriptor.h.

References executor_.

Referenced by anonymous_namespace{Execute.cpp}::build_row_for_empty_input(), ResultSetReductionJIT::codegen(), anonymous_namespace{Execute.cpp}::fill_entries_for_empty_input(), ResultSet::getVarlenOrderEntry(), ResultSet::makeGeoTargetValue(), and ResultSet::makeVarlenTargetValue().

167 { return executor_; }

+ Here is the caller graph for this function:

size_t QueryMemoryDescriptor::getKeyCount ( ) const
inline

Definition at line 281 of file QueryMemoryDescriptor.h.

References getGroupbyColCount(), and keyless_hash_.

Referenced by anonymous_namespace{Execute.cpp}::permute_storage_columnar().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const int8_t QueryMemoryDescriptor::getLogicalSlotWidthBytes ( const size_t  slot_idx) const

Definition at line 1119 of file QueryMemoryDescriptor.cpp.

References col_slot_context_, ColSlotContext::getSlotInfo(), and SlotSize::logical_size.

Referenced by QueryMemoryInitializer::allocateCountDistinctBuffers(), QueryMemoryInitializer::allocateTDigests(), TargetExprCodegen::codegenAggregate(), and ResultSet::getTargetValueFromBufferRowwise().

1120  {
1121  return col_slot_context_.getSlotInfo(slot_idx).logical_size;
1122 }
int8_t logical_size
const SlotSize & getSlotInfo(const size_t slot_idx) const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t QueryMemoryDescriptor::getMaxVal ( ) const
inline

Definition at line 249 of file QueryMemoryDescriptor.h.

References max_val_.

Referenced by GroupByAndAggregate::codegenGroupBy().

249 { return max_val_; }

+ Here is the caller graph for this function:

int64_t QueryMemoryDescriptor::getMinVal ( ) const
inline

Definition at line 248 of file QueryMemoryDescriptor.h.

References min_val_.

Referenced by GroupByAndAggregate::codegenSingleColumnPerfectHash().

248 { return min_val_; }

+ Here is the caller graph for this function:

size_t QueryMemoryDescriptor::getNextColOffInBytes ( const int8_t *  col_ptr,
const size_t  bin,
const size_t  col_idx 
) const

Definition at line 928 of file QueryMemoryDescriptor.cpp.

References align_to_int64(), CHECK, CHECK_EQ, entry_count_, getPaddedSlotWidthBytes(), getSlotCount(), getWarpCount(), group_col_widths_, and output_columnar_.

930  {
932  size_t offset{0};
933  auto warp_count = getWarpCount();
934  const auto chosen_bytes = getPaddedSlotWidthBytes(col_idx);
935  const auto total_slot_count = getSlotCount();
936  if (col_idx + 1 == total_slot_count) {
937  if (output_columnar_) {
938  return (entry_count_ - bin) * chosen_bytes;
939  } else {
940  return static_cast<size_t>(align_to_int64(col_ptr + chosen_bytes) - col_ptr);
941  }
942  }
943 
944  const auto next_chosen_bytes = getPaddedSlotWidthBytes(col_idx + 1);
945  if (output_columnar_) {
946  CHECK_EQ(size_t(1), group_col_widths_.size());
947  CHECK_EQ(size_t(1), warp_count);
948 
949  offset = align_to_int64(entry_count_ * chosen_bytes);
950 
951  offset += bin * (next_chosen_bytes - chosen_bytes);
952  return offset;
953  }
954 
955  if (next_chosen_bytes == sizeof(int64_t)) {
956  return static_cast<size_t>(align_to_int64(col_ptr + chosen_bytes) - col_ptr);
957  } else {
958  return chosen_bytes;
959  }
960 }
#define CHECK_EQ(x, y)
Definition: Logger.h:211
const int8_t getPaddedSlotWidthBytes(const size_t slot_idx) const
#define CHECK(condition)
Definition: Logger.h:203
std::vector< int8_t > group_col_widths_
FORCE_INLINE HOST DEVICE T align_to_int64(T addr)

+ Here is the call graph for this function:

size_t QueryMemoryDescriptor::getNextColOffInBytesRowOnly ( const int8_t *  col_ptr,
const size_t  col_idx 
) const

Definition at line 962 of file QueryMemoryDescriptor.cpp.

References align_to_int64(), getPaddedSlotWidthBytes(), and getSlotCount().

Referenced by QueryMemoryInitializer::initColumnsPerRow().

963  {
964  const auto chosen_bytes = getPaddedSlotWidthBytes(col_idx);
965  const auto total_slot_count = getSlotCount();
966  if (col_idx + 1 == total_slot_count) {
967  return static_cast<size_t>(align_to_int64(col_ptr + chosen_bytes) - col_ptr);
968  }
969 
970  const auto next_chosen_bytes = getPaddedSlotWidthBytes(col_idx + 1);
971 
972  if (next_chosen_bytes == sizeof(int64_t)) {
973  return static_cast<size_t>(align_to_int64(col_ptr + chosen_bytes) - col_ptr);
974  } else {
975  return chosen_bytes;
976  }
977 }
const int8_t getPaddedSlotWidthBytes(const size_t slot_idx) const
FORCE_INLINE HOST DEVICE T align_to_int64(T addr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t QueryMemoryDescriptor::getPaddedColWidthForRange ( const size_t  offset,
const size_t  range 
) const
inline

Definition at line 208 of file QueryMemoryDescriptor.h.

References getPaddedSlotWidthBytes(), and i.

Referenced by result_set::get_byteoff_of_slot(), and ResultSet::makeGeoTargetValue().

208  {
209  size_t ret = 0;
210  for (size_t i = offset; i < offset + range; i++) {
211  ret += static_cast<size_t>(getPaddedSlotWidthBytes(i));
212  }
213  return ret;
214  }
const int8_t getPaddedSlotWidthBytes(const size_t slot_idx) const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const int8_t QueryMemoryDescriptor::getPaddedSlotWidthBytes ( const size_t  slot_idx) const

Definition at line 1115 of file QueryMemoryDescriptor.cpp.

References col_slot_context_, ColSlotContext::getSlotInfo(), and SlotSize::padded_size.

Referenced by advance_target_ptr_row_wise(), advance_to_next_columnar_target_buff(), TargetExprCodegen::codegen(), anonymous_namespace{GpuSharedMemoryUtils.cpp}::codegen_smem_dest_slot_ptr(), TargetExprCodegen::codegenAggregate(), GroupByAndAggregate::codegenOutputSlot(), compact_init_vals(), anonymous_namespace{QueryMemoryInitializer.cpp}::compact_projection_buffer_for_cpu_columnar(), copy_projection_buffer_from_gpu_columnar(), ResultSet::copyColumnIntoBuffer(), Executor::executePlanWithoutGroupBy(), result_set::get_width_for_slot(), getColOffInBytes(), getColOffInBytesInNextBin(), getNextColOffInBytes(), getNextColOffInBytesRowOnly(), getPaddedColWidthForRange(), ResultSet::getPaddedSlotWidthBytes(), ResultSet::getTargetValueFromBufferColwise(), ResultSet::getTargetValueFromBufferRowwise(), init_agg_val_vec(), QueryMemoryInitializer::initColumnarGroups(), QueryMemoryInitializer::initColumnsPerRow(), inplace_sort_gpu(), ResultSetReductionJIT::isEmpty(), ResultSetStorage::isEmptyEntry(), ResultSetStorage::isEmptyEntryColumnar(), ResultSet::makeGeoTargetValue(), TargetExprCodegenBuilder::operator()(), anonymous_namespace{Execute.cpp}::permute_storage_columnar(), ResultSetStorage::reduceEntriesNoCollisionsColWise(), ResultSetReductionJIT::reduceOneAggregateSlot(), ResultSetReductionJIT::reduceOneEntryTargetsNoCollisions(), ResultSetStorage::reduceOneSlot(), ResultSetStorage::reduceSingleRow(), and ResultSetStorage::rewriteAggregateBufferOffsets().

1115  {
1116  return col_slot_context_.getSlotInfo(slot_idx).padded_size;
1117 }
const SlotSize & getSlotInfo(const size_t slot_idx) const
int8_t padded_size

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t QueryMemoryDescriptor::getPrependedGroupBufferSizeInBytes ( ) const

Definition at line 906 of file QueryMemoryDescriptor.cpp.

References align_to_int64(), CHECK, getEntryCount(), getGroupbyColCount(), groupColWidth(), and output_columnar_.

Referenced by getColOffInBytes().

906  {
908  size_t buffer_size{0};
909  for (size_t group_idx = 0; group_idx < getGroupbyColCount(); group_idx++) {
910  buffer_size += align_to_int64(
911  std::max(groupColWidth(group_idx), static_cast<int8_t>(sizeof(int64_t))) *
912  getEntryCount());
913  }
914  return buffer_size;
915 }
int8_t groupColWidth(const size_t key_idx) const
size_t getGroupbyColCount() const
#define CHECK(condition)
Definition: Logger.h:203
FORCE_INLINE HOST DEVICE T align_to_int64(T addr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t QueryMemoryDescriptor::getPrependedGroupColOffInBytes ( const size_t  group_idx) const

Definition at line 888 of file QueryMemoryDescriptor.cpp.

References align_to_int64(), CHECK, getEntryCount(), getGroupbyColCount(), groupColWidth(), and output_columnar_.

Referenced by ResultSetStorage::copyKeyColWise(), ResultSetStorage::isEmptyEntryColumnar(), and anonymous_namespace{Execute.cpp}::permute_storage_columnar().

889  {
891  CHECK(group_idx < getGroupbyColCount());
892  size_t offset{0};
893  for (size_t col_idx = 0; col_idx < group_idx; col_idx++) {
894  // TODO(Saman): relax that int64_bit part immediately
895  offset += align_to_int64(
896  std::max(groupColWidth(col_idx), static_cast<int8_t>(sizeof(int64_t))) *
897  getEntryCount());
898  }
899  return offset;
900 }
int8_t groupColWidth(const size_t key_idx) const
size_t getGroupbyColCount() const
#define CHECK(condition)
Definition: Logger.h:203
FORCE_INLINE HOST DEVICE T align_to_int64(T addr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

QueryDescriptionType QueryMemoryDescriptor::getQueryDescriptionType ( ) const
inline

Definition at line 169 of file QueryMemoryDescriptor.h.

References query_desc_type_.

Referenced by ResultSetStorage::binSearchRowCount(), ResultSetReductionJIT::codegen(), GroupByAndAggregate::codegen(), GpuReductionHelperJIT::codegen(), GroupByAndAggregate::codegenAggCalls(), GroupByAndAggregate::codegenAggColumnPtr(), GroupByAndAggregate::codegenGroupBy(), GroupByAndAggregate::codegenMultiColumnPerfectHash(), GroupByAndAggregate::codegenOutputSlot(), Executor::collectAllDeviceResults(), copy_projection_buffer_from_gpu_columnar(), Executor::createKernels(), ResultSet::getQueryDescriptionType(), GpuReductionHelperJIT::GpuReductionHelperJIT(), GpuSharedMemCodeBuilder::GpuSharedMemCodeBuilder(), init_agg_val_vec(), QueryMemoryInitializer::initColumnarGroups(), anonymous_namespace{TargetExprBuilder.cpp}::is_columnar_projection(), ResultSetReductionJIT::isEmpty(), ResultSetStorage::isEmptyEntry(), ResultSetStorage::isEmptyEntryColumnar(), isSingleColumnGroupByWithPerfectHash(), QueryExecutionContext::launchCpuCode(), QueryExecutionContext::launchGpuCode(), ResultSetStorage::moveEntriesToBuffer(), TargetExprCodegenBuilder::operator()(), ResultSetStorage::reduce(), Executor::reduceMultiDeviceResultSets(), ResultSetStorage::reduceOneEntryBaseline(), ResultSetReductionJIT::reduceOneEntryBaselineIdx(), ResultSetReductionJIT::reduceOneEntryNoCollisionsIdx(), ExecutionKernel::run(), ExecutionKernel::runImpl(), target_exprs_to_infos(), and ResultSet::updateStorageEntryCount().

169 { return query_desc_type_; }
QueryDescriptionType query_desc_type_

+ Here is the caller graph for this function:

std::unique_ptr< QueryExecutionContext > QueryMemoryDescriptor::getQueryExecutionContext ( const RelAlgExecutionUnit ra_exe_unit,
const Executor executor,
const ExecutorDeviceType  device_type,
const ExecutorDispatchMode  dispatch_mode,
const int  device_id,
const int64_t  num_rows,
const std::vector< std::vector< const int8_t * >> &  col_buffers,
const std::vector< std::vector< uint64_t >> &  frag_offsets,
std::shared_ptr< RowSetMemoryOwner row_set_mem_owner,
const bool  output_columnar,
const bool  sort_on_gpu,
const size_t  thread_idx,
RenderInfo render_info 
) const

Definition at line 662 of file QueryMemoryDescriptor.cpp.

References DEBUG_TIMER, and QueryExecutionContext.

Referenced by ExecutionKernel::runImpl().

675  {
676  auto timer = DEBUG_TIMER(__func__);
677  if (frag_offsets.empty()) {
678  return nullptr;
679  }
680  return std::unique_ptr<QueryExecutionContext>(
681  new QueryExecutionContext(ra_exe_unit,
682  *this,
683  executor,
684  device_type,
685  dispatch_mode,
686  device_id,
687  num_rows,
688  col_buffers,
689  frag_offsets,
690  row_set_mem_owner,
691  output_columnar,
692  sort_on_gpu,
693  thread_idx,
694  render_info));
695 }
#define DEBUG_TIMER(name)
Definition: Logger.h:319
void sort_on_gpu(int64_t *val_buff, int32_t *idx_buff, const uint64_t entry_count, const bool desc, const uint32_t chosen_bytes, ThrustAllocator &alloc)

+ Here is the caller graph for this function:

size_t QueryMemoryDescriptor::getRowSize ( ) const

Definition at line 788 of file QueryMemoryDescriptor.cpp.

References align_to_int64(), CHECK, getColsSize(), getEffectiveKeyWidth(), group_col_widths_, GroupByPerfectHash, keyless_hash_, output_columnar_, and query_desc_type_.

Referenced by QueryMemoryInitializer::applyStreamingTopNOffsetCpu(), QueryMemoryInitializer::applyStreamingTopNOffsetGpu(), ResultSetLogicalValuesBuilder::build(), GroupByAndAggregate::codegenGroupBy(), GroupByAndAggregate::codegenOutputSlot(), GroupByAndAggregate::codegenWindowRowPointer(), QueryMemoryInitializer::copyGroupByBuffersFromGpu(), create_dev_group_by_buffers(), getBufferSizeBytes(), getColOffInBytesInNextBin(), QueryMemoryInitializer::initRowGroups(), Executor::inlineHoistedLiterals(), anonymous_namespace{Execute.cpp}::permute_storage_row_wise(), QueryMemoryDescriptor(), QueryMemoryInitializer::QueryMemoryInitializer(), and ResultSetStorage::reduceSingleRow().

788  {
790  size_t total_bytes{0};
791  if (keyless_hash_) {
792  // ignore, there's no group column in the output buffer
794  } else {
795  total_bytes += group_col_widths_.size() * getEffectiveKeyWidth();
796  total_bytes = align_to_int64(total_bytes);
797  }
798  total_bytes += getColsSize();
799  return align_to_int64(total_bytes);
800 }
size_t getEffectiveKeyWidth() const
QueryDescriptionType query_desc_type_
#define CHECK(condition)
Definition: Logger.h:203
std::vector< int8_t > group_col_widths_
FORCE_INLINE HOST DEVICE T align_to_int64(T addr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t QueryMemoryDescriptor::getRowWidth ( ) const

Definition at line 1135 of file QueryMemoryDescriptor.cpp.

References col_slot_context_, and ColSlotContext::getAllSlotsPaddedSize().

Referenced by get_row_bytes().

1135  {
1136  // Note: Actual row size may include padding (see ResultSetBufferAccessors.h)
1138 }
size_t getAllSlotsPaddedSize() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t QueryMemoryDescriptor::getSlotCount ( ) const
const int8_t QueryMemoryDescriptor::getSlotIndexForSingleSlotCol ( const size_t  col_idx) const

Definition at line 1124 of file QueryMemoryDescriptor.cpp.

References CHECK_EQ, col_slot_context_, and ColSlotContext::getSlotsForCol().

Referenced by QueryMemoryInitializer::allocateCountDistinctBuffers(), and QueryMemoryInitializer::allocateTDigests().

1125  {
1126  const auto& col_slots = col_slot_context_.getSlotsForCol(col_idx);
1127  CHECK_EQ(col_slots.size(), size_t(1));
1128  return col_slots.front();
1129 }
#define CHECK_EQ(x, y)
Definition: Logger.h:211
const std::vector< size_t > & getSlotsForCol(const size_t col_idx) const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t QueryMemoryDescriptor::getTargetGroupbyIndex ( const size_t  target_idx) const
inline

Definition at line 227 of file QueryMemoryDescriptor.h.

References CHECK_LT, and target_groupby_indices_.

Referenced by ResultSet::getTargetValueFromBufferColwise(), ResultSet::getTargetValueFromBufferRowwise(), ResultSetReductionJIT::reduceOneEntryBaseline(), ResultSetStorage::reduceOneEntrySlotsBaseline(), ResultSetReductionJIT::reduceOneEntryTargetsNoCollisions(), ResultSetReductionJIT::reduceOneSlot(), ResultSetStorage::reduceOneSlot(), and reductionKey().

227  {
228  CHECK_LT(target_idx, target_groupby_indices_.size());
229  return target_groupby_indices_[target_idx];
230  }
std::vector< int64_t > target_groupby_indices_
#define CHECK_LT(x, y)
Definition: Logger.h:213

+ Here is the caller graph for this function:

int32_t QueryMemoryDescriptor::getTargetIdxForKey ( ) const
inline

Definition at line 182 of file QueryMemoryDescriptor.h.

References idx_target_as_key_.

Referenced by ResultSetReductionJIT::isEmpty(), ResultSetStorage::isEmptyEntry(), ResultSetStorage::isEmptyEntryColumnar(), ResultSetStorage::reduceSingleRow(), and reductionKey().

182 { return idx_target_as_key_; }

+ Here is the caller graph for this function:

size_t QueryMemoryDescriptor::getTotalBytesOfColumnarBuffers ( ) const
private

Returns the maximum total number of bytes (including required paddings) to store all non-lazy columns' results for columnar cases.

Definition at line 815 of file QueryMemoryDescriptor.cpp.

References CHECK, col_slot_context_, entry_count_, ColSlotContext::getTotalBytesOfColumnarBuffers(), and output_columnar_.

Referenced by getBufferSizeBytes(), and getTotalBytesOfColumnarProjections().

815  {
818 }
size_t getTotalBytesOfColumnarBuffers(const size_t entry_count) const
#define CHECK(condition)
Definition: Logger.h:203

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t QueryMemoryDescriptor::getTotalBytesOfColumnarBuffers ( const size_t  num_entries_per_column) const
private

This is a helper function that returns the total number of bytes (including required paddings) to store all non-lazy columns' results for columnar cases.

Definition at line 824 of file QueryMemoryDescriptor.cpp.

References col_slot_context_, and ColSlotContext::getTotalBytesOfColumnarBuffers().

825  {
826  return col_slot_context_.getTotalBytesOfColumnarBuffers(num_entries_per_column);
827 }
size_t getTotalBytesOfColumnarBuffers(const size_t entry_count) const

+ Here is the call graph for this function:

size_t QueryMemoryDescriptor::getTotalBytesOfColumnarProjections ( const size_t  projection_count) const
private

Returns the effective total number of bytes from columnar projections, which includes 1) total number of bytes used to store all non-lazy columns 2) total number of bytes used to store row indices (for lazy fetches, etc.)

NOTE: this function does not represent the buffer sizes dedicated for the results, but the required memory to fill all valid results into a compact new buffer (with no holes in it)

Definition at line 838 of file QueryMemoryDescriptor.cpp.

References getTotalBytesOfColumnarBuffers().

839  {
840  constexpr size_t row_index_width = sizeof(int64_t);
841  return getTotalBytesOfColumnarBuffers(projection_count) +
842  row_index_width * projection_count;
843 }
size_t getTotalBytesOfColumnarBuffers() const

+ Here is the call graph for this function:

size_t QueryMemoryDescriptor::getWarpCount ( ) const

Definition at line 802 of file QueryMemoryDescriptor.cpp.

References executor_, and interleaved_bins_on_gpu_.

Referenced by getColOffInBytes(), getColOffInBytesInNextBin(), and getNextColOffInBytes().

802  {
803  return (interleaved_bins_on_gpu_ ? executor_->warpSize() : 1);
804 }

+ Here is the caller graph for this function:

int8_t QueryMemoryDescriptor::groupColWidth ( const size_t  key_idx) const
inline

Definition at line 185 of file QueryMemoryDescriptor.h.

References CHECK_LT, and group_col_widths_.

Referenced by ResultSetStorage::copyKeyColWise(), getPrependedGroupBufferSizeInBytes(), getPrependedGroupColOffInBytes(), ResultSetStorage::isEmptyEntryColumnar(), and anonymous_namespace{Execute.cpp}::permute_storage_columnar().

185  {
186  CHECK_LT(key_idx, group_col_widths_.size());
187  return group_col_widths_[key_idx];
188  }
#define CHECK_LT(x, y)
Definition: Logger.h:213
std::vector< int8_t > group_col_widths_

+ Here is the caller graph for this function:

const auto QueryMemoryDescriptor::groupColWidthsBegin ( ) const
inline

Definition at line 192 of file QueryMemoryDescriptor.h.

References group_col_widths_.

192 { return group_col_widths_.begin(); }
std::vector< int8_t > group_col_widths_
const auto QueryMemoryDescriptor::groupColWidthsEnd ( ) const
inline

Definition at line 193 of file QueryMemoryDescriptor.h.

References group_col_widths_.

193 { return group_col_widths_.end(); }
std::vector< int8_t > group_col_widths_
bool QueryMemoryDescriptor::hasInterleavedBinsOnGpu ( ) const
inline

Definition at line 179 of file QueryMemoryDescriptor.h.

References interleaved_bins_on_gpu_.

bool QueryMemoryDescriptor::hasNulls ( ) const
inline

Definition at line 252 of file QueryMemoryDescriptor.h.

References has_nulls_.

Referenced by GroupByAndAggregate::codegenGroupBy().

252 { return has_nulls_; }

+ Here is the caller graph for this function:

std::unique_ptr< QueryMemoryDescriptor > QueryMemoryDescriptor::init ( const Executor executor,
const RelAlgExecutionUnit ra_exe_unit,
const std::vector< InputTableInfo > &  query_infos,
const ColRangeInfo col_range_info,
const KeylessInfo keyless_info,
const bool  allow_multifrag,
const ExecutorDeviceType  device_type,
const int8_t  crt_min_byte_width,
const bool  sort_on_gpu_hint,
const size_t  shard_count,
const size_t  max_groups_buffer_entry_count,
RenderInfo render_info,
const CountDistinctDescriptors  count_distinct_descriptors,
const bool  must_use_baseline_sort,
const bool  output_columnar_hint,
const bool  streaming_top_n_hint 
)
static

Definition at line 226 of file QueryMemoryDescriptor.cpp.

References anonymous_namespace{QueryMemoryDescriptor.cpp}::get_col_byte_widths(), RelAlgExecutionUnit::groupby_exprs, and RelAlgExecutionUnit::target_exprs.

Referenced by GroupByAndAggregate::initQueryMemoryDescriptorImpl().

242  {
243  auto group_col_widths = get_col_byte_widths(ra_exe_unit.groupby_exprs);
244  const bool is_group_by{!group_col_widths.empty()};
245 
246  auto col_slot_context = ColSlotContext(ra_exe_unit.target_exprs, {});
247 
248  const auto min_slot_size = QueryMemoryDescriptor::pick_target_compact_width(
249  ra_exe_unit, query_infos, crt_min_byte_width);
250 
251  col_slot_context.setAllSlotsPaddedSize(min_slot_size);
252  col_slot_context.validate();
253 
254  if (!is_group_by) {
255  CHECK(!must_use_baseline_sort);
256 
257  return std::make_unique<QueryMemoryDescriptor>(
258  executor,
259  ra_exe_unit,
260  query_infos,
261  allow_multifrag,
262  false,
263  false,
264  -1,
265  ColRangeInfo{ra_exe_unit.estimator ? QueryDescriptionType::Estimator
267  0,
268  0,
269  0,
270  false},
271  col_slot_context,
272  std::vector<int8_t>{},
273  /*group_col_compact_width=*/0,
274  std::vector<int64_t>{},
275  /*entry_count=*/1,
276  count_distinct_descriptors,
277  false,
278  output_columnar_hint,
279  render_info && render_info->isPotentialInSituRender(),
280  must_use_baseline_sort,
281  /*use_streaming_top_n=*/false);
282  }
283 
284  size_t entry_count = 1;
285  auto actual_col_range_info = col_range_info;
286  bool interleaved_bins_on_gpu = false;
287  bool keyless_hash = false;
288  bool streaming_top_n = false;
289  int8_t group_col_compact_width = 0;
290  int32_t idx_target_as_key = -1;
291  auto output_columnar = output_columnar_hint;
292  std::vector<int64_t> target_groupby_indices;
293 
294  switch (col_range_info.hash_type_) {
296  if (render_info) {
297  render_info->setInSituDataIfUnset(false);
298  }
299  // keyless hash: whether or not group columns are stored at the beginning of the
300  // output buffer
301  keyless_hash =
302  (!sort_on_gpu_hint ||
304  col_range_info.max, col_range_info.min, col_range_info.bucket)) &&
305  !col_range_info.bucket && !must_use_baseline_sort && keyless_info.keyless;
306 
307  // if keyless, then this target index indicates wheter an entry is empty or not
308  // (acts as a key)
309  idx_target_as_key = keyless_info.target_index;
310 
311  if (group_col_widths.size() > 1) {
312  // col range info max contains the expected cardinality of the output
313  entry_count = static_cast<size_t>(actual_col_range_info.max);
314  actual_col_range_info.bucket = 0;
315  } else {
316  // single column perfect hash
317  entry_count = std::max(
318  GroupByAndAggregate::getBucketedCardinality(col_range_info), int64_t(1));
319  const size_t interleaved_max_threshold{512};
320 
321  if (must_use_baseline_sort) {
322  target_groupby_indices = target_expr_group_by_indices(ra_exe_unit.groupby_exprs,
323  ra_exe_unit.target_exprs);
324  col_slot_context =
325  ColSlotContext(ra_exe_unit.target_exprs, target_groupby_indices);
326  }
327 
328  bool has_varlen_sample_agg = false;
329  for (const auto& target_expr : ra_exe_unit.target_exprs) {
330  if (target_expr->get_contains_agg()) {
331  const auto agg_expr = dynamic_cast<Analyzer::AggExpr*>(target_expr);
332  CHECK(agg_expr);
333  if (agg_expr->get_aggtype() == kSAMPLE &&
334  agg_expr->get_type_info().is_varlen()) {
335  has_varlen_sample_agg = true;
336  break;
337  }
338  }
339  }
340 
341  interleaved_bins_on_gpu = keyless_hash && !has_varlen_sample_agg &&
342  (entry_count <= interleaved_max_threshold) &&
343  (device_type == ExecutorDeviceType::GPU) &&
345  count_distinct_descriptors) &&
346  !output_columnar;
347  }
348  break;
349  }
351  if (render_info) {
352  render_info->setInSituDataIfUnset(false);
353  }
354  entry_count = shard_count
355  ? (max_groups_buffer_entry_count + shard_count - 1) / shard_count
356  : max_groups_buffer_entry_count;
357  target_groupby_indices = target_expr_group_by_indices(ra_exe_unit.groupby_exprs,
358  ra_exe_unit.target_exprs);
359  col_slot_context = ColSlotContext(ra_exe_unit.target_exprs, target_groupby_indices);
360 
361  group_col_compact_width =
362  output_columnar ? 8
363  : pick_baseline_key_width(ra_exe_unit, query_infos, executor);
364 
365  actual_col_range_info =
367  break;
368  }
370  CHECK(!must_use_baseline_sort);
371 
372  if (streaming_top_n_hint && use_streaming_top_n(ra_exe_unit, output_columnar)) {
373  streaming_top_n = true;
374  entry_count = ra_exe_unit.sort_info.offset + ra_exe_unit.sort_info.limit;
375  } else {
376  if (ra_exe_unit.use_bump_allocator) {
377  output_columnar = false;
378  entry_count = 0;
379  } else {
380  entry_count = ra_exe_unit.scan_limit
381  ? static_cast<size_t>(ra_exe_unit.scan_limit)
382  : max_groups_buffer_entry_count;
383  }
384  }
385 
386  const auto catalog = executor->getCatalog();
387  CHECK(catalog);
388  target_groupby_indices = executor->plan_state_->allow_lazy_fetch_
389  ? target_expr_proj_indices(ra_exe_unit, *catalog)
390  : std::vector<int64_t>{};
391 
392  col_slot_context = ColSlotContext(ra_exe_unit.target_exprs, target_groupby_indices);
393  break;
394  }
395  default:
396  UNREACHABLE() << "Unknown query type";
397  }
398 
399  return std::make_unique<QueryMemoryDescriptor>(
400  executor,
401  ra_exe_unit,
402  query_infos,
403  allow_multifrag,
404  keyless_hash,
405  interleaved_bins_on_gpu,
406  idx_target_as_key,
407  actual_col_range_info,
408  col_slot_context,
409  group_col_widths,
410  group_col_compact_width,
411  target_groupby_indices,
412  entry_count,
413  count_distinct_descriptors,
414  sort_on_gpu_hint,
415  output_columnar,
416  render_info && render_info->isPotentialInSituRender(),
417  must_use_baseline_sort,
418  streaming_top_n);
419 }
std::vector< Analyzer::Expr * > target_exprs
static bool many_entries(const int64_t max_val, const int64_t min_val, const int64_t bucket)
static int64_t getBucketedCardinality(const ColRangeInfo &col_range_info)
std::vector< int64_t > target_expr_proj_indices(const RelAlgExecutionUnit &ra_exe_unit, const Catalog_Namespace::Catalog &cat)
const bool keyless
std::vector< int8_t > get_col_byte_widths(const T &col_expr_list)
bool setInSituDataIfUnset(const bool is_in_situ_data)
Definition: RenderInfo.cpp:98
QueryDescriptionType hash_type_
#define UNREACHABLE()
Definition: Logger.h:247
bool use_streaming_top_n(const RelAlgExecutionUnit &ra_exe_unit, const bool output_columnar)
const std::list< std::shared_ptr< Analyzer::Expr > > groupby_exprs
static int8_t pick_target_compact_width(const RelAlgExecutionUnit &ra_exe_unit, const std::vector< InputTableInfo > &query_infos, const int8_t crt_min_byte_width)
const int32_t target_index
std::vector< int64_t > target_expr_group_by_indices(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby_exprs, const std::vector< Analyzer::Expr * > &target_exprs)
bool isPotentialInSituRender() const
Definition: RenderInfo.cpp:64
#define CHECK(condition)
Definition: Logger.h:203
static bool countDescriptorsLogicallyEmpty(const CountDistinctDescriptors &count_distinct_descriptors)
if(yyssp >=yyss+yystacksize-1)
int8_t pick_baseline_key_width(const RelAlgExecutionUnit &ra_exe_unit, const std::vector< InputTableInfo > &query_infos, const Executor *executor)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool QueryMemoryDescriptor::interleavedBins ( const ExecutorDeviceType  device_type) const

Definition at line 1091 of file QueryMemoryDescriptor.cpp.

References GPU, and interleaved_bins_on_gpu_.

Referenced by canOutputColumnar(), GroupByAndAggregate::codegenSingleColumnPerfectHash(), getBufferSizeBytes(), QueryExecutionContext::groupBufferToResults(), QueryMemoryInitializer::initGroupByBuffer(), and QueryMemoryInitializer::QueryMemoryInitializer().

1091  {
1092  return interleaved_bins_on_gpu_ && device_type == ExecutorDeviceType::GPU;
1093 }

+ Here is the caller graph for this function:

bool QueryMemoryDescriptor::isGroupBy ( ) const
inline

Definition at line 196 of file QueryMemoryDescriptor.h.

References group_col_widths_.

Referenced by anonymous_namespace{TargetExprBuilder.cpp}::get_initial_agg_val(), init_agg_val_vec(), QueryMemoryInitializer::initColumnsPerRow(), QueryExecutionContext::launchCpuCode(), QueryExecutionContext::launchGpuCode(), and QueryMemoryInitializer::QueryMemoryInitializer().

196 { return !group_col_widths_.empty(); }
std::vector< int8_t > group_col_widths_

+ Here is the caller graph for this function:

bool QueryMemoryDescriptor::isLogicalSizedColumnsAllowed ( ) const

Definition at line 1041 of file QueryMemoryDescriptor.cpp.

References g_cluster, output_columnar_, Projection, and query_desc_type_.

Referenced by TargetExprCodegen::codegenAggregate(), TargetExprCodegenBuilder::codegenMultiSlotSampleExpressions(), TargetExprCodegenBuilder::codegenSlotEmptyKey(), init_agg_val_vec(), ResultSet::makeTargetValue(), QueryMemoryDescriptor(), ResultSetStorage::reduceOneSlot(), ResultSetStorage::reduceOneSlotSingleValue(), and setOutputColumnar().

1041  {
1042  // In distributed mode, result sets are serialized using rowwise iterators, so we use
1043  // consistent slot widths for now
1044  return output_columnar_ && !g_cluster &&
1046 }
QueryDescriptionType query_desc_type_
bool g_cluster

+ Here is the caller graph for this function:

bool QueryMemoryDescriptor::isSingleColumnGroupByWithPerfectHash ( ) const
inline

Definition at line 171 of file QueryMemoryDescriptor.h.

References getGroupbyColCount(), getQueryDescriptionType(), and GroupByPerfectHash.

Referenced by GroupByAndAggregate::codegenGroupBy(), and ResultSet::getTargetValueFromBufferRowwise().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool QueryMemoryDescriptor::isWarpSyncRequired ( const ExecutorDeviceType  device_type) const

Definition at line 1096 of file QueryMemoryDescriptor.cpp.

References CHECK, executor_, and GPU.

Referenced by query_group_by_template_impl().

1097  {
1098  if (device_type != ExecutorDeviceType::GPU) {
1099  return false;
1100  } else {
1101  auto cuda_mgr = executor_->getCatalog()->getDataMgr().getCudaMgr();
1102  CHECK(cuda_mgr);
1103  return cuda_mgr->isArchVoltaOrGreaterForAll();
1104  }
1105 }
#define CHECK(condition)
Definition: Logger.h:203

+ Here is the caller graph for this function:

bool QueryMemoryDescriptor::lazyInitGroups ( const ExecutorDeviceType  device_type) const

Definition at line 1086 of file QueryMemoryDescriptor.cpp.

References count_distinct_descriptors_, countDescriptorsLogicallyEmpty(), GPU, and render_output_.

Referenced by create_dev_group_by_buffers(), QueryMemoryInitializer::QueryMemoryInitializer(), and toString().

1086  {
1087  return device_type == ExecutorDeviceType::GPU && !render_output_ &&
1089 }
CountDistinctDescriptors count_distinct_descriptors_
static bool countDescriptorsLogicallyEmpty(const CountDistinctDescriptors &count_distinct_descriptors)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool QueryMemoryDescriptor::many_entries ( const int64_t  max_val,
const int64_t  min_val,
const int64_t  bucket 
)
inlinestatic

Definition at line 143 of file QueryMemoryDescriptor.h.

Referenced by blocksShareMemory().

145  {
146  return max_val - min_val > 10000 * std::max(bucket, int64_t(1));
147  }

+ Here is the caller graph for this function:

bool QueryMemoryDescriptor::mustUseBaselineSort ( ) const
inline

Definition at line 272 of file QueryMemoryDescriptor.h.

References must_use_baseline_sort_.

Referenced by GroupByAndAggregate::codegenSingleColumnPerfectHash().

+ Here is the caller graph for this function:

bool QueryMemoryDescriptor::operator== ( const QueryMemoryDescriptor other) const

Definition at line 598 of file QueryMemoryDescriptor.cpp.

References bucket_, col_slot_context_, count_distinct_descriptors_, force_4byte_float_, group_col_compact_width_, group_col_widths_, has_nulls_, i, idx_target_as_key_, interleaved_bins_on_gpu_, keyless_hash_, max_val_, min_val_, output_columnar_, query_desc_type_, sort_on_gpu_, and target_groupby_indices_.

598  {
599  // Note that this method does not check ptr reference members (e.g. executor_) or
600  // entry_count_
601  if (query_desc_type_ != other.query_desc_type_) {
602  return false;
603  }
604  if (keyless_hash_ != other.keyless_hash_) {
605  return false;
606  }
608  return false;
609  }
610  if (idx_target_as_key_ != other.idx_target_as_key_) {
611  return false;
612  }
613  if (force_4byte_float_ != other.force_4byte_float_) {
614  return false;
615  }
616  if (group_col_widths_ != other.group_col_widths_) {
617  return false;
618  }
620  return false;
621  }
623  return false;
624  }
625  if (min_val_ != other.min_val_) {
626  return false;
627  }
628  if (max_val_ != other.max_val_) {
629  return false;
630  }
631  if (bucket_ != other.bucket_) {
632  return false;
633  }
634  if (has_nulls_ != other.has_nulls_) {
635  return false;
636  }
638  return false;
639  } else {
640  // Count distinct descriptors can legitimately differ in device only.
641  for (size_t i = 0; i < count_distinct_descriptors_.size(); ++i) {
642  auto ref_count_distinct_desc = other.count_distinct_descriptors_[i];
643  auto count_distinct_desc = count_distinct_descriptors_[i];
644  count_distinct_desc.device_type = ref_count_distinct_desc.device_type;
645  if (ref_count_distinct_desc != count_distinct_desc) {
646  return false;
647  }
648  }
649  }
650  if (sort_on_gpu_ != other.sort_on_gpu_) {
651  return false;
652  }
653  if (output_columnar_ != other.output_columnar_) {
654  return false;
655  }
656  if (col_slot_context_ != other.col_slot_context_) {
657  return false;
658  }
659  return true;
660 }
std::vector< int64_t > target_groupby_indices_
CountDistinctDescriptors count_distinct_descriptors_
QueryDescriptionType query_desc_type_
std::vector< int8_t > group_col_widths_
int8_t QueryMemoryDescriptor::pick_target_compact_width ( const RelAlgExecutionUnit ra_exe_unit,
const std::vector< InputTableInfo > &  query_infos,
const int8_t  crt_min_byte_width 
)
static

Definition at line 697 of file QueryMemoryDescriptor.cpp.

References CHECK, CHECK_EQ, g_bigint_count, anonymous_namespace{QueryMemoryDescriptor.cpp}::get_col_byte_widths(), Analyzer::UOper::get_operand(), Analyzer::Expr::get_type_info(), RelAlgExecutionUnit::groupby_exprs, RelAlgExecutionUnit::input_col_descs, anonymous_namespace{QueryMemoryDescriptor.cpp}::is_int_and_no_bigger_than(), kCOUNT, kENCODING_DICT, kUNNEST, and RelAlgExecutionUnit::target_exprs.

700  {
701  if (g_bigint_count) {
702  return sizeof(int64_t);
703  }
704  int8_t compact_width{0};
705  auto col_it = ra_exe_unit.input_col_descs.begin();
706  int unnest_array_col_id{std::numeric_limits<int>::min()};
707  for (const auto& groupby_expr : ra_exe_unit.groupby_exprs) {
708  const auto uoper = dynamic_cast<Analyzer::UOper*>(groupby_expr.get());
709  if (uoper && uoper->get_optype() == kUNNEST) {
710  const auto& arg_ti = uoper->get_operand()->get_type_info();
711  CHECK(arg_ti.is_array());
712  const auto& elem_ti = arg_ti.get_elem_type();
713  if (elem_ti.is_string() && elem_ti.get_compression() == kENCODING_DICT) {
714  unnest_array_col_id = (*col_it)->getColId();
715  } else {
716  compact_width = crt_min_byte_width;
717  break;
718  }
719  }
720  ++col_it;
721  }
722  if (!compact_width &&
723  (ra_exe_unit.groupby_exprs.size() != 1 || !ra_exe_unit.groupby_exprs.front())) {
724  compact_width = crt_min_byte_width;
725  }
726  if (!compact_width) {
727  col_it = ra_exe_unit.input_col_descs.begin();
728  std::advance(col_it, ra_exe_unit.groupby_exprs.size());
729  for (const auto target : ra_exe_unit.target_exprs) {
730  const auto& ti = target->get_type_info();
731  const auto agg = dynamic_cast<const Analyzer::AggExpr*>(target);
732  if (agg && agg->get_arg()) {
733  compact_width = crt_min_byte_width;
734  break;
735  }
736 
737  if (agg) {
738  CHECK_EQ(kCOUNT, agg->get_aggtype());
739  CHECK(!agg->get_is_distinct());
740  ++col_it;
741  continue;
742  }
743 
744  if (is_int_and_no_bigger_than(ti, 4) ||
745  (ti.is_string() && ti.get_compression() == kENCODING_DICT)) {
746  ++col_it;
747  continue;
748  }
749 
750  const auto uoper = dynamic_cast<Analyzer::UOper*>(target);
751  if (uoper && uoper->get_optype() == kUNNEST &&
752  (*col_it)->getColId() == unnest_array_col_id) {
753  const auto arg_ti = uoper->get_operand()->get_type_info();
754  CHECK(arg_ti.is_array());
755  const auto& elem_ti = arg_ti.get_elem_type();
756  if (elem_ti.is_string() && elem_ti.get_compression() == kENCODING_DICT) {
757  ++col_it;
758  continue;
759  }
760  }
761 
762  compact_width = crt_min_byte_width;
763  break;
764  }
765  }
766  if (!compact_width) {
767  size_t total_tuples{0};
768  for (const auto& qi : query_infos) {
769  total_tuples += qi.info.getNumTuples();
770  }
771  return total_tuples <= static_cast<size_t>(std::numeric_limits<uint32_t>::max()) ||
772  unnest_array_col_id != std::numeric_limits<int>::min()
773  ? 4
774  : crt_min_byte_width;
775  } else {
776  // TODO(miyu): relax this condition to allow more cases just w/o padding
777  for (auto wid : get_col_byte_widths(ra_exe_unit.target_exprs)) {
778  compact_width = std::max(compact_width, wid);
779  }
780  return compact_width;
781  }
782 }
std::vector< Analyzer::Expr * > target_exprs
#define CHECK_EQ(x, y)
Definition: Logger.h:211
std::vector< int8_t > get_col_byte_widths(const T &col_expr_list)
const std::list< std::shared_ptr< Analyzer::Expr > > groupby_exprs
bool g_bigint_count
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:78
const Expr * get_operand() const
Definition: Analyzer.h:371
Definition: sqldefs.h:76
bool is_int_and_no_bigger_than(const SQLTypeInfo &ti, const size_t byte_width)
#define CHECK(condition)
Definition: Logger.h:203
std::list< std::shared_ptr< const InputColDescriptor > > input_col_descs

+ Here is the call graph for this function:

std::string QueryMemoryDescriptor::queryDescTypeToString ( ) const

Definition at line 1164 of file QueryMemoryDescriptor.cpp.

References Estimator, GroupByBaselineHash, GroupByPerfectHash, NonGroupedAggregate, Projection, query_desc_type_, and UNREACHABLE.

Referenced by reductionKey().

1164  {
1165  switch (query_desc_type_) {
1167  return "Perfect Hash";
1169  return "Baseline Hash";
1171  return "Projection";
1173  return "Non-grouped Aggregate";
1175  return "Estimator";
1176  default:
1177  UNREACHABLE();
1178  }
1179  return "";
1180 }
#define UNREACHABLE()
Definition: Logger.h:247
QueryDescriptionType query_desc_type_

+ Here is the caller graph for this function:

std::string QueryMemoryDescriptor::reductionKey ( ) const

Definition at line 1205 of file QueryMemoryDescriptor.cpp.

References col_slot_context_, getEffectiveKeyWidth(), getGroupbyColCount(), getTargetGroupbyIndex(), getTargetIdxForKey(), join(), keyless_hash_, queryDescTypeToString(), targetGroupbyIndicesSize(), to_string(), ColSlotContext::toString(), and toString().

Referenced by ResultSetReductionJIT::cacheKey(), and toString().

1205  {
1206  std::string str;
1207  str += "Query Memory Descriptor State\n";
1208  str += "\tQuery Type: " + queryDescTypeToString() + "\n";
1209  str +=
1210  "\tKeyless Hash: " + ::toString(keyless_hash_) +
1211  (keyless_hash_ ? ", target index for key: " + std::to_string(getTargetIdxForKey())
1212  : "") +
1213  "\n";
1214  str += "\tEffective key width: " + std::to_string(getEffectiveKeyWidth()) + "\n";
1215  str += "\tNumber of group columns: " + std::to_string(getGroupbyColCount()) + "\n";
1216  const auto group_indices_size = targetGroupbyIndicesSize();
1217  if (group_indices_size) {
1218  std::vector<std::string> group_indices_strings;
1219  for (size_t target_idx = 0; target_idx < group_indices_size; ++target_idx) {
1220  group_indices_strings.push_back(std::to_string(getTargetGroupbyIndex(target_idx)));
1221  }
1222  str += "\tTarget group by indices: " +
1223  boost::algorithm::join(group_indices_strings, ",") + "\n";
1224  }
1225  str += "\t" + col_slot_context_.toString();
1226  return str;
1227 }
int64_t getTargetGroupbyIndex(const size_t target_idx) const
std::string toString() const
std::string join(T const &container, std::string const &delim)
size_t getEffectiveKeyWidth() const
std::string to_string(char const *&&v)
size_t getGroupbyColCount() const
size_t targetGroupbyIndicesSize() const
std::string toString() const
std::string queryDescTypeToString() const
int32_t getTargetIdxForKey() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QueryMemoryDescriptor::resetGroupColWidths ( const std::vector< int8_t > &  new_group_col_widths)
inlineprotected

Definition at line 331 of file QueryMemoryDescriptor.h.

References group_col_widths_.

331  {
332  group_col_widths_ = new_group_col_widths;
333  }
std::vector< int8_t > group_col_widths_
void QueryMemoryDescriptor::setAllTargetGroupbyIndices ( std::vector< int64_t >  group_by_indices)
inline

Definition at line 232 of file QueryMemoryDescriptor.h.

References target_groupby_indices_.

232  {
233  target_groupby_indices_ = group_by_indices;
234  }
std::vector< int64_t > target_groupby_indices_
void QueryMemoryDescriptor::setEntryCount ( const size_t  val)
inline

Definition at line 246 of file QueryMemoryDescriptor.h.

References entry_count_.

Referenced by Executor::executePlanWithGroupBy(), Executor::reduceMultiDeviceResultSets(), ResultSetStorage::updateEntryCount(), and ResultSet::updateStorageEntryCount().

246 { entry_count_ = val; }

+ Here is the caller graph for this function:

void QueryMemoryDescriptor::setForceFourByteFloat ( const bool  val)
inline

Definition at line 277 of file QueryMemoryDescriptor.h.

References force_4byte_float_.

void QueryMemoryDescriptor::setGroupColCompactWidth ( const int8_t  val)
inline

Definition at line 198 of file QueryMemoryDescriptor.h.

References group_col_compact_width_.

void QueryMemoryDescriptor::setHasInterleavedBinsOnGpu ( const bool  val)
inline

Definition at line 180 of file QueryMemoryDescriptor.h.

References interleaved_bins_on_gpu_.

void QueryMemoryDescriptor::setHasKeylessHash ( const bool  val)
inline

Definition at line 177 of file QueryMemoryDescriptor.h.

References keyless_hash_.

void QueryMemoryDescriptor::setOutputColumnar ( const bool  val)

Definition at line 1030 of file QueryMemoryDescriptor.cpp.

References col_slot_context_, isLogicalSizedColumnsAllowed(), output_columnar_, and ColSlotContext::setAllSlotsPaddedSizeToLogicalSize().

Referenced by Executor::executeTableFunction(), TableFunctionExecutionContext::launchCpuCode(), and TableFunctionExecutionContext::launchGpuCode().

1030  {
1031  output_columnar_ = val;
1034  }
1035 }
bool isLogicalSizedColumnsAllowed() const
void setAllSlotsPaddedSizeToLogicalSize()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QueryMemoryDescriptor::setQueryDescriptionType ( const QueryDescriptionType  val)
inline

Definition at line 170 of file QueryMemoryDescriptor.h.

References query_desc_type_.

170 { query_desc_type_ = val; }
QueryDescriptionType query_desc_type_
void QueryMemoryDescriptor::setTargetIdxForKey ( const int32_t  val)
inline

Definition at line 183 of file QueryMemoryDescriptor.h.

References idx_target_as_key_.

bool QueryMemoryDescriptor::sortOnGpu ( ) const
inline

Definition at line 262 of file QueryMemoryDescriptor.h.

References sort_on_gpu_.

Referenced by alignPaddedSlots(), QueryExecutionContext::launchGpuCode(), ExecutionKernel::runImpl(), and use_speculative_top_n().

+ Here is the caller graph for this function:

size_t QueryMemoryDescriptor::targetGroupbyIndicesSize ( ) const
inline
size_t QueryMemoryDescriptor::targetGroupbyNegativeIndicesSize ( ) const
inline

Definition at line 237 of file QueryMemoryDescriptor.h.

References target_groupby_indices_.

237  {
238  return std::count_if(
239  target_groupby_indices_.begin(),
241  [](const int64_t& target_group_by_index) { return target_group_by_index < 0; });
242  }
std::vector< int64_t > target_groupby_indices_
bool QueryMemoryDescriptor::threadsShareMemory ( ) const
std::string QueryMemoryDescriptor::toString ( ) const

Definition at line 1182 of file QueryMemoryDescriptor.cpp.

References allow_multifrag_, blocksShareMemory(), bucket_, entry_count_, GPU, interleaved_bins_on_gpu_, is_table_function_, lazyInitGroups(), max_val_, min_val_, must_use_baseline_sort_, output_columnar_, reductionKey(), render_output_, sort_on_gpu_, threadsShareMemory(), to_string(), use_streaming_top_n_, and usesGetGroupValueFast().

Referenced by Executor::createKernels(), and reductionKey().

1182  {
1183  auto str = reductionKey();
1184  str += "\tAllow Multifrag: " + ::toString(allow_multifrag_) + "\n";
1185  str += "\tInterleaved Bins on GPU: " + ::toString(interleaved_bins_on_gpu_) + "\n";
1186  str += "\tBlocks Share Memory: " + ::toString(blocksShareMemory()) + "\n";
1187  str += "\tThreads Share Memory: " + ::toString(threadsShareMemory()) + "\n";
1188  str += "\tUses Fast Group Values: " + ::toString(usesGetGroupValueFast()) + "\n";
1189  str +=
1190  "\tLazy Init Groups (GPU): " + ::toString(lazyInitGroups(ExecutorDeviceType::GPU)) +
1191  "\n";
1192  str += "\tEntry Count: " + std::to_string(entry_count_) + "\n";
1193  str += "\tMin Val (perfect hash only): " + std::to_string(min_val_) + "\n";
1194  str += "\tMax Val (perfect hash only): " + std::to_string(max_val_) + "\n";
1195  str += "\tBucket Val (perfect hash only): " + std::to_string(bucket_) + "\n";
1196  str += "\tSort on GPU: " + ::toString(sort_on_gpu_) + "\n";
1197  str += "\tUse Streaming Top N: " + ::toString(use_streaming_top_n_) + "\n";
1198  str += "\tOutput Columnar: " + ::toString(output_columnar_) + "\n";
1199  str += "\tRender Output: " + ::toString(render_output_) + "\n";
1200  str += "\tUse Baseline Sort: " + ::toString(must_use_baseline_sort_) + "\n";
1201  str += "\tIs Table Function: " + ::toString(is_table_function_) + "\n";
1202  return str;
1203 }
std::string toString() const
std::string to_string(char const *&&v)
bool lazyInitGroups(const ExecutorDeviceType) const
std::string reductionKey() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static TResultSetBufferDescriptor QueryMemoryDescriptor::toThrift ( const QueryMemoryDescriptor )
static
int8_t QueryMemoryDescriptor::updateActualMinByteWidth ( const int8_t  actual_min_byte_width) const

Definition at line 1140 of file QueryMemoryDescriptor.cpp.

References col_slot_context_, and ColSlotContext::getMinPaddedByteSize().

1141  {
1142  return col_slot_context_.getMinPaddedByteSize(actual_min_byte_width);
1143 }
int8_t getMinPaddedByteSize(const int8_t actual_min_byte_width) const

+ Here is the call graph for this function:

void QueryMemoryDescriptor::useConsistentSlotWidthSize ( const int8_t  slot_width_size)

Definition at line 1131 of file QueryMemoryDescriptor.cpp.

References col_slot_context_, and ColSlotContext::setAllSlotsSize().

1131  {
1132  col_slot_context_.setAllSlotsSize(slot_width_size);
1133 }
void setAllSlotsSize(const int8_t slot_width_size)

+ Here is the call graph for this function:

bool QueryMemoryDescriptor::usesGetGroupValueFast ( ) const

Definition at line 1059 of file QueryMemoryDescriptor.cpp.

References getGroupbyColCount(), GroupByPerfectHash, and query_desc_type_.

Referenced by canOutputColumnar(), GroupByAndAggregate::codegen(), GroupByAndAggregate::codegenSingleColumnPerfectHash(), and toString().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool QueryMemoryDescriptor::useStreamingTopN ( ) const
inline

Definition at line 268 of file QueryMemoryDescriptor.h.

References use_streaming_top_n_.

Referenced by GroupByAndAggregate::codegen(), GroupByAndAggregate::codegenOutputSlot(), QueryMemoryInitializer::copyGroupByBuffersFromGpu(), QueryMemoryInitializer::initGroupByBuffer(), QueryExecutionContext::launchCpuCode(), and QueryExecutionContext::launchGpuCode().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend class QueryExecutionContext
friend

Definition at line 373 of file QueryMemoryDescriptor.h.

Referenced by getQueryExecutionContext().

friend class ResultSet
friend

Definition at line 372 of file QueryMemoryDescriptor.h.

Member Data Documentation

bool QueryMemoryDescriptor::allow_multifrag_
private

Definition at line 337 of file QueryMemoryDescriptor.h.

Referenced by toString().

int64_t QueryMemoryDescriptor::bucket_
private

Definition at line 354 of file QueryMemoryDescriptor.h.

Referenced by blocksShareMemory(), getBucket(), operator==(), and toString().

size_t QueryMemoryDescriptor::entry_count_
private
const Executor* QueryMemoryDescriptor::executor_
private
bool QueryMemoryDescriptor::force_4byte_float_
private

Definition at line 364 of file QueryMemoryDescriptor.h.

Referenced by forceFourByteFloat(), operator==(), and setForceFourByteFloat().

int8_t QueryMemoryDescriptor::group_col_compact_width_
private
bool QueryMemoryDescriptor::has_nulls_
private

Definition at line 355 of file QueryMemoryDescriptor.h.

Referenced by hasNulls(), and operator==().

int32_t QueryMemoryDescriptor::idx_target_as_key_
private

Definition at line 341 of file QueryMemoryDescriptor.h.

Referenced by getTargetIdxForKey(), operator==(), and setTargetIdxForKey().

bool QueryMemoryDescriptor::interleaved_bins_on_gpu_
private
bool QueryMemoryDescriptor::is_table_function_
private

Definition at line 361 of file QueryMemoryDescriptor.h.

Referenced by blocksShareMemory(), and toString().

bool QueryMemoryDescriptor::keyless_hash_
private
int64_t QueryMemoryDescriptor::max_val_
private

Definition at line 353 of file QueryMemoryDescriptor.h.

Referenced by blocksShareMemory(), getMaxVal(), operator==(), and toString().

int64_t QueryMemoryDescriptor::min_val_
private

Definition at line 351 of file QueryMemoryDescriptor.h.

Referenced by blocksShareMemory(), getMinVal(), operator==(), and toString().

bool QueryMemoryDescriptor::must_use_baseline_sort_
private

Definition at line 360 of file QueryMemoryDescriptor.h.

Referenced by mustUseBaselineSort(), and toString().

bool QueryMemoryDescriptor::render_output_
private

Definition at line 359 of file QueryMemoryDescriptor.h.

Referenced by blocksShareMemory(), lazyInitGroups(), and toString().

bool QueryMemoryDescriptor::sort_on_gpu_
private

Definition at line 357 of file QueryMemoryDescriptor.h.

Referenced by operator==(), QueryMemoryDescriptor(), sortOnGpu(), and toString().

std::vector<int64_t> QueryMemoryDescriptor::target_groupby_indices_
private
bool QueryMemoryDescriptor::use_streaming_top_n_
private

The documentation for this class was generated from the following files: