Clover Git
OpenCL 1.1 software implementation
|
Base class for all events. More...
#include <commandqueue.h>
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] |
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.
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.
enum Coal::Event::Status |
Event status.
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.
enum Coal::Event::Timing |
Timing counters of an event.
Definition at line 262 of file commandqueue.h.
enum Coal::Event::Type |
Event type.
The allows objects using Coal::Event
to know which event it is, and to cast it to the correct sub-class.
Reimplemented from Coal::Object.
Definition at line 206 of file commandqueue.h.
Event::Event | ( | CommandQueue * | parent, |
Status | status, | ||
cl_uint | num_events_in_wait_list, | ||
const Event ** | event_wait_list, | ||
cl_int * | errcode_ret | ||
) |
Constructor.
parent | parent Coal::CommandQueue |
status | Status the event has when it is created |
num_events_in_wait_list | number of events to wait on |
event_wait_list | list of events to wait on |
errcode_ret | return 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] |
Destructor.
Definition at line 486 of file commandqueue.cpp.
References clReleaseEvent(), p_event_wait_list, p_num_events_in_wait_list, p_state_change_cond, and p_state_mutex.
void * Event::deviceData | ( | ) |
Device-specific data.
setDeviceData()
Definition at line 606 of file commandqueue.cpp.
References p_device_data.
Referenced by Coal::CPUDevice::freeEventDeviceData(), and worker().
void Event::freeDeviceData | ( | ) |
Call Coal::DeviceInterface::freeEventDeviceData()
Definition at line 475 of file commandqueue.cpp.
References Coal::DeviceInterface::freeEventDeviceData(), info(), p_device_data, and Coal::Object::parent().
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);
param_name | Name of the property to retrieve |
param_value_size | Size of the application-allocated buffer in which to put the value. |
param_value | Pointer to an application-allocated buffer where the property data will be stored. Ignored if NULL. |
param_value_size_ret | Size of the value retrieved, ignored if NULL. |
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
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);
param_name | Name of the property to retrieve |
param_value_size | Size of the application-allocated buffer in which to put the value. |
param_value | Pointer to an application-allocated buffer where the property data will be stored. Ignored if NULL. |
param_value_size_ret | Size of the value retrieved, ignored if NULL. |
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.
command_exec_callback_type | status the event must have in order to have the callback called |
callback | callback function |
user_data | user 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.
data | device-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
.
status | new 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.
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] |
Type of the event.
Reimplemented from Coal::Object.
Implemented in Coal::ReadBufferEvent, Coal::WriteBufferEvent, Coal::MapBufferEvent, Coal::MapImageEvent, Coal::UnmapBufferEvent, Coal::CopyBufferEvent, Coal::CopyBufferRectEvent, Coal::ReadBufferRectEvent, Coal::WriteBufferRectEvent, Coal::ReadImageEvent, Coal::WriteImageEvent, Coal::CopyImageEvent, Coal::CopyImageToBufferEvent, Coal::CopyBufferToImageEvent, Coal::NativeKernelEvent, Coal::KernelEvent, Coal::TaskEvent, Coal::UserEvent, Coal::BarrierEvent, Coal::WaitForEventsEvent, and Coal::MarkerEvent.
Referenced by clSetUserEventStatus(), Event(), Coal::CPUDevice::freeEventDeviceData(), info(), Coal::CPUDevice::initEventDeviceData(), isDummy(), profilingInfo(), setStatus(), and worker().
void Event::updateTiming | ( | Timing | timing | ) |
Update timing info.
This function reads current system time and puts it in p_timing
timing | timing 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.
count | number of events in the list |
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.
status | the 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.
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().
const Event** Coal::Event::p_event_wait_list [private] |
Definition at line 391 of file commandqueue.h.
Referenced by Event(), waitEvents(), and ~Event().
cl_uint Coal::Event::p_num_events_in_wait_list [private] |
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().
Status Coal::Event::p_status [private] |
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().