java.lang.Object
uk.ac.manchester.tornado.api.TornadoExecutionPlan
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
ExecutionPlanType
public sealed class TornadoExecutionPlan
extends Object
implements AutoCloseable
permits ExecutionPlanType
Class to create and optimize execution plans for running a set of
immutable tasks-graphs on modern hardware. An executor plan contains an
executor object, which in turn, contains a set of immutable task-graphs.
All actions applied to the execution plan affect to all the immutable
graphs associated with it.
- Since:
- v0.15
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TornadoExecutionPlanReference to the next node in the list.static TornadoDeviceMethod to obtain the default device in TornadoVM.protected ExecutorFrameprotected TornadoExecutionPlanReference to the previous node in the list.protected List<TornadoExecutionResult> protected TornadoExecutionPlanReference to the Root of the List.protected uk.ac.manchester.tornado.api.TornadoExecutorThe TornadoVM executor is a list of chain of actions to be performed. -
Constructor Summary
ConstructorsConstructorDescriptionTornadoExecutionPlan(ImmutableTaskGraph... immutableTaskGraphs) Create an Execution Plan: Object to create and optimize an execution plan for running a set of immutable tasks-graphs. -
Method Summary
Modifier and TypeMethodDescriptionClean all events associated with previous executions.voidclose()execute()Execute an execution plan.Mark all device buffers that correspond to the current execution plan as free in order for the TornadoVM runtime system to reuse those buffers and avoid continuous device memory deallocation and allocation.longIt returns the current memory usage on the device in bytes.getDevice(int immutableTaskGraphIndex) It obtains the device for a specific immutable task-graph.static TornadoDevicegetDevice(int driverIndex, int deviceIndex) Method to obtain a specific device using the driver index (backend index) and device index.longObtains the total number of execution plans instantiated in a TornadoVM application.longgetId()Obtains the ID that was assigned to the execution plan.getPlanResult(int index) static TornadoDeviceMapReturn a data structure that contains all drivers and devices that the TornadoVM Runtime can access.static intMethod to return the total number of execution plans instantiated in a single JVM instance.Returns a string with all the operations enabled/disabled from the Execution Plan.voidmapOnDeviceMemoryRegion(Object destTornadoArray, Object srcTornadoArray, long offset, int fromGraphIndex, int toGraphIndex) This function maps the device memory region that corresponds to a TornadoVM object to another on-device memory region.voidPrint all operations enabled/disabled from the Execution Plan.Reset the execution context for the current execution plan.toString()Select all graphs from theTornadoExecutionPlan.Enable batch processing.withCompilerFlags(TornadoVMBackendType backend, String compilerFlags) Set compiler flags for each backend.It enables multiple tasks in a task graph to run concurrently on the same or different devices.Notify the TornadoVM runtime system to utilize the default thread scheduler.withDevice(String taskName, TornadoDevice device) It selects a specific device for one particular task of the task-graph.withDevice(TornadoDevice device) It selects a specific device for all immutable tasks graphs associated to an executor.withGraph(int graphIndex) Select a graph from theTornadoExecutionPlanto execute.withGridScheduler(GridScheduler gridScheduler) Use aGridSchedulerfor thread dispatch.withMemoryLimit(String memoryLimit) This method sets a limit to the amount of memory used on the target hardware accelerator.It disables multiple tasks in a task graph to run concurrently on the same or different devices.It disables the memory limit for the current instance of anTornadoExecutionPlan.Disable printing of the generated kernels for each task in a task-graph.Disables the profiler if previous execution plan had the profiler enabled.Disable printing of the Thread-Block Deployment for the generated kernels.It invokes the JIT compiler for all immutable tasks-graphs associated to an executor.Enable printing of the generated kernels for each task in a task-graph.withProfiler(ProfilerMode profilerMode) Enables the profiler.Enable printing of the Thread-Block Deployment for the generated kernels.withWarmUpIterations(int iterations) This function allows developers to warm up the whole execution plan before running it.withWarmUpTime(long milliseconds) This function allows developers to warm up the whole execution plan before running it.
-
Field Details
-
DEFAULT_DEVICE
Method to obtain the default device in TornadoVM. The default one corresponds to the device assigned to the driver (backend) with index 0 and device 0. -
tornadoExecutor
protected uk.ac.manchester.tornado.api.TornadoExecutor tornadoExecutorThe TornadoVM executor is a list of chain of actions to be performed. Each action can enable/disable runtime features, influence the compiler, influence the code optimization, adapt runtime parameters, etc. -
executionFrame
-
rootNode
Reference to the Root of the List. -
childLink
Reference to the next node in the list. -
parentLink
Reference to the previous node in the list. -
planResults
-
-
Constructor Details
-
TornadoExecutionPlan
Create an Execution Plan: Object to create and optimize an execution plan for running a set of immutable tasks-graphs. An executor plan contains an executor object, which in turn, contains a set of immutable task-graphs. All actions applied to the execution plan affect to all the immutable graphs associated with it.- Parameters:
immutableTaskGraphs-ImmutableTaskGraph
-
-
Method Details
-
getDevice
Method to obtain a specific device using the driver index (backend index) and device index.- Parameters:
driverIndex- Integer value that identifies the backend to be used.deviceIndex- Integer value that identifies the device within the backend to be used.- Returns:
TornadoDevice
-
getTotalPlans
public static int getTotalPlans()Method to return the total number of execution plans instantiated in a single JVM instance.- Returns:
- int
- Since:
- 1.0.2
-
getTornadoDeviceMap
Return a data structure that contains all drivers and devices that the TornadoVM Runtime can access.- Returns:
TornadoDeviceMap
-
execute
Execute an execution plan. It returns aTornadoExecutionPlanfor further build different optimization after the execution as well as obtain the profiler results.- Returns:
TornadoExecutionPlan
-
withGraph
Select a graph from theTornadoExecutionPlanto execute. This method allows developers to select a specific graph from the execution plan to launch. Developers can choose which graph from the input list to use (passed in the constructor).- Parameters:
graphIndex-- Returns:
TornadoExecutionPlan- Since:
- 1.0.9
-
withAllGraphs
Select all graphs from theTornadoExecutionPlan. This method has an effect if thewithGraph(int)method was invoked.- Returns:
TornadoExecutionPlan- Since:
- 1.0.9
-
withPreCompilation
It invokes the JIT compiler for all immutable tasks-graphs associated to an executor.- Returns:
TornadoExecutionPlan
-
withDevice
It selects a specific device for all immutable tasks graphs associated to an executor.- Returns:
TornadoExecutionPlan
-
printTraceExecutionPlan
public void printTraceExecutionPlan()Print all operations enabled/disabled from the Execution Plan.- Since:
- 1.0.8
-
getTraceExecutionPlan
Returns a string with all the operations enabled/disabled from the Execution Plan.- Since:
- 1.0.8
-
toString
-
withDevice
It selects a specific device for one particular task of the task-graph.- Parameters:
taskName- The task-name is identified by the task-graph name followed by a dot (".") and the task name. For example: "graph.task1".device- The device is an instance of aTornadoDevice- Returns:
TornadoExecutionPlan
-
withConcurrentDevices
It enables multiple tasks in a task graph to run concurrently on the same or different devices. Note that the TornadoVM runtime does not check for data dependencies across tasks when using this API call. Thus, it is the responsibility of the programmer to provide tasks with no data dependencies when invoking the methodwithConcurrentDevices().- Returns:
TornadoExecutionPlan
-
withoutConcurrentDevices
It disables multiple tasks in a task graph to run concurrently on the same or different devices.- Returns:
TornadoExecutionPlan
-
getDevice
It obtains the device for a specific immutable task-graph. Note that, ideally, different task immutable task-graph could be executed on different devices.- Parameters:
immutableTaskGraphIndex- Index of a specific immutable task-graph- Returns:
TornadoExecutionPlan
-
freeDeviceMemory
Mark all device buffers that correspond to the current execution plan as free in order for the TornadoVM runtime system to reuse those buffers and avoid continuous device memory deallocation and allocation.Note that, in this context, "free device memory" means the TornadoVM runtime system marks device buffers to be reusable, thus, for the runtime system, device buffers are no longer linked to the current execution plan.
- Returns:
TornadoExecutionPlan
-
withGridScheduler
Use aGridSchedulerfor thread dispatch. The same GridScheduler will be applied to all tasks within the executor. Note that the grid-scheduler API can specify all workers for each task-graph.- Parameters:
gridScheduler-GridScheduler- Returns:
TornadoExecutionPlan
-
withDefaultScheduler
Notify the TornadoVM runtime system to utilize the default thread scheduler.- Returns:
TornadoExecutionPlan
-
withBatch
Enable batch processing. TornadoVM will split the iteration space in smaller batches (with batch size specified by the user). This is used mainly when users want to execute big data applications that do not fit on the device's global memory.- Parameters:
batchSize- String in the format a number + "MB" Example "512MB".- Returns:
TornadoExecutionPlan
-
withProfiler
Enables the profiler. The profiler includes options to query device kernel time, data transfers and compilation at different stages (JIT, driver compilation, Graal, etc.).- Parameters:
profilerMode-ProfilerMode- Returns:
TornadoExecutionPlan
-
withoutProfiler
Disables the profiler if previous execution plan had the profiler enabled.- Returns:
TornadoExecutionPlan
-
withMemoryLimit
This method sets a limit to the amount of memory used on the target hardware accelerator. The TornadoVM runtime will check that the current instance of theTornadoExecutionPlandoes not exceed the limit that was specified.- Parameters:
memoryLimit- Specify the limit in a string format. E.g., "1GB", "512MB".- Returns:
TornadoExecutionPlan
-
withoutMemoryLimit
It disables the memory limit for the current instance of anTornadoExecutionPlan. This is the default action. If the memory limit is not set, then the maximum memory to use is set to the maximum buffer allocation (e.g., 1/4 of the total capacity using the OpenCL backend), or the maximum memory available on the target device.- Returns:
TornadoExecutionPlan
-
resetDevice
Reset the execution context for the current execution plan. The TornadoVM runtime system will clean the code cache and all events associated with the current execution. It resets the internal GPU/FPGA/CPU execution context to its default values.- Returns:
TornadoExecutionPlan
-
getId
public long getId()Obtains the ID that was assigned to the execution plan. -
getGlobalExecutionPlansCounter
public long getGlobalExecutionPlansCounter()Obtains the total number of execution plans instantiated in a TornadoVM application. -
clearProfiles
Clean all events associated with previous executions.- Returns:
TornadoExecutionPlan
-
withThreadInfo
Enable printing of the Thread-Block Deployment for the generated kernels.- Returns:
TornadoExecutionPlan- Since:
- 1.0.2
-
withoutThreadInfo
Disable printing of the Thread-Block Deployment for the generated kernels.- Returns:
TornadoExecutionPlan- Since:
- 1.0.2
-
withPrintKernel
Enable printing of the generated kernels for each task in a task-graph.- Returns:
TornadoExecutionPlan- Since:
- 1.0.2
-
withoutPrintKernel
Disable printing of the generated kernels for each task in a task-graph.- Returns:
TornadoExecutionPlan- Since:
- 1.0.2
-
withCompilerFlags
Set compiler flags for each backend.- Parameters:
backend-TornadoVMBackendTypecompilerFlags-String- Returns:
TornadoExecutionPlan- Since:
- 1.0.7
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
TornadoExecutionPlanException- Since:
- 1.0.4
-
getCurrentDeviceMemoryUsage
public long getCurrentDeviceMemoryUsage()It returns the current memory usage on the device in bytes.- Returns:
- long Number of bytes used.
-
getPlanResult
-
mapOnDeviceMemoryRegion
public void mapOnDeviceMemoryRegion(Object destTornadoArray, Object srcTornadoArray, long offset, int fromGraphIndex, int toGraphIndex) This function maps the device memory region that corresponds to a TornadoVM object to another on-device memory region. This call instructs the TornadoVM runtime to avoid transferring data between `device` -> `host` -> `device`. Instead, it can update the corresponding device pointers.The semantics are as follows: there is the source object, and the destination object. This call maps the dest object to the source object from a given offset. The source object is passed from the task-graph `fromGraphIndex`, and the destination object is taken from the `toGraphIndex`. This method can be invoked in a multi-task-graph execution plan. It will not work if there is only one task-graph in the execution plan.
- Parameters:
destTornadoArray-srcTornadoArray-offset-fromGraphIndex-toGraphIndex-- Since:
- v1.1.0
-
withWarmUpTime
This function allows developers to warm up the whole execution plan before running it. This covers copy in and out data, compiling all tasks and executing all tasks once for the specified amount of time.- Parameters:
milliseconds- Amount of time to warm up the execution plan. This amount means that the execution plan will run, at least for the specified amount of time. if the tasks within the task-graphs takes longer to execute, in a second run, the code will not be dispatched.- Returns:
TornadoExecutionPlan- Throws:
InterruptedException
-
withWarmUpIterations
This function allows developers to warm up the whole execution plan before running it. This covers copy in and out data, compiling all tasks and executing all tasks once for the specified amount of time.- Parameters:
iterations- Number of iterations to run the whole execution plan as warm-up.- Returns:
TornadoExecutionPlan
-