Halide
CodeGen_GPU_Host.h
Go to the documentation of this file.
1 #ifndef HALIDE_CODEGEN_GPU_HOST_H
2 #define HALIDE_CODEGEN_GPU_HOST_H
3 
4 /** \file
5  * Defines the code-generator for producing GPU host code
6  */
7 
8 #include <map>
9 #include <string>
10 
11 #include "CodeGen_ARM.h"
12 #include "CodeGen_MIPS.h"
13 #include "CodeGen_PowerPC.h"
14 #include "CodeGen_RISCV.h"
15 #include "CodeGen_WebAssembly.h"
16 #include "CodeGen_X86.h"
17 #include "IR.h"
18 
19 namespace Halide {
20 namespace Internal {
21 
22 struct CodeGen_GPU_Dev;
23 struct GPU_Argument;
24 
25 /** A code generator that emits GPU code from a given Halide stmt. */
26 template<typename CodeGen_CPU>
27 class CodeGen_GPU_Host : public CodeGen_CPU {
28 public:
29  /** Create a GPU code generator. GPU target is selected via
30  * CodeGen_GPU_Options. Processor features can be enabled using the
31  * appropriate flags from Target */
33 
34  ~CodeGen_GPU_Host() override;
35 
36 protected:
37  void compile_func(const LoweredFunc &func, const std::string &simple_name, const std::string &extern_name) override;
38 
39  /** Declare members of the base class that must exist to help the
40  * compiler do name lookup. Annoying but necessary, because the
41  * compiler doesn't know that CodeGen_CPU will in fact inherit
42  * from CodeGen for every instantiation of this template. */
43  using CodeGen_CPU::allocations;
44  using CodeGen_CPU::builder;
45  using CodeGen_CPU::codegen;
46  using CodeGen_CPU::context;
47  using CodeGen_CPU::create_alloca_at_entry;
48  using CodeGen_CPU::function;
49  using CodeGen_CPU::get_user_context;
50  using CodeGen_CPU::halide_buffer_t_type;
51  using CodeGen_CPU::i16_t;
52  using CodeGen_CPU::i32_t;
53  using CodeGen_CPU::i64_t;
54  using CodeGen_CPU::i8_t;
55  using CodeGen_CPU::init_module;
57  using CodeGen_CPU::module;
58  using CodeGen_CPU::register_destructor;
59  using CodeGen_CPU::sym_exists;
60  using CodeGen_CPU::sym_get;
61  using CodeGen_CPU::sym_pop;
62  using CodeGen_CPU::sym_push;
63  using CodeGen_CPU::target;
64  using CodeGen_CPU::type_t_type;
65  using CodeGen_CPU::visit;
66 
67  /** Nodes for which we need to override default behavior for the GPU runtime */
68  // @{
69  void visit(const For *) override;
70  // @}
71 
72  std::string function_name;
73 
74  llvm::Value *get_module_state(const std::string &api_unique_name,
75  bool create = true);
76 
77 private:
78  /** Child code generator for device kernels. */
79  std::map<DeviceAPI, CodeGen_GPU_Dev *> cgdev;
80 };
81 
82 } // namespace Internal
83 } // namespace Halide
84 
85 #endif
CodeGen_X86.h
CodeGen_MIPS.h
CodeGen_WebAssembly.h
Halide::Internal::CodeGen_GPU_Host::visit
void visit(const For *) override
Nodes for which we need to override default behavior for the GPU runtime.
Halide::Internal::For
A for loop.
Definition: IR.h:698
CodeGen_PowerPC.h
Halide::Internal::CodeGen_GPU_Host::get_module_state
llvm::Value * get_module_state(const std::string &api_unique_name, bool create=true)
IR.h
CodeGen_ARM.h
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition: AddAtomicMutex.h:21
Halide::LinkageType::Internal
@ Internal
Not visible externally, similar to 'static' linkage in C.
Halide::Internal::llvm_type_of
llvm::Type * llvm_type_of(llvm::LLVMContext *context, Halide::Type t)
Get the llvm type equivalent to a given halide type.
Halide::Internal::CodeGen_GPU_Host::compile_func
void compile_func(const LoweredFunc &func, const std::string &simple_name, const std::string &extern_name) override
Halide::Internal::CodeGen_GPU_Host::function_name
std::string function_name
Definition: CodeGen_GPU_Host.h:72
Halide::Internal::LoweredFunc
Definition of a lowered function.
Definition: Module.h:97
Halide::Internal::CodeGen_GPU_Host::CodeGen_GPU_Host
CodeGen_GPU_Host(Target)
Create a GPU code generator.
CodeGen_RISCV.h
Halide::Internal::CodeGen_GPU_Host
A code generator that emits GPU code from a given Halide stmt.
Definition: CodeGen_GPU_Host.h:27
Halide::Internal::CodeGen_GPU_Host::~CodeGen_GPU_Host
~CodeGen_GPU_Host() override
Halide::Target
A struct representing a target machine and os to generate code for.
Definition: Target.h:19