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_platform_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_PLATFORM_WRAPPER_H_
30 #define _CCL_PLATFORM_WRAPPER_H_
31 
32 #include "ccl_common.h"
33 #include "ccl_device_wrapper.h"
34 #include "ccl_errors.h"
35 
107 /* Get the platform wrapper for the given OpenCL platform. */
108 CCL_EXPORT
109 CCLPlatform* ccl_platform_new_wrap(cl_platform_id platform);
110 
111 /* Get the platform wrapper for the given device wrapper. */
112 CCL_EXPORT
114 
115 /* Decrements the reference count of the platform wrapper
116  * object. If it reaches 0, the platform wrapper object is destroyed. */
117 CCL_EXPORT
118 void ccl_platform_destroy(CCLPlatform* platf);
119 
120 /* Get integer OpenCL version of platform. */
121 CCL_EXPORT
123  CCLPlatform* platf, CCLErr** err);
124 
136 #define ccl_platform_get_info(platf, param_name, err) \
137  ccl_wrapper_get_info((CCLWrapper*) platf, NULL, param_name, 0, \
138  CCL_INFO_PLATFORM, CL_FALSE, err)
139 
156 #define ccl_platform_get_info_scalar(platf, param_name, param_type, err) \
157  *((param_type*) ccl_wrapper_get_info_value((CCLWrapper*) platf, \
158  NULL, param_name, sizeof(param_type), \
159  CCL_INFO_PLATFORM, CL_FALSE, err))
160 
177 #define ccl_platform_get_info_array(platf, param_name, param_type, err) \
178  (param_type) ccl_wrapper_get_info_value((CCLWrapper*) platf, \
179  NULL, param_name, sizeof(param_type), \
180  CCL_INFO_PLATFORM, CL_FALSE, err)
181 
195 #define ccl_platform_get_info_string(platf, param_name, err) \
196  ccl_platform_get_info_array(platf, param_name, char*, err)
197 
203 #define ccl_platform_ref(platform) \
204  ccl_wrapper_ref((CCLWrapper*) platform)
205 
212 #define ccl_platform_unref(platform) ccl_platform_destroy(platform)
213 
220 #define ccl_platform_unwrap(platform) \
221  ((cl_platform_id) ccl_wrapper_unwrap((CCLWrapper*) platform))
222 
223 /* Get all device wrappers in platform. */
224 CCL_EXPORT
226  CCLPlatform* platf, CCLErr** err);
227 
228 /* Get ::CCLDevice wrapper at given index. */
229 CCL_EXPORT
231  CCLPlatform* platf, cl_uint index, CCLErr** err);
232 
233 /* Return number of devices in platform. */
234 CCL_EXPORT
235 cl_uint ccl_platform_get_num_devices(CCLPlatform* platf, CCLErr** err);
236 
239 #endif
Definition of a wrapper class and its methods for OpenCL device objects.
CCLPlatform * ccl_platform_new_from_device(CCLDevice *dev, CCLErr **err)
Get the platform wrapper for the given device wrapper.
CCLPlatform * ccl_platform_new_wrap(cl_platform_id platform)
Get the platform wrapper for the given OpenCL platform.
CCLDevice *const * ccl_platform_get_all_devices(CCLPlatform *platf, CCLErr **err)
Get all device wrappers in platform.
Convert OpenCL error codes to readable strings (function header).
cl_uint ccl_platform_get_num_devices(CCLPlatform *platf, CCLErr **err)
Return number of devices in platform.
void ccl_platform_destroy(CCLPlatform *platf)
Decrements the reference count of the platform wrapper object.
GError CCLErr
Error handling class.
Definition: ccl_common.h:291
Common cf4ocl definitions.
Device wrapper class.
The platform wrapper class.
CCLDevice * ccl_platform_get_device(CCLPlatform *platf, cl_uint index, CCLErr **err)
Get CCLDevice wrapper at given index.
cl_uint ccl_platform_get_opencl_version(CCLPlatform *platf, CCLErr **err)
Get the OpenCL version of this platform.