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_selector.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_SELECTOR_H_
31 #define _CCL_DEVICE_SELECTOR_H_
32 
33 #include <glib.h>
34 #include "ccl_oclversions.h"
35 #include "ccl_device_wrapper.h"
36 #include "ccl_platforms.h"
37 
119 
125 
127 
156 typedef GPtrArray* CCLDevSelDevices;
157 
168 typedef cl_bool (*ccl_devsel_indep)(
169  CCLDevice* device, void *data, CCLErr **err);
170 
182  CCLDevSelDevices devices, void *data, CCLErr **err);
183 
201 typedef GPtrArray* CCLDevSelFilters;
202 
203 /* Create and return an object with device wrappers for all OpenCL devices
204  * present in the system. */
205 CCL_EXPORT
207 
208 /* Destroy an object containing device wrappers. */
209 CCL_EXPORT
211 
212 /* Returns a NULL-terminated array of strings, each one containing the name and
213  * vendor of each device in the system. */
214 CCL_EXPORT
216 
217 /* Print to stdout a device description string for each device in the system. */
218 CCL_EXPORT
220 
221 /* Add a independent device filter to the filter set. */
222 CCL_EXPORT
224  CCLDevSelFilters* filters, ccl_devsel_indep filter, void* data);
225 
226 /* Add a dependent device filter to the filter set. */
227 CCL_EXPORT
229  CCLDevSelFilters* filters, ccl_devsel_dep filter, void* data);
230 
231 /* Select one or more OpenCL devices based on the provided filters. */
232 CCL_EXPORT
234  CCLDevSelFilters* filters, CCLErr **err);
235 
255 /* Independent filter function which accepts devices of the type
256  * given in the data parameter. */
257 CCL_EXPORT
258 cl_bool ccl_devsel_indep_type(
259  CCLDevice* dev, void* data, CCLErr **err);
260 
261 /* Independent filter function which only accepts GPU devices. */
262 CCL_EXPORT
264  CCLDevice* dev, void *data, CCLErr **err);
265 
266 /* Independent filter function which only accepts CPU devices. */
267 CCL_EXPORT
269  CCLDevice* dev, void *data, CCLErr **err);
270 
271 /* Independent filter function which only accepts accelerator
272  * devices. */
273 CCL_EXPORT
275  CCLDevice* dev, void *data, CCLErr **err);
276 
277 /* Independent filter which selects devices based on device
278  * name, device vendor and/or platform name. */
279 CCL_EXPORT
281  CCLDevice* dev, void *data, CCLErr **err);
282 
283 /* Independent filter function which only accepts devices of a
284  * specified platform. */
285 CCL_EXPORT
287  CCLDevice* device, void *data, CCLErr **err);
288 
311 /* Dependent filter function which only accepts devices of the
312  * same platform (the platform to which the first device belong to). */
313 CCL_EXPORT
315  CCLDevSelDevices devices, void *data, CCLErr **err);
316 
317 /* Dependent filter function which presents a menu to the user
318  * allowing him to select the desired device. */
319 CCL_EXPORT
321  CCLDevSelDevices devices, void *data, CCLErr **err);
322 
323 /* Dependent filter function which selects the device at the specified
324  * index, failing if no device is found at that index. */
325 CCL_EXPORT
327  CCLDevSelDevices devices, void *data, CCLErr **err);
328 
333 #endif
ccl_devsel_filter_type
Filter type.
CCLDevSelDevices ccl_devsel_dep_platform(CCLDevSelDevices devices, void *data, CCLErr **err)
Dependent filter function which only accepts devices of the same platform (the platform to which the ...
Definition of a wrapper class and its methods for OpenCL device objects.
Definition of a class which represents the list of OpenCL platforms available in the system and respe...
CCLDevSelDevices ccl_devsel_dep_menu(CCLDevSelDevices devices, void *data, CCLErr **err)
Dependent filter function which presents a menu to the user allowing him to select the desired device...
void ccl_devsel_devices_destroy(CCLDevSelDevices devices)
Destroy an object containing device wrappers.
cl_bool ccl_devsel_indep_type_cpu(CCLDevice *dev, void *data, CCLErr **err)
Independent filter function which only accepts CPU devices.
cl_bool(* ccl_devsel_indep)(CCLDevice *device, void *data, CCLErr **err)
Independent filter function: Abstract function for filtering one OpenCL device at a time...
cl_bool ccl_devsel_indep_type_accel(CCLDevice *dev, void *data, CCLErr **err)
Independent filter function which only accepts accelerator devices.
GPtrArray * CCLDevSelDevices
An object containing device wrappers.
Independent filter, filters one device at a time.
CCLDevSelDevices ccl_devsel_select(CCLDevSelFilters *filters, CCLErr **err)
Select one or more OpenCL devices based on the provided filters.
void ccl_devsel_add_dep_filter(CCLDevSelFilters *filters, ccl_devsel_dep filter, void *data)
Add a dependent filter to the filter set.
gchar ** ccl_devsel_get_device_strings(CCLErr **err)
Returns a NULL-terminated array of strings, each one containing the name and vendor of each device in...
void ccl_devsel_add_indep_filter(CCLDevSelFilters *filters, ccl_devsel_indep filter, void *data)
Add an independent filter to the filter set.
CCLDevSelDevices ccl_devsel_dep_index(CCLDevSelDevices devices, void *data, CCLErr **err)
Dependent filter function which selects the device at the specified index, failing if no device is fo...
CCLDevSelDevices(* ccl_devsel_dep)(CCLDevSelDevices devices, void *data, CCLErr **err)
Dependent filter function: Abstract function for filtering several OpenCL devices depending on the av...
cl_bool ccl_devsel_indep_string(CCLDevice *dev, void *data, CCLErr **err)
Independent filter which selects devices based on device name, device vendor and/or platform name...
GPtrArray * CCLDevSelFilters
A set of independent and dependent device filters.
cl_bool ccl_devsel_indep_type_gpu(CCLDevice *dev, void *data, CCLErr **err)
Independent filter function which only accepts GPU devices.
Dependent filter, filters devices depending on the currently available device choices.
Header for normalizing OpenCL versions within cf4ocl.
enum ccl_devsel_filter_type CCLDevSelFilterType
Filter type.
cl_bool ccl_devsel_indep_type(CCLDevice *dev, void *data, CCLErr **err)
Independent filter function which accepts devices of the type given in the data parameter.
GError CCLErr
Error handling class.
Definition: ccl_common.h:291
void ccl_devsel_print_device_strings(CCLErr **err)
Print to stdout a device description string for each device in the system.
CCLDevSelDevices ccl_devsel_devices_new(CCLErr **err)
Create and return an object with device wrappers for all OpenCL devices present in the system...
Device wrapper class.
cl_bool ccl_devsel_indep_platform(CCLDevice *device, void *data, CCLErr **err)
Independent filter function which only accepts devices of a specified platform.