OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GpuSharedMemoryUtils.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, 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,
50  const size_t executor_id);
55  void codegen();
56 
62  void injectFunctionsInto(llvm::Function* query_func);
63 
64  llvm::Function* getReductionFunction() const { return reduction_func_; }
65  llvm::Function* getInitFunction() const { return init_func_; }
66  std::string toString() const;
67 
68  protected:
73  void codegenReduction();
77  void codegenInitialization();
82  llvm::Function* createReductionFunction() const;
87  llvm::Function* createInitFunction() const;
91  llvm::Function* getFunction(const std::string& func_name) const;
92 
93  size_t executor_id_;
94  llvm::Module* module_;
95  llvm::LLVMContext& context_;
96  llvm::Function* reduction_func_;
97  llvm::Function* init_func_;
99  const std::vector<TargetInfo> targets_;
100  const std::vector<int64_t> init_agg_values_;
101 };
const QueryMemoryDescriptor query_mem_desc_
llvm::Function * getInitFunction() const
llvm::Function * createInitFunction() const
llvm::LLVMContext & context_
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)
std::string toString() const
const std::vector< int64_t > init_agg_values_
Descriptor for the result set buffer layout.
const std::vector< TargetInfo > targets_
Basic constructors and methods of the row set interface.
llvm::Function * getFunction(const std::string &func_name) const
void injectFunctionsInto(llvm::Function *query_func)
llvm::Function * reduction_func_
llvm::Function * createReductionFunction() const
llvm::Function * getReductionFunction() const