cf4ocl (C Framework for OpenCL)  v2.1.0
Object-oriented framework for developing and benchmarking OpenCL projects in C/C++
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ccl_event_wrapper.h
Go to the documentation of this file.
1 /*
2  * This file is part of cf4ocl (C Framework for OpenCL).
3  *
4  * cf4ocl is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as
6  * published by the Free Software Foundation, either version 3 of the
7  * License, or (at your option) any later version.
8  *
9  * cf4ocl is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with cf4ocl. If not, see
16  * <http://www.gnu.org/licenses/>.
17  * */
18 
30 #ifndef _CCL_EVENT_WRAPPER_H_
31 #define _CCL_EVENT_WRAPPER_H_
32 
33 #include <glib.h>
34 #include "ccl_oclversions.h"
35 #include "ccl_abstract_wrapper.h"
36 #include "ccl_context_wrapper.h"
37 
92 typedef void (CL_CALLBACK *ccl_event_callback)(cl_event event,
93  cl_int event_command_exec_status, void *user_data);
94 
95 /* Get the event wrapper for the given OpenCL event. */
96 CCL_EXPORT
97 CCLEvent* ccl_event_new_wrap(cl_event event);
98 
99 /* Decrements the reference count of the event wrapper object. */
100 CCL_EXPORT
101 void ccl_event_destroy(CCLEvent* evt);
102 
103 /* Set event name for profiling purposes. */
104 CCL_EXPORT
105 void ccl_event_set_name(CCLEvent* evt, const char* name);
106 
107 /* Get the event name for profiling purposes. */
108 CCL_EXPORT
109 const char* ccl_event_get_name(CCLEvent* evt);
110 
111 /* Get the final event name for profiling purposes. */
112 CCL_EXPORT
113 const char* ccl_event_get_final_name(CCLEvent* evt);
114 
115 /* Get the command type which fired the given event. */
116 CCL_EXPORT
117 cl_command_type ccl_event_get_command_type(
118  CCLEvent* evt, CCLErr** err);
119 
120 /* Get the OpenCL version of the platform associated with this event
121  * object. */
122 CCL_EXPORT
123 cl_uint ccl_event_get_opencl_version(CCLEvent* evt, CCLErr** err);
124 
125 /* Wrapper for OpenCL clSetEventCallback() function. */
126 CCL_EXPORT
127 cl_bool ccl_event_set_callback(CCLEvent* evt,
128  cl_int command_exec_callback_type, ccl_event_callback pfn_notify,
129  void *user_data, CCLErr** err);
130 
131 /* Create a new user event. */
132 CCL_EXPORT
134 
135 /* Sets the execution status of a user event object. */
136 CCL_EXPORT
138  CCLEvent* evt, cl_int execution_status, CCLErr** err);
139 
151 #define ccl_event_get_info(evt, param_name, err) \
152  ccl_wrapper_get_info((CCLWrapper*) evt, NULL, param_name, 0, \
153  CCL_INFO_EVENT, CL_FALSE, err)
154 
171 #define ccl_event_get_info_scalar(evt, param_name, param_type, err) \
172  *((param_type*) ccl_wrapper_get_info_value((CCLWrapper*) evt, \
173  NULL, param_name, sizeof(param_type), CCL_INFO_EVENT, CL_FALSE, err))
174 
191 #define ccl_event_get_info_array(evt, param_name, param_type, err) \
192  (param_type) ccl_wrapper_get_info_value((CCLWrapper*) evt, \
193  NULL, param_name, sizeof(param_type), CCL_INFO_EVENT, CL_FALSE, err)
194 
206 #define ccl_event_get_profiling_info(evt, param_name, err) \
207  ccl_wrapper_get_info((CCLWrapper*) evt, NULL, param_name, 0, \
208  CCL_INFO_EVENT_PROFILING, CL_FALSE, err)
209 
226 #define ccl_event_get_profiling_info_scalar(evt, param_name, param_type, err) \
227  *((param_type*) ccl_wrapper_get_info_value((CCLWrapper*) evt, \
228  NULL, param_name, sizeof(param_type), \
229  CCL_INFO_EVENT_PROFILING, CL_FALSE, err))
230 
247 #define ccl_event_get_profiling_info_array(evt, param_name, param_type, err) \
248  (param_type) ccl_wrapper_get_info_value((CCLWrapper*) evt, \
249  NULL, param_name, sizeof(param_type), \
250  CCL_INFO_EVENT_PROFILING, CL_FALSE, err)
251 
257 #define ccl_event_ref(evt) \
258  ccl_wrapper_ref((CCLWrapper*) evt)
259 
266 #define ccl_event_unref(evt) ccl_event_destroy(evt)
267 
274 #define ccl_event_unwrap(evt) \
275  ((cl_event) ccl_wrapper_unwrap((CCLWrapper*) evt))
276 
324 typedef GPtrArray* CCLEventWaitList;
325 
331 #define ccl_ewl ccl_event_wait_list_add
332 
333 /* Add event wrapper objects to an event wait list (variable argument
334  * list version). */
335 CCL_EXPORT
337  CCLEventWaitList* evt_wait_lst, ...) G_GNUC_NULL_TERMINATED;
338 
339 /* Add event wrapper objects to an event wait list (array version). */
340 CCL_EXPORT
342  CCLEventWaitList* evt_wait_lst, CCLEvent** evt);
343 
344 /* Clears an event wait list. */
345 CCL_EXPORT
346 void ccl_event_wait_list_clear(CCLEventWaitList* evt_wait_lst);
347 
358 #define ccl_event_wait_list_get_num_events(evt_wait_lst) \
359  ((((evt_wait_lst) != NULL) && (*(evt_wait_lst) != NULL)) \
360  ? (*(evt_wait_lst))->len \
361  : 0)
362 
373 #define ccl_event_wait_list_get_clevents(evt_wait_lst) \
374  ((((evt_wait_lst) != NULL) && (*(evt_wait_lst) != NULL)) \
375  ? (const cl_event*) (*(evt_wait_lst))->pdata \
376  : NULL)
377 
380 /* Waits on the host thread for commands identified by events in the
381  * wait list to complete. */
382 CCL_EXPORT
383 cl_bool ccl_event_wait(CCLEventWaitList* evt_wait_lst, CCLErr** err);
384 
387 #endif
388 
389 
void ccl_event_set_name(CCLEvent *evt, const char *name)
Set event name for profiling purposes.
const char * ccl_event_get_final_name(CCLEvent *evt)
Get the final event name for profiling purposes.
cl_bool ccl_event_set_callback(CCLEvent *evt, cl_int command_exec_callback_type, ccl_event_callback pfn_notify, void *user_data, CCLErr **err)
Wrapper for OpenCL clSetEventCallback() function.
CCLEvent * ccl_user_event_new(CCLContext *ctx, CCLErr **err)
Create a new user event.
GPtrArray * CCLEventWaitList
A list of event objects on which enqueued commands can wait.
void ccl_event_destroy(CCLEvent *evt)
Decrements the reference count of the event wrapper object.
Definition of a wrapper class and its methods for OpenCL context objects.
The context wrapper class.
void ccl_event_wait_list_clear(CCLEventWaitList *evt_wait_lst)
Clears an event wait list.
cl_uint ccl_event_get_opencl_version(CCLEvent *evt, CCLErr **err)
Get the OpenCL version of the platform associated with this event object.
CCLEventWaitList * ccl_event_wait_list_add_v(CCLEventWaitList *evt_wait_lst, CCLEvent **evt)
Add event wrapper objects to an event wait list (array version).
cl_command_type ccl_event_get_command_type(CCLEvent *evt, CCLErr **err)
Get the command type which fired the given event.
Event wrapper class.
cl_bool ccl_user_event_set_status(CCLEvent *evt, cl_int execution_status, CCLErr **err)
Sets the execution status of a user event object.
const char * ccl_event_get_name(CCLEvent *evt)
Get the event name for profiling purposes.
Definition of an abstract wrapper class and its methods for OpenCL objects.
Header for normalizing OpenCL versions within cf4ocl.
CCLEventWaitList * ccl_event_wait_list_add(CCLEventWaitList *evt_wait_lst,...) G_GNUC_NULL_TERMINATED
Add event wrapper objects to an event wait list (variable argument list version). ...
GError CCLErr
Error handling class.
Definition: ccl_common.h:291
CCLEvent * ccl_event_new_wrap(cl_event event)
Get the event wrapper for the given OpenCL event.
cl_bool ccl_event_wait(CCLEventWaitList *evt_wait_lst, CCLErr **err)
Waits on the host thread for commands identified by events in the wait list to complete.
void(* ccl_event_callback)(cl_event event, cl_int event_command_exec_status, void *user_data)
Prototype for user event callback functions.