Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Deepak-Sangle/TornadoVM/llms.txt
Use this file to discover all available pages before exploring further.
TornadoExecutionPlan is the runtime orchestration object in TornadoVM. It wraps one or more ImmutableTaskGraph snapshots and exposes a rich fluent API for controlling every aspect of execution: device selection, profiling, warm-up passes, batch sizing, CUDA Graph capture, concurrent device dispatch, and memory limits. Because the class implements AutoCloseable, it integrates naturally with try-with-resources blocks. All configuration methods return a new TornadoExecutionPlan node chained to the previous one, preserving a complete trace of the applied settings that can be inspected with getTraceExecutionPlan().
TornadoExecutionPlan is a sealed class. Only the internal plan-type subclasses (WithDevice, WithProfiler, WithBatch, etc.) may extend it. Application code should interact exclusively through the public API described here.ImmutableTaskGraph
ImmutableTaskGraph is the read-only snapshot produced by TaskGraph.snapshot(). It encapsulates a frozen copy of the task graph’s tasks, transfer directives, and device hints. You cannot add or remove tasks from an ImmutableTaskGraph — to change the graph, mutate the source TaskGraph and call snapshot() again.
ImmutableTaskGraph instances to the TornadoExecutionPlan constructor:
Constructor
Creates an execution plan over the given set of immutable task graphs. When more than one graph is supplied, the runtime automatically adjusts data-access types across graphs to avoid redundant transfers. All configuration methods applied to the plan affect every graph in the executor.
| Parameter | Type | Description |
|---|---|---|
immutableTaskGraphs | ImmutableTaskGraph... | One or more immutable task graphs to execute. |
Core Execution
Runs all task graphs managed by the plan, in order, on their assigned devices. Returns a
TornadoExecutionResult that carries profiler data and supports on-demand host readback.Invokes the TornadoVM JIT compiler for all tasks without running them. Use this to separate compilation latency from the first timed execution.
Device Selection
Sets the target device for all task graphs in the plan. Overrides any device previously set on individual graphs.
| Parameter | Type | Description |
|---|---|---|
device | TornadoDevice | Target device obtained from TornadoExecutionPlan.getDevice(driverIdx, deviceIdx). |
Sets the target device for a single named task. The task name must be fully qualified as
"graphName.taskId".| Parameter | Type | Description |
|---|---|---|
taskName | String | Fully qualified task name, e.g. "myGraph.t0". |
device | TornadoDevice | Target device for this task only. |
Static helper to look up a device by backend (driver) index and device index within that backend.
Enables simultaneous dispatch of all tasks across multiple devices. TornadoVM does not check for inter-task data dependencies in this mode — ensuring data independence across concurrent tasks is the caller’s responsibility.
Grid Scheduler
Attaches a
GridScheduler that maps task names to explicit WorkerGrid thread configurations. Any task not found in the scheduler uses TornadoVM’s default thread-count heuristic.| Parameter | Type | Description |
|---|---|---|
scheduler | GridScheduler | A scheduler with at least one registered worker grid. |
Reverts thread scheduling to TornadoVM’s built-in auto-tuned heuristic, discarding any previously attached
GridScheduler.Profiling
Enables the built-in profiler. After each
execute(), the TornadoExecutionResult carries detailed timing for JIT compilation, data transfers, kernel dispatch, and device-side execution.| Parameter | Type | Description |
|---|---|---|
profilerMode | ProfilerMode | One of ProfilerMode.CONSOLE or ProfilerMode.SILENT. |
Disables the profiler if it was previously enabled. This is the default state for a new execution plan.
ProfilerMode Values
Prints a formatted profiler report to
stdout after each execute() call. Useful for quick iteration during development.Collects profiler data silently. Query results via
TornadoExecutionResult.getProfilerResult() after execution. Suitable for production benchmarking pipelines.Warm-Up
Runs the full execution plan — including data transfers and kernel execution — repeatedly for at least the specified duration in milliseconds. This ensures the JIT compiler has compiled all tasks before the timed benchmark begins.
| Parameter | Type | Description |
|---|---|---|
milliseconds | long | Minimum warm-up duration. Must be non-negative. |
Runs the full execution plan a fixed number of times as a warm-up pass.
| Parameter | Type | Description |
|---|---|---|
iterations | int | Number of warm-up iterations. Must be non-negative. |
Batch Execution
Splits the iteration space into chunks of the given size. Use this when the full dataset exceeds the device’s global memory. TornadoVM transparently tiles the execution and stitches the results.
| Parameter | Type | Description |
|---|---|---|
batchSize | String | Size string in the format "<number>MB", e.g. "512MB". |
CUDA-Specific Features
Enables CUDA Graph capture on the CUDA backend. On first execution TornadoVM records the entire kernel launch sequence into a CUDA Graph and replays it on subsequent calls, eliminating CPU-side launch overhead for repetitive workloads.
Routes independent operations (H2D copies, kernel launches, D2H copies) to separate CUDA streams so that they may overlap. Cross-stream ordering is enforced via device events derived from the bytecode dependency DAG. Currently active on the CUDA backend only; a no-op for OpenCL and Metal.
Enables pipelined host-to-device transfers via pinned staging buffers for large read-only uploads (
FIRST_EXECUTION mode, ≥ 16 MB by default). Chunk i+1 is staged while chunk i is in flight over DMA. CUDA backend only; a no-op elsewhere.Memory Management
Caps the total device memory that this execution plan may allocate. The runtime enforces the limit before each allocation.
| Parameter | Type | Description |
|---|---|---|
memoryLimit | String | Size string, e.g. "1GB" or "512MB". |
Removes any previously set memory cap, restoring the default behaviour (use as much device memory as the backend allows).
Returns the current number of bytes consumed on the device by all task graphs in this plan.
Resets the internal GPU/CPU execution context to its default state. This cleans the code cache, clears all events associated with the current execution plan, and resets runtime parameters. Use after
close() when you need guaranteed context cleanup in memory-constrained scenarios.TornadoExecutionResult
TornadoExecutionResult is returned by every execute() call. It provides access to profiler data and supports explicit host readback for UNDER_DEMAND buffers.
Returns the
TornadoProfilerResult object containing kernel time, data transfer time, compilation time, and byte counts. Only populated when withProfiler() was set on the execution plan.Forces an immediate device-to-host copy for the specified objects. Required for any buffer tagged with
DataTransferMode.UNDER_DEMAND. Returns this for fluent chaining.Returns
true when all task graphs in the associated executor have finished execution.Intra-Plan Graph Selection
AutoCloseable and Resource Management
TornadoExecutionPlan implements AutoCloseable. The close() method calls freeDeviceMemory(), releasing all device buffers back to the pool.
Complete Fluent Example
Task Graph
Build and configure the task graphs that feed this execution plan.
Worker Grid
Control thread block dimensions with WorkerGrid and GridScheduler.