OmniSciDB  471d68cefb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{ResultSetReductionJIT.cpp} Namespace Reference

Functions

Valueemit_load (Value *ptr, Type ptr_type, Function *function)
 
Valueemit_load_i32 (Value *ptr, Function *function)
 
Valueemit_load_i64 (Value *ptr, Function *function)
 
Valueemit_read_int_from_buff (Value *ptr, const int8_t compact_sz, Function *function)
 
void 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 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 emit_aggregate_one_count (Value *val_ptr, Value *other_ptr, const size_t chosen_bytes, Function *ir_reduce_one_entry)
 
void 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 Valueemit_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< Functioncreate_function (const std::string name, const std::vector< Function::NamedArg > &arg_types, const Type ret_type, const bool always_inline)
 
std::unique_ptr< Functionsetup_is_empty_entry (ReductionCode *reduction_code)
 
std::unique_ptr< Functionsetup_reduce_one_entry (ReductionCode *reduction_code, const QueryDescriptionType hash_type)
 
std::unique_ptr< Functionsetup_reduce_one_entry_idx (ReductionCode *reduction_code)
 
std::unique_ptr< Functionsetup_reduce_loop (ReductionCode *reduction_code)
 
llvm::Function * create_llvm_function (const Function *function, CgenState *cgen_state)
 
ReductionCode setup_functions_ir (const QueryDescriptionType hash_type)
 
bool is_aggregate_query (const QueryDescriptionType hash_type)
 
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)
 
void 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 target_info_key (const TargetInfo &target_info)
 

Variables

const int32_t WATCHDOG_ERROR
 
const int32_t INTERRUPT_ERROR {10}
 
const size_t INTERP_THRESHOLD {25}
 

Function Documentation

std::unique_ptr<Function> anonymous_namespace{ResultSetReductionJIT.cpp}::create_function ( const std::string  name,
const std::vector< Function::NamedArg > &  arg_types,
const Type  ret_type,
const bool  always_inline 
)

Definition at line 279 of file ResultSetReductionJIT.cpp.

References setup::name.

Referenced by setup_is_empty_entry(), setup_reduce_loop(), setup_reduce_one_entry(), and setup_reduce_one_entry_idx().

283  {
284  return std::make_unique<Function>(name, arg_types, ret_type, always_inline);
285 }
string name
Definition: setup.in.py:72

+ Here is the caller graph for this function:

llvm::Function* anonymous_namespace{ResultSetReductionJIT.cpp}::create_llvm_function ( const Function function,
CgenState cgen_state 
)

Definition at line 355 of file ResultSetReductionJIT.cpp.

References AUTOMATIC_IR_METADATA, CHECK, CgenState::context_, i, llvm_type(), mark_function_always_inline(), CgenState::module_, setup::name, and Void.

Referenced by ResultSetReductionJIT::codegen(), and GpuReductionHelperJIT::codegen().

355  {
356  AUTOMATIC_IR_METADATA(cgen_state);
357  auto& ctx = cgen_state->context_;
358  std::vector<llvm::Type*> parameter_types;
359  const auto& arg_types = function->arg_types();
360  for (const auto& named_arg : arg_types) {
361  CHECK(named_arg.type != Type::Void);
362  parameter_types.push_back(llvm_type(named_arg.type, ctx));
363  }
364  const auto func_type = llvm::FunctionType::get(
365  llvm_type(function->ret_type(), ctx), parameter_types, false);
366  const auto linkage = function->always_inline() ? llvm::Function::PrivateLinkage
367  : llvm::Function::ExternalLinkage;
368  auto func =
369  llvm::Function::Create(func_type, linkage, function->name(), cgen_state->module_);
370  const auto arg_it = func->arg_begin();
371  for (size_t i = 0; i < arg_types.size(); ++i) {
372  const auto arg = &*(arg_it + i);
373  arg->setName(arg_types[i].name);
374  }
375  if (function->always_inline()) {
377  }
378  return func;
379 }
void mark_function_always_inline(llvm::Function *func)
string name
Definition: setup.in.py:72
llvm::Module * module_
Definition: CgenState.h:329
llvm::LLVMContext & context_
Definition: CgenState.h:338
#define AUTOMATIC_IR_METADATA(CGENSTATE)
llvm::Type * llvm_type(const Type type, llvm::LLVMContext &ctx)
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 189 of file ResultSetReductionJIT.cpp.

References Cast::BitCast, CHECK_EQ, emit_load(), Int32Ptr, and Int64Ptr.

Referenced by ResultSetReductionJIT::reduceOneAggregateSlot().

192  {
193  const auto dest_name = "count_dest";
194  if (chosen_bytes == sizeof(int32_t)) {
195  const auto agg = ir_reduce_one_entry->add<Cast>(
196  Cast::CastOp::BitCast, val_ptr, Type::Int32Ptr, dest_name);
197  const auto val = emit_load(other_ptr, Type::Int32Ptr, ir_reduce_one_entry);
198  ir_reduce_one_entry->add<Call>(
199  "agg_sum_int32", std::vector<const Value*>{agg, val}, "");
200  } else {
201  CHECK_EQ(chosen_bytes, sizeof(int64_t));
202  const auto agg = ir_reduce_one_entry->add<Cast>(
203  Cast::CastOp::BitCast, val_ptr, Type::Int64Ptr, dest_name);
204  const auto val = emit_load(other_ptr, Type::Int64Ptr, ir_reduce_one_entry);
205  ir_reduce_one_entry->add<Call>("agg_sum", std::vector<const Value*>{agg, val}, "");
206  }
207 }
#define CHECK_EQ(x, y)
Definition: Logger.h:217
Value * emit_load(Value *ptr, Type ptr_type, Function *function)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 129 of file ResultSetReductionJIT.cpp.

References Cast::BitCast, CHECK_EQ, Double, DoublePtr, emit_aggregate_one_value(), emit_load(), Float, FloatPtr, get_compact_type(), Int32, Int32Ptr, Int64, Int64Ptr, and TargetInfo::skip_null_val.

Referenced by ResultSetReductionJIT::reduceOneAggregateSlot().

135  {
136  const auto dest_name = agg_kind + "_dest";
137  if (agg_info.skip_null_val) {
138  const auto sql_type = get_compact_type(agg_info);
139  if (sql_type.is_fp()) {
140  if (chosen_bytes == sizeof(float)) {
141  const auto agg = ir_reduce_one_entry->add<Cast>(
142  Cast::CastOp::BitCast, val_ptr, Type::Int32Ptr, dest_name);
143  const auto val = emit_load(other_ptr, Type::FloatPtr, ir_reduce_one_entry);
144  const auto init_val_lv = ir_reduce_one_entry->addConstant<ConstantFP>(
145  *reinterpret_cast<const float*>(may_alias_ptr(&init_val)), Type::Float);
146  ir_reduce_one_entry->add<Call>("agg_" + agg_kind + "_float_skip_val",
147  std::vector<const Value*>{agg, val, init_val_lv},
148  "");
149  } else {
150  CHECK_EQ(chosen_bytes, sizeof(double));
151  const auto agg = ir_reduce_one_entry->add<Cast>(
152  Cast::CastOp::BitCast, val_ptr, Type::Int64Ptr, dest_name);
153  const auto val = emit_load(other_ptr, Type::DoublePtr, ir_reduce_one_entry);
154  const auto init_val_lv = ir_reduce_one_entry->addConstant<ConstantFP>(
155  *reinterpret_cast<const double*>(may_alias_ptr(&init_val)), Type::Double);
156  ir_reduce_one_entry->add<Call>("agg_" + agg_kind + "_double_skip_val",
157  std::vector<const Value*>{agg, val, init_val_lv},
158  "");
159  }
160  } else {
161  if (chosen_bytes == sizeof(int32_t)) {
162  const auto agg = ir_reduce_one_entry->add<Cast>(
163  Cast::CastOp::BitCast, val_ptr, Type::Int32Ptr, dest_name);
164  const auto val = emit_load(other_ptr, Type::Int32Ptr, ir_reduce_one_entry);
165  const auto init_val_lv =
166  ir_reduce_one_entry->addConstant<ConstantInt>(init_val, Type::Int32);
167  ir_reduce_one_entry->add<Call>("agg_" + agg_kind + "_int32_skip_val",
168  std::vector<const Value*>{agg, val, init_val_lv},
169  "");
170  } else {
171  CHECK_EQ(chosen_bytes, sizeof(int64_t));
172  const auto agg = ir_reduce_one_entry->add<Cast>(
173  Cast::CastOp::BitCast, val_ptr, Type::Int64Ptr, dest_name);
174  const auto val = emit_load(other_ptr, Type::Int64Ptr, ir_reduce_one_entry);
175  const auto init_val_lv =
176  ir_reduce_one_entry->addConstant<ConstantInt>(init_val, Type::Int64);
177  ir_reduce_one_entry->add<Call>("agg_" + agg_kind + "_skip_val",
178  std::vector<const Value*>{agg, val, init_val_lv},
179  "");
180  }
181  }
182  } else {
184  agg_kind, val_ptr, other_ptr, chosen_bytes, agg_info, ir_reduce_one_entry);
185  }
186 }
#define CHECK_EQ(x, y)
Definition: Logger.h:217
bool skip_null_val
Definition: TargetInfo.h:53
void 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)
const SQLTypeInfo get_compact_type(const TargetInfo &target)
Value * emit_load(Value *ptr, Type ptr_type, Function *function)

