Halide
Halide::Internal::JITModule Struct Reference

#include <JITModule.h>

Classes

struct  Symbol
 

Public Types

typedef int(* argv_wrapper) (const void **args)
 A slightly more type-safe wrapper around the raw halide module. More...
 

Public Member Functions

 JITModule ()
 
 JITModule (const Module &m, const LoweredFunc &fn, const std::vector< JITModule > &dependencies=std::vector< JITModule >())
 
const std::map< std::string, Symbol > & exports () const
 The exports map of a JITModule contains all symbols which are available to other JITModules which depend on this one. More...
 
void * main_function () const
 A pointer to the raw halide function. More...
 
Symbol entrypoint_symbol () const
 Returns the Symbol structure for the routine documented in main_function. More...
 
Symbol argv_entrypoint_symbol () const
 Returns the Symbol structure for the argv wrapper routine corresponding to the entrypoint. More...
 
argv_wrapper argv_function () const
 
void add_dependency (JITModule &dep)
 Add another JITModule to the dependency chain. More...
 
void add_symbol_for_export (const std::string &name, const Symbol &extern_symbol)
 Registers a single Symbol as available to modules which depend on this one. More...
 
void add_extern_for_export (const std::string &name, const ExternCFunction &extern_c_function)
 Registers a single function as available to modules which depend on this one. More...
 
Symbol find_symbol_by_name (const std::string &) const
 Look up a symbol by name in this module or its dependencies. More...
 
void compile_module (std::unique_ptr< llvm::Module > mod, const std::string &function_name, const Target &target, const std::vector< JITModule > &dependencies=std::vector< JITModule >(), const std::vector< std::string > &requested_exports=std::vector< std::string >())
 Take an llvm module and compile it. More...
 
void memoization_cache_set_size (int64_t size) const
 See JITSharedRuntime::memoization_cache_set_size. More...
 
void reuse_device_allocations (bool) const
 See JITSharedRuntime::reuse_device_allocations. More...
 
bool compiled () const
 Return true if compile_module has been called on this module. More...
 

Static Public Member Functions

static JITModule make_trampolines_module (const Target &target, const std::map< std::string, JITExtern > &externs, const std::string &suffix, const std::vector< JITModule > &deps)
 Take a list of JITExterns and generate trampoline functions which can be called dynamically via a function pointer that takes an array of void *'s for each argument and the return value. More...
 

Public Attributes

IntrusivePtr< JITModuleContents > jit_module
 

Detailed Description

Definition at line 32 of file JITModule.h.

Member Typedef Documentation

◆ argv_wrapper

typedef int(* Halide::Internal::JITModule::argv_wrapper) (const void **args)

A slightly more type-safe wrapper around the raw halide module.

Takes it arguments as an array of pointers that correspond to the arguments to main_function . This will be nullptr for a JITModule which has not yet been compiled or one that is not a Halide Func compilation at all.

Definition at line 97 of file JITModule.h.

Constructor & Destructor Documentation

◆ JITModule() [1/2]

Halide::Internal::JITModule::JITModule ( )

◆ JITModule() [2/2]

Halide::Internal::JITModule::JITModule ( const Module m,
const LoweredFunc fn,
const std::vector< JITModule > &  dependencies = std::vector< JITModule >() 
)

Member Function Documentation

◆ make_trampolines_module()

static JITModule Halide::Internal::JITModule::make_trampolines_module ( const Target target,
const std::map< std::string, JITExtern > &  externs,
const std::string &  suffix,
const std::vector< JITModule > &  deps 
)
static

Take a list of JITExterns and generate trampoline functions which can be called dynamically via a function pointer that takes an array of void *'s for each argument and the return value.

◆ exports()

const std::map<std::string, Symbol>& Halide::Internal::JITModule::exports ( ) const

The exports map of a JITModule contains all symbols which are available to other JITModules which depend on this one.

For runtime modules, this is all of the symbols exported from the runtime. For a JITted Func, it generally only contains the main result Func of the compilation, which takes its name directly from the Func declaration. One can also make a module which contains no code itself but is just an exports maps providing arbitrary pointers to functions or global variables to JITted code.

◆ main_function()

void* Halide::Internal::JITModule::main_function ( ) const

A pointer to the raw halide function.

Its true type depends on the Argument vector passed to CodeGen_LLVM::compile. Image parameters become (halide_buffer_t *), and scalar parameters become pointers to the appropriate values. The final argument is a pointer to the halide_buffer_t defining the output. This will be nullptr for a JITModule which has not yet been compiled or one that is not a Halide Func compilation at all.

◆ entrypoint_symbol()

Symbol Halide::Internal::JITModule::entrypoint_symbol ( ) const

Returns the Symbol structure for the routine documented in main_function.

Returning a Symbol allows access to the LLVM type as well as the address. The address and type will be nullptr if the module has not been compiled.

◆ argv_entrypoint_symbol()

Symbol Halide::Internal::JITModule::argv_entrypoint_symbol ( ) const

Returns the Symbol structure for the argv wrapper routine corresponding to the entrypoint.

The argv wrapper is callable via an array of void * pointers to the arguments for the call. Returning a Symbol allows access to the LLVM type as well as the address. The address and type will be nullptr if the module has not been compiled.

◆ argv_function()

argv_wrapper Halide::Internal::JITModule::argv_function ( ) const

◆ add_dependency()

void Halide::Internal::JITModule::add_dependency ( JITModule dep)

Add another JITModule to the dependency chain.

Dependencies are searched to resolve symbols not found in the current compilation unit while JITting.

◆ add_symbol_for_export()

void Halide::Internal::JITModule::add_symbol_for_export ( const std::string &  name,
const Symbol extern_symbol 
)

Registers a single Symbol as available to modules which depend on this one.

The Symbol structure provides both the address and the LLVM type for the function, which allows type safe linkage of extenal routines.

◆ add_extern_for_export()

void Halide::Internal::JITModule::add_extern_for_export ( const std::string &  name,
const ExternCFunction extern_c_function 
)

Registers a single function as available to modules which depend on this one.

This routine converts the ExternSignature info into an LLVM type, which allows type safe linkage of external routines.

◆ find_symbol_by_name()

Symbol Halide::Internal::JITModule::find_symbol_by_name ( const std::string &  ) const

Look up a symbol by name in this module or its dependencies.

◆ compile_module()

void Halide::Internal::JITModule::compile_module ( std::unique_ptr< llvm::Module >  mod,
const std::string &  function_name,
const Target target,
const std::vector< JITModule > &  dependencies = std::vector< JITModule >(),
const std::vector< std::string > &  requested_exports = std::vector< std::string >() 
)

Take an llvm module and compile it.

The requested exports will be available via the exports method.

◆ memoization_cache_set_size()

void Halide::Internal::JITModule::memoization_cache_set_size ( int64_t  size) const

◆ reuse_device_allocations()

void Halide::Internal::JITModule::reuse_device_allocations ( bool  ) const

◆ compiled()

bool Halide::Internal::JITModule::compiled ( ) const

Return true if compile_module has been called on this module.

Member Data Documentation

◆ jit_module

IntrusivePtr<JITModuleContents> Halide::Internal::JITModule::jit_module

Definition at line 33 of file JITModule.h.


The documentation for this struct was generated from the following file: