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_queue_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 
29 #ifndef _CCL_QUEUE_WRAPPER_H_
30 #define _CCL_QUEUE_WRAPPER_H_
31 
32 #include <glib.h>
33 #include "ccl_oclversions.h"
34 #include "ccl_abstract_wrapper.h"
35 #include "ccl_device_wrapper.h"
36 #include "ccl_context_wrapper.h"
37 #include "ccl_event_wrapper.h"
38 
83 /* Get the command queue wrapper for the given OpenCL command
84  * queue. */
85 CCL_EXPORT
86 CCLQueue* ccl_queue_new_wrap(cl_command_queue command_queue);
87 
88 /* Create a new command queue wrapper object. */
89 CCL_EXPORT
91  const cl_queue_properties* prop_full, CCLErr** err);
92 
93 /* Create a new command queue wrapper object. */
94 CCL_EXPORT
96  cl_command_queue_properties properties, CCLErr** err);
97 
98 /* Decrements the reference count of the command queue wrapper
99  * object. If it reaches 0, the command queue wrapper object is
100  * destroyed. */
101 CCL_EXPORT
102 void ccl_queue_destroy(CCLQueue* cq);
103 
104 /* Get the context associated with the given command queue wrapper
105  * object. */
106 CCL_EXPORT
108 
109 /* Get the device associated with the given command queue wrapper
110  * object. */
111 CCL_EXPORT
113 
114 /* Create an event wrapper from a given OpenCL event object and
115  * associate it with the command queue. */
116 CCL_EXPORT
117 CCLEvent* ccl_queue_produce_event(CCLQueue* cq, cl_event event);
118 
119 /* Initialize an iterator for this command queue's list of event
120  * wrappers. */
121 CCL_EXPORT
122 void ccl_queue_iter_event_init(CCLQueue* cq);
123 
124 /* Get the next event wrapper associated with this queue. */
125 CCL_EXPORT
126 CCLEvent* ccl_queue_iter_event_next(CCLQueue* cq);
127 
128 /* Issues all previously queued commands in a command queue to the
129  * associated device. */
130 CCL_EXPORT
131 cl_bool ccl_queue_flush(CCLQueue* cq, CCLErr** err);
132 
133 /* Blocks until all previously queued OpenCL commands in a command-queue
134  * are issued to the associated device and have completed. */
135 CCL_EXPORT
136 cl_bool ccl_queue_finish(CCLQueue* cq, CCLErr** err);
137 
138 /* Release all events associated with the command queue. */
139 CCL_EXPORT
140 void ccl_queue_gc(CCLQueue* cq);
141 
142 /* Enqueues a barrier command on the given command queue. */
143 CCL_EXPORT
145  CCLEventWaitList* evt_wait_lst, CCLErr** err);
146 
147 /* Enqueues a marker command on the given command queue. */
148 CCL_EXPORT
150  CCLEventWaitList* evt_wait_lst, CCLErr** err);
151 
163 #define ccl_queue_get_info(cq, param_name, err) \
164  ccl_wrapper_get_info((CCLWrapper*) cq, NULL, param_name, 0, \
165  CCL_INFO_QUEUE, CL_FALSE, err)
166 
183 #define ccl_queue_get_info_scalar(cq, param_name, param_type, err) \
184  *((param_type*) ccl_wrapper_get_info_value((CCLWrapper*) cq, \
185  NULL, param_name, sizeof(param_type), CCL_INFO_QUEUE, CL_FALSE, err))
186 
203 #define ccl_queue_get_info_array(cq, param_name, param_type, err) \
204  (param_type) ccl_wrapper_get_info_value((CCLWrapper*) cq, \
205  NULL, param_name, sizeof(param_type), CCL_INFO_QUEUE, CL_FALSE, err)
206 
212 #define ccl_queue_ref(cq) \
213  ccl_wrapper_ref((CCLWrapper*) cq)
214 
221 #define ccl_queue_unref(cq) ccl_queue_destroy(cq)
222 
229 #define ccl_queue_unwrap(cq) \
230  ((cl_command_queue) ccl_wrapper_unwrap((CCLWrapper*) cq))
231 
234 #endif
CCLEvent * ccl_enqueue_barrier(CCLQueue *cq, CCLEventWaitList *evt_wait_lst, CCLErr **err)
Enqueues a barrier command on the given command queue.
Definition of a wrapper class and its methods for OpenCL device objects.
CCLQueue * ccl_queue_new(CCLContext *ctx, CCLDevice *dev, cl_command_queue_properties properties, CCLErr **err)
Create a new command queue wrapper object.
GPtrArray * CCLEventWaitList
A list of event objects on which enqueued commands can wait.
Definition of a wrapper class and its methods for OpenCL context objects.
Definition of a wrapper class and its methods for OpenCL event objects.
The context wrapper class.
CCLEvent * ccl_enqueue_marker(CCLQueue *cq, CCLEventWaitList *evt_wait_lst, CCLErr **err)
Enqueues a marker command on the given command queue.
Command queue wrapper class.
cl_bool ccl_queue_flush(CCLQueue *cq, CCLErr **err)
Issues all previously queued commands in a command queue to the associated device.
CCLQueue * ccl_queue_new_wrap(cl_command_queue command_queue)
Get the command queue wrapper for the given OpenCL command queue.
void ccl_queue_gc(CCLQueue *cq)
Release all events associated with the command queue.
cl_bool ccl_queue_finish(CCLQueue *cq, CCLErr **err)
Blocks until all previously queued OpenCL commands in a command-queue are issued to the associated de...
Event wrapper class.
CCLDevice * ccl_queue_get_device(CCLQueue *cq, CCLErr **err)
Get the device associated with the given command queue wrapper object.
CCLQueue * ccl_queue_new_full(CCLContext *ctx, CCLDevice *dev, const cl_queue_properties *prop_full, CCLErr **err)
Create a new command queue wrapper object.
Definition of an abstract wrapper class and its methods for OpenCL objects.
Header for normalizing OpenCL versions within cf4ocl.
GError CCLErr
Error handling class.
Definition: ccl_common.h:291
CCLContext * ccl_queue_get_context(CCLQueue *cq, CCLErr **err)
Get the context associated with the given command queue wrapper object.
void ccl_queue_destroy(CCLQueue *cq)
Decrements the reference count of the command queue wrapper object.
Device wrapper class.