+ Here is the call graph for this function:

+ Here is the caller graph for this 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 
)

Definition at line 87 of file ResultSetReductionJIT.cpp.

References Cast::BitCast, CHECK_EQ, DoublePtr, emit_load(), FloatPtr, get_compact_type(), Int32Ptr, and Int64Ptr.

Referenced by emit_aggregate_one_nullable_value().

92  {
93  const auto sql_type = get_compact_type(agg_info);
94  const auto dest_name = agg_kind + "_dest";
95  if (sql_type.is_fp()) {
96  if (chosen_bytes == sizeof(float)) {
97  const auto agg = ir_reduce_one_entry->add<Cast>(
98  Cast::CastOp::BitCast, val_ptr, Type::Int32Ptr, dest_name);
99  const auto val = emit_load(other_ptr, Type::FloatPtr, ir_reduce_one_entry);
100  ir_reduce_one_entry->add<Call>(
101  "agg_" + agg_kind + "_float", std::vector<const Value*>{agg, val}, "");
102  } else {
103  CHECK_EQ(chosen_bytes, sizeof(double));
104  const auto agg = ir_reduce_one_entry->add<Cast>(
105  Cast::CastOp::BitCast, val_ptr, Type::Int64Ptr, dest_name);
106  const auto val = emit_load(other_ptr, Type::DoublePtr, ir_reduce_one_entry);
107  ir_reduce_one_entry->add<Call>(
108  "agg_" + agg_kind + "_double", std::vector<const Value*>{agg, val}, "");
109  }
110  } else {
111  if (chosen_bytes == sizeof(int32_t)) {
112  const auto agg = ir_reduce_one_entry->add<Cast>(
113  Cast::CastOp::BitCast, val_ptr, Type::Int32Ptr, dest_name);
114  const auto val = emit_load(other_ptr, Type::Int32Ptr, ir_reduce_one_entry);
115  ir_reduce_one_entry->add<Call>(
116  "agg_" + agg_kind + "_int32", std::vector<const Value*>{agg, val}, "");
117  } else {
118  CHECK_EQ(chosen_bytes, sizeof(int64_t));
119  const auto agg = ir_reduce_one_entry->add<Cast>(
120  Cast::CastOp::BitCast, val_ptr, Type::Int64Ptr, dest_name);
121  const auto val = emit_load(other_ptr, Type::Int64Ptr, ir_reduce_one_entry);
122  ir_reduce_one_entry->add<Call>(
123  "agg_" + agg_kind, std::vector<const Value*>{agg, val}, "");
124  }
125  }
126 }
#define CHECK_EQ(x, y)
Definition: Logger.h:217
const SQLTypeInfo get_compact_type(const TargetInfo &target)
Value * emit_load(Value *ptr, Type ptr_type, Function *function)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const Value* anonymous_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 
)

Definition at line 243 of file ResultSetReductionJIT.cpp.

References Cast::BitCast, CHECK_EQ, emit_load_i32(), emit_load_i64(), Int32, Int32Ptr, Int64, and Int64Ptr.

Referenced by ResultSetReductionJIT::reduceOneSlot().

247  {
248  if (chosen_bytes == sizeof(int32_t)) {
249  const auto func_name = "checked_single_agg_id_int32";
250  const auto proj_val = emit_load_i32(other_pi8, ir_reduce_one_entry);
251  const auto slot_pi32 = ir_reduce_one_entry->add<Cast>(
252  Cast::CastOp::BitCast, slot_pi8, Type::Int32Ptr, "");
253  return ir_reduce_one_entry->add<Call>(
254  func_name,
255  Type::Int32,
256  std::vector<const Value*>{
257  slot_pi32,
258  proj_val,
259  ir_reduce_one_entry->addConstant<ConstantInt>(init_val, Type::Int32)},
260  "");
261  } else {
262  const auto func_name = "checked_single_agg_id";
263  CHECK_EQ(chosen_bytes, sizeof(int64_t));
264  const auto proj_val = emit_load_i64(other_pi8, ir_reduce_one_entry);
265  const auto slot_pi64 = ir_reduce_one_entry->add<Cast>(
266  Cast::CastOp::BitCast, slot_pi8, Type::Int64Ptr, "");
267 
268  return ir_reduce_one_entry->add<Call>(
269  func_name,
270  Type::Int32,
271  std::vector<const Value*>{
272  slot_pi64,
273  proj_val,
274  ir_reduce_one_entry->addConstant<ConstantInt>(init_val, Type::Int64)},
275  "");
276  }
277 }
#define CHECK_EQ(x, y)
Definition: Logger.h:217
Value * emit_load_i32(Value *ptr, Function *function)
Value * emit_load_i64(Value *ptr, Function *function)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Value* anonymous_namespace{ResultSetReductionJIT.cpp}::emit_load ( Value ptr,
Type  ptr_type,
Function function 
)

Definition at line 52 of file ResultSetReductionJIT.cpp.

References Cast::BitCast, and Value::label().

Referenced by emit_aggregate_one_count(), emit_aggregate_one_nullable_value(), emit_aggregate_one_value(), emit_load_i32(), and emit_load_i64().

52  {
53  return function->add<Load>(
54  function->add<Cast>(Cast::CastOp::BitCast, ptr, ptr_type, ""),
55  ptr->label() + "_loaded");
56 }
const std::string & label() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Value* anonymous_namespace{ResultSetReductionJIT.cpp}::emit_load_i32 ( Value ptr,
Function function 
)

Definition at line 59 of file ResultSetReductionJIT.cpp.

References emit_load(), and Int32Ptr.

Referenced by emit_checked_write_projection(), emit_read_int_from_buff(), emit_write_projection(), and ResultSetReductionJIT::isEmpty().

59  {
60  return emit_load(ptr, Type::Int32Ptr, function);
61 }
Value * emit_load(Value *ptr, Type ptr_type, Function *function)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Value* anonymous_namespace{ResultSetReductionJIT.cpp}::emit_load_i64 ( Value ptr,
Function function 
)

Definition at line 64 of file ResultSetReductionJIT.cpp.

References emit_load(), and Int64Ptr.

Referenced by emit_checked_write_projection(), emit_read_int_from_buff(), emit_write_projection(), ResultSetReductionJIT::isEmpty(), ResultSetReductionJIT::reduceOneApproxQuantileSlot(), and ResultSetReductionJIT::reduceOneCountDistinctSlot().

64  {
65  return emit_load(ptr, Type::Int64Ptr, function);
66 }
Value * emit_load(Value *ptr, Type ptr_type, Function *function)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Value* anonymous_namespace{ResultSetReductionJIT.cpp}::emit_read_int_from_buff ( Value ptr,
const int8_t  compact_sz,
Function function 
)

Definition at line 69 of file ResultSetReductionJIT.cpp.

References emit_load_i32(), emit_load_i64(), logger::FATAL, Int64, LOG, and Cast::SExt.

Referenced by ResultSetReductionJIT::isEmpty().

69  {
70  switch (compact_sz) {
71  case 8: {
72  return emit_load_i64(ptr, function);
73  }
74  case 4: {
75  const auto loaded_val = emit_load_i32(ptr, function);
76  return function->add<Cast>(Cast::CastOp::SExt, loaded_val, Type::Int64, "");
77  }
78  default: {
79  LOG(FATAL) << "Invalid byte width: " << compact_sz;
80  return nullptr;
81  }
82  }
83 }
#define LOG(tag)
Definition: Logger.h:203
Value * emit_load_i32(Value *ptr, Function *function)
Value * emit_load_i64(Value *ptr, Function *function)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 212 of file ResultSetReductionJIT.cpp.

References CHECK_EQ, emit_load_i32(), emit_load_i64(), Int64, and to_string().

