OmniSciDB  b28c0d5765
 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 (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 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 276 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().

280  {
281  return std::make_unique<Function>(name, arg_types, ret_type, always_inline);
282 }
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 352 of file ResultSetReductionJIT.cpp.

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

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

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

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

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

Referenced by ResultSetReductionJIT::reduceOneAggregateSlot().

189  {
190  const auto dest_name = "count_dest";
191  if (chosen_bytes == sizeof(int32_t)) {
192  const auto agg = ir_reduce_one_entry->add<Cast>(
193  Cast::CastOp::BitCast, val_ptr, Type::Int32Ptr, dest_name);
194  const auto val = emit_load(other_ptr, Type::Int32Ptr, ir_reduce_one_entry);
195  ir_reduce_one_entry->add<Call>(
196  "agg_sum_int32", std::vector<const Value*>{agg, val}, "");
197  } else {
198  CHECK_EQ(chosen_bytes, sizeof(int64_t));
199  const auto agg = ir_reduce_one_entry->add<Cast>(
200  Cast::CastOp::BitCast, val_ptr, Type::Int64Ptr, dest_name);
201  const auto val = emit_load(other_ptr, Type::Int64Ptr, ir_reduce_one_entry);
202  ir_reduce_one_entry->add<Call>("agg_sum", std::vector<const Value*>{agg, val}, "");
203  }
204 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
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 ( 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 
)

Definition at line 125 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, TargetInfo::skip_null_val, to_lower(), and toString().

Referenced by ResultSetReductionJIT::reduceOneAggregateSlot().

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

88  {
89  const auto sql_type = get_compact_type(agg_info);
90  const auto dest_name = agg_kind + "_dest";
91  if (sql_type.is_fp()) {
92  if (chosen_bytes == sizeof(float)) {
93  const auto agg = ir_reduce_one_entry->add<Cast>(
94  Cast::CastOp::BitCast, val_ptr, Type::Int32Ptr, dest_name);
95  const auto val = emit_load(other_ptr, Type::FloatPtr, ir_reduce_one_entry);
96  ir_reduce_one_entry->add<Call>(
97  "agg_" + agg_kind + "_float", std::vector<const Value*>{agg, val}, "");
98  } else {
99  CHECK_EQ(chosen_bytes, sizeof(double));
100  const auto agg = ir_reduce_one_entry->add<Cast>(
101  Cast::CastOp::BitCast, val_ptr, Type::Int64Ptr, dest_name);
102  const auto val = emit_load(other_ptr, Type::DoublePtr, ir_reduce_one_entry);
103  ir_reduce_one_entry->add<Call>(
104  "agg_" + agg_kind + "_double", std::vector<const Value*>{agg, val}, "");
105  }
106  } else {
107  if (chosen_bytes == sizeof(int32_t)) {
108  const auto agg = ir_reduce_one_entry->add<Cast>(
109  Cast::CastOp::BitCast, val_ptr, Type::Int32Ptr, dest_name);
110  const auto val = emit_load(other_ptr, Type::Int32Ptr, ir_reduce_one_entry);
111  ir_reduce_one_entry->add<Call>(
112  "agg_" + agg_kind + "_int32", std::vector<const Value*>{agg, val}, "");
113  } else {
114  CHECK_EQ(chosen_bytes, sizeof(int64_t));
115  const auto agg = ir_reduce_one_entry->add<Cast>(
116  Cast::CastOp::BitCast, val_ptr, Type::Int64Ptr, dest_name);
117  const auto val = emit_load(other_ptr, Type::Int64Ptr, ir_reduce_one_entry);
118  ir_reduce_one_entry->add<Call>(
119  "agg_" + agg_kind, std::vector<const Value*>{agg, val}, "");
120  }
121  }
122 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
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 240 of file ResultSetReductionJIT.cpp.

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

Referenced by ResultSetReductionJIT::reduceOneSlot().

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

48  {
49  return function->add<Load>(
50  function->add<Cast>(Cast::CastOp::BitCast, ptr, ptr_type, ""),
51  ptr->label() + "_loaded");
52 }
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 55 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().

55  {
56  return emit_load(ptr, Type::Int32Ptr, function);
57 }
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 60 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(), ResultSetReductionJIT::reduceOneCountDistinctSlot(), and ResultSetReductionJIT::reduceOneModeSlot().

60  {
61  return emit_load(ptr, Type::Int64Ptr, function);
62 }
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 65 of file ResultSetReductionJIT.cpp.

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

Referenced by ResultSetReductionJIT::isEmpty().

65  {
66  switch (compact_sz) {
67  case 8: {
68  return emit_load_i64(ptr, function);
69  }
70  case 4: {
71  const auto loaded_val = emit_load_i32(ptr, function);
72  return function->add<Cast>(Cast::CastOp::SExt, loaded_val, Type::Int64, "");
73  }
74  default: {
75  LOG(FATAL) << "Invalid byte width: " << compact_sz;
76  return nullptr;
77  }
78  }
79 }
#define LOG(tag)
Definition: Logger.h:216
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 209 of file ResultSetReductionJIT.cpp.

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

Referenced by ResultSetReductionJIT::reduceOneSlot().

213  {
214  const auto func_name = "write_projection_int" + std::to_string(chosen_bytes * 8);
215  if (chosen_bytes == sizeof(int32_t)) {
216  const auto proj_val = emit_load_i32(other_pi8, ir_reduce_one_entry);
217  ir_reduce_one_entry->add<Call>(
218  func_name,
219  std::vector<const Value*>{
220  slot_pi8,
221  proj_val,
222  ir_reduce_one_entry->addConstant<ConstantInt>(init_val, Type::Int64)},
223  "");
224  } else {
225  CHECK_EQ(chosen_bytes, sizeof(int64_t));
226  const auto proj_val = emit_load_i64(other_pi8, ir_reduce_one_entry);
227  ir_reduce_one_entry->add<Call>(
228  func_name,
229  std::vector<const Value*>{
230  slot_pi8,
231  proj_val,
232  ir_reduce_one_entry->addConstant<ConstantInt>(init_val, Type::Int64)},
233  "");
234  }
235 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
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 980 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().

989  {
990  const auto that_entry_idx = for_loop->add<BinaryOperator>(
991  BinaryOperator::BinaryOp::Add, for_loop->iter(), start_index, "that_entry_idx");
992  const auto sample_seed =
993  for_loop->add<Cast>(Cast::CastOp::SExt, that_entry_idx, Type::Int64, "");
995  const auto checker_rt_name =
996  g_enable_dynamic_watchdog ? "check_watchdog_rt" : "check_interrupt_rt";
997  const auto error_code = g_enable_dynamic_watchdog ? WATCHDOG_ERROR : INTERRUPT_ERROR;
998  const auto checker_triggered = for_loop->add<ExternalCall>(
999  checker_rt_name, Type::Int8, std::vector<const Value*>{sample_seed}, "");
1000  const auto interrupt_triggered_bool =
1001  for_loop->add<ICmp>(ICmp::Predicate::NE,
1002  checker_triggered,
1003  ir_reduce_loop->addConstant<ConstantInt>(0, Type::Int8),
1004  "");
1005  for_loop->add<ReturnEarly>(
1006  interrupt_triggered_bool,
1007  ir_reduce_loop->addConstant<ConstantInt>(error_code, Type::Int32),
1008  "");
1009  }
1010  const auto reduce_rc =
1011  for_loop->add<Call>(ir_reduce_one_entry_idx,
1012  std::vector<const Value*>{this_buff,
1013  that_buff,
1014  that_entry_idx,
1015  that_entry_count,
1016  this_qmd_handle,
1017  that_qmd_handle,
1018  serialized_varlen_buffer},
1019  "");
1020 
1021  auto reduce_rc_bool =
1022  for_loop->add<ICmp>(ICmp::Predicate::NE,
1023  reduce_rc,
1024  ir_reduce_loop->addConstant<ConstantInt>(0, Type::Int32),
1025  "");
1026  for_loop->add<ReturnEarly>(reduce_rc_bool, reduce_rc, "");
1027 }
bool g_enable_dynamic_watchdog
Definition: Execute.cpp:80
bool g_enable_non_kernel_time_query_interrupt
Definition: Execute.cpp:126
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 389 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 380 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().

380  {
381  ReductionCode reduction_code{};
382  reduction_code.ir_is_empty = setup_is_empty_entry(&reduction_code);
383  reduction_code.ir_reduce_one_entry = setup_reduce_one_entry(&reduction_code, hash_type);
384  reduction_code.ir_reduce_one_entry_idx = setup_reduce_one_entry_idx(&reduction_code);
385  reduction_code.ir_reduce_loop = setup_reduce_loop(&reduction_code);
386  return reduction_code;
387 }
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 286 of file ResultSetReductionJIT.cpp.

References create_function(), Int1, and Int8Ptr.

Referenced by setup_functions_ir().

286  {
287  return create_function(
288  "is_empty_entry", {{"row_ptr", Type::Int8Ptr}}, Type::Int1, /*always_inline=*/true);
289 }
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 338 of file ResultSetReductionJIT.cpp.

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

Referenced by setup_functions_ir().

338  {
339  return create_function("reduce_loop",
340  {{"this_buff", Type::Int8Ptr},
341  {"that_buff", Type::Int8Ptr},
342  {"start_index", Type::Int32},
343  {"end_index", Type::Int32},
344  {"that_entry_count", Type::Int32},
345  {"this_qmd_handle", Type::VoidPtr},
346  {"that_qmd_handle", Type::VoidPtr},
347  {"serialized_varlen_buffer", Type::VoidPtr}},
348  Type::Int32,
349  /*always_inline=*/false);
350 }
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 292 of file ResultSetReductionJIT.cpp.

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

Referenced by setup_functions_ir().

293  {
294  std::string this_ptr_name;
295  std::string that_ptr_name;
296  switch (hash_type) {
298  this_ptr_name = "this_targets_ptr";
299  that_ptr_name = "that_targets_ptr";
300  break;
301  }
304  this_ptr_name = "this_row_ptr";
305  that_ptr_name = "that_row_ptr";
306  break;
307  }
308  default: {
309  LOG(FATAL) << "Unexpected query description type";
310  }
311  }
312  return create_function("reduce_one_entry",
313  {{this_ptr_name, Type::Int8Ptr},
314  {that_ptr_name, Type::Int8Ptr},
315  {"this_qmd", Type::VoidPtr},
316  {"that_qmd", Type::VoidPtr},
317  {"serialized_varlen_buffer_arg", Type::VoidPtr}},
318  Type::Int32,
319  /*always_inline=*/true);
320 }
#define LOG(tag)
Definition: Logger.h:216
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 323 of file ResultSetReductionJIT.cpp.

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

Referenced by setup_functions_ir().

323  {
324  return create_function("reduce_one_entry_idx",
325  {{"this_buff", Type::Int8Ptr},
326  {"that_buff", Type::Int8Ptr},
327  {"that_entry_idx", Type::Int32},
328  {"that_entry_count", Type::Int32},
329  {"this_qmd_handle", Type::VoidPtr},
330  {"that_qmd_handle", Type::VoidPtr},
331  {"serialized_varlen_buffer", Type::VoidPtr}},
332  Type::Int32,
333  /*always_inline=*/true);
334 }
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 1284 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().

1284  {
1285  return std::to_string(target_info.is_agg) + "\n" +
1286  std::to_string(target_info.agg_kind) + "\n" +
1287  target_info.sql_type.get_type_name() + "\n" +
1288  std::to_string(target_info.sql_type.get_notnull()) + "\n" +
1289  target_info.agg_arg_type.get_type_name() + "\n" +
1290  std::to_string(target_info.agg_arg_type.get_notnull()) + "\n" +
1291  std::to_string(target_info.skip_null_val) + "\n" +
1292  std::to_string(target_info.is_distinct);
1293 }
SQLTypeInfo sql_type
Definition: TargetInfo.h:52
bool skip_null_val
Definition: TargetInfo.h:54
std::string to_string(char const *&&v)
SQLTypeInfo agg_arg_type
Definition: TargetInfo.h:53
bool is_agg
Definition: TargetInfo.h:50
SQLAgg agg_kind
Definition: TargetInfo.h:51
std::string get_type_name() const
Definition: sqltypes.h:504
bool is_distinct
Definition: TargetInfo.h:55
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:387

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

References CHECK.

Referenced by serialized_varlen_buffer_sample().

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

+ Here is the caller graph for this function:

Variable Documentation

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

Definition at line 45 of file ResultSetReductionJIT.cpp.

Referenced by ResultSetReductionJIT::codegen().

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

Definition at line 43 of file ResultSetReductionJIT.cpp.

Referenced by generate_loop_body().

const int32_t anonymous_namespace{ResultSetReductionJIT.cpp}::WATCHDOG_ERROR

Definition at line 41 of file ResultSetReductionJIT.cpp.

Referenced by generate_loop_body().