OmniSciDB  04ee39c94c
ResultSetReductionJIT.cpp File Reference
#include "ResultSetReductionJIT.h"
#include "CodeGenerator.h"
#include "DynamicWatchdog.h"
#include "Execute.h"
#include "IRCodegenUtils.h"
#include "LLVMFunctionAttributesUtil.h"
#include "Shared/likely.h"
#include "Shared/mapdpath.h"
#include <llvm/Bitcode/BitcodeReader.h>
#include <llvm/ExecutionEngine/Interpreter.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 <llvm/Transforms/Utils/Cloning.h>
+ Include dependency graph for ResultSetReductionJIT.cpp:

Go to the source code of this file.

Namespaces

 anonymous_namespace{ResultSetReductionJIT.cpp}
 

Functions

std::unique_ptr< llvm::Module > anonymous_namespace{ResultSetReductionJIT.cpp}::runtime_module_shallow_copy (CgenState *cgen_state)
 
llvm::Value * anonymous_namespace{ResultSetReductionJIT.cpp}::emit_load (llvm::Value *ptr, llvm::Type *loaded_type, CgenState *cgen_state)
 
llvm::Value * anonymous_namespace{ResultSetReductionJIT.cpp}::emit_load_i32 (llvm::Value *ptr, CgenState *cgen_state)
 
llvm::Value * anonymous_namespace{ResultSetReductionJIT.cpp}::emit_load_i64 (llvm::Value *ptr, CgenState *cgen_state)
 
llvm::Value * anonymous_namespace{ResultSetReductionJIT.cpp}::emit_read_int_from_buff (llvm::Value *ptr, const int8_t compact_sz, CgenState *cgen_state)
 
void anonymous_namespace{ResultSetReductionJIT.cpp}::emit_aggregate_one_value (const std::string &agg_kind, llvm::Value *val_ptr, llvm::Value *other_ptr, const size_t chosen_bytes, const TargetInfo &agg_info, CgenState *cgen_state)
 
void anonymous_namespace{ResultSetReductionJIT.cpp}::emit_aggregate_one_nullable_value (const std::string &agg_kind, llvm::Value *val_ptr, llvm::Value *other_ptr, const int64_t init_val, const size_t chosen_bytes, const TargetInfo &agg_info, CgenState *cgen_state)
 
void anonymous_namespace{ResultSetReductionJIT.cpp}::emit_aggregate_one_count (llvm::Value *val_ptr, llvm::Value *other_ptr, const size_t chosen_bytes, CgenState *cgen_state)
 
void anonymous_namespace{ResultSetReductionJIT.cpp}::emit_write_projection (llvm::Value *slot_pi8, llvm::Value *other_pi8, const int64_t init_val, const size_t chosen_bytes, CgenState *cgen_state)
 
llvm::Function * anonymous_namespace{ResultSetReductionJIT.cpp}::setup_is_empty_entry (const CgenState *cgen_state)
 
llvm::Function * anonymous_namespace{ResultSetReductionJIT.cpp}::setup_reduce_one_entry (const CgenState *cgen_state, const QueryDescriptionType hash_type)
 
llvm::Function * anonymous_namespace{ResultSetReductionJIT.cpp}::setup_reduce_one_entry_idx (const CgenState *cgen_state)
 
llvm::Function * anonymous_namespace{ResultSetReductionJIT.cpp}::setup_reduce_loop (const CgenState *cgen_state)
 
ReductionCode anonymous_namespace{ResultSetReductionJIT.cpp}::setup_functions_ir (const QueryDescriptionType hash_type)
 
ExecutionEngineWrapper anonymous_namespace{ResultSetReductionJIT.cpp}::create_interpreter_engine (llvm::Function *func)
 
bool anonymous_namespace{ResultSetReductionJIT.cpp}::is_group_query (const QueryDescriptionType hash_type)
 
void anonymous_namespace{ResultSetReductionJIT.cpp}::return_early (llvm::Value *cond, const ReductionCode &reduction_code, llvm::Function *func, int error_code)
 
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)
 
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)
 
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)
 
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)
 
uint8_t check_watchdog_rt (const size_t sample_seed)
 
llvm::BasicBlock * anonymous_namespace{ResultSetReductionJIT.cpp}::generate_loop_body (const ReductionCode &reduction_code, llvm::Value *this_buff, llvm::Value *that_buff, llvm::Value *iterator, llvm::Value *start_index, llvm::Value *that_entry_count, llvm::Value *this_qmd_handle, llvm::Value *that_qmd_handle, llvm::Value *serialized_varlen_buffer, bool emit_watchdog_check)
 

