CLSETUSEREVENTSTATUS(3clc)
π clSetUserEventStatus β from the OpenCL Manual (3clc)
okay bestie, sit down, hydrate, because we're talking about clSetUserEventStatus and it's genuinely one of those tiny functions that has so much main character energy. It lives in the OpenCL Manual, it's a 3clc page, and it does exactly one thing: it tells a user event "hey girl, you're done."
β¨ NAME β¨
clSetUserEventStatus β sets the execution status of a user event object.
and here's the whole signature, no cap:
cl_int clSetUserEventStatus(cl_event event, cl_int execution_status);
πΈ PARAMETERS πΈ
eventβ a user event object, and specifically one you made withclCreateUserEvent(3clc). like, it has to be a user event, okay? we'll get to that.execution_statusβ this is the new execution status you're setting, and it's giving two moods: it can beCL_COMPLETE, or it can be a negative integer value to indicate an error. And lowkey, that negative integer is a big deal β it causes all enqueued commands that wait on this user event to be terminated. also!!clSetUserEventStatuscan only be called once to change the execution status ofevent. one and done. that's it. periodt.
π¦ NOTES π¦
so here's the tea. enqueued commands that specify user events in the event_wait_list argument of clEnqueue*** commands must make sure 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. π not a vibe. do not do this.
π ERRORS π
Returns CL_SUCCESS if the function was executed successfully. Otherwise, it returns one of the following errors:
CL_INVALID_EVENTβ ifeventis not a valid user event. (like, you brought the wrong event to the function. embarrassing but recoverable.)CL_INVALID_VALUEβ if theexecution_statusis notCL_COMPLETEor a negative integer value.CL_INVALID_OPERATIONβ if theexecution_statusforeventhas already been changed by a previous call toclSetUserEventStatus. bestie I told you it's once only π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.
π Example
For example, the following code sequence will result in undefined behavior of clReleaseMemObject(3clc).
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);
see how the second one moves clSetUserEventStatus up before the release? that's the whole plot twist. it's giving "order matters." π
β SPECIFICATION β
OpenCL Specification[1]
π SEE ALSO π
π AUTHORS π
The Khronos Group
π COPYRIGHT π
Copyright Β© 2007-2011 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the following condition:
the above copyright notice and this permission notice shall be included in all copies or substantial portions of the Materials.
π§ NOTES π§
- OpenCL Specification β page 178, section 5.9 - Event Objects
and that's the whole page, bestie!! β¨ this was CLSETUSEREVENTSTATUS(3clc) from the OpenCL Manual, brought to you by The Khronos Group, dated 01/14/2021. go set some user event statuses responsibly. mwah. ππ«ΆπΈ
π¦ where this page comes from
- ubuntu jammy: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- ubuntu noble: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms