OmniSciDB  2e3a973ef4
GpuSharedMemoryUtils.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <string>
20 #include <vector>
21 
22 #include <llvm/IR/Function.h>
23 #include <llvm/IR/IRBuilder.h>
24 #include <llvm/IR/InstIterator.h>
25 #include <llvm/IR/Module.h>
26 #include <llvm/IR/Value.h>
27 #include <llvm/Linker/Linker.h>
28 #include <llvm/Transforms/Utils/BasicBlockUtils.h>
29 
31 #include "IRCodegenUtils.h"
32 #include "Logger/Logger.h"
33 #include "ResultSet.h"
34 #include "Shared/TargetInfo.h"
35 
44  public:
45  GpuSharedMemCodeBuilder(llvm::Module* module,
46  llvm::LLVMContext& context,
47  const QueryMemoryDescriptor& qmd,
48  const std::vector<TargetInfo>& targets,
49  const std::vector<int64_t>& init_agg_values);
54  void codegen();
55 
61  void injectFunctionsInto(llvm::Function* query_func);
62 
63  llvm::Function* getReductionFunction() const { return reduction_func_; }
64  llvm::Function* getInitFunction() const { return init_func_; }
65  std::string toString() const;
66 
67  protected:
72  void codegenReduction();
76  void codegenInitialization();
81  llvm::Function* createReductionFunction() const;
86  llvm::Function* createInitFunction() const;
90  llvm::Function* getFunction(const std::string& func_name) const;
91 
92  llvm::Module* module_;
93  llvm::LLVMContext& context_;
94  llvm::Function* reduction_func_;
95  llvm::Function* init_func_;
97  const std::vector<TargetInfo> targets_;
98  const std::vector<int64_t> init_agg_values_;
99 };
llvm::Function * getReductionFunction() const
llvm::Function * getFunction(const std::string &func_name) const
llvm::Function * createReductionFunction() const
const QueryMemoryDescriptor query_mem_desc_
llvm::LLVMContext & context_
llvm::Function * createInitFunction() const
const std::vector< int64_t > init_agg_values_
llvm::Function * getInitFunction() const
Descriptor for the result set buffer layout.
const std::vector< TargetInfo > targets_
Basic constructors and methods of the row set interface.
void injectFunctionsInto(llvm::Function *query_func)
llvm::Function * reduction_func_
GpuSharedMemCodeBuilder(llvm::Module *module, llvm::LLVMContext &context, const QueryMemoryDescriptor &qmd, const std::vector< TargetInfo > &targets, const std::vector< int64_t > &init_agg_values)