Variables

std::unique_ptr< llvm::Module > g_rt_module
 
const int32_t anonymous_namespace{ResultSetReductionJIT.cpp}::WATCHDOG_ERROR {-1}
 
const size_t anonymous_namespace{ResultSetReductionJIT.cpp}::INTERP_THRESHOLD {50}
 

Function Documentation

◆ check_watchdog_rt()

uint8_t check_watchdog_rt ( const size_t  sample_seed)

Definition at line 530 of file ResultSetReductionJIT.cpp.

References dynamic_watchdog(), g_enable_dynamic_watchdog, and UNLIKELY.

530  {
531  if (UNLIKELY(g_enable_dynamic_watchdog && (sample_seed & 0x3F) == 0 &&
532  dynamic_watchdog())) {
533  return true;
534  }
535  return false;
536 }
bool dynamic_watchdog()
bool g_enable_dynamic_watchdog
Definition: Execute.cpp:70
#define UNLIKELY(x)
Definition: likely.h:20
+ Here is the call graph for this function:

◆ count_distinct_set_union_jit_rt()

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

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

492  {
493  const auto that_qmd = reinterpret_cast<const QueryMemoryDescriptor*>(that_qmd_handle);
494  const auto this_qmd = reinterpret_cast<const QueryMemoryDescriptor*>(this_qmd_handle);
495  const auto& new_count_distinct_desc =
496  that_qmd->getCountDistinctDescriptor(target_logical_idx);
497  const auto& old_count_distinct_desc =
498  this_qmd->getCountDistinctDescriptor(target_logical_idx);
499  CHECK(old_count_distinct_desc.impl_type_ != CountDistinctImplType::Invalid);
500  CHECK(old_count_distinct_desc.impl_type_ == new_count_distinct_desc.impl_type_);
502  new_set_handle, old_set_handle, new_count_distinct_desc, old_count_distinct_desc);
503 }
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)
#define CHECK(condition)
Definition: Logger.h:187
const CountDistinctDescriptor & getCountDistinctDescriptor(const size_t idx) const
+ Here is the call graph for this function:

◆ get_group_value_reduction_rt()

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

References get_group_value_reduction().

514  {
515  const auto& this_qmd = *reinterpret_cast<const QueryMemoryDescriptor*>(this_qmd_handle);
516  const auto gvi = get_group_value_reduction(reinterpret_cast<int64_t*>(groups_buffer),
517  this_qmd.getEntryCount(),
518  reinterpret_cast<const int64_t*>(key),
519  key_count,
520  this_qmd.getEffectiveKeyWidth(),
521  this_qmd,
522  reinterpret_cast<const int64_t*>(that_buff),
523  that_entry_idx,
524  that_entry_count,
525  row_size_bytes >> 3);
526  *buff_out = gvi.first;
527  *empty = gvi.second;
528 }
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:

◆ serialized_varlen_buffer_sample()

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

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

465  {
466  if (!serialized_varlen_buffer_handle) {
467  varlen_buffer_sample(this_ptr1, this_ptr2, that_ptr1, that_ptr2, init_val);
468  return;
469  }
470  const auto& serialized_varlen_buffer =
471  *reinterpret_cast<const std::vector<std::string>*>(serialized_varlen_buffer_handle);
472  if (!serialized_varlen_buffer.empty()) {
473  const auto rhs_proj_col = *reinterpret_cast<const int64_t*>(that_ptr1);
474  CHECK_LT(static_cast<size_t>(rhs_proj_col), serialized_varlen_buffer.size());
475  const auto& varlen_bytes_str = serialized_varlen_buffer[rhs_proj_col];
476  const auto str_ptr = reinterpret_cast<const int8_t*>(varlen_bytes_str.c_str());
477  *reinterpret_cast<int64_t*>(this_ptr1) = reinterpret_cast<const int64_t>(str_ptr);
478  *reinterpret_cast<int64_t*>(this_ptr2) =
479  static_cast<int64_t>(varlen_bytes_str.size() / length_to_elems);
480  } else {
481  varlen_buffer_sample(this_ptr1, this_ptr2, that_ptr1, that_ptr2, init_val);
482  }
483 }
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:197
+ Here is the call graph for this function:

Variable Documentation

◆ g_rt_module