OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GpuReductionHelperJIT Class Reference

#include <ResultSetReductionJIT.h>

+ Inheritance diagram for GpuReductionHelperJIT:
+ Collaboration diagram for GpuReductionHelperJIT:

Public Member Functions

 GpuReductionHelperJIT (const QueryMemoryDescriptor &query_mem_desc, const std::vector< TargetInfo > &targets, const std::vector< int64_t > &target_init_vals, const size_t executor_id)
 
ReductionCode codegen () const override
 
- Public Member Functions inherited from ResultSetReductionJIT
 ResultSetReductionJIT (const QueryMemoryDescriptor &query_mem_desc, const std::vector< TargetInfo > &targets, const std::vector< int64_t > &target_init_vals, const size_t executor_id)
 
virtual ~ResultSetReductionJIT ()=default
 

Private Attributes

const QueryMemoryDescriptorquery_mem_desc_
 

Additional Inherited Members

- Protected Member Functions inherited from ResultSetReductionJIT
void isEmpty (const ReductionCode &reduction_code) const
 
void reduceOneEntryNoCollisions (const ReductionCode &reduction_code) const
 
void reduceOneEntryNoCollisionsIdx (const ReductionCode &reduction_code) const
 
void reduceLoop (const ReductionCode &reduction_code) const
 
- Protected Attributes inherited from ResultSetReductionJIT
size_t executor_id_
 

Detailed Description

This is a helper class for performing GPU reduction code. It uses the same functions that ResultSetReductionJIT generates so that it can be reused and help the reduction procedure within GPU.

Definition at line 150 of file ResultSetReductionJIT.h.

Constructor & Destructor Documentation

GpuReductionHelperJIT::GpuReductionHelperJIT ( const QueryMemoryDescriptor query_mem_desc,
const std::vector< TargetInfo > &  targets,
const std::vector< int64_t > &  target_init_vals,
const size_t  executor_id 
)
inline

Definition at line 152 of file ResultSetReductionJIT.h.

References CHECK, QueryMemoryDescriptor::didOutputColumnar(), QueryMemoryDescriptor::getQueryDescriptionType(), heavyai::GroupByPerfectHash, QueryMemoryDescriptor::hasKeylessHash(), and query_mem_desc_.

156  : ResultSetReductionJIT(query_mem_desc, targets, target_init_vals, executor_id)
157  , query_mem_desc_(query_mem_desc) {
162  }
GroupByPerfectHash
Definition: enums.h:58
const QueryMemoryDescriptor & query_mem_desc_
QueryDescriptionType getQueryDescriptionType() const
#define CHECK(condition)
Definition: Logger.h:291
ResultSetReductionJIT(const QueryMemoryDescriptor &query_mem_desc, const std::vector< TargetInfo > &targets, const std::vector< int64_t > &target_init_vals, const size_t executor_id)

+ Here is the call graph for this function:

Member Function Documentation

ReductionCode GpuReductionHelperJIT::codegen ( ) const
overridevirtual

generates code for perfect hash group by reduction: the following functions are internally created: isEmpty, reduceOneEntryNoCollision (reduce for perfect hash), reduceOneEntryNoCollissionsIdx(reduce one slot for perfect hash), and reduceLoop (the outer loop).

Reimplemented from ResultSetReductionJIT.

Definition at line 1327 of file ResultSetReductionJIT.cpp.

References AUTOMATIC_IR_METADATA, ReductionCode::cgen_state, CHECK, anonymous_namespace{ResultSetReductionJIT.cpp}::create_llvm_function(), ResultSetReductionJIT::executor_id_, f(), Executor::getExecutor(), QueryMemoryDescriptor::getQueryDescriptionType(), heavyai::GroupByPerfectHash, ReductionCode::ir_is_empty, ReductionCode::ir_reduce_loop, ReductionCode::ir_reduce_one_entry, ReductionCode::ir_reduce_one_entry_idx, ResultSetReductionJIT::isEmpty(), ReductionCode::module, ResultSetReductionJIT::query_mem_desc_, ResultSetReductionJIT::reduceLoop(), ResultSetReductionJIT::reduceOneEntryNoCollisions(), ResultSetReductionJIT::reduceOneEntryNoCollisionsIdx(), CgenState::set_module_shallow_copy(), anonymous_namespace{ResultSetReductionJIT.cpp}::setup_functions_ir(), and translate_function().

