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_device_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_DEVICE_WRAPPER_H_
31 #define _CCL_DEVICE_WRAPPER_H_
32 
33 #include "ccl_common.h"
34 #include "ccl_abstract_wrapper.h"
35 #include "ccl_errors.h"
36 #include "ccl_oclversions.h"
37 #include <string.h>
38 
75 /* Decrements the reference count of the device wrapper object.
76  * If it reaches 0, the device wrapper object is destroyed. */
77 CCL_EXPORT
78 void ccl_device_destroy(CCLDevice* dev);
79 
80 /* Get the device wrapper for the given OpenCL device. */
81 CCL_EXPORT
82 CCLDevice* ccl_device_new_wrap(cl_device_id device);
83 
84 /* Get the OpenCL version supported by the device. */
85 CCL_EXPORT
87 
88 /* Get the OpenCL version of the device. */
89 CCL_EXPORT
91 
92 /* Creates an array of sub-devices that each reference a
93  * non-intersecting set of compute units within the given device. */
94 CCL_EXPORT
96  const cl_device_partition_property *properties,
97  cl_uint *num_devs_ret, CCLErr** err);
98 
110 #define ccl_device_get_info(dev, param_name, err) \
111  ccl_wrapper_get_info((CCLWrapper*) dev, NULL, param_name, 0, \
112  CCL_INFO_DEVICE, CL_FALSE, err)
113 
130 #define ccl_device_get_info_scalar(dev, param_name, param_type, err) \
131  *((param_type*) ccl_wrapper_get_info_value((CCLWrapper*) dev, \
132  NULL, param_name, sizeof(param_type), \
133  CCL_INFO_DEVICE, CL_FALSE, err))
134 
151 #define ccl_device_get_info_array(dev, param_name, param_type, err) \
152  (param_type) ccl_wrapper_get_info_value((CCLWrapper*) dev, \
153  NULL, param_name, sizeof(param_type), \
154  CCL_INFO_DEVICE, CL_FALSE, err)
155 
161 #define ccl_device_ref(dev) \
162  ccl_wrapper_ref((CCLWrapper*) dev)
163 
170 #define ccl_device_unref(dev) ccl_device_destroy(dev)
171 
178 #define ccl_device_unwrap(dev) \
179  ((cl_device_id) ccl_wrapper_unwrap((CCLWrapper*) dev))
180 
183 #endif
void ccl_device_destroy(CCLDevice *dev)
Decrements the reference count of the device wrapper object.
CCLDevice *const * ccl_device_create_subdevices(CCLDevice *dev, const cl_device_partition_property *properties, cl_uint *num_devs_ret, CCLErr **err)
Creates a NULL-terminated array of sub-devices that each reference a non-intersecting set of compute ...
Definition of an abstract wrapper class and its methods for OpenCL objects.
Header for normalizing OpenCL versions within cf4ocl.
cl_uint ccl_device_get_opencl_c_version(CCLDevice *dev, CCLErr **err)
Get the OpenCL C version supported by the device.
GError CCLErr
Error handling class.
Definition: ccl_common.h:291
cl_uint ccl_device_get_opencl_version(CCLDevice *dev, CCLErr **err)
Get the OpenCL version supported by the device.
Common cf4ocl definitions.
Convert OpenCL error codes to readable strings (function header).
Device wrapper class.
CCLDevice * ccl_device_new_wrap(cl_device_id device)
Get the device wrapper for the given OpenCL device.