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_query.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_DEVICE_QUERY_H_
30 #define _CCL_DEVICE_QUERY_H_
31 
32 #include <string.h>
33 #include "ccl_common.h"
34 #include "ccl_device_wrapper.h"
35 #include "ccl_errors.h"
36 #include "ccl_oclversions.h"
37 
58 typedef char* (*ccl_devquery_format)(CCLWrapperInfo* info, char* out,
59  size_t size, const char* units);
60 
64 typedef struct ccl_devquery_map {
65 
70  const char* const param_name;
71 
77  const cl_device_info device_info;
78 
83  const char* const description;
84 
90 
95  const char* const units;
96 
98 
100 CCL_EXPORT
101 extern const int ccl_devquery_info_map_size;
102 
106 CCL_EXPORT
108 
109 /* Get a final device info prefix in the same format as
110  * kept in the ccl_devquery_info_map. */
111 CCL_EXPORT
112 gchar* ccl_devquery_get_prefix_final(const char* prefix);
113 
114 /* Return a cl_device_info object given its name. */
115 CCL_EXPORT
116 cl_device_info ccl_devquery_name(const char* name);
117 
118 /* Get a list of device information parameters which have the
119  * given prefix. */
120 CCL_EXPORT
121 const CCLDevQueryMap* ccl_devquery_prefix(const char* prefix, int* size);
122 
123 /* Search for a device information parameter by matching part
124  * of its name. This function is supposed to be used in a loop. */
125 CCL_EXPORT
126 const CCLDevQueryMap* ccl_devquery_match(const char* substr, int* idx);
127 
135 #define ccl_devquery_type2str(type) \
136  (((type) & CL_DEVICE_TYPE_CPU) ? "CPU" : \
137  (((type) & CL_DEVICE_TYPE_GPU) ? "GPU" : \
138  (((type) & CL_DEVICE_TYPE_ACCELERATOR) ? "Accelerator" : \
139  (((type) & CL_DEVICE_TYPE_CUSTOM) ? "Custom" : \
140  "Unknown"))))
141 
144 #endif
Maps a string to a cl_device_info bitfield.
const ccl_devquery_format format
Output formatting function.
Definition of a wrapper class and its methods for OpenCL device objects.
struct ccl_devquery_map CCLDevQueryMap
Maps a string to a cl_device_info bitfield.
const CCLDevQueryMap * ccl_devquery_prefix(const char *prefix, int *size)
Get a pointer to the first device information parameter which has the given prefix.
const cl_device_info device_info
CL device information bitfield.
Header for normalizing OpenCL versions within cf4ocl.
const char *const description
Long description of parameter.
Class which represents information about a wrapped OpenCL object.
const int ccl_devquery_info_map_size
Size of parameter information map.
cl_device_info ccl_devquery_name(const char *name)
Return a cl_device_info object given its name.
gchar * ccl_devquery_get_prefix_final(const char *prefix)
Get a final device info prefix in the same format as kept in the ccl_devquery_info_map.
Common cf4ocl definitions.
const char *const param_name
Parameter name string.
Convert OpenCL error codes to readable strings (function header).
const CCLDevQueryMap ccl_devquery_info_map[]
Map of parameter name strings to respective cl_device_info bitfields, long description string...
const CCLDevQueryMap * ccl_devquery_match(const char *substr, int *idx)
Search for a device information parameter by matching part of its name.
const char *const units
Parameter units suffix.
char *(* ccl_devquery_format)(CCLWrapperInfo *info, char *out, size_t size, const char *units)
Output formatting function.