Halide
WasmExecutor.h
Go to the documentation of this file.
1 #ifndef HALIDE_WASM_EXECUTOR_H
2 #define HALIDE_WASM_EXECUTOR_H
3 
4 /** \file
5  *
6  * Support for running Halide-compiled Wasm code in-process.
7  * Bindings for parameters, extern calls, etc. are established and the
8  * Wasm code is executed. Allows calls to realize to work
9  * exactly as if native code had been run, but via a JavaScript/Wasm VM.
10  * Currently, only the WABT interpreter is supported.
11  */
12 
13 #include "Argument.h"
14 #include "JITModule.h"
15 #include "Parameter.h"
16 #include "Target.h"
17 #include "Type.h"
18 
19 namespace Halide {
20 namespace Internal {
21 
22 struct WasmModuleContents;
23 
24 /** Handle to compiled wasm code which can be called later. */
25 struct WasmModule {
27 
28  /** If the given target can be executed via the wasm executor, return true. */
29  static bool can_jit_target(const Target &target);
30 
31  /** Compile generated wasm code with a set of externs. */
32  static WasmModule compile(
33  const Module &module,
34  const std::vector<Argument> &arguments,
35  const std::string &fn_name,
36  const std::map<std::string, JITExtern> &externs,
37  const std::vector<JITModule> &extern_deps);
38 
39  /** Run generated previously compiled wasm code with a set of arguments. */
40  int run(const void **args);
41 };
42 
43 } // namespace Internal
44 } // namespace Halide
45 
46 #endif // HALIDE_WASM_EXECUTOR_H
Parameter.h
Halide::Internal::WasmModule::can_jit_target
static bool can_jit_target(const Target &target)
If the given target can be executed via the wasm executor, return true.
Target.h
Halide::Internal::IntrusivePtr< WasmModuleContents >
Halide::Module
A halide module.
Definition: Module.h:136
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition: AddAtomicMutex.h:21
Halide::LinkageType::Internal
@ Internal
Not visible externally, similar to 'static' linkage in C.
Argument.h
JITModule.h
Type.h
Halide::Internal::WasmModule::compile
static WasmModule compile(const Module &module, const std::vector< Argument > &arguments, const std::string &fn_name, const std::map< std::string, JITExtern > &externs, const std::vector< JITModule > &extern_deps)
Compile generated wasm code with a set of externs.
Halide::Internal::WasmModule::contents
Internal::IntrusivePtr< WasmModuleContents > contents
Definition: WasmExecutor.h:26
Halide::Internal::WasmModule
Handle to compiled wasm code which can be called later.
Definition: WasmExecutor.h:25
Halide::Target
A struct representing a target machine and os to generate code for.
Definition: Target.h:19
Halide::Internal::WasmModule::run
int run(const void **args)
Run generated previously compiled wasm code with a set of arguments.