Referenced by ResultSetReductionJIT::reduceOneSlot().

216  {
217  const auto func_name = "write_projection_int" + std::to_string(chosen_bytes * 8);
218  if (chosen_bytes == sizeof(int32_t)) {
219  const auto proj_val = emit_load_i32(other_pi8, ir_reduce_one_entry);
220  ir_reduce_one_entry->add<Call>(
221  func_name,
222  std::vector<const Value*>{
223  slot_pi8,
224  proj_val,
225  ir_reduce_one_entry->addConstant<ConstantInt>(init_val, Type::Int64)},
226  "");
227  } else {
228  CHECK_EQ(chosen_bytes, sizeof(int64_t));
229  const auto proj_val = emit_load_i64(other_pi8, ir_reduce_one_entry);
230  ir_reduce_one_entry->add<Call>(
231  func_name,
232  std::vector<const Value*>{
233  slot_pi8,
234  proj_val,
235  ir_reduce_one_entry->addConstant<ConstantInt>(init_val, Type::Int64)},
236  "");
237  }
238 }
#define CHECK_EQ(x, y)
Definition: Logger.h:217
std::string to_string(char const *&&v)
Value * emit_load_i32(Value *ptr, Function *function)
Value * emit_load_i64(Value *ptr, Function *function)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 986 of file ResultSetReductionJIT.cpp.

References BinaryOperator::Add, For::add(), g_enable_dynamic_watchdog, g_enable_non_kernel_time_query_interrupt, Int32, Int64, Int8, INTERRUPT_ERROR, For::iter(), ICmp::NE, Cast::SExt, and WATCHDOG_ERROR.

Referenced by ResultSetReductionJIT::reduceLoop().

995  {
996  const auto that_entry_idx = for_loop->add<BinaryOperator>(
997  BinaryOperator::BinaryOp::Add, for_loop->iter(), start_index, "that_entry_idx");
998  const auto sample_seed =
999  for_loop->add<Cast>(Cast::CastOp::SExt, that_entry_idx, Type::Int64, "");
1001  const auto checker_rt_name =
1002  g_enable_dynamic_watchdog ? "check_watchdog_rt" : "check_interrupt_rt";
1003  const auto error_code = g_enable_dynamic_watchdog ? WATCHDOG_ERROR : INTERRUPT_ERROR;
1004  const auto checker_triggered = for_loop->add<ExternalCall>(
1005  checker_rt_name, Type::Int8, std::vector<const Value*>{sample_seed}, "");
1006  const auto interrupt_triggered_bool =
1007  for_loop->add<ICmp>(ICmp::Predicate::NE,
1008  checker_triggered,
1009  ir_reduce_loop->addConstant<ConstantInt>(0, Type::Int8),
1010  "");
1011  for_loop->add<ReturnEarly>(
1012  interrupt_triggered_bool,
1013  ir_reduce_loop->addConstant<ConstantInt>(error_code, Type::Int32),
1014  "");
1015  }
1016  const auto reduce_rc =
1017  for_loop->add<Call>(ir_reduce_one_entry_idx,
1018  std::vector<const Value*>{this_buff,
1019  that_buff,
1020  that_entry_idx,
1021  that_entry_count,
1022  this_qmd_handle,
1023  that_qmd_handle,
1024  serialized_varlen_buffer},
1025  "");
1026 
1027  auto reduce_rc_bool =
1028  for_loop->add<ICmp>(ICmp::Predicate::NE,
1029  reduce_rc,
1030  ir_reduce_loop->addConstant<ConstantInt>(0, Type::Int32),
1031  "");
1032  for_loop->add<ReturnEarly>(reduce_rc_bool, reduce_rc, "");
1033 }
bool g_enable_dynamic_watchdog
Definition: Execute.cpp:77
bool g_enable_non_kernel_time_query_interrupt
Definition: Execute.cpp:119
Value * add(Args &&...args)
const Value * iter() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool anonymous_namespace{ResultSetReductionJIT.cpp}::is_aggregate_query ( const QueryDescriptionType  hash_type)

Definition at line 392 of file ResultSetReductionJIT.cpp.

References GroupByBaselineHash, GroupByPerfectHash, and NonGroupedAggregate.

Referenced by ResultSetReductionJIT::codegen(), and ResultSetReductionJIT::isEmpty().

