1 #ifndef HALIDE_JIT_MODULE_H
2 #define HALIDE_JIT_MODULE_H
22 struct ExternCFunction;
29 class JITModuleContents;
45 const std::vector<JITModule> &dependencies = std::vector<JITModule>());
53 const std::map<std::string, JITExtern> &externs,
54 const std::string &suffix,
55 const std::vector<JITModule> &deps);
66 const std::map<std::string, Symbol> &
exports()
const;
123 const std::string &function_name,
const Target &target,
124 const std::vector<JITModule> &dependencies = std::vector<JITModule>(),
125 const std::vector<std::string> &requested_exports = std::vector<std::string>());
144 void *(*custom_malloc)(
void *,
size_t){
nullptr};
150 void *(*custom_get_symbol)(
const char *name){
nullptr};
151 void *(*custom_load_library)(
const char *name){
nullptr};
152 void *(*custom_get_library_symbol)(
void *lib,
const char *name){
nullptr};
163 static std::vector<JITModule>
get(llvm::Module *m,
const Target &target,
bool create =
true);
This file declares the routines used by Halide internally in its runtime.
Support classes for reference-counting via intrusive shared pointers.
static void init_jit_user_context(JITUserContext &jit_user_context, void *user_context, const JITHandlers &handlers)
static void memoization_cache_evict(uint64_t eviction_key)
Evict all cache entries that were tagged with the given eviction_key in the memoize scheduling direct...
static void memoization_cache_set_size(int64_t size)
Set the maximum number of bytes used by memoization caching.
static JITHandlers set_default_handlers(const JITHandlers &handlers)
static std::vector< JITModule > get(llvm::Module *m, const Target &target, bool create=true)
static void reuse_device_allocations(bool)
Set whether or not Halide may hold onto and reuse device allocations to avoid calling expensive devic...
static void release_all()
HALIDE_ALWAYS_INLINE auto mod(A &&a, B &&b) -> decltype(IRMatcher::operator%(a, b))
void * get_symbol_address(const char *s)
int(* halide_task)(void *user_context, int, uint8_t *)
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
unsigned __INT64_TYPE__ uint64_t
signed __INT64_TYPE__ int64_t
signed __INT32_TYPE__ int32_t
unsigned __INT8_TYPE__ uint8_t
int(* custom_do_task)(void *, halide_task, int, uint8_t *)
void(* custom_free)(void *, void *)
void(* custom_error)(void *, const char *)
void(* custom_print)(void *, const char *)
int(* custom_do_par_for)(void *, halide_task, int, int, uint8_t *)
int32_t(* custom_trace)(void *, const halide_trace_event_t *)
void memoization_cache_evict(uint64_t eviction_key) const
See JITSharedRuntime::memoization_cache_evict.
void memoization_cache_set_size(int64_t size) const
See JITSharedRuntime::memoization_cache_set_size.
int(* argv_wrapper)(const void **args)
A slightly more type-safe wrapper around the raw halide module.
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.
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.
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.
void reuse_device_allocations(bool) const
See JITSharedRuntime::reuse_device_allocations.
void add_dependency(JITModule &dep)
Add another JITModule to the dependency chain.
Symbol find_symbol_by_name(const std::string &) const
Look up a symbol by name in this module or its dependencies.
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 fun...
Symbol argv_entrypoint_symbol() const
Returns the Symbol structure for the argv wrapper routine corresponding to the entrypoint.
bool compiled() const
Return true if compile_module has been called on this module.
const std::map< std::string, Symbol > & exports() const
The exports map of a JITModule contains all symbols which are available to other JITModules which dep...
Symbol entrypoint_symbol() const
Returns the Symbol structure for the routine documented in main_function.
void * main_function() const
A pointer to the raw halide function.
argv_wrapper argv_function() const
IntrusivePtr< JITModuleContents > jit_module
JITModule(const Module &m, const LoweredFunc &fn, const std::vector< JITModule > &dependencies=std::vector< JITModule >())
Definition of a lowered function.
A struct representing a target machine and os to generate code for.