OmniSciDB  baf940c279
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 {-1}
 
const size_t INTERP_THRESHOLD {25}
 

Function Documentation

◆ create_function()

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 277 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().

281  {
282  return std::make_unique<Function>(name, arg_types, ret_type, always_inline);
283 }
name
Definition: setup.py:35
+ Here is the caller graph for this function:

◆ create_llvm_function()

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

Definition at line 353 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().

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

◆ emit_aggregate_one_count()

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

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

Referenced by ResultSetReductionJIT::reduceOneAggregateSlot().

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

◆ emit_aggregate_one_nullable_value()

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 127 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().

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

◆ emit_aggregate_one_value()

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 85 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().

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

◆ emit_checked_write_projection()

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

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

Referenced by ResultSetReductionJIT::reduceOneSlot().

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

◆ emit_load()

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

Definition at line 50 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().

50  {
51  return function->add<Load>(
52  function->add<Cast>(Cast::CastOp::BitCast, ptr, ptr_type, ""),
53  ptr->label() + "_loaded");
54 }
const std::string & label() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ emit_load_i32()

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

Definition at line 57 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().

57  {
58  return emit_load(ptr, Type::Int32Ptr, function);
59 }
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:

◆ emit_load_i64()

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

Definition at line 62 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(), and ResultSetReductionJIT::reduceOneCountDistinctSlot().

62  {
63  return emit_load(ptr, Type::Int64Ptr, function);
64 }
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:

◆ emit_read_int_from_buff()

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

Definition at line 67 of file ResultSetReductionJIT.cpp.

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

Referenced by ResultSetReductionJIT::isEmpty().

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

◆ emit_write_projection()

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

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

Referenced by ResultSetReductionJIT::reduceOneSlot().

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

◆ generate_loop_body()

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

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

Referenced by ResultSetReductionJIT::reduceLoop().

969  {
970  const auto that_entry_idx = for_loop->add<BinaryOperator>(
971  BinaryOperator::BinaryOp::Add, for_loop->iter(), start_index, "that_entry_idx");
972  const auto watchdog_sample_seed =
973  for_loop->add<Cast>(Cast::CastOp::SExt, that_entry_idx, Type::Int64, "");
974  const auto watchdog_triggered =
975  for_loop->add<ExternalCall>("check_watchdog_rt",
976  Type::Int8,
977  std::vector<const Value*>{watchdog_sample_seed},
978  "");
979  const auto watchdog_triggered_bool =
980  for_loop->add<ICmp>(ICmp::Predicate::NE,
981  watchdog_triggered,
982  ir_reduce_loop->addConstant<ConstantInt>(0, Type::Int8),
983  "");
984  for_loop->add<ReturnEarly>(
985  watchdog_triggered_bool,
986  ir_reduce_loop->addConstant<ConstantInt>(WATCHDOG_ERROR, Type::Int32),
987  "");
988  const auto reduce_rc =
989  for_loop->add<Call>(ir_reduce_one_entry_idx,
990  std::vector<const Value*>{this_buff,
991  that_buff,
992  that_entry_idx,
993  that_entry_count,
994  this_qmd_handle,
995  that_qmd_handle,
996  serialized_varlen_buffer},
997  "");
998 
999  auto reduce_rc_bool =
1000  for_loop->add<ICmp>(ICmp::Predicate::NE,
1001  reduce_rc,
1002  ir_reduce_loop->addConstant<ConstantInt>(0, Type::Int32),
1003  "");
1004  for_loop->add<ReturnEarly>(reduce_rc_bool, reduce_rc, "");
1005 }
Value * add(Args &&... args)
const Value * iter() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_aggregate_query()

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

Definition at line 390 of file ResultSetReductionJIT.cpp.

References GroupByBaselineHash, GroupByPerfectHash, and NonGroupedAggregate.

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

+ Here is the caller graph for this function:

◆ setup_functions_ir()

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

Definition at line 381 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().

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

◆ setup_is_empty_entry()

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

Definition at line 287 of file ResultSetReductionJIT.cpp.

References create_function(), Int1, and Int8Ptr.

Referenced by setup_functions_ir().

287  {
288  return create_function(
289  "is_empty_entry", {{"row_ptr", Type::Int8Ptr}}, Type::Int1, /*always_inline=*/true);
290 }
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:

◆ setup_reduce_loop()

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

Definition at line 339 of file ResultSetReductionJIT.cpp.

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

Referenced by setup_functions_ir().

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

◆ setup_reduce_one_entry()

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

Definition at line 293 of file ResultSetReductionJIT.cpp.

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

Referenced by setup_functions_ir().

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

◆ setup_reduce_one_entry_idx()

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

Definition at line 324 of file ResultSetReductionJIT.cpp.

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

Referenced by setup_functions_ir().

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

◆ target_info_key()

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

Definition at line 1235 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().

1235  {
1236  return std::to_string(target_info.is_agg) + "\n" +
1237  std::to_string(target_info.agg_kind) + "\n" +
1238  target_info.sql_type.get_type_name() + "\n" +
1239  std::to_string(target_info.sql_type.get_notnull()) + "\n" +
1240  target_info.agg_arg_type.get_type_name() + "\n" +
1241  std::to_string(target_info.agg_arg_type.get_notnull()) + "\n" +
1242  std::to_string(target_info.skip_null_val) + "\n" +
1243  std::to_string(target_info.is_distinct);
1244 }
SQLTypeInfo sql_type
Definition: TargetInfo.h:42
bool skip_null_val
Definition: TargetInfo.h:44
std::string to_string(char const *&&v)
SQLTypeInfo agg_arg_type
Definition: TargetInfo.h:43
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:266
bool is_agg
Definition: TargetInfo.h:40
SQLAgg agg_kind
Definition: TargetInfo.h:41
std::string get_type_name() const
Definition: sqltypes.h:362
bool is_distinct
Definition: TargetInfo.h:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ varlen_buffer_sample()

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

References CHECK.

Referenced by serialized_varlen_buffer_sample().

401  {
402  const auto rhs_proj_col = *reinterpret_cast<const int64_t*>(that_ptr1);
403  if (rhs_proj_col != init_val) {
404  *reinterpret_cast<int64_t*>(this_ptr1) = rhs_proj_col;
405  }
406  CHECK(this_ptr2 && that_ptr2);
407  *reinterpret_cast<int64_t*>(this_ptr2) = *reinterpret_cast<const int64_t*>(that_ptr2);
408 }
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the caller graph for this function:

Variable Documentation

◆ INTERP_THRESHOLD

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

Definition at line 47 of file ResultSetReductionJIT.cpp.

Referenced by ResultSetReductionJIT::codegen().

◆ WATCHDOG_ERROR

const int32_t anonymous_namespace{ResultSetReductionJIT.cpp}::WATCHDOG_ERROR {-1}

Definition at line 45 of file ResultSetReductionJIT.cpp.

Referenced by generate_loop_body().