121 #ifndef CCL_DEVINFO_OUT
123 #define CCL_DEVINFO_OUT stdout
126 #ifndef CCL_DEVINFO_NA
127 #define CCL_DEVINFO_NA "N/A"
131 #define CCL_DEVINFO_DESCRIPTION "Utility for querying OpenCL " \
132 "platforms and devices"
135 #define CCL_DEVINFO_MAXINFOLEN 500
138 static gboolean opt_all = FALSE;
139 static gboolean opt_basic = TRUE;
140 static gboolean no_platf = FALSE;
141 static gchar** opt_custom = NULL;
142 static guint opt_platf = G_MAXUINT;
143 static guint opt_dev = G_MAXUINT;
144 static gboolean opt_nfound = FALSE;
145 static gboolean opt_verb = FALSE;
146 static gboolean opt_list = FALSE;
147 static gboolean version = FALSE;
150 static GOptionEntry entries[] = {
151 {
"all",
'a', 0, G_OPTION_ARG_NONE, &opt_all,
152 "Show all the available device information", NULL},
153 {
"basic",
'b', 0, G_OPTION_ARG_NONE, &opt_basic,
154 "Show basic device information (default)", NULL},
155 {
"custom",
'c', 0, G_OPTION_ARG_STRING_ARRAY, &opt_custom,
156 "Show specific information, repeat as necessary",
"cl_device_info"},
157 {
"device",
'd', 0, G_OPTION_ARG_INT, &opt_dev,
158 "Specify the index of a device to query",
"dev_idx"},
159 {
"no-platf",
'o', 0, G_OPTION_ARG_NONE, &no_platf,
160 "Ignore platforms, device index reports to all "
161 "devices available in the system", NULL},
162 {
"list",
'l', 0, G_OPTION_ARG_NONE, &opt_list,
163 "List known information parameters", NULL},
164 {
"platform",
'p', 0, G_OPTION_ARG_INT, &opt_platf,
165 "Specify the index of a platform to query",
"platf_idx"},
166 {
"notfound",
'n', 0, G_OPTION_ARG_NONE, &opt_nfound,
167 "Show known parameters even if not found in device", NULL},
168 {
"verbose",
'v', 0, G_OPTION_ARG_NONE, &opt_verb,
169 "Show description of each parameter", NULL},
170 {
"version", 0, 0, G_OPTION_ARG_NONE, &version,
171 "Output version information and exit", NULL},
172 { NULL, 0, 0, 0, NULL, NULL, NULL }
176 static gchar* basic_info[] = {
182 "max_mem_alloc_size",
185 "max_work_group_size",
190 #define ccl_devinfo_show_device_info(d) \
191 if (opt_all) ccl_devinfo_show_device_info_all(d); \
192 else if (opt_custom) ccl_devinfo_show_device_info_custom(d); \
193 else ccl_devinfo_show_device_info_basic(d);
206 g_return_if_fail(err == NULL || *err == NULL);
209 GOptionContext* context = NULL;
215 g_option_context_add_main_entries(context, entries, NULL);
218 g_option_context_parse(context, &argc, &argv, err);
222 g_assert(*err == NULL);
228 g_assert(*err != NULL);
233 if (context) g_option_context_free(context);
249 gchar *profile, *version, *name, *vendor;
258 profile =
"Unknown profile";
265 version =
"Unknown version";
272 name =
"Unknown name";
279 vendor =
"Unknown vendor";
284 "\n* Platform #%d: %s (%s)\n %s, %s\n",
285 idx, name, vendor, version, profile);
291 #define ccl_devinfo_output_device_info(key, value, desc) \
293 g_fprintf(CCL_DEVINFO_OUT, \
294 "\t\t Parameter : %s\n" \
295 "\t\t Description : %s\n" \
296 "\t\t Value : %s\n\n", \
299 g_fprintf(CCL_DEVINFO_OUT, \
300 " %-36.36s | %s\n", \
331 ccl_devinfo_output_device_info(
334 param_value, param_value_str,
346 ccl_devinfo_output_device_info(
376 gchar* custom_param_name;
382 for (guint i = 0; opt_custom[i] != NULL; i++) {
395 while (info_row != NULL) {
404 ccl_devinfo_output_device_info(
407 param_value, param_value_str,
419 ccl_devinfo_output_device_info(
432 g_free(custom_param_name);
458 for (guint i = 0; basic_info[i] != NULL; i++) {
465 g_assert(info_row != NULL);
474 ccl_devinfo_output_device_info(
477 param_value, param_value_str,
489 ccl_devinfo_output_device_info(
508 int main(
int argc,
char* argv[]) {
579 for (guint j = 0; j < devices->len; j++) {
582 if ((opt_dev != G_MAXUINT) && (j != opt_dev))
592 dev_name = (gchar*) info_value->
value;
596 "\n [ Device #%d: %s ]\n\n",
598 ccl_devinfo_show_device_info(d);
615 if ((opt_platf != G_MAXUINT) && (i != opt_platf))
629 (err->code == CL_DEVICE_NOT_FOUND)) {
636 "\n [ No devices found ]\n\n");
644 for (guint j = 0; j < num_devs; j++) {
647 if ((opt_dev != G_MAXUINT) && (j != opt_dev))
658 dev_name = (gchar*) info_value->
value;
662 "\n [ Device #%d: %s ]\n\n",
664 ccl_devinfo_show_device_info(d);
673 g_assert(err == NULL);
680 g_assert(err != NULL);
681 g_fprintf(stderr,
"%s\n", err->message);
690 g_strfreev(opt_custom);
void ccl_devinfo_show_device_info_basic(CCLDevice *d)
Show basic device information.
Maps a string to a cl_device_info bitfield.
const ccl_devquery_format format
Output formatting function.
#define CCL_OCL_ERROR
Resolves to error category identifying string, in this case an error in the OpenCL library...
#define ccl_platform_get_info_string(platf, param_name, err)
Helper macro which gets a platform information string.
void ccl_devinfo_show_platform_info(CCLPlatform *p, guint idx)
Show platform information.
void ccl_devinfo_show_device_info_all(CCLDevice *d)
Show all available device information.
void ccl_devsel_devices_destroy(CCLDevSelDevices devices)
Destroy an object containing device wrappers.
#define ccl_if_err_goto(err, label)
If error is detected in err object (err != NULL), go to the specified label.
void ccl_platforms_destroy(CCLPlatforms *platforms)
Destroy a CCLPlatforms* object, including all underlying platforms, devices and data.
CCLPlatforms * ccl_platforms_new(CCLErr **err)
Creates a new CCLPlatforms* object, which contains the list of OpenCL platforms available in the syst...
const CCLDevQueryMap * ccl_devquery_prefix(const char *prefix, int *size)
Get a pointer to the first device information parameter which has the given prefix.
#define ccl_device_get_info(dev, param_name, err)
Get a CCLWrapperInfo device information object.
void ccl_common_version_print(const char *exec_name)
Print executable version.
cl_uint ccl_platforms_count(CCLPlatforms *platforms)
Return number of OpenCL platforms found in CCLPlatforms object.
#define CCL_ERROR
Resolves to error category identifying string, in this case an error in cf4ocl.
GPtrArray * CCLDevSelDevices
An object containing device wrappers.
Common header file for _cf4ocl utilities.
#define CCL_DEVINFO_DESCRIPTION
Program description.
const cl_device_info device_info
CL device information bitfield.
void ccl_devinfo_show_device_info_custom(CCLDevice *d)
Show user specified device information.
void ccl_devinfo_args_parse(int argc, char *argv[], CCLErr **err)
Parse and verify command line arguments.
#define CCL_DEVINFO_OUT
Default device information output stream.
void * value
Object information.
cl_uint ccl_platform_get_num_devices(CCLPlatform *platf, CCLErr **err)
Return number of devices in platform.
int main(int argc, char *argv[])
Device info main program function.
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.
GError CCLErr
Error handling class.
cl_bool ccl_wrapper_memcheck()
Debug function which checks if memory allocated by wrappers has been properly freed.
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.
CCLDevSelDevices ccl_devsel_devices_new(CCLErr **err)
Create and return an object with device wrappers for all OpenCL devices present in the system...
const char *const param_name
Parameter name string.
CCLPlatform * ccl_platforms_get(CCLPlatforms *platforms, cl_uint index)
Get platform wrapper object at given index.
#define CCL_DEVINFO_MAXINFOLEN
Maximum length of device information output, per parameter.
const CCLDevQueryMap ccl_devquery_info_map[]
Map of parameter name strings to respective cl_device_info bitfields, long description string...
CCLDevice * ccl_platform_get_device(CCLPlatform *platf, cl_uint index, CCLErr **err)
Get CCLDevice wrapper at given index.
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.