OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ResultSetReductionJIT.cpp File Reference
#include "ResultSetReductionJIT.h"
#include "ResultSetReductionCodegen.h"
#include "ResultSetReductionInterpreterStubs.h"
#include "CodeGenerator.h"
#include "DynamicWatchdog.h"
#include "Execute.h"
#include "IRCodegenUtils.h"
#include "LLVMFunctionAttributesUtil.h"
#include "QueryEngine/QueryEngine.h"
#include "Shared/StringTransform.h"
#include "Shared/likely.h"
#include "Shared/quantile.h"
#include <llvm/Bitcode/BitcodeReader.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/Verifier.h>
#include <llvm/Support/SourceMgr.h>
#include <llvm/Support/raw_os_ostream.h>
+ Include dependency graph for ResultSetReductionJIT.cpp:

Go to the source code of this file.

Namespaces

 anonymous_namespace{ResultSetReductionJIT.cpp}
 

Functions

Valueanonymous_namespace{ResultSetReductionJIT.cpp}::emit_load (Value *ptr, Type ptr_type, Function *function)
 
Valueanonymous_namespace{ResultSetReductionJIT.cpp}::emit_load_i32 (Value *ptr, Function *function)
 
Valueanonymous_namespace{ResultSetReductionJIT.cpp}::emit_load_i64 (Value *ptr, Function *function)
 
Valueanonymous_namespace{ResultSetReductionJIT.cpp}::emit_read_int_from_buff (Value *ptr, const int8_t compact_sz, Function *function)
 
void anonymous_namespace{ResultSetReductionJIT.cpp}::emit_aggregate_one_value (const std::string &agg_kind, Value *val_ptr, Value *other_ptr, const size_t chosen_bytes, const TargetInfo &agg_info, Function *ir_reduce_one_entry)
 
void anonymous_namespace{ResultSetReductionJIT.cpp}::emit_aggregate_one_nullable_value (SQLAgg const sql_agg, Value *val_ptr, Value *other_ptr, const int64_t init_val, const size_t chosen_bytes, const TargetInfo &agg_info, Function *ir_reduce_one_entry)
 
void anonymous_namespace{ResultSetReductionJIT.cpp}::emit_aggregate_one_count (Value *val_ptr, Value *other_ptr, const size_t chosen_bytes, Function *ir_reduce_one_entry)
 
void anonymous_namespace{ResultSetReductionJIT.cpp}::emit_write_projection (Value *slot_pi8, Value *other_pi8, const int64_t init_val, const size_t chosen_bytes, Function *ir_reduce_one_entry)
 
const Valueanonymous_namespace{ResultSetReductionJIT.cpp}::emit_checked_write_projection (Value *slot_pi8, Value *other_pi8, const int64_t init_val, const size_t chosen_bytes, Function *ir_reduce_one_entry)
 
std::unique_ptr< Functionanonymous_namespace{ResultSetReductionJIT.cpp}::create_function (const std::string name, const std::vector< Function::NamedArg > &arg_types, const Type ret_type, const bool always_inline)
 
std::unique_ptr< Functionanonymous_namespace{ResultSetReductionJIT.cpp}::setup_is_empty_entry (ReductionCode *reduction_code)
 
std::unique_ptr< Functionanonymous_namespace{ResultSetReductionJIT.cpp}::setup_reduce_one_entry (ReductionCode *reduction_code, const QueryDescriptionType hash_type)
 
std::unique_ptr< Functionanonymous_namespace{ResultSetReductionJIT.cpp}::setup_reduce_one_entry_idx (ReductionCode *reduction_code)
 
std::unique_ptr< Functionanonymous_namespace{ResultSetReductionJIT.cpp}::setup_reduce_loop (ReductionCode *reduction_code)
 
llvm::Function * anonymous_namespace{ResultSetReductionJIT.cpp}::create_llvm_function (const Function *function, CgenState *cgen_state)
 
ReductionCode anonymous_namespace{ResultSetReductionJIT.cpp}::setup_functions_ir (const QueryDescriptionType hash_type)
 
bool anonymous_namespace{ResultSetReductionJIT.cpp}::is_aggregate_query (const QueryDescriptionType hash_type)
 
void anonymous_namespace{ResultSetReductionJIT.cpp}::varlen_buffer_sample (int8_t *this_ptr1, int8_t *this_ptr2, const int8_t *that_ptr1, const int8_t *that_ptr2, const int64_t init_val)
 
RUNTIME_EXPORT void serialized_varlen_buffer_sample (const void *serialized_varlen_buffer_handle, int8_t *this_ptr1, int8_t *this_ptr2, const int8_t *that_ptr1, const int8_t *that_ptr2, const int64_t init_val, const int64_t length_to_elems)
 
RUNTIME_EXPORT void count_distinct_set_union_jit_rt (const int64_t new_set_handle, const int64_t old_set_handle, const void *that_qmd_handle, const void *this_qmd_handle, const int64_t target_logical_idx)
 
RUNTIME_EXPORT void approx_quantile_jit_rt (const int64_t new_set_handle, const int64_t old_set_handle, const void *that_qmd_handle, const void *this_qmd_handle, const int64_t target_logical_idx)
 
RUNTIME_EXPORT void mode_jit_rt (const int64_t new_set_handle, const int64_t old_set_handle, const void *that_qmd_handle, const void *this_qmd_handle, const int64_t target_logical_idx)
 
RUNTIME_EXPORT void get_group_value_reduction_rt (int8_t *groups_buffer, const int8_t *key, const uint32_t key_count, const void *this_qmd_handle, const int8_t *that_buff, const uint32_t that_entry_idx, const uint32_t that_entry_count, const uint32_t row_size_bytes, int64_t **buff_out, uint8_t *empty)
 
RUNTIME_EXPORT uint8_t check_watchdog_rt (const size_t sample_seed)
 
uint8_t check_interrupt_rt (const size_t sample_seed)
 
void anonymous_namespace{ResultSetReductionJIT.cpp}::generate_loop_body (For *for_loop, Function *ir_reduce_loop, Function *ir_reduce_one_entry_idx, Value *this_buff, Value *that_buff, Value *start_index, Value *that_entry_count, Value *this_qmd_handle, Value *that_qmd_handle, Value *serialized_varlen_buffer)
 
std::string anonymous_namespace{ResultSetReductionJIT.cpp}::target_info_key (const TargetInfo &target_info)
 

Variables

const int32_t anonymous_namespace{ResultSetReductionJIT.cpp}::WATCHDOG_ERROR
 
const int32_t anonymous_namespace{ResultSetReductionJIT.cpp}::INTERRUPT_ERROR {10}
 
const size_t anonymous_namespace{ResultSetReductionJIT.cpp}::INTERP_THRESHOLD {25}
 

Function Documentation

RUNTIME_EXPORT void approx_quantile_jit_rt ( const int64_t  new_set_handle,
const int64_t  old_set_handle,
const void *  that_qmd_handle,
const void *  this_qmd_handle,
const int64_t  target_logical_idx 
)

Definition at line 458 of file ResultSetReductionJIT.cpp.

References quantile::detail::TDigest< RealType, IndexType >::allocate().

462  {
463  auto* incoming = reinterpret_cast<quantile::TDigest*>(new_set_handle);
464  if (incoming->centroids().capacity()) {
465  auto* accumulator = reinterpret_cast<quantile::TDigest*>(old_set_handle);
466  accumulator->allocate();
467  accumulator->mergeTDigest(*incoming);
468  }
469 }
DEVICE void allocate()
Definition: quantile.h:613

+ Here is the call graph for this function:

uint8_t check_interrupt_rt ( const size_t  sample_seed)

Definition at line 516 of file ResultSetReductionJIT.cpp.

References check_interrupt(), and UNLIKELY.

516  {
517  // this func is called iff we enable runtime query interrupt
518  if (UNLIKELY((sample_seed & 0xFFFF) == 0 && check_interrupt())) {
519  return true;
520  }
521  return false;
522 }
__device__ bool check_interrupt()
#define UNLIKELY(x)
Definition: likely.h:25

+ Here is the call graph for this function:

RUNTIME_EXPORT uint8_t check_watchdog_rt ( const size_t  sample_seed)

Definition at line 508 of file ResultSetReductionJIT.cpp.

References dynamic_watchdog(), g_enable_dynamic_watchdog, and UNLIKELY.

508  {
509  if (UNLIKELY(g_enable_dynamic_watchdog && (sample_seed & 0x3F) == 0 &&
510  dynamic_watchdog())) {
511  return true;
512  }
513  return false;
514 }
__device__ bool dynamic_watchdog()
bool g_enable_dynamic_watchdog
Definition: Execute.cpp:81
#define UNLIKELY(x)
Definition: likely.h:25

+ Here is the call graph for this function:

RUNTIME_EXPORT void count_distinct_set_union_jit_rt ( const int64_t  new_set_handle,
const int64_t  old_set_handle,
const void *  that_qmd_handle,
const void *  this_qmd_handle,
const int64_t  target_logical_idx 
)

Definition at line 440 of file ResultSetReductionJIT.cpp.

References CHECK, count_distinct_set_union(), QueryMemoryDescriptor::getCountDistinctDescriptor(), and Invalid.

445  {
446  const auto that_qmd = reinterpret_cast<const QueryMemoryDescriptor*>(that_qmd_handle);
447  const auto this_qmd = reinterpret_cast<const QueryMemoryDescriptor*>(this_qmd_handle);
448  const auto& new_count_distinct_desc =
449  that_qmd->getCountDistinctDescriptor(target_logical_idx);
450  const auto& old_count_distinct_desc =
451  this_qmd->getCountDistinctDescriptor(target_logical_idx);
452  CHECK(old_count_distinct_desc.impl_type_ != CountDistinctImplType::Invalid);
453  CHECK(old_count_distinct_desc.impl_type_ == new_count_distinct_desc.impl_type_);
455  new_set_handle, old_set_handle, new_count_distinct_desc, old_count_distinct_desc);
456 }
void count_distinct_set_union(const int64_t new_set_handle, const int64_t old_set_handle, const CountDistinctDescriptor &new_count_distinct_desc, const CountDistinctDescriptor &old_count_distinct_desc)
const CountDistinctDescriptor & getCountDistinctDescriptor(const size_t idx) const
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

RUNTIME_EXPORT void get_group_value_reduction_rt ( int8_t *  groups_buffer,
const int8_t *  key,
const uint32_t  key_count,
const void *  this_qmd_handle,
const int8_t *  that_buff,
const uint32_t  that_entry_idx,
const uint32_t  that_entry_count,
const uint32_t  row_size_bytes,
int64_t **  buff_out,
uint8_t *  empty 
)

Definition at line 481 of file ResultSetReductionJIT.cpp.

References result_set::get_group_value_reduction().

491  {
492  const auto& this_qmd = *reinterpret_cast<const QueryMemoryDescriptor*>(this_qmd_handle);
493  const auto gvi =
494  result_set::get_group_value_reduction(reinterpret_cast<int64_t*>(groups_buffer),
495  this_qmd.getEntryCount(),
496  reinterpret_cast<const int64_t*>(key),
497  key_count,
498  this_qmd.getEffectiveKeyWidth(),
499  this_qmd,
500  reinterpret_cast<const int64_t*>(that_buff),
501  that_entry_idx,
502  that_entry_count,
503  row_size_bytes >> 3);
504  *buff_out = gvi.first;
505  *empty = gvi.second;
506 }
GroupValueInfo get_group_value_reduction(int64_t *groups_buffer, const uint32_t groups_buffer_entry_count, const int64_t *key, const uint32_t key_count, const size_t key_width, const QueryMemoryDescriptor &query_mem_desc, const int64_t *that_buff_i64, const size_t that_entry_idx, const size_t that_entry_count, const uint32_t row_size_quad)

+ Here is the call graph for this function:

RUNTIME_EXPORT void mode_jit_rt ( const int64_t  new_set_handle,
const int64_t  old_set_handle,
const void *  that_qmd_handle,
const void *  this_qmd_handle,
const int64_t  target_logical_idx 
)

Definition at line 471 of file ResultSetReductionJIT.cpp.

References AggMode::reduce().

475  {
476  auto* accumulator = reinterpret_cast<AggMode*>(old_set_handle);
477  auto* incoming = reinterpret_cast<AggMode*>(new_set_handle);
478  accumulator->reduce(std::move(*incoming));
479 }
void reduce(AggMode &&rhs)
Definition: AggMode.h:47

+ Here is the call graph for this function:

RUNTIME_EXPORT void serialized_varlen_buffer_sample ( const void *  serialized_varlen_buffer_handle,
int8_t *  this_ptr1,
int8_t *  this_ptr2,
const int8_t *  that_ptr1,
const int8_t *  that_ptr2,
const int64_t  init_val,
const int64_t  length_to_elems 
)

Definition at line 410 of file ResultSetReductionJIT.cpp.

References CHECK_LT, and anonymous_namespace{ResultSetReductionJIT.cpp}::varlen_buffer_sample().

417  {
418  if (!serialized_varlen_buffer_handle) {
419  varlen_buffer_sample(this_ptr1, this_ptr2, that_ptr1, that_ptr2, init_val);
420  return;
421  }
422  const auto& serialized_varlen_buffer =
423  *reinterpret_cast<const std::vector<std::string>*>(serialized_varlen_buffer_handle);
424  if (!serialized_varlen_buffer.empty()) {
425  const auto rhs_proj_col = *reinterpret_cast<const int64_t*>(that_ptr1);
426  CHECK_LT(static_cast<size_t>(rhs_proj_col), serialized_varlen_buffer.size());
427  const auto& varlen_bytes_str = serialized_varlen_buffer[rhs_proj_col];
428  const auto str_ptr = reinterpret_cast<const int8_t*>(varlen_bytes_str.c_str());
429  *reinterpret_cast<int64_t*>(this_ptr1) = reinterpret_cast<const int64_t>(str_ptr);
430  *reinterpret_cast<int64_t*>(this_ptr2) =
431  static_cast<int64_t>(varlen_bytes_str.size() / length_to_elems);
432  } else {
433  varlen_buffer_sample(this_ptr1, this_ptr2, that_ptr1, that_ptr2, init_val);
434  }
435 }
void varlen_buffer_sample(int8_t *this_ptr1, int8_t *this_ptr2, const int8_t *that_ptr1, const int8_t *that_ptr2, const int64_t init_val)
#define CHECK_LT(x, y)
Definition: Logger.h:303

+ Here is the call graph for this function: