CLSETUSEREVENTSTATUS(3clc)

πŸ“¦
version 1.0~svn33624 Β· 3 versions
, in ubuntu jammy, ubuntu noble

πŸ’… 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 with clCreateUserEvent(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 be CL_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!! clSetUserEventStatus can only be called once to change the execution status of event. 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 β€” if event is not a valid user event. (like, you brought the wrong event to the function. embarrassing but recoverable.)
  • 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. 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 Β© 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 🧚

  1. 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