go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
Public Types | Public Member Functions | Private Member Functions | Friends
itk::OpenCLUserEvent Class Reference

#include <itkOpenCLUserEvent.h>

Detailed Description

The OpenCLUserEvent class represents OpenCL user events.

User events allow applications to enqueue commands that wait on a user event to finish before the command is executed by the device. Commands that depend upon the user event will not be executed until the application triggers the user event with SetComplete(). User events are constructed with OpenCLContext::CreateUserEvent().

OpenCLBuffer buffer = context->CreateBufferDevice(size, OpenCLMemoryObject::WriteOnly);
OpenCLUserEvent user_event = context->CreateUserEvent();
OpenCLEventList events;
events << user_event;
OpenCLEvent event1 = buffer.WriteAsync(..., events, ...);
OpenCLEvent event2 = buffer.WriteAsync(..., events, ...);
events << event1 << event2;
Developers should be careful when releasing their last reference count on events created by OpenCLContext::CreateUserEvent() that have not yet been set to status of {CL_COMPLETE} or an error. If the user event was used in the OpenCLEventList argument passed to a clEnqueue*** API or another application host thread is waiting for it in OpenCLEvent::WaitForFinished(), those commands and host threads will continue to wait for the event status to reach {CL_COMPLETE} or error, even after the user has released the object. Since in this scenario the developer has released his last reference count to the user event, it would be in principle no longer valid for him to change the status of the event to unblock all the other machinery. As a result the waiting tasks will wait forever, and associated events, cl_mem objects, command queues and contexts are likely to leak. In-order command queues caught up in this deadlock may cease to do any work.
See also
OpenCLEvent, OpenCLContext::CreateUserEvent()

Definition at line 66 of file itkOpenCLUserEvent.h.

Inheritance diagram for itk::OpenCLUserEvent:
Inheritance graph

Public Types

typedef OpenCLUserEvent Self
- Public Types inherited from itk::OpenCLEvent
typedef OpenCLEvent Self

Public Member Functions

 OpenCLUserEvent ()
 OpenCLUserEvent (cl_event id)
 OpenCLUserEvent (const OpenCLEvent &other)
OpenCLUserEventoperator= (const OpenCLEvent &other)
void SetComplete ()
void SetStatus (const cl_int status)
- Public Member Functions inherited from itk::OpenCLEvent
cl_command_type GetCommandType () const
cl_event GetEventId () const
cl_ulong GetFinishTime () const
cl_ulong GetQueueTime () const
cl_ulong GetRunTime () const
cl_int GetStatus () const
cl_ulong GetSubmitTime () const
bool IsComplete () const
bool IsError () const
bool IsNull () const
bool IsQueued () const
bool IsRunning () const
bool IsSubmitted () const
 OpenCLEvent ()
 OpenCLEvent (const cl_event id)
 OpenCLEvent (const OpenCLEvent &other)
OpenCLEventoperator= (const OpenCLEvent &other)
cl_int SetCallback (cl_int type, void(CL_CALLBACK *pfn_notify)(cl_event, cl_int, void *), void *user_data=NULL)
cl_int WaitForFinished ()
 ~OpenCLEvent ()

Private Member Functions

 OpenCLUserEvent (cl_event id, bool)
void ReleaseIfNotUserEvent ()


class OpenCLContext

Member Typedef Documentation

Standard class typedefs.

Definition at line 71 of file itkOpenCLUserEvent.h.

Constructor & Destructor Documentation

itk::OpenCLUserEvent::OpenCLUserEvent ( )

Constructs a null user event.

Definition at line 74 of file itkOpenCLUserEvent.h.

itk::OpenCLUserEvent::OpenCLUserEvent ( cl_event  id)

Constructs an OpenCL event object from the native identifier id. This class takes over ownership of id and will release it in the destructor. If id is not a user event, then the newly constructed event will be set to null, and id will be released.

itk::OpenCLUserEvent::OpenCLUserEvent ( const OpenCLEvent other)

Constructs a copy of other. The {clRetainEvent()} function will be called to update the reference count on GetEventId(). If other is not a user event, then the newly constructed event will be set to null.

itk::OpenCLUserEvent::OpenCLUserEvent ( cl_event  id,

Definition at line 112 of file itkOpenCLUserEvent.h.

Member Function Documentation

OpenCLUserEvent& itk::OpenCLUserEvent::operator= ( const OpenCLEvent other)

Assigns other to this OpenCL event object. The current GetEventId() will be released with {clReleaseEvent()}, and the new GetEventId() will be retained with {clRetainEvent()}. If other is not a user event, then this event will be set to null.

void itk::OpenCLUserEvent::ReleaseIfNotUserEvent ( )

Checks the event type agains {CL_COMMAND_USER} and release it if not.

void itk::OpenCLUserEvent::SetComplete ( )

Sets this user event to the complete state. Any queued commands that depend upon this event can now proceed.

See also
void itk::OpenCLUserEvent::SetStatus ( const cl_int  status)

Sets the status of this user event. The status should be either {CL_COMPLETE} or a negative OpenCL error code.

See also

Friends And Related Function Documentation

friend class OpenCLContext

friends from OpenCL core

Definition at line 116 of file itkOpenCLUserEvent.h.

Generated on 04-09-2015 for elastix by doxygen elastix logo