OmniSciDB  fe05a0c208
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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)
 
virtual ReductionCode codegen () const
 
- 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)
 
virtual ~ResultSetReductionJIT ()=default
 

Private Attributes

const QueryMemoryDescriptorquery_mem_desc_
 

Additional Inherited Members

- Static Public Member Functions inherited from ResultSetReductionJIT
static void clearCache ()
 
- 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
 

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 147 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 
)
inline

Definition at line 149 of file ResultSetReductionJIT.h.

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

152  : ResultSetReductionJIT(query_mem_desc, targets, target_init_vals)
153  , query_mem_desc_(query_mem_desc) {
158  }
const QueryMemoryDescriptor & query_mem_desc_
ResultSetReductionJIT(const QueryMemoryDescriptor &query_mem_desc, const std::vector< TargetInfo > &targets, const std::vector< int64_t > &target_init_vals)
QueryDescriptionType getQueryDescriptionType() const
#define CHECK(condition)
Definition: Logger.h:203

+ Here is the call graph for this function:

Member Function Documentation

ReductionCode GpuReductionHelperJIT::codegen ( ) const
virtual

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

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

1322  {
1323  const auto hash_type = query_mem_desc_.getQueryDescriptionType();
1324  auto reduction_code = setup_functions_ir(hash_type);
1326  isEmpty(reduction_code);
1327  reduceOneEntryNoCollisions(reduction_code);
1328  reduceOneEntryNoCollisionsIdx(reduction_code);
1329  reduceLoop(reduction_code);
1330  reduction_code.cgen_state.reset(new CgenState({}, false));
1331  auto cgen_state = reduction_code.cgen_state.get();
1332  std::unique_ptr<llvm::Module> module(runtime_module_shallow_copy(cgen_state));
1333 
1334  cgen_state->module_ = module.get();
1335  AUTOMATIC_IR_METADATA(cgen_state);
1336  auto ir_is_empty = create_llvm_function(reduction_code.ir_is_empty.get(), cgen_state);
1337  auto ir_reduce_one_entry =
1338  create_llvm_function(reduction_code.ir_reduce_one_entry.get(), cgen_state);
1339  auto ir_reduce_one_entry_idx =
1340  create_llvm_function(reduction_code.ir_reduce_one_entry_idx.get(), cgen_state);
1341  auto ir_reduce_loop =
1342  create_llvm_function(reduction_code.ir_reduce_loop.get(), cgen_state);
1343  std::unordered_map<const Function*, llvm::Function*> f;
1344  f.emplace(reduction_code.ir_is_empty.get(), ir_is_empty);
1345  f.emplace(reduction_code.ir_reduce_one_entry.get(), ir_reduce_one_entry);
1346  f.emplace(reduction_code.ir_reduce_one_entry_idx.get(), ir_reduce_one_entry_idx);
1347  f.emplace(reduction_code.ir_reduce_loop.get(), ir_reduce_loop);
1348  translate_function(reduction_code.ir_is_empty.get(), ir_is_empty, reduction_code, f);
1350  reduction_code.ir_reduce_one_entry.get(), ir_reduce_one_entry, reduction_code, f);
1351  translate_function(reduction_code.ir_reduce_one_entry_idx.get(),
1352  ir_reduce_one_entry_idx,
1353  reduction_code,
1354  f);
1356  reduction_code.ir_reduce_loop.get(), ir_reduce_loop, reduction_code, f);
1357  reduction_code.llvm_reduce_loop = ir_reduce_loop;
1358  reduction_code.module = std::move(module);
1359  return reduction_code;
1360 }
std::unique_ptr< llvm::Module > runtime_module_shallow_copy(CgenState *cgen_state)
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)
ReductionCode setup_functions_ir(const QueryDescriptionType hash_type)
#define AUTOMATIC_IR_METADATA(CGENSTATE)
QueryDescriptionType getQueryDescriptionType() const
void isEmpty(const ReductionCode &reduction_code) const
#define CHECK(condition)
Definition: Logger.h:203
char * f
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 168 of file ResultSetReductionJIT.h.

Referenced by GpuReductionHelperJIT().


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