+ Here is the caller graph for this function:

ReductionCode anonymous_namespace{ResultSetReductionJIT.cpp}::setup_functions_ir ( const QueryDescriptionType  hash_type)

Definition at line 383 of file ResultSetReductionJIT.cpp.

References ReductionCode::ir_is_empty, setup_is_empty_entry(), setup_reduce_loop(), setup_reduce_one_entry(), and setup_reduce_one_entry_idx().

Referenced by ResultSetReductionJIT::codegen(), and GpuReductionHelperJIT::codegen().

383  {
384  ReductionCode reduction_code{};
385  reduction_code.ir_is_empty = setup_is_empty_entry(&reduction_code);
386  reduction_code.ir_reduce_one_entry = setup_reduce_one_entry(&reduction_code, hash_type);
387  reduction_code.ir_reduce_one_entry_idx = setup_reduce_one_entry_idx(&reduction_code);
388  reduction_code.ir_reduce_loop = setup_reduce_loop(&reduction_code);
389  return reduction_code;
390 }
std::unique_ptr< Function > setup_reduce_one_entry_idx(ReductionCode *reduction_code)
std::unique_ptr< Function > ir_is_empty
std::unique_ptr< Function > setup_is_empty_entry(ReductionCode *reduction_code)
std::unique_ptr< Function > setup_reduce_one_entry(ReductionCode *reduction_code, const QueryDescriptionType hash_type)
std::unique_ptr< Function > setup_reduce_loop(ReductionCode *reduction_code)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::unique_ptr<Function> anonymous_namespace{ResultSetReductionJIT.cpp}::setup_is_empty_entry ( ReductionCode reduction_code)

Definition at line 289 of file ResultSetReductionJIT.cpp.

References create_function(), Int1, and Int8Ptr.

Referenced by setup_functions_ir().

289  {
290  return create_function(
291  "is_empty_entry", {{"row_ptr", Type::Int8Ptr}}, Type::Int1, /*always_inline=*/true);
292 }
std::unique_ptr< Function > create_function(const std::string name, const std::vector< Function::NamedArg > &arg_types, const Type ret_type, const bool always_inline)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::unique_ptr<Function> anonymous_namespace{ResultSetReductionJIT.cpp}::setup_reduce_loop ( ReductionCode reduction_code)

Definition at line 341 of file ResultSetReductionJIT.cpp.

References create_function(), Int32, Int8Ptr, and VoidPtr.

Referenced by setup_functions_ir().

341  {
342  return create_function("reduce_loop",
343  {{"this_buff", Type::Int8Ptr},
344  {"that_buff", Type::Int8Ptr},
345  {"start_index", Type::Int32},
346  {"end_index", Type::Int32},
347  {"that_entry_count", Type::Int32},
348  {"this_qmd_handle", Type::VoidPtr},
349  {"that_qmd_handle", Type::VoidPtr},
350  {"serialized_varlen_buffer", Type::VoidPtr}},
351  Type::Int32,
352  /*always_inline=*/false);
353 }
std::unique_ptr< Function > create_function(const std::string name, const std::vector< Function::NamedArg > &arg_types, const Type ret_type, const bool always_inline)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::unique_ptr<Function> anonymous_namespace{ResultSetReductionJIT.cpp}::setup_reduce_one_entry ( ReductionCode reduction_code,
const QueryDescriptionType  hash_type 
)

Definition at line 295 of file ResultSetReductionJIT.cpp.

References create_function(), logger::FATAL, GroupByBaselineHash, GroupByPerfectHash, Int32, Int8Ptr, LOG, NonGroupedAggregate, and VoidPtr.

Referenced by setup_functions_ir().

296  {
297  std::string this_ptr_name;
298  std::string that_ptr_name;
299  switch (hash_type) {
301  this_ptr_name = "this_targets_ptr";
302  that_ptr_name = "that_targets_ptr";
303  break;
304  }
307  this_ptr_name = "this_row_ptr";
308  that_ptr_name = "that_row_ptr";
309  break;
310  }
311  default: {
312  LOG(FATAL) << "Unexpected query description type";
313  }
314  }
315  return create_function("reduce_one_entry",
316  {{this_ptr_name, Type::Int8Ptr},
317  {that_ptr_name, Type::Int8Ptr},
318  {"this_qmd", Type::VoidPtr},
319  {"that_qmd", Type::VoidPtr},
320  {"serialized_varlen_buffer_arg", Type::VoidPtr}},
321  Type::Int32,
322  /*always_inline=*/true);
323 }
#define LOG(tag)
Definition: Logger.h:203
std::unique_ptr< Function > create_function(const std::string name, const std::vector< Function::NamedArg > &arg_types, const Type ret_type, const bool always_inline)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::unique_ptr<Function> anonymous_namespace{ResultSetReductionJIT.cpp}::setup_reduce_one_entry_idx ( ReductionCode reduction_code)

Definition at line 326 of file ResultSetReductionJIT.cpp.

References create_function(), Int32, Int8Ptr, and VoidPtr.

Referenced by setup_functions_ir().

326  {
327  return create_function("reduce_one_entry_idx",
328  {{"this_buff", Type::Int8Ptr},
329  {"that_buff", Type::Int8Ptr},
330  {"that_entry_idx", Type::Int32},
331  {"that_entry_count", Type::Int32},
332  {"this_qmd_handle", Type::VoidPtr},
333  {"that_qmd_handle", Type::VoidPtr},
334  {"serialized_varlen_buffer", Type::VoidPtr}},
335  Type::Int32,
336  /*always_inline=*/true);
337 }
std::unique_ptr< Function > create_function(const std::string name, const std::vector< Function::NamedArg > &arg_types, const Type ret_type, const bool always_inline)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string anonymous_namespace{ResultSetReductionJIT.cpp}::target_info_key ( const TargetInfo target_info)

Definition at line 1290 of file ResultSetReductionJIT.cpp.

References TargetInfo::agg_arg_type, TargetInfo::agg_kind, SQLTypeInfo::get_notnull(), SQLTypeInfo::get_type_name(), TargetInfo::is_agg, TargetInfo::is_distinct, TargetInfo::skip_null_val, TargetInfo::sql_type, and to_string().

Referenced by ResultSetReductionJIT::cacheKey().

1290  {
1291  return std::to_string(target_info.is_agg) + "\n" +
1292  std::to_string(target_info.agg_kind) + "\n" +
1293  target_info.sql_type.get_type_name() + "\n" +
1294  std::to_string(target_info.sql_type.get_notnull()) + "\n" +
1295  target_info.agg_arg_type.get_type_name() + "\n" +
1296  std::to_string(target_info.agg_arg_type.get_notnull()) + "\n" +
1297  std::to_string(target_info.skip_null_val) + "\n" +
1298  std::to_string(target_info.is_distinct);
1299 }
SQLTypeInfo sql_type
Definition: TargetInfo.h:51
bool skip_null_val
Definition: TargetInfo.h:53
std::string to_string(char const *&&v)
SQLTypeInfo agg_arg_type
Definition: TargetInfo.h:52
bool is_agg
Definition: TargetInfo.h:49
SQLAgg agg_kind
Definition: TargetInfo.h:50
std::string get_type_name() const
Definition: sqltypes.h:432
bool is_distinct
Definition: TargetInfo.h:54
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:336

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

Definition at line 399 of file ResultSetReductionJIT.cpp.

References CHECK.

Referenced by serialized_varlen_buffer_sample().

403  {
404  const auto rhs_proj_col = *reinterpret_cast<const int64_t*>(that_ptr1);
405  if (rhs_proj_col != init_val) {
406  *reinterpret_cast<int64_t*>(this_ptr1) = rhs_proj_col;
407  }
408  CHECK(this_ptr2 && that_ptr2);
409  *reinterpret_cast<int64_t*>(this_ptr2) = *reinterpret_cast<const int64_t*>(that_ptr2);
410 }
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the caller graph for this function:

Variable Documentation

const size_t anonymous_namespace{ResultSetReductionJIT.cpp}::INTERP_THRESHOLD {25}

Definition at line 49 of file ResultSetReductionJIT.cpp.

Referenced by ResultSetReductionJIT::codegen().

const int32_t anonymous_namespace{ResultSetReductionJIT.cpp}::INTERRUPT_ERROR {10}

Definition at line 47 of file ResultSetReductionJIT.cpp.

Referenced by generate_loop_body().

const int32_t anonymous_namespace{ResultSetReductionJIT.cpp}::WATCHDOG_ERROR

Definition at line 45 of file ResultSetReductionJIT.cpp.

Referenced by generate_loop_body().