OmniSciDB
a5dc49c757
|
#include <GpuSharedMemoryUtils.h>
Public Member Functions | |
GpuSharedMemCodeBuilder (llvm::Module *module, llvm::LLVMContext &context, const QueryMemoryDescriptor &qmd, const std::vector< TargetInfo > &targets, const std::vector< int64_t > &init_agg_values, const size_t executor_id) | |
void | codegen () |
void | injectFunctionsInto (llvm::Function *query_func) |
llvm::Function * | getReductionFunction () const |
llvm::Function * | getInitFunction () const |
std::string | toString () const |
Protected Member Functions | |
void | codegenReduction () |
void | codegenInitialization () |
llvm::Function * | createReductionFunction () const |
llvm::Function * | createInitFunction () const |
llvm::Function * | getFunction (const std::string &func_name) const |
Protected Attributes | |
size_t | executor_id_ |
llvm::Module * | module_ |
llvm::LLVMContext & | context_ |
llvm::Function * | reduction_func_ |
llvm::Function * | init_func_ |
const QueryMemoryDescriptor | query_mem_desc_ |
const std::vector< TargetInfo > | targets_ |
const std::vector< int64_t > | init_agg_values_ |
This is a builder class for extra functions that are required to support GPU shared memory usage for GroupByPerfectHash query types.
This class does not own its own LLVM module and uses a pointer to the global module provided to it as an argument during construction
Definition at line 43 of file GpuSharedMemoryUtils.h.
GpuSharedMemCodeBuilder::GpuSharedMemCodeBuilder | ( | llvm::Module * | module, |
llvm::LLVMContext & | context, | ||
const QueryMemoryDescriptor & | qmd, | ||
const std::vector< TargetInfo > & | targets, | ||
const std::vector< int64_t > & | init_agg_values, | ||
const size_t | executor_id | ||
) |
This class currently works only with:
All conditions in 1, 3, and 4 can be easily relaxed if proper code is added to support them in the future.
Definition at line 24 of file GpuSharedMemoryUtils.cpp.
References CHECK, QueryMemoryDescriptor::didOutputColumnar(), QueryMemoryDescriptor::getQueryDescriptionType(), heavyai::GroupByPerfectHash, QueryMemoryDescriptor::hasKeylessHash(), and query_mem_desc_.
void GpuSharedMemCodeBuilder::codegen | ( | ) |
generates code for both the reduction and initialization steps required for shared memory usage
Definition at line 55 of file GpuSharedMemoryUtils.cpp.
References CHECK, codegenInitialization(), codegenReduction(), createInitFunction(), createReductionFunction(), DEBUG_TIMER, init_func_, reduction_func_, and verify_function_ir().
|
protected |
Generates code for the shared memory buffer initialization
This function generates code to initialize the shared memory buffer, the way we initialize the group by output buffer on the host. Similar to the reduction function, it is assumed that there are at least as many threads as there are entries in the buffer. Each entry is assigned to a single thread, and then all slots corresponding to that entry are initialized with aggregate init values.
Definition at line 258 of file GpuSharedMemoryUtils.cpp.
References CHECK, CHECK_GE, anonymous_namespace{GpuSharedMemoryUtils.cpp}::codegen_smem_dest_slot_ptr(), context_, ResultSet::fixupQueryMemoryDescriptor(), getFunction(), init_agg_values_, init_func_, ll_int(), query_mem_desc_, sync_threadblock(), targets_, and UNREACHABLE.
Referenced by codegen().
|
protected |
Generates code for the reduction functionality (from shared memory into global memory)
The reduction function is going to be used to reduce group by buffer stored in the shared memory, back into global memory buffer. The general procedure is very similar to the what we have ResultSetReductionJIT, with some major differences that will be discussed below:
The general procedure is as follows:
Definition at line 98 of file GpuSharedMemoryUtils.cpp.
References run_benchmark_import::args, CHECK, context_, executor_id_, ResultSet::fixupQueryMemoryDescriptor(), get_int_type(), CodegenUtil::getCalledFunctionName(), QueryMemoryDescriptor::getEntryCount(), getFunction(), result_set::initialize_target_values_for_storage(), ll_int(), module_, query_mem_desc_, reduction_func_, sync_threadblock(), and targets_.
Referenced by codegen().
|
protected |
Creates the initialization function in the LLVM module, with predefined arguments and return type
Definition at line 354 of file GpuSharedMemoryUtils.cpp.
References context_, and module_.
Referenced by codegen().
|
protected |
Create the reduction function in the LLVM module, with predefined arguments and return type
Definition at line 341 of file GpuSharedMemoryUtils.cpp.
References context_, and module_.
Referenced by codegen().
|
protected |
Search for a particular funciton name in the module, and returns it if found
Definition at line 367 of file GpuSharedMemoryUtils.cpp.
References CHECK, and module_.
Referenced by codegenInitialization(), and codegenReduction().
|
inline |
|
inline |
void GpuSharedMemCodeBuilder::injectFunctionsInto | ( | llvm::Function * | query_func | ) |
Once the reduction and init functions are generated, this function takes the main query function and replaces the previous placeholders, which were inserted in the query template, with these new functions.
Definition at line 405 of file GpuSharedMemoryUtils.cpp.
References CHECK, init_func_, reduction_func_, and anonymous_namespace{GpuSharedMemoryUtils.cpp}::replace_called_function_with().
std::string GpuSharedMemCodeBuilder::toString | ( | ) | const |
Definition at line 412 of file GpuSharedMemoryUtils.cpp.
References CHECK, init_func_, reduction_func_, and serialize_llvm_object().
|
protected |
Definition at line 95 of file GpuSharedMemoryUtils.h.
Referenced by codegenInitialization(), codegenReduction(), createInitFunction(), and createReductionFunction().
|
protected |
Definition at line 93 of file GpuSharedMemoryUtils.h.
Referenced by codegenReduction().
|
protected |
Definition at line 100 of file GpuSharedMemoryUtils.h.
Referenced by codegenInitialization().
|
protected |
Definition at line 97 of file GpuSharedMemoryUtils.h.
Referenced by codegen(), codegenInitialization(), getInitFunction(), injectFunctionsInto(), and toString().
|
protected |
Definition at line 94 of file GpuSharedMemoryUtils.h.
Referenced by codegenReduction(), createInitFunction(), createReductionFunction(), and getFunction().
|
protected |
Definition at line 98 of file GpuSharedMemoryUtils.h.
Referenced by codegenInitialization(), codegenReduction(), and GpuSharedMemCodeBuilder().
|
protected |
Definition at line 96 of file GpuSharedMemoryUtils.h.
Referenced by codegen(), codegenReduction(), getReductionFunction(), injectFunctionsInto(), and toString().
|
protected |
Definition at line 99 of file GpuSharedMemoryUtils.h.
Referenced by codegenInitialization(), and codegenReduction().