OpenCL provides an API to release a context. This operation is done only after all queues, memory object, programs and kernels are released, which in turn might wait for all ongoing operations to complete. However, there are cases in which a fast release is required, or release operation cannot be done, as commands are stuck in mid execution. An example of the first case can be program termination due to exception, or quick shutdown due to low power. Examples of the second case are when a kernel is running too long, or gets stuck, or it may result from user action which makes the results of the computation unnecessary.
In many cases, the driver or the device is capable of speeding up the closure of ongoing operations when the results are no longer required in a much more expedient manner than waiting for all previously enqueued operations to finish.
This extension implements a new query to check whether a device can terminate an OpenCL context and adds an API to terminate a context.
| Modifier and Type | Field and Description |
|---|---|
| public static final int | CL_CONTEXT_TERMINATE_KHR
Specifies whether the context can be terminated. |
| public static final int | CL_DEVICE_TERMINATE_CAPABILITY_KHR
Describes the termination capability of the OpenCL device. |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public static int | Returns: SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:
"INVALID_CONTEXT if context is not a valid OpenCL context.",
"CONTEXT_TERMINATED_KHR if context has already been terminated.",
"INVALID_OPERATION if context was not created with CONTEXT_TERMINATE_KHR set to TRUE.",
OORE,
OOHMEthe context to terminate context)Terminates all pending work associated with the context and renders all data owned by the context invalid. |
| CL_CONTEXT_TERMINATE_KHR | back to summary |
|---|---|
| public static final int CL_CONTEXT_TERMINATE_KHR Specifies whether the context can be terminated. The default value is | |
| CL_DEVICE_TERMINATE_CAPABILITY_KHR | back to summary |
|---|---|
| public static final int CL_DEVICE_TERMINATE_CAPABILITY_KHR Describes the termination capability of the OpenCL device. This is a bitfield where a value of | |
| KHRTerminateContext | back to summary |
|---|---|
| protected KHRTerminateContext() | |
| clTerminateContextKHR | back to summary |
|---|---|
| public static int clTerminateContextKHR(long context) Terminates all pending work associated with the context and renders all data owned by the context invalid. It is the responsibility of the application to release all objects associated with the context being terminated. When a context is terminated:
| |