Halide
CodeGen_OpenGLCompute_Dev.h
Go to the documentation of this file.
1 #ifndef HALIDE_CODEGEN_OPENGLCOMPUTE_DEV_H
2 #define HALIDE_CODEGEN_OPENGLCOMPUTE_DEV_H
3 
4 /** \file
5  * Defines the code-generator for producing GLSL kernel code for OpenGL Compute.
6  */
7 
8 #include <map>
9 #include <sstream>
10 
11 #include "CodeGen_C.h"
12 #include "CodeGen_GPU_Dev.h"
13 #include "CodeGen_OpenGL_Dev.h"
14 #include "Target.h"
15 
16 namespace Halide {
17 namespace Internal {
18 
20 public:
22 
23  // CodeGen_GPU_Dev interface
24  void add_kernel(Stmt stmt,
25  const std::string &name,
26  const std::vector<DeviceArgument> &args) override;
27 
28  void init_module() override;
29 
30  std::vector<char> compile_to_src() override;
31 
32  std::string get_current_kernel_name() override;
33 
34  void dump() override;
35 
36  std::string print_gpu_name(const std::string &name) override;
37 
38  std::string api_unique_name() override {
39  return "openglcompute";
40  }
41  bool kernel_run_takes_types() const override {
42  return true;
43  }
44 
45 protected:
47  public:
48  CodeGen_OpenGLCompute_C(std::ostream &s, Target t);
49  void add_kernel(const Stmt &stmt,
50  const std::string &name,
51  const std::vector<DeviceArgument> &args);
52 
53  protected:
54  std::string print_type(Type type, AppendSpaceIfNeeded space_option = DoNotAppendSpace) override;
55 
57  void visit(const For *) override;
58  void visit(const Ramp *op) override;
59  void visit(const Broadcast *op) override;
60  void visit(const Load *op) override;
61  void visit(const Store *op) override;
62  void visit(const Call *op) override;
63  void visit(const Allocate *op) override;
64  void visit(const Free *op) override;
65  void visit(const Select *op) override;
66  void visit(const Evaluate *op) override;
67  void visit(const IntImm *op) override;
68 
69  public:
71  };
72 
73  std::ostringstream src_stream;
74  std::string cur_kernel_name;
76 };
77 
78 } // namespace Internal
79 } // namespace Halide
80 
81 #endif
Halide::Internal::Allocate
Allocate a scratch area called with the given name, type, and size.
Definition: IR.h:352
Halide::Internal::CodeGen_OpenGLCompute_Dev::CodeGen_OpenGLCompute_C::print_type
std::string print_type(Type type, AppendSpaceIfNeeded space_option=DoNotAppendSpace) override
Emit the C name for a halide type.
Halide::Internal::CodeGen_GLSLBase::visit
void visit(const Cast *) override
Halide::Internal::CodeGen_OpenGLCompute_Dev::glc
CodeGen_OpenGLCompute_C glc
Definition: CodeGen_OpenGLCompute_Dev.h:75
Halide::Internal::CodeGen_OpenGLCompute_Dev::init_module
void init_module() override
(Re)initialize the GPU kernel module.
CodeGen_C.h
Halide::Internal::CodeGen_OpenGLCompute_Dev::print_gpu_name
std::string print_gpu_name(const std::string &name) override
Returns the specified name transformed by the variable naming rules for the GPU language backend.
Halide::Internal::For
A for loop.
Definition: IR.h:698
Halide::Internal::CodeGen_OpenGLCompute_Dev::kernel_run_takes_types
bool kernel_run_takes_types() const override
Allows the GPU device specific code to request halide_type_t values to be passed to the kernel_run ro...
Definition: CodeGen_OpenGLCompute_Dev.h:41
Halide::Internal::Broadcast
A vector with 'lanes' elements, in which every element is 'value'.
Definition: IR.h:241
Halide::Internal::IntImm
Integer constants.
Definition: Expr.h:216
Target.h
CodeGen_OpenGL_Dev.h
Halide::Internal::CodeGen_OpenGLCompute_Dev::api_unique_name
std::string api_unique_name() override
This routine returns the GPU API name that is combined into runtime routine names to ensure each GPU ...
Definition: CodeGen_OpenGLCompute_Dev.h:38
Halide::Internal::CodeGen_OpenGLCompute_Dev::add_kernel
void add_kernel(Stmt stmt, const std::string &name, const std::vector< DeviceArgument > &args) override
Compile a GPU kernel into the module.
Halide::Internal::CodeGen_OpenGLCompute_Dev::cur_kernel_name
std::string cur_kernel_name
Definition: CodeGen_OpenGLCompute_Dev.h:74
Halide::Internal::Stmt
A reference-counted handle to a statement node.
Definition: Expr.h:409
Halide::Type
Types in the halide type system.
Definition: Type.h:269
Halide::Internal::Load
Load a value from a named symbol if predicate is true.
Definition: IR.h:199
Halide::Internal::Free
Free the resources associated with the given buffer.
Definition: IR.h:388
Halide::Internal::CodeGen_OpenGLCompute_Dev::CodeGen_OpenGLCompute_Dev
CodeGen_OpenGLCompute_Dev(Target target)
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition: AddAtomicMutex.h:21
Halide::Internal::CodeGen_OpenGLCompute_Dev::get_current_kernel_name
std::string get_current_kernel_name() override
Halide::Internal::CodeGen_OpenGLCompute_Dev::CodeGen_OpenGLCompute_C::visit
void visit(const For *) override
Halide::Internal::CodeGen_C::AppendSpaceIfNeeded
AppendSpaceIfNeeded
Definition: CodeGen_C.h:89
Halide::LinkageType::Internal
@ Internal
Not visible externally, similar to 'static' linkage in C.
Halide::Internal::CodeGen_GPU_Dev
A code generator that emits GPU code from a given Halide stmt.
Definition: CodeGen_GPU_Dev.h:17
Halide::Internal::CodeGen_OpenGLCompute_Dev::src_stream
std::ostringstream src_stream
Definition: CodeGen_OpenGLCompute_Dev.h:73
Halide::Internal::CodeGen_OpenGLCompute_Dev::dump
void dump() override
Halide::Internal::Ramp
A linear ramp vector node.
Definition: IR.h:229
CodeGen_GPU_Dev.h
Halide::Internal::CodeGen_OpenGLCompute_Dev::compile_to_src
std::vector< char > compile_to_src() override
Halide::Internal::Evaluate
Evaluate and discard an expression, presumably because it has some side-effect.
Definition: IR.h:450
Halide::Internal::CodeGen_OpenGLCompute_Dev::CodeGen_OpenGLCompute_C
Definition: CodeGen_OpenGLCompute_Dev.h:46
Halide::Internal::Store
Store a 'value' to the buffer called 'name' at a given 'index' if 'predicate' is true.
Definition: IR.h:315
Halide::Internal::CodeGen_OpenGLCompute_Dev::CodeGen_OpenGLCompute_C::add_kernel
void add_kernel(const Stmt &stmt, const std::string &name, const std::vector< DeviceArgument > &args)
Halide::Internal::CodeGen_OpenGLCompute_Dev
Definition: CodeGen_OpenGLCompute_Dev.h:19
Halide::Internal::Call
A function call.
Definition: IR.h:464
Halide::Internal::CodeGen_GLSLBase
This class handles GLSL arithmetic, shared by CodeGen_GLSL and CodeGen_OpenGLCompute_C.
Definition: CodeGen_OpenGL_Dev.h:55
Halide::Internal::CodeGen_OpenGLCompute_Dev::CodeGen_OpenGLCompute_C::CodeGen_OpenGLCompute_C
CodeGen_OpenGLCompute_C(std::ostream &s, Target t)
Halide::Internal::Select
A ternary operator.
Definition: IR.h:186
Halide::Output::stmt
@ stmt
Halide::Internal::CodeGen_OpenGLCompute_Dev::CodeGen_OpenGLCompute_C::workgroup_size
int workgroup_size[3]
Definition: CodeGen_OpenGLCompute_Dev.h:70
Halide::Internal::CodeGen_C::DoNotAppendSpace
@ DoNotAppendSpace
Definition: CodeGen_C.h:90
Halide::Target
A struct representing a target machine and os to generate code for.
Definition: Target.h:19