1#ifndef HALIDE_JIT_MODULE_H
2#define HALIDE_JIT_MODULE_H
25struct ExternCFunction;
100 void *(*custom_get_symbol)(
const char *name){
nullptr};
105 void *(*custom_load_library)(
const char *name){
nullptr};
110 void *(*custom_get_library_symbol)(
void *lib,
const char *name){
nullptr};
130struct JITErrorBuffer;
143class JITModuleContents;
159 const std::vector<JITModule> &dependencies = std::vector<JITModule>());
167 const std::map<std::string, JITExtern> &externs,
168 const std::string &suffix,
169 const std::vector<JITModule> &deps);
180 const std::map<std::string, Symbol> &
exports()
const;
237 const std::string &function_name,
const Target &target,
238 const std::vector<JITModule> &dependencies = std::vector<JITModule>(),
239 const std::vector<std::string> &requested_exports = std::vector<std::string>());
263 static std::vector<JITModule>
get(llvm::Module *m,
const Target &target,
bool create =
true);
329 std::atomic<size_t>
end{0};
This file declares the routines used by Halide internally in its runtime.
Support classes for reference-counting via intrusive shared pointers.
Defines the structure that describes a Halide target.
Support for running Halide-compiled Wasm code in-process.
static int get_num_threads()
Get the number of threads in the Halide thread pool.
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 int set_num_threads(int)
Set the number of threads to use in the Halide thread pool, inclusive of the calling thread.
static JITHandlers set_default_handlers(const JITHandlers &handlers)
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 populate_jit_handlers(JITUserContext *jit_user_context, const JITHandlers &handlers)
static void release_all()
static std::vector< JITModule > get(llvm::Module *m, const Target &target, bool create=true)
void * get_symbol_address(const char *s)
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
Intrusive shared pointers have a reference count (a RefCount object) stored in the class itself.
int call_jit_code(const void *const *args)
Target get_compiled_jit_target() const
std::map< std::string, JITExtern > jit_externs
std::vector< Argument > arguments
JITCache(Target jit_target, std::vector< Argument > arguments, std::map< std::string, JITExtern > jit_externs, JITModule jit_module, WasmModule wasm_module)
void finish_profiling(JITUserContext *context)
void concat(const char *message)
static void handler(JITUserContext *ctx, const char *message)
std::atomic< size_t > end
void finalize(int exit_status)
bool custom_error_handler
JITErrorBuffer error_buffer
JITFuncCallContext(JITUserContext *context, const JITHandlers &pipeline_handlers)
void memoization_cache_evict(uint64_t eviction_key) const
See JITSharedRuntime::memoization_cache_evict.
int set_num_threads(int) const
See JITSharedRuntime::set_num_threads.
void memoization_cache_set_size(int64_t size) const
See JITSharedRuntime::memoization_cache_set_size.
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.
int(*) argv_wrapper(const void *const *args)
A slightly more type-safe wrapper around the raw halide module.
int get_num_threads() const
See JITSharedRuntime::get_num_threads.
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.
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...
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...
void * main_function() const
A pointer to the raw halide function.
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.
Symbol entrypoint_symbol() const
Returns the Symbol structure for the routine documented in main_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.
Handle to compiled wasm code which can be called later.
A set of custom overrides of runtime functions.
int(* custom_do_par_for)(JITUserContext *, int(*)(JITUserContext *, int, uint8_t *), int, int, uint8_t *)
A custom parallel for loop launcher.
int32_t(* custom_cuda_acquire_context)(JITUserContext *user_context, void **cuda_context_ptr, bool create)
A custom method for the Halide runtime acquire a cuda context.
int32_t(* custom_cuda_get_stream)(JITUserContext *user_context, void *cuda_context, void **stream_ptr)
A custom method for the Halide runtime to acquire a cuda stream to use.
void(* custom_error)(JITUserContext *, const char *)
The error handler function that be called in the case of runtime errors during halide pipelines.
int32_t(* custom_cuda_release_context)(JITUserContext *user_context)
The Halide runtime calls this when it is done with a cuda context.
void(* custom_free)(JITUserContext *, void *)
int32_t(* custom_trace)(JITUserContext *, const halide_trace_event_t *)
A custom routine to call when tracing is enabled.
int(* custom_do_task)(JITUserContext *, int(*)(JITUserContext *, int, uint8_t *), int, uint8_t *)
A custom task handler to be called by the parallel for loop.
void(* custom_print)(JITUserContext *, const char *)
Set the function called to print messages from the runtime.
A context to be passed to Pipeline::realize.
Internal::JITErrorBuffer * error_buffer
A struct representing a target machine and os to generate code for.