C Specification

To set the execution status of a user event object, call the function

cl_int clSetUserEventStatus(
    cl_event event,
    cl_int execution_status);

Parameters

  • event is a user event object created using clCreateUserEvent.

  • execution_status specifies the new execution status to be set and can be CL_​COMPLETE or a negative integer value to indicate an error. A negative integer value causes all enqueued commands that wait on this user event to be terminated. clSetUserEventStatus can only be called once to change the execution status of event.

Description

If there are enqueued commands with user events in the event_wait_list argument of clEnqueue* commands, the user must ensure that the status of these user events being waited on are set using clSetUserEventStatus before any OpenCL APIs that release OpenCL objects except for event objects are called; otherwise the behavior is undefined.

For example, the following code sequence will result in undefined behavior of clReleaseMemObject.

ev1 = clCreateUserEvent(ctx, NULL);
clEnqueueWriteBuffer(cq, buf1, CL_FALSE, ..., 1, &ev1, NULL);
clEnqueueWriteBuffer(cq, buf2, CL_FALSE, ...);
clReleaseMemObject(buf2);
clSetUserEventStatus(ev1, CL_COMPLETE);

The following code sequence, however, works correctly.

ev1 = clCreateUserEvent(ctx, NULL);
clEnqueueWriteBuffer(cq, buf1, CL_FALSE, ..., 1, &ev1, NULL);
clEnqueueWriteBuffer(cq, buf2, CL_FALSE, ...);
clSetUserEventStatus(ev1, CL_COMPLETE);
clReleaseMemObject(buf2);

clSetUserEventStatus returns CL_​SUCCESS if the function was executed successfully. Otherwise, it returns one of the following errors:

  • CL_​INVALID_​EVENT if event is not a valid user event object.

  • CL_​INVALID_​VALUE if the execution_status is not CL_​COMPLETE or a negative integer value.

  • CL_​INVALID_​OPERATION if the execution_status for event has already been changed by a previous call to clSetUserEventStatus.

  • CL_​OUT_​OF_​RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.

  • CL_​OUT_​OF_​HOST_​MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.

See Also

Document Notes

For more information, see the OpenCL Specification

This page is extracted from the OpenCL Specification. Fixes and changes should be made to the Specification, not directly.

Copyright (c) 2014-2020 Khronos Group. This work is licensed under a Creative Commons Attribution 4.0 International License.