OmniSciDB  085a039ca4
 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 "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 (const std::string &agg_kind, 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 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 456 of file ResultSetReductionJIT.cpp.

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

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

+ Here is the call graph for this function:

uint8_t check_interrupt_rt ( const size_t  sample_seed)

Definition at line 504 of file ResultSetReductionJIT.cpp.

References check_interrupt(), and UNLIKELY.

504  {
505  // this func is called iff we enable runtime query interrupt
506  if (UNLIKELY((sample_seed & 0xFFFF) == 0 && check_interrupt())) {
507  return true;
508  }
509  return false;
510 }
__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 496 of file ResultSetReductionJIT.cpp.

References dynamic_watchdog(), g_enable_dynamic_watchdog, and UNLIKELY.

496  {
497  if (UNLIKELY(g_enable_dynamic_watchdog && (sample_seed & 0x3F) == 0 &&
498  dynamic_watchdog())) {
499  return true;
500  }
501  return false;
502 }
__device__ bool dynamic_watchdog()
bool g_enable_dynamic_watchdog
Definition: Execute.cpp:80
#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 438 of file ResultSetReductionJIT.cpp.

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

443  {
444  const auto that_qmd = reinterpret_cast<const QueryMemoryDescriptor*>(that_qmd_handle);
445  const auto this_qmd = reinterpret_cast<const QueryMemoryDescriptor*>(this_qmd_handle);
446  const auto& new_count_distinct_desc =
447  that_qmd->getCountDistinctDescriptor(target_logical_idx);
448  const auto& old_count_distinct_desc =
449  this_qmd->getCountDistinctDescriptor(target_logical_idx);
450  CHECK(old_count_distinct_desc.impl_type_ != CountDistinctImplType::Invalid);
451  CHECK(old_count_distinct_desc.impl_type_ == new_count_distinct_desc.impl_type_);
453  new_set_handle, old_set_handle, new_count_distinct_desc, old_count_distinct_desc);
454 }
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:223

+ 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 469 of file ResultSetReductionJIT.cpp.

References result_set::get_group_value_reduction().

479  {
480  const auto& this_qmd = *reinterpret_cast<const QueryMemoryDescriptor*>(this_qmd_handle);
481  const auto gvi =
482  result_set::get_group_value_reduction(reinterpret_cast<int64_t*>(groups_buffer),
483  this_qmd.getEntryCount(),
484  reinterpret_cast<const int64_t*>(key),
485  key_count,
486  this_qmd.getEffectiveKeyWidth(),
487  this_qmd,
488  reinterpret_cast<const int64_t*>(that_buff),
489  that_entry_idx,
490  that_entry_count,
491  row_size_bytes >> 3);
492  *buff_out = gvi.first;
493  *empty = gvi.second;
494 }
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 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 408 of file ResultSetReductionJIT.cpp.

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

415  {
416  if (!serialized_varlen_buffer_handle) {
417  varlen_buffer_sample(this_ptr1, this_ptr2, that_ptr1, that_ptr2, init_val);
418  return;
419  }
420  const auto& serialized_varlen_buffer =
421  *reinterpret_cast<const std::vector<std::string>*>(serialized_varlen_buffer_handle);
422  if (!serialized_varlen_buffer.empty()) {
423  const auto rhs_proj_col = *reinterpret_cast<const int64_t*>(that_ptr1);
424  CHECK_LT(static_cast<size_t>(rhs_proj_col), serialized_varlen_buffer.size());
425  const auto& varlen_bytes_str = serialized_varlen_buffer[rhs_proj_col];
426  const auto str_ptr = reinterpret_cast<const int8_t*>(varlen_bytes_str.c_str());
427  *reinterpret_cast<int64_t*>(this_ptr1) = reinterpret_cast<const int64_t>(str_ptr);
428  *reinterpret_cast<int64_t*>(this_ptr2) =
429  static_cast<int64_t>(varlen_bytes_str.size() / length_to_elems);
430  } else {
431  varlen_buffer_sample(this_ptr1, this_ptr2, that_ptr1, that_ptr2, init_val);
432  }
433 }
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:233

+ Here is the call graph for this function: