Halide 19.0.0
Halide compiler and libraries
|
A base class for GPU backends that require C-like shader output. More...
#include <CodeGen_GPU_Dev.h>
Public Types | |
enum class | VectorDeclarationStyle { CLikeSyntax = 0 , OpenCLSyntax = 1 , WGSLSyntax = 2 } |
OpenCL and WGSL use different syntax than C for immediate vectors. More... | |
Public Types inherited from Halide::Internal::CodeGen_C | |
enum | OutputKind { CHeader , CPlusPlusHeader , CImplementation , CPlusPlusImplementation , CExternDecl , CPlusPlusExternDecl , CPlusPlusFunctionInfoHeader } |
Public Member Functions | |
CodeGen_GPU_C (std::ostream &s, Target t) | |
Public Member Functions inherited from Halide::Internal::CodeGen_C | |
CodeGen_C (std::ostream &dest, const Target &target, OutputKind output_kind=CImplementation, const std::string &include_guard="") | |
Initialize a C code generator pointing at a particular output stream (e.g. | |
~CodeGen_C () override | |
void | compile (const Module &module) |
Emit the declarations contained in the module as C code. | |
const Target & | get_target () const |
The target we're generating code for. | |
Public Member Functions inherited from Halide::Internal::IRPrinter | |
IRPrinter (std::ostream &) | |
Construct an IRPrinter pointed at a given output stream (e.g. | |
void | print (const Expr &) |
emit an expression on the output stream | |
void | print_no_parens (const Expr &) |
Emit an expression on the output stream without enclosing parens. | |
void | print (const Stmt &) |
emit a statement on the output stream | |
void | print_summary (const Stmt &) |
emit a statement summary on the output stream | |
void | print_list (const std::vector< Expr > &exprs) |
emit a comma delimited list of exprs, without any leading or trailing punctuation. | |
Public Member Functions inherited from Halide::Internal::IRVisitor | |
IRVisitor ()=default | |
virtual | ~IRVisitor ()=default |
Protected Member Functions | |
void | visit (const Shuffle *op) override |
void | visit (const Call *op) override |
void | visit (const Variable *) override |
void | visit (const IntImm *) override |
void | visit (const UIntImm *) override |
void | visit (const StringImm *) override |
void | visit (const FloatImm *) override |
void | visit (const Cast *) override |
void | visit (const Reinterpret *) override |
void | visit (const Add *) override |
void | visit (const Sub *) override |
void | visit (const Mul *) override |
void | visit (const Div *) override |
void | visit (const Mod *) override |
void | visit (const Max *) override |
void | visit (const Min *) override |
void | visit (const EQ *) override |
void | visit (const NE *) override |
void | visit (const LT *) override |
void | visit (const LE *) override |
void | visit (const GT *) override |
void | visit (const GE *) override |
void | visit (const And *) override |
void | visit (const Or *) override |
void | visit (const Not *) override |
void | visit (const Select *) override |
void | visit (const Load *) override |
void | visit (const Store *) override |
void | visit (const Let *) override |
void | visit (const LetStmt *) override |
void | visit (const AssertStmt *) override |
void | visit (const ProducerConsumer *) override |
void | visit (const For *) override |
void | visit (const Ramp *) override |
void | visit (const Broadcast *) override |
void | visit (const Provide *) override |
void | visit (const Allocate *) override |
void | visit (const Free *) override |
void | visit (const Realize *) override |
void | visit (const IfThenElse *) override |
void | visit (const Evaluate *) override |
void | visit (const Prefetch *) override |
void | visit (const Fork *) override |
void | visit (const Acquire *) override |
void | visit (const Atomic *) override |
void | visit (const VectorReduce *) override |
void | visit (const Block *) override |
void | visit (const HoistedStorage *) override |
Protected Member Functions inherited from Halide::Internal::CodeGen_C | |
void | compile (const LoweredFunc &func, const MetadataNameMap &metadata_name_map) |
Emit a declaration. | |
void | compile (const Buffer<> &buffer) |
virtual Stmt | preprocess_function_body (const Stmt &stmt) |
This is a hook that subclasses can use to transform a function body just before it is emitted – e.g., to transform the IR to code that is easier to recognize and emit. | |
std::string | print_expr (const Expr &) |
Emit an expression as an assignment, then return the id of the resulting var. | |
std::string | print_cast_expr (const Type &, const Expr &) |
Like print_expr, but cast the Expr to the given Type. | |
void | print_stmt (const Stmt &) |
Emit a statement. | |
void | create_assertion (const std::string &id_cond, const Expr &message) |
void | create_assertion (const Expr &cond, const Expr &message) |
Expr | scalarize_vector_reduce (const VectorReduce *op) |
virtual std::string | print_type (Type, AppendSpaceIfNeeded space_option=DoNotAppendSpace) |
Emit the C name for a halide type. | |
virtual std::string | print_reinterpret (Type, const Expr &) |
Emit a statement to reinterpret an expression as another type. | |
virtual std::string | print_name (const std::string &) |
Emit a version of a string that is a valid identifier in C (. | |
virtual void | add_platform_prologue () |
Add platform specific prologue. | |
virtual void | add_vector_typedefs (const std::set< Type > &vector_types) |
Add typedefs for vector types. | |
virtual std::string | print_extern_call (const Call *op) |
Bottleneck to allow customization of calls to generic Extern/PureExtern calls. | |
std::string | print_scalarized_expr (const Expr &e) |
Convert a vector Expr into a series of scalar Exprs, then reassemble into vector of original type. | |
virtual std::string | print_assignment (Type t, const std::string &rhs) |
Emit an SSA-style assignment, and set id to the freshly generated name. | |
void | print_heap_free (const std::string &alloc_name) |
Emit free for the heap allocation. | |
bool | is_header () |
Return true if only generating an interface, which may be extern "C" or C++. | |
bool | is_extern_decl () |
Return true if only generating an interface, which may be extern "C" or C++. | |
bool | is_header_or_extern_decl () |
Return true if only generating an interface, which may be extern "C" or C++. | |
bool | is_c_plus_plus_interface () |
Return true if generating C++ linkage. | |
void | open_scope () |
Open a new C scope (i.e. | |
void | close_scope (const std::string &comment) |
Close a C scope (i.e. | |
void | forward_declare_type_if_needed (const Type &t) |
If the Type is a handle type, emit a forward-declaration for it if we haven't already. | |
void | set_name_mangling_mode (NameMangling mode) |
void | visit_binop (Type t, const Expr &a, const Expr &b, const char *op) |
void | visit_relop (Type t, const Expr &a, const Expr &b, const char *scalar_op, const char *vector_op) |
virtual bool | is_stack_private_to_thread () const |
Some architectures have private memory for the call stack; this means a thread cannot hand pointers to stack memory to another thread. | |
void | emit_argv_wrapper (const std::string &function_name, const std::vector< LoweredArgument > &args) |
void | emit_metadata_getter (const std::string &function_name, const std::vector< LoweredArgument > &args, const MetadataNameMap &metadata_name_map) |
void | emit_constexpr_function_info (const std::string &function_name, const std::vector< LoweredArgument > &args, const MetadataNameMap &metadata_name_map) |
void | emit_halide_free_helper (const std::string &alloc_name, const std::string &free_function) |
Protected Member Functions inherited from Halide::Internal::IRPrinter | |
Indentation | get_indent () const |
void | open () |
Either emits "(" or "", depending on the value of implicit_parens. | |
void | close () |
Either emits ")" or "", depending on the value of implicit_parens. | |
void | print_lets (const Let *let) |
A helper for printing a chain of lets with line breaks. | |
void | print_braced_stmt (const Stmt &, int extra_indent=2) |
A helper for printing a braced statement. | |
void | visit (const IntImm *) override |
void | visit (const UIntImm *) override |
void | visit (const FloatImm *) override |
void | visit (const StringImm *) override |
void | visit (const Cast *) override |
void | visit (const Reinterpret *) override |
void | visit (const Variable *) override |
void | visit (const Add *) override |
void | visit (const Sub *) override |
void | visit (const Mul *) override |
void | visit (const Div *) override |
void | visit (const Mod *) override |
void | visit (const Min *) override |
void | visit (const Max *) override |
void | visit (const EQ *) override |
void | visit (const NE *) override |
void | visit (const LT *) override |
void | visit (const LE *) override |
void | visit (const GT *) override |
void | visit (const GE *) override |
void | visit (const And *) override |
void | visit (const Or *) override |
void | visit (const Not *) override |
void | visit (const Select *) override |
void | visit (const Load *) override |
void | visit (const Ramp *) override |
void | visit (const Broadcast *) override |
void | visit (const Call *) override |
void | visit (const Let *) override |
void | visit (const LetStmt *) override |
void | visit (const AssertStmt *) override |
void | visit (const ProducerConsumer *) override |
void | visit (const For *) override |
void | visit (const Acquire *) override |
void | visit (const Store *) override |
void | visit (const Provide *) override |
void | visit (const Allocate *) override |
void | visit (const Free *) override |
void | visit (const Realize *) override |
void | visit (const Block *) override |
void | visit (const Fork *) override |
void | visit (const IfThenElse *) override |
void | visit (const Evaluate *) override |
void | visit (const Shuffle *) override |
void | visit (const VectorReduce *) override |
void | visit (const Prefetch *) override |
void | visit (const Atomic *) override |
void | visit (const HoistedStorage *) override |
Protected Member Functions inherited from Halide::Internal::IRVisitor |
Protected Attributes | |
VectorDeclarationStyle | vector_declaration_style = VectorDeclarationStyle::CLikeSyntax |
Protected Attributes inherited from Halide::Internal::CodeGen_C | |
IntegerSuffixStyle | integer_suffix_style = IntegerSuffixStyle::PlainC |
How to emit 64-bit integer constants. | |
std::string | id |
An ID for the most recently generated ssa variable. | |
Target | target |
The target being generated for. | |
OutputKind | output_kind |
Controls whether this instance is generating declarations or definitions and whether the interface us extern "C" or C++. | |
std::map< std::string, std::string > | cache |
A cache of generated values in scope. | |
Scope< Allocation > | allocations |
Track the types of allocations to avoid unnecessary casts. | |
Scope | heap_allocations |
Track which allocations actually went on the heap. | |
bool | have_user_context |
True if there is a void * __user_context parameter in the arguments. | |
bool | extern_c_open = false |
Track current calling convention scope. | |
bool | uses_gpu_for_loops |
True if at least one gpu-based for loop is used. | |
std::set< const halide_handle_cplusplus_type * > | forward_declared |
Track which handle types have been forward-declared already. | |
bool | inside_atomic_mutex_node = false |
Are we inside an atomic node that uses mutex locks? This is used for detecting deadlocks from nested atomics. | |
bool | emit_atomic_stores = false |
Emit atomic store instructions? | |
bool | using_vector_typedefs = false |
true if add_vector_typedefs() has been called. | |
Protected Attributes inherited from Halide::Internal::IRPrinter | |
std::ostream & | stream |
The stream on which we're outputting. | |
int | indent = 0 |
The current indentation level, useful for pretty-printing statements. | |
bool | implicit_parens = false |
Certain expressions do not need parens around them, e.g. | |
bool | is_summary = false |
Print only a summary of a statement, with sub-statements replaced by ellipses (...). | |
Scope | known_type |
The symbols whose types can be inferred from values printed already. | |
Additional Inherited Members | |
Static Public Member Functions inherited from Halide::Internal::CodeGen_C | |
static void | test () |
Static Public Member Functions inherited from Halide::Internal::IRPrinter | |
static void | test () |
Protected Types inherited from Halide::Internal::CodeGen_C | |
enum class | IntegerSuffixStyle { PlainC = 0 , OpenCL = 1 , HLSL = 2 } |
enum | AppendSpaceIfNeeded { DoNotAppendSpace , AppendSpace } |
Static Protected Member Functions inherited from Halide::Internal::CodeGen_C | |
template<typename T > | |
static std::string | with_sep (const std::vector< T > &v, const std::string &sep) |
template<typename T > | |
static std::string | with_commas (const std::vector< T > &v) |
A base class for GPU backends that require C-like shader output.
GPU backends derive from and specialize this class.
Definition at line 84 of file CodeGen_GPU_Dev.h.
|
strong |
OpenCL and WGSL use different syntax than C for immediate vectors.
This enum defines which style should be used by the backend.
Enumerator | |
---|---|
CLikeSyntax | |
OpenCLSyntax | |
WGSLSyntax |
Definition at line 88 of file CodeGen_GPU_Dev.h.
|
inline |
Definition at line 94 of file CodeGen_GPU_Dev.h.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
overrideprotectedvirtual |
Reimplemented from Halide::Internal::CodeGen_C.
|
protected |
Definition at line 103 of file CodeGen_GPU_Dev.h.