OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TableFunctionCompilationContext.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 <llvm/ExecutionEngine/ExecutionEngine.h>
20 
21 #include <QueryEngine/CgenState.h>
22 #include <QueryEngine/CodeCache.h>
26 
27 class Executor;
28 
30  public:
32 
33  // non-copyable
36  delete;
37 
38  void compile(const TableFunctionExecutionUnit& exe_unit,
39  const CompilationOptions& co,
40  Executor* executor);
41 
42  using FuncPtr = int32_t (*)(const int8_t* mgr_ptr,
43  const int8_t** input_cols,
44  const int64_t* input_row_count,
45  int64_t** out,
46  int64_t* output_row_count);
48 
49  GpuCompilationContext* getGpuCode() const { return gpu_code_.get(); }
50 
51  private:
52  void generateEntryPoint(const TableFunctionExecutionUnit& exe_unit, bool is_gpu);
54  const std::vector<llvm::Value*>& args);
55  void generateGpuKernel();
56  bool passColumnsByValue(const TableFunctionExecutionUnit& exe_unit, bool is_gpu);
57  void finalize(const CompilationOptions& co, Executor* executor);
58 
59  std::unique_ptr<CgenState> cgen_state_;
60  std::unique_ptr<llvm::Module> module_;
61  ExecutionEngineWrapper own_execution_engine_; // TODO: remove and replace with cache
62  std::shared_ptr<GpuCompilationContext> gpu_code_;
63  llvm::Function* entry_point_func_;
64  llvm::Function* kernel_func_;
66 };
GpuCompilationContext * getGpuCode() const
void generateEntryPoint(const TableFunctionExecutionUnit &exe_unit, bool is_gpu)
void generateRequireCheckCall(const TableFunctionExecutionUnit &exe_unit, const std::vector< llvm::Value * > &args)
std::shared_ptr< GpuCompilationContext > gpu_code_
std::unique_ptr< llvm::Module > module_
Executor(const ExecutorId id, Data_Namespace::DataMgr *data_mgr, const size_t block_size_x, const size_t grid_size_x, const size_t max_gpu_slab_size, const std::string &debug_dir, const std::string &debug_file)
Definition: Execute.cpp:155
TableFunctionCompilationContext::FuncPtr getFuncPtr() const
void finalize(const CompilationOptions &co, Executor *executor)
TableFunctionCompilationContext & operator=(const TableFunctionCompilationContext &)=delete
bool passColumnsByValue(const TableFunctionExecutionUnit &exe_unit, bool is_gpu)
Execution unit for relational algebra. It&#39;s a low-level description of any relational algebra operati...
int32_t(*)(const int8_t *mgr_ptr, const int8_t **input_cols, const int64_t *input_row_count, int64_t **out, int64_t *output_row_count) FuncPtr
void compile(const TableFunctionExecutionUnit &exe_unit, const CompilationOptions &co, Executor *executor)