1327  {
1328  const auto hash_type = query_mem_desc_.getQueryDescriptionType();
1329  auto reduction_code = setup_functions_ir(hash_type);
1331  isEmpty(reduction_code);
1332  reduceOneEntryNoCollisions(reduction_code);
1333  reduceOneEntryNoCollisionsIdx(reduction_code);
1334  reduceLoop(reduction_code);
1335  auto executor = Executor::getExecutor(executor_id_);
1336  auto cgen_state_ = std::unique_ptr<CgenState>(new CgenState({}, false, executor.get()));
1337  auto cgen_state = reduction_code.cgen_state = cgen_state_.get();
1338  // CHECK(executor->thread_id_ == logger::thread_id()); // do we need compilation mutex?
1339  cgen_state->set_module_shallow_copy(executor->get_rt_module());
1340  reduction_code.module = cgen_state->module_;
1341 
1342  AUTOMATIC_IR_METADATA(cgen_state);
1343  auto ir_is_empty = create_llvm_function(reduction_code.ir_is_empty.get(), cgen_state);
1344  auto ir_reduce_one_entry =
1345  create_llvm_function(reduction_code.ir_reduce_one_entry.get(), cgen_state);
1346  auto ir_reduce_one_entry_idx =
1347  create_llvm_function(reduction_code.ir_reduce_one_entry_idx.get(), cgen_state);
1348  auto ir_reduce_loop =
1349  create_llvm_function(reduction_code.ir_reduce_loop.get(), cgen_state);
1350  std::unordered_map<const Function*, llvm::Function*> f;
1351  f.emplace(reduction_code.ir_is_empty.get(), ir_is_empty);
1352  f.emplace(reduction_code.ir_reduce_one_entry.get(), ir_reduce_one_entry);
1353  f.emplace(reduction_code.ir_reduce_one_entry_idx.get(), ir_reduce_one_entry_idx);
1354  f.emplace(reduction_code.ir_reduce_loop.get(), ir_reduce_loop);
1355  translate_function(reduction_code.ir_is_empty.get(), ir_is_empty, reduction_code, f);
1357  reduction_code.ir_reduce_one_entry.get(), ir_reduce_one_entry, reduction_code, f);
1358  translate_function(reduction_code.ir_reduce_one_entry_idx.get(),
1359  ir_reduce_one_entry_idx,
1360  reduction_code,
1361  f);
1363  reduction_code.ir_reduce_loop.get(), ir_reduce_loop, reduction_code, f);
1364  reduction_code.llvm_reduce_loop = ir_reduce_loop;
1365  reduction_code.cgen_state = nullptr;
1366  return reduction_code;
1367 }
GroupByPerfectHash
Definition: enums.h:58
void reduceOneEntryNoCollisions(const ReductionCode &reduction_code) const
void reduceLoop(const ReductionCode &reduction_code) const
void reduceOneEntryNoCollisionsIdx(const ReductionCode &reduction_code) const
const QueryMemoryDescriptor & query_mem_desc_
void translate_function(const Function *function, llvm::Function *llvm_function, const ReductionCode &reduction_code, const std::unordered_map< const Function *, llvm::Function * > &f)
static std::shared_ptr< Executor > getExecutor(const ExecutorId id, const std::string &debug_dir="", const std::string &debug_file="", const SystemParameters &system_parameters=SystemParameters())
Definition: Execute.cpp:513
ReductionCode setup_functions_ir(const QueryDescriptionType hash_type)
#define AUTOMATIC_IR_METADATA(CGENSTATE)
QueryDescriptionType getQueryDescriptionType() const
torch::Tensor f(torch::Tensor x, torch::Tensor W_target, torch::Tensor b_target)
void isEmpty(const ReductionCode &reduction_code) const
#define CHECK(condition)
Definition: Logger.h:291
llvm::Function * create_llvm_function(const Function *function, CgenState *cgen_state)

+ Here is the call graph for this function:

Member Data Documentation

const QueryMemoryDescriptor& GpuReductionHelperJIT::query_mem_desc_
private

Definition at line 172 of file ResultSetReductionJIT.h.

Referenced by GpuReductionHelperJIT().


The documentation for this class was generated from the following files: