Results 1 to 4 of 4

Thread: Can event callbacks be preempted by other event callbacks?

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    1

    Can event callbacks be preempted by other event callbacks?

    Hi,

    I could not find anything in the OpenCL 1.1 standard that talks about preemption of event callback functions by other event callback functions. Could someone enlighten me on this? What happens if multiple OpenCL events register the same callback function to trigger on event completion, and all of the events complete? Are there any guarantees that only a single instance of the callback will be in progress at any given time? If not, is there a way to get a shared callback to run like a critical section? Would spinlocks suffice or are there again no guarantees about progression of state through blocking lock requests?

    Many thanks.

    Albert.

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Can event callbacks be preempted by other event callback

    What happens if multiple OpenCL events register the same callback function to trigger on event completion, and all of the events complete? Are there any guarantees that only a single instance of the callback will be in progress at any given time? If not, is there a way to get a shared callback to run like a critical section?
    What will happen is implementation-dependent. In some implementations, multiple different threads may execute the callback simultaneously. There is no guarantee that the callbacks will be executed serially. It's the application's responsibility to ensure that the callback is thread-safe.

    If you require the callbacks to be serialized, I recommend using a critical section inside the callback function.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  3. #3
    Junior Member
    Join Date
    Jul 2011
    Location
    Minnesota, USA
    Posts
    1

    Re: Can event callbacks be preempted by other event callback

    I've been looking for an answer for this specific problem & now at last I have the possible answer. You're an angel! Thanks!

  4. #4
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Can event callbacks be preempted by other event callback

    For future cases, I recommend reading the OpenCL 1.1 specification available from http://www.khronos.org/registry/cl/specs/opencl-1.1.pdf or at least the man pages available from http://www.khronos.org/registry/cl/sdk/ ... man/xhtml/

    If you look at the description of function clSetEventCallback() either in the spec or the man pages it says that "This callback function may be called asynchronously by the OpenCL implementation. It is the application's responsibility to ensure that the callback function is thread-safe."
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

Similar Threads

  1. Replies: 0
    Last Post: 04-10-2012, 03:40 PM
  2. Regarding Event mechanism
    By binunippon in forum OpenKODE discussions
    Replies: 3
    Last Post: 02-27-2008, 04:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •