Clover Git
OpenCL 1.1 software implementation
Classes | Public Types | Public Member Functions | Private Attributes

Coal::Event Class Reference

Base class for all events. More...

#include <commandqueue.h>

Inheritance diagram for Coal::Event:
Collaboration diagram for Coal::Event:

List of all members.

Classes

struct  CallbackData

Public Types

enum  Type {
  NDRangeKernel = CL_COMMAND_NDRANGE_KERNEL, TaskKernel = CL_COMMAND_TASK, NativeKernel = CL_COMMAND_NATIVE_KERNEL, ReadBuffer = CL_COMMAND_READ_BUFFER,
  WriteBuffer = CL_COMMAND_WRITE_BUFFER, CopyBuffer = CL_COMMAND_COPY_BUFFER, ReadImage = CL_COMMAND_READ_IMAGE, WriteImage = CL_COMMAND_WRITE_IMAGE,
  CopyImage = CL_COMMAND_COPY_IMAGE, CopyImageToBuffer = CL_COMMAND_COPY_IMAGE_TO_BUFFER, CopyBufferToImage = CL_COMMAND_COPY_BUFFER_TO_IMAGE, MapBuffer = CL_COMMAND_MAP_BUFFER,
  MapImage = CL_COMMAND_MAP_IMAGE, UnmapMemObject = CL_COMMAND_UNMAP_MEM_OBJECT, Marker = CL_COMMAND_MARKER, AcquireGLObjects = CL_COMMAND_ACQUIRE_GL_OBJECTS,
  ReleaseGLObjects = CL_COMMAND_RELEASE_GL_OBJECTS, ReadBufferRect = CL_COMMAND_READ_BUFFER_RECT, WriteBufferRect = CL_COMMAND_WRITE_BUFFER_RECT, CopyBufferRect = CL_COMMAND_COPY_BUFFER_RECT,
  User = CL_COMMAND_USER, Barrier, WaitForEvents
}
 

Event type.

More...
enum  Status { Queued = CL_QUEUED, Submitted = CL_SUBMITTED, Running = CL_RUNNING, Complete = CL_COMPLETE }
 

Event status.

More...
enum  Timing {
  Queue, Submit, Start, End,
  Max
}
 

Timing counters of an event.

More...
typedef void(CL_CALLBACK * event_callback )(cl_event, cl_int, void *)
 Function that can be called when an event change status.

Public Member Functions

 Event (CommandQueue *parent, Status status, cl_uint num_events_in_wait_list, const Event **event_wait_list, cl_int *errcode_ret)
 Constructor.
void freeDeviceData ()
 Call Coal::DeviceInterface::freeEventDeviceData()
virtual ~Event ()
 Destructor.
virtual Type type () const =0
 Type of the event.
bool isDummy () const
 Dummy event.
void setStatus (Status status)
 Set the event status.
void setDeviceData (void *data)
 Set device-specific data.
void updateTiming (Timing timing)
 Update timing info.
Status status () const
 Status.
void waitForStatus (Status status)
 Wait for a specified status.
void * deviceData ()
 Device-specific data.
const Event ** waitEvents (cl_uint &count) const
 List of events on which this event depends on.
void setCallback (cl_int command_exec_callback_type, event_callback callback, void *user_data)
 Add a callback for this event.
cl_int info (cl_event_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) const
 Info about the event.
cl_int profilingInfo (cl_profiling_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) const
 Profiling info.

Private Attributes

cl_uint p_num_events_in_wait_list
const Event ** p_event_wait_list
pthread_cond_t p_state_change_cond
pthread_mutex_t p_state_mutex
Status p_status
void * p_device_data
std::multimap< Status,
CallbackData
p_callbacks
cl_uint p_timing [Max]

Detailed Description

Base class for all events.

This class contains logic common to all the events.

Beside handling OpenCL-specific stuff, Coal::Event objects do nothing implementation-wise. They do not compile kernels, copy data around, etc. They only contain static and immutable data that is then used by the devices to actually implement the event.

Definition at line 197 of file commandqueue.h.


Member Typedef Documentation

typedef void(CL_CALLBACK * Coal::Event::event_callback)(cl_event, cl_int, void *)

Function that can be called when an event change status.

Definition at line 247 of file commandqueue.h.


Member Enumeration Documentation

Event status.

Enumerator:
Queued 

Simply queued in a command queue.

Submitted 

Submitted to a device.

Running 

Running on the device.

Complete 

Completed.

Definition at line 236 of file commandqueue.h.

Timing counters of an event.

Enumerator:
Queue 

Time when the event was queued

Submit 

Time when the event was submitted to the device

Start 

Time when its execution began on the device

End 

Time when its execution finished

Max 

Number of items in this enum

Definition at line 262 of file commandqueue.h.

Event type.

The allows objects using Coal::Event to know which event it is, and to cast it to the correct sub-class.

Enumerator:
NDRangeKernel 
TaskKernel 
NativeKernel 
ReadBuffer 
WriteBuffer 
CopyBuffer 
ReadImage 
WriteImage 
CopyImage 
CopyImageToBuffer 
CopyBufferToImage 
MapBuffer 
MapImage 
UnmapMemObject 
Marker 
AcquireGLObjects 
ReleaseGLObjects 
ReadBufferRect 
WriteBufferRect 
CopyBufferRect 
User 
Barrier 
WaitForEvents 

Reimplemented from Coal::Object.

Definition at line 206 of file commandqueue.h.


Constructor & Destructor Documentation

Event::Event ( CommandQueue parent,
Status  status,
cl_uint  num_events_in_wait_list,
const Event **  event_wait_list,
cl_int *  errcode_ret 
)

Constructor.

Parameters:
parentparent Coal::CommandQueue
statusStatus the event has when it is created
num_events_in_wait_listnumber of events to wait on
event_wait_listlist of events to wait on
errcode_retreturn value

Definition at line 407 of file commandqueue.cpp.

References clRetainEvent(), p_event_wait_list, p_state_change_cond, p_state_mutex, p_timing, status(), type(), and User.

Event::~Event ( ) [virtual]

Member Function Documentation

void * Event::deviceData ( )

Device-specific data.

Returns:
data set using setDeviceData()

Definition at line 606 of file commandqueue.cpp.

References p_device_data.

Referenced by Coal::CPUDevice::freeEventDeviceData(), and worker().

void Event::freeDeviceData ( )
cl_int Event::info ( cl_event_info  param_name,
size_t  param_value_size,
void *  param_value,
size_t *  param_value_size_ret 
) const

Info about the event.

This function is used to retrieve information about an object. Sometimes, the size of the data retrieved is unknown (for example, a string). The application can call this function twice, the first time to get the size, then it allocates a buffer, and finally get the data.

 const char *string = 0;
 size_t len;

 object->info(FOO_PROPERTY_STRING, 0, 0, &len);
 string = std::malloc(len);
 object->info(FOO_PROPERTY_STRING, len, string, 0);
Parameters:
param_nameName of the property to retrieve
param_value_sizeSize of the application-allocated buffer in which to put the value.
param_valuePointer to an application-allocated buffer where the property data will be stored. Ignored if NULL.
param_value_size_retSize of the value retrieved, ignored if NULL.
Returns:
CL_SUCCESS in case of success, otherwise a CL error code.

Definition at line 635 of file commandqueue.cpp.

References Coal::Object::parent(), Coal::Object::references(), SIMPLE_ASSIGN, status(), type(), and User.

Referenced by freeDeviceData(), and profilingInfo().

bool Event::isDummy ( ) const

Dummy event.

A dummy event is an event that doesn't have to be pushed on a device, it is only a hint for Coal::CommandQueue

Returns:
true if the event is dummy

Definition at line 498 of file commandqueue.cpp.

References Barrier, Marker, type(), User, and WaitForEvents.

cl_int Event::profilingInfo ( cl_profiling_info  param_name,
size_t  param_value_size,
void *  param_value,
size_t *  param_value_size_ret 
) const

Profiling info.

This function is used to retrieve information about an object. Sometimes, the size of the data retrieved is unknown (for example, a string). The application can call this function twice, the first time to get the size, then it allocates a buffer, and finally get the data.

 const char *string = 0;
 size_t len;

 object->info(FOO_PROPERTY_STRING, 0, 0, &len);
 string = std::malloc(len);
 object->info(FOO_PROPERTY_STRING, len, string, 0);
Parameters:
param_nameName of the property to retrieve
param_value_sizeSize of the application-allocated buffer in which to put the value.
param_valuePointer to an application-allocated buffer where the property data will be stored. Ignored if NULL.
param_value_size_retSize of the value retrieved, ignored if NULL.
Returns:
CL_SUCCESS in case of success, otherwise a CL error code.

Definition at line 698 of file commandqueue.cpp.

References Complete, End, info(), p_timing, Coal::Object::parent(), Queue, SIMPLE_ASSIGN, Start, status(), Submit, type(), and User.

void Event::setCallback ( cl_int  command_exec_callback_type,
event_callback  callback,
void *  user_data 
)

Add a callback for this event.

Parameters:
command_exec_callback_typestatus the event must have in order to have the callback called
callbackcallback function
user_datauser data given to the callback

Definition at line 617 of file commandqueue.cpp.

References Coal::Event::CallbackData::callback, p_callbacks, p_state_mutex, and Coal::Event::CallbackData::user_data.

void Event::setDeviceData ( void *  data)

Set device-specific data.

Parameters:
datadevice-specific data

Definition at line 547 of file commandqueue.cpp.

References p_device_data.

Referenced by Coal::CPUDevice::initEventDeviceData().

void Event::setStatus ( Status  status)

Set the event status.

This function calls the event callbacks, and Coal::CommandQueue::pushEventsOnDevice() if status is Complete .

Parameters:
statusnew status of the event

Definition at line 516 of file commandqueue.cpp.

References Coal::Event::CallbackData::callback, Complete, p_callbacks, p_state_change_cond, p_state_mutex, p_status, Coal::Object::parent(), status(), type(), User, and Coal::Event::CallbackData::user_data.

Referenced by clSetUserEventStatus().

Event::Status Event::status ( ) const

Status.

Returns:
status of the event

Definition at line 580 of file commandqueue.cpp.

References p_state_mutex, and p_status.

Referenced by clSetUserEventStatus(), Event(), info(), profilingInfo(), and setStatus().

virtual Type Coal::Event::type ( ) const [pure virtual]
void Event::updateTiming ( Timing  timing)

Update timing info.

This function reads current system time and puts it in p_timing

Parameters:
timingtiming event having just finished

Definition at line 552 of file commandqueue.cpp.

References Max, p_state_mutex, and p_timing.

const Event ** Event::waitEvents ( cl_uint &  count) const

List of events on which this event depends on.

Parameters:
countnumber of events in the list
Returns:
list of the events
Warning:
the data is not copied, it's a simple pointer to internal data

Definition at line 611 of file commandqueue.cpp.

References p_event_wait_list, and p_num_events_in_wait_list.

Referenced by Coal::CommandQueue::pushEventsOnDevice().

void Event::waitForStatus ( Status  status)

Wait for a specified status.

This function blocks until the event's status is set to status by another thread.

Parameters:
statusthe status the event must have for the function to return

Definition at line 594 of file commandqueue.cpp.

References p_state_change_cond, p_state_mutex, and p_status.


Member Data Documentation

std::multimap<Status, CallbackData> Coal::Event::p_callbacks [private]

Definition at line 398 of file commandqueue.h.

Referenced by setCallback(), and setStatus().

void* Coal::Event::p_device_data [private]

Definition at line 397 of file commandqueue.h.

Referenced by deviceData(), freeDeviceData(), and setDeviceData().

Definition at line 391 of file commandqueue.h.

Referenced by Event(), waitEvents(), and ~Event().

Definition at line 390 of file commandqueue.h.

Referenced by waitEvents(), and ~Event().

pthread_cond_t Coal::Event::p_state_change_cond [private]

Definition at line 393 of file commandqueue.h.

Referenced by Event(), setStatus(), waitForStatus(), and ~Event().

pthread_mutex_t Coal::Event::p_state_mutex [private]

Definition at line 394 of file commandqueue.h.

Referenced by Event(), setCallback(), setStatus(), status(), updateTiming(), waitForStatus(), and ~Event().

Definition at line 396 of file commandqueue.h.

Referenced by setStatus(), status(), and waitForStatus().

cl_uint Coal::Event::p_timing[Max] [private]

Definition at line 400 of file commandqueue.h.

Referenced by Event(), profilingInfo(), and updateTiming().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines