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_c.c
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 General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (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 General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with cf4ocl. If not, see <http://www.gnu.org/licenses/>.
16  * */
17 
101 #include "ccl_utils.h"
102 
103 #define CCL_C_DESCRIPTION "Static kernel compiler and analyzer"
104 
105 #define ccl_c_get_build_status_str(build_status) \
106  (build_status) == CL_BUILD_NONE ? "Program not built (unexpected)" : \
107  ((build_status) == CL_BUILD_ERROR ? "Error" : \
108  (((build_status) == CL_BUILD_SUCCESS ? "Success" : \
109  ((((build_status) == CL_BUILD_IN_PROGRESS ? "In progress (unexpected)" : \
110  "Unknown"))))))
111 
112 #define ccl_c_is_build_error(err) \
113  (((err != NULL) && (err->domain == CCL_OCL_ERROR) && \
114  ((err->code == CL_BUILD_PROGRAM_FAILURE) || \
115  (err->code == CL_COMPILE_PROGRAM_FAILURE) || \
116  (err->code == CL_LINK_PROGRAM_FAILURE))))
117 
118 #define ccl_c_info_unavailable(err) \
119  ((err) != NULL) && ((err)->domain == CCL_ERROR) && \
120  ((err)->code == CCL_ERROR_INFO_UNAVAILABLE_OCL)
121 
122 /* Available tasks. */
123 typedef enum ccl_c_tasks {
124  CCL_C_BUILD = 0,
125  CCL_C_COMPILE = 1,
126  CCL_C_LINK = 2
127 } CCLCTasks;
128 
129 /* Command line arguments and respective default values. */
130 static gboolean opt_list = FALSE;
131 static guint dev_idx = CCL_UTILS_NODEVICE;
132 static guint task = CCL_C_BUILD;
133 static gchar* options = NULL;
134 static gchar** src_files = NULL;
135 static gchar** bin_files = NULL;
136 static gchar** src_h_files = NULL;
137 static gchar** src_h_names = NULL;
138 static gchar** kernel_names = NULL;
139 static gchar* output = NULL;
140 static gchar* bld_log_out = NULL;
141 static gboolean version = FALSE;
142 
143 /* Valid command line options. */
144 static GOptionEntry entries[] = {
145  {"list", 'l', 0, G_OPTION_ARG_NONE, &opt_list,
146  "List available devices and exit.", NULL},
147  {"device", 'd', 0, G_OPTION_ARG_INT, &dev_idx,
148  "Specify a device on which to perform the task.", "DEV"},
149  {"task", 't', 0, G_OPTION_ARG_INT, &task,
150  "0 (Build, default), 1 (Compile) or 2 (Link). Tasks 1 and 2 are only "
151  "available for platforms with support for OpenCL 1.2 or higher.",
152  "TASK"},
153  {"options", '0', 0, G_OPTION_ARG_STRING, &options,
154  "Compiler/linker options.", "OPTIONS"},
155  {"src", 's', 0, G_OPTION_ARG_FILENAME_ARRAY, &src_files,
156  "Source input files. This option can be specified multiple times.",
157  "FILE"},
158  {"input-headers", 'i', 0, G_OPTION_ARG_FILENAME_ARRAY, &src_h_files,
159  "Embedded header input files for the compile task. This option can be "
160  "specified multiple times.", "FILE"},
161  {"header-include-names", 'n', 0, G_OPTION_ARG_STRING_ARRAY, &src_h_names,
162  "Embedded header include names for the compile task. This option can be "
163  "specified multiple times and has a one to one correspondence with "
164  "--input-headers.", "STRING"},
165  {"bin", 'b', 0, G_OPTION_ARG_FILENAME_ARRAY, &bin_files,
166  "Binary input file. This option can be specified multiple times.",
167  "FILE"},
168  {"output", 'o', 0, G_OPTION_ARG_FILENAME, &output,
169  "Binary output file.", "FILE"},
170  {"kernel-info", 'k', 0, G_OPTION_ARG_STRING_ARRAY, &kernel_names,
171  "Show information about the specified kernel. This option can be "
172  "specified multiple times.", "STRING"},
173  {"build-log", 'u', 0, G_OPTION_ARG_FILENAME, &bld_log_out,
174  "Save build log to the specified file. By default the build log is "
175  "printed to stderr.", "FILE"},
176  {"version", 0, 0, G_OPTION_ARG_NONE, &version,
177  "Output version information and exit.", NULL},
178  { NULL, 0, 0, 0, NULL, NULL, NULL }
179 };
180 
188 void ccl_c_args_parse(int argc, char* argv[], CCLErr** err) {
189 
190  /* Make sure err is NULL or it is not set. */
191  g_return_if_fail(err == NULL || *err == NULL);
192 
193  /* Command line options context. */
194  GOptionContext* context = NULL;
195 
196  /* Create parsing context. */
197  context = g_option_context_new(" - " CCL_C_DESCRIPTION);
198 
199  /* Add acceptable command line options to context. */
200  g_option_context_add_main_entries(context, entries, NULL);
201 
202  /* Use context to parse command line options. */
203  g_option_context_parse(context, &argc, &argv, err);
204  ccl_if_err_goto(*err, error_handler);
205 
206  /* If we get here, no need for error treatment, jump to cleanup. */
207  g_assert(*err == NULL);
208  goto cleanup;
209 
210 error_handler:
211 
212  /* If we got here, everything is OK. */
213  g_assert(*err != NULL);
214 
215 cleanup:
216 
217  /* Free context. */
218  if (context) g_option_context_free(context);
219 
220  /* Return. */
221  return;
222 
223 }
224 
234  CCLProgram* prg, CCLDevice* dev, const char* kernel, CCLErr** err) {
235 
236  /* OpenCL version. */
237  cl_uint ocl_ver;
238 
239  /* Kernel wrapper. */
240  CCLKernel* krnl = NULL;
241 
242  /* Kernel workgroup info variables. */
243  size_t k_wg_size;
244  size_t k_pref_wg_size_mult;
245  size_t* k_compile_wg_size;
246  cl_ulong k_loc_mem_size;
247  cl_ulong k_priv_mem_size;
248 
249  /* Internal error handling object. */
250  CCLErr* err_internal = NULL;
251 
252  /* Get OpenCL version. */
253  ocl_ver = ccl_program_get_opencl_version(prg, &err_internal);
254  ccl_if_err_propagate_goto(err, err_internal, error_handler);
255 
256 
257  /* Get kernel. */
258  krnl = ccl_program_get_kernel(prg, kernel, &err_internal);
259  ccl_if_err_propagate_goto(err, err_internal, error_handler);
260 
261  g_printf("\n");
262 
263  /* Show CL_KERNEL_WORK_GROUP_SIZE information. */
265  krnl, dev, CL_KERNEL_WORK_GROUP_SIZE, size_t, &err_internal);
266  if (ccl_c_info_unavailable(err_internal)) {
267  g_clear_error(&err_internal);
268  g_printf(" - Maximum workgroup size : N/A\n");
269  } else {
270  ccl_if_err_propagate_goto(err, err_internal, error_handler);
271  g_printf(" - Maximum workgroup size : %lu\n",
272  (unsigned long) k_wg_size);
273  }
274 
275  /* Only show info about CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE
276  * if OpenCL version of the underlying platform is >= 1.1. */
277  if (ocl_ver >= 110) {
278  k_pref_wg_size_mult = ccl_kernel_get_workgroup_info_scalar(krnl,
279  dev, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE,
280  size_t, &err_internal);
281  if (ccl_c_info_unavailable(err_internal)) {
282  g_clear_error(&err_internal);
283  g_printf(" - Preferred multiple of workgroup size : N/A\n");
284  } else {
285  ccl_if_err_propagate_goto(err, err_internal, error_handler);
286  g_printf(" - Preferred multiple of workgroup size : %lu\n",
287  (unsigned long) k_pref_wg_size_mult);
288  }
289  }
290 
291  /* Show CL_KERNEL_COMPILE_WORK_GROUP_SIZE information. */
292  k_compile_wg_size = ccl_kernel_get_workgroup_info_array(krnl, dev,
293  CL_KERNEL_COMPILE_WORK_GROUP_SIZE, size_t*, &err_internal);
294  if (ccl_c_info_unavailable(err_internal)) {
295  g_clear_error(&err_internal);
296  g_printf(" - WG size in __attribute__ qualifier : N/A\n");
297  } else {
298  ccl_if_err_propagate_goto(err, err_internal, error_handler);
299  g_printf(" - WG size in __attribute__ qualifier : "
300  "(%lu, %lu, %lu)\n",
301  (unsigned long) k_compile_wg_size[0],
302  (unsigned long) k_compile_wg_size[1],
303  (unsigned long) k_compile_wg_size[2]);
304  }
305 
306  /* Show CL_KERNEL_LOCAL_MEM_SIZE information. */
307  k_loc_mem_size = ccl_kernel_get_workgroup_info_scalar(krnl, dev,
308  CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong, &err_internal);
309  if (ccl_c_info_unavailable(err_internal)) {
310  g_clear_error(&err_internal);
311  g_printf(" - Local memory used by kernel : N/A\n");
312  } else {
313  ccl_if_err_propagate_goto(err, err_internal, error_handler);
314  g_printf(" - Local memory used by kernel : %lu bytes\n",
315  (unsigned long) k_loc_mem_size);
316  }
317 
318  /* Show CL_KERNEL_PRIVATE_MEM_SIZE information. */
319  k_priv_mem_size = ccl_kernel_get_workgroup_info_scalar(krnl, dev,
320  CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong, &err_internal);
321  if (ccl_c_info_unavailable(err_internal)) {
322  g_clear_error(&err_internal);
323  g_printf(" - Min. private mem. used by each workitem : N/A\n");
324  } else {
325  ccl_if_err_propagate_goto(err, err_internal, error_handler);
326  g_printf(" - Min. private mem. used by each workitem : %lu bytes\n",
327  (unsigned long) k_priv_mem_size);
328  }
329 
330  g_printf("\n");
331 
332  /* If we got here, everything is OK. */
333  g_assert(err == NULL || *err == NULL);
334  goto finish;
335 
336 error_handler:
337 
338  /* If we got here there was an error, verify that it is so. */
339  g_assert(err == NULL || *err != NULL);
340 
341 finish:
342 
343  /* Return. */
344  return;
345 
346 }
347 
356 int main(int argc, char* argv[]) {
357 
358  /* Error object. */
359  CCLErr* err = NULL, *err_build = NULL;
360 
361  /* Program return status. */
362  gint status;
363 
364  /* Counter for for loops. */
365  guint i = 0;
366 
367  /* Number of types of files, file names and kernel names. */
368  guint n_src_files, n_bin_files, n_src_h_files,
369  n_src_h_names, n_kernel_names;
370 
371  /* Context wrapper. */
372  CCLContext* ctx = NULL;
373 
374  /* Device wrapper. */
375  CCLDevice* dev = NULL;
376 
377  /* Device name. */
378  char* dname;
379 
380  /* Main program wrapper. */
381  CCLProgram* prg = NULL;
382 
383  /* Auxiliary program wrapper. */
384  CCLProgram* prg_aux = NULL;
385 
386  /* Array containing multiple program wrappers. */
387  GPtrArray* prgs = NULL;
388 
389  /* Build status. */
390  cl_build_status build_status;
391 
392  /* Build status string. */
393  const char* build_status_str;
394 
395  /* Build log. */
396  const char* build_log;
397 
398  /* Parse command line options. */
399  ccl_c_args_parse(argc, argv, &err);
400  ccl_if_err_goto(err, error_handler);
401 
402  g_printf("\n");
403 
404  /* Determine main program goal. */
405  if (version) {
406 
407  /* If version was requested, show version. */
408  ccl_common_version_print("ccl_c");
409 
410  } else if (opt_list) {
411 
412  /* If user requested a list of available devices, present the list. */
414  ccl_if_err_goto(err, error_handler);
415 
416  } else {
417 
418  /* Otherwise perform a task, which requires at least one input
419  * file and the specification of a device. */
420 
421  /* Check for input files. */
422  ccl_if_err_create_goto(err, CCL_ERROR, (src_files == NULL) &&
423  (src_h_files == NULL) && (bin_files == NULL),
424  CCL_ERROR_ARGS, error_handler,
425  "No source or binary input files have been specified.");
426 
427  /* How many files of each type? */
428  n_src_files = src_files != NULL ? g_strv_length(src_files) : 0;
429  n_bin_files = bin_files != NULL ? g_strv_length(bin_files) : 0;
430  n_src_h_files = src_h_files != NULL ? g_strv_length(src_h_files) : 0;
431  n_src_h_names = src_h_names != NULL ? g_strv_length(src_h_names) : 0;
432  n_kernel_names = kernel_names != NULL ? g_strv_length(kernel_names) : 0;
433 
434  /* Select a context/device. */
435  if (dev_idx == CCL_UTILS_NODEVICE) {
436  ctx = ccl_context_new_from_menu(&err);
437  } else {
438  ctx = ccl_context_new_from_device_index(&dev_idx, &err);
439  }
440  ccl_if_err_goto(err, error_handler);
441 
442  /* Get device. */
443  dev = ccl_context_get_device(ctx, 0, &err);
444  ccl_if_err_goto(err, error_handler);
445 
446  /* Perform task. */
447  switch (task) {
448  case CCL_C_BUILD:
449 
450  /* For direct builds we can only have either one binary
451  * or one or more source files (but not both). */
453  (n_src_files > 0) && (n_bin_files > 0),
454  CCL_ERROR_ARGS, error_handler,
455  "The 'build' task requires either: 1) one or more "
456  "source files; or, 2) one binary file.");
457  ccl_if_err_create_goto(err, CCL_ERROR, n_bin_files > 1,
458  CCL_ERROR_ARGS, error_handler,
459  "The 'build' task accepts at most one binary file.");
460 
461  /* Input headers are not accepted by the compile task. */
463  (n_src_h_files > 0) || (n_src_h_names > 0),
464  CCL_ERROR_ARGS, error_handler,
465  "Input headers can only be specified for the 'compile' "
466  "task.");
467 
468  /* Create program object. */
469  if (n_bin_files == 1) {
470 
471  /* Create program from binary file. */
472  prg = ccl_program_new_from_binary_file(ctx, dev,
473  *bin_files, NULL, &err);
474 
475  } else {
476 
477  /* Create program from source. */
479  ctx, n_src_files, (const char**) src_files, &err);
480 
481  }
482  ccl_if_err_goto(err, error_handler);
483 
484  /* Build program. */
485  ccl_program_build(prg, options, &err_build);
486 
487  /* Only check for errors that are not build/compile/link
488  * failures. */
489  if (!ccl_c_is_build_error(err_build)) {
490  ccl_if_err_propagate_goto(&err, err_build, error_handler);
491  }
492 
493  break;
494 
495  case CCL_C_COMPILE:
496 
497  /* Compilation requires at least one source file. */
498  ccl_if_err_create_goto(err, CCL_ERROR, n_src_files == 0,
499  CCL_ERROR_ARGS, error_handler,
500  "The 'compile' task requires at least one source file.");
501 
502  /* Compilation does not support binaries. */
503  ccl_if_err_create_goto(err, CCL_ERROR, n_bin_files > 0,
504  CCL_ERROR_ARGS, error_handler,
505  "The 'compile' task does not support binaries.");
506 
507  /* Number of header include names must be zero OR be the same as
508  * the number of input headers. */
510  (n_src_h_files != n_src_h_names) && (n_src_h_names > 0),
511  CCL_ERROR_ARGS, error_handler,
512  "Number of header include names must be the same as the "
513  "number of input headers.");
514 
515  /* Create header programs, if any. */
516  if (n_src_h_files) {
517 
518  /* Instantiate array of header programs. */
519  prgs = g_ptr_array_new_full(
520  n_src_h_files,
521  (GDestroyNotify) ccl_program_destroy);
522 
523  /* Create individual header programs. */
524  for (i = 0; i < n_src_h_files; i++) {
525 
526  /* Create current header program from source. */
527  prg_aux = ccl_program_new_from_source_files(ctx,
528  1, (const char**) &(src_h_files[i]), &err);
529  ccl_if_err_goto(err, error_handler);
530 
531  /* Add header program to array. */
532  g_ptr_array_add(prgs, (gpointer) prg_aux);
533 
534  }
535  }
536 
537  /* Create main program from source. */
539  n_src_files, (const char**) src_files, &err);
540  ccl_if_err_goto(err, error_handler);
541 
542  /* Compile program. */
543  ccl_program_compile(prg, 1, &dev, options,
544  n_src_h_files,
545  (CCLProgram**) (prgs ? prgs->pdata : NULL),
546  (const char**) (src_h_names ? src_h_names : src_h_files),
547  NULL, NULL, &err_build);
548 
549  /* Only check for errors that are not build/compile/link
550  * failures. */
551  if (!ccl_c_is_build_error(err_build)) {
552  ccl_if_err_propagate_goto(&err, err_build, error_handler);
553  }
554 
555  break;
556 
557  case CCL_C_LINK:
558 
559  /* Linking requires at least one binary file and does
560  * not support source files. */
561  ccl_if_err_create_goto(err, CCL_ERROR, (n_bin_files == 0) ||
562  (n_src_files > 0) || (n_src_h_files > 0),
563  CCL_ERROR_ARGS, error_handler,
564  "The 'link' task requires at least one binary file "
565  "and does not support source files.");
566 
567  /* Instantiate array of programs. */
568  prgs = g_ptr_array_new_full(
569  n_bin_files,
570  (GDestroyNotify) ccl_program_destroy);
571 
572  /* Create programs from binaries. */
573  for (i = 0; i < n_bin_files; i++) {
574 
575  /* Create program from current binary file. */
576  prg_aux = ccl_program_new_from_binary_file(ctx, dev,
577  bin_files[i], NULL, &err);
578  ccl_if_err_goto(err, error_handler);
579 
580  /* Add binary program to array. */
581  g_ptr_array_add(prgs, (gpointer) prg_aux);
582 
583  }
584 
585  /* Link programs. */
586  prg = ccl_program_link(ctx, 1, &dev, options,
587  n_bin_files, (CCLProgram**) prgs->pdata, NULL,
588  NULL, &err_build);
589  /* Only check for errors that are not build/compile/link
590  * failures. */
591  if (!ccl_c_is_build_error(err_build)) {
592  ccl_if_err_propagate_goto(&err, err_build, error_handler);
593  }
594 
595  break;
596 
597  default:
599  CCL_ERROR_ARGS, error_handler, "Unknown task: %d",
600  task);
601  }
602 
603  /* Get and show device name. */
604  dname = ccl_device_get_info_array(dev, CL_DEVICE_NAME, char*, &err);
605  ccl_if_err_goto(err, error_handler);
606  g_printf("* Device : %s\n", dname);
607 
608  /* Ir program object exists... */
609  if (prg) {
610 
611  /* ...get build status and build status string. */
612  build_status = ccl_program_get_build_info_scalar(prg, dev,
613  CL_PROGRAM_BUILD_STATUS, cl_build_status, &err);
614  ccl_if_err_goto(err, error_handler);
615  build_status_str = ccl_c_get_build_status_str(build_status);
616 
617  } else {
618 
619  /* If program object does not exist, set build status string to
620  * unavailable. */
621  build_status = CL_BUILD_NONE;
622  build_status_str = "Unavailable";
623 
624  }
625 
626  /* Show build status. */
627  g_printf("* Build status : %s\n", build_status_str);
628 
629  /* If build successful, save binary? */
630  if (output && prg && (build_status == CL_BUILD_SUCCESS)) {
631 
632  ccl_program_save_binary(prg, dev, output, &err);
633  ccl_if_err_goto(err, error_handler);
634  g_printf("* Binary output file : %s\n", output);
635 
636  }
637 
638  /* Show build error message, if any. */
639  if (err_build) {
640  g_printf("* Additional information : %s\n", err_build->message);
641  }
642 
643  /* Show kernel information? */
644  if (kernel_names && !err_build) {
645 
646  /* Cycle through kernel names. */
647  for (i = 0; i < n_kernel_names; i++) {
648 
649  /* Show information for current kernel name. */
650  g_printf("* Kernel information : %s\n", kernel_names[i]);
651  ccl_c_kernel_info_show(prg, dev, kernel_names[i], &err);
652  ccl_if_err_goto(err, error_handler);
653 
654  }
655  }
656 
657  /* Show build log, if any. */
658  g_printf("* Build log :");
659  if (!prg) {
660 
661  /* No build log if program object does not exist. */
662  g_printf(" Unavailable.\n");
663 
664  } else {
665 
666  /* Get build log. */
667  build_log = ccl_program_get_device_build_log(prg, dev, &err);
668  if (err) {
669 
670  /* Not possible to retrieve build log due to error. */
671  g_info("Unable to retrieve build log. %s", err->message);
672  g_clear_error(&err);
673 
674  }
675 
676  /* If build log was retrieved successfully and has length greater
677  * than zero, output it. */
678  if ((build_log) && (strlen(build_log) > 0)) {
679 
680  /* Should we output print log to file or to stderr? */
681  if (bld_log_out) {
682 
683  /* Output to file. */
684  g_printf(" Saved to %s.\n", bld_log_out);
685  g_file_set_contents(bld_log_out, build_log, -1, &err);
686  ccl_if_err_goto(err, error_handler);
687 
688  } else {
689 
690  /* Output to stderr. */
691  g_printf(" Printed to error output stream.\n");
692  g_fprintf(stderr, "\n%s\n", build_log);
693 
694  }
695 
696  } else {
697 
698  /* No build log or build log is empty. */
699  g_printf(" Empty.\n");
700 
701  }
702  }
703 
704  }
705 
706  /* If we got here, everything is OK. */
707  g_assert(err == NULL);
708  status = err_build ? EXIT_FAILURE : EXIT_SUCCESS;
709  goto cleanup;
710 
711 error_handler:
712 
713  /* If we got here there was an error, verify that it is so. */
714  g_assert(err != NULL);
715 
716  /* Show error message and set return status to failure. */
717  g_fprintf(stderr, "* Error : %s\n", err->message);
718  status = EXIT_FAILURE;
719 
720  /* Release error object. */
721  g_error_free(err);
722 
723 cleanup:
724 
725  g_printf("\n");
726 
727  /* Free stuff! */
728  g_clear_error(&err_build);
729  if (src_files) g_strfreev(src_files);
730  if (src_h_files) g_strfreev(src_h_files);
731  if (src_h_names) g_strfreev(src_h_names);
732  if (kernel_names) g_strfreev(kernel_names);
733  if (bin_files) g_strfreev(bin_files);
734  if (options) g_free(options);
735  if (bld_log_out) g_free(bld_log_out);
736  if (output) g_free(output);
737  if (ctx) ccl_context_destroy(ctx);
738  if (prg) ccl_program_destroy(prg);
739  if (prgs) g_ptr_array_free(prgs, TRUE);
740 
741  /* Confirm that memory allocated by wrappers has been properly
742  * freed. */
743  g_return_val_if_fail(ccl_wrapper_memcheck(), EXIT_FAILURE);
744 
745  /* Return status. */
746  return status;
747 
748 }
void ccl_context_destroy(CCLContext *ctx)
Decrements the reference count of the context wrapper object.
int main(int argc, char *argv[])
Kernel analyzer main program function.
Definition: ccl_c.c:356
const char * ccl_program_get_device_build_log(CCLProgram *prg, CCLDevice *dev, CCLErr **err)
Get build log for most recent build, compile or link for the specified device.
#define ccl_kernel_get_workgroup_info_scalar(krnl, dev, param_name, param_type, err)
Macro which returns a scalar kernel workgroup information value.
#define ccl_if_err_create_goto(err, quark, error_condition, error_code, label, msg,...)
If error is detected (error_code != no_error_code), create an error object (CCLErr) and go to the spe...
Definition: _ccl_defs.h:91
CCLProgram * ccl_program_new_from_binary_file(CCLContext *ctx, CCLDevice *dev, const char *filename, cl_int *binary_status, CCLErr **err)
Create a new program wrapper object from a file containing binary code executable on a specific devic...
void ccl_c_args_parse(int argc, char *argv[], CCLErr **err)
Parse and verify command line arguments.
Definition: ccl_c.c:188
The context wrapper class.
#define ccl_if_err_propagate_goto(err_dest, err_src, label)
Same as ccl_if_err_goto(), but rethrows error in a source CCLErr object to a new destination CCLErr o...
Definition: _ccl_defs.h:120
#define ccl_if_err_goto(err, label)
If error is detected in err object (err != NULL), go to the specified label.
Definition: _ccl_defs.h:106
CCLDevice * ccl_context_get_device(CCLContext *ctx, cl_uint index, CCLErr **err)
Get CCLDevice wrapper at given index.
cl_uint ccl_program_get_opencl_version(CCLProgram *prg, CCLErr **err)
Get the OpenCL version of the platform associated with this program.
void ccl_common_version_print(const char *exec_name)
Print executable version.
Definition: ccl_common.c:37
#define CCL_ERROR
Resolves to error category identifying string, in this case an error in cf4ocl.
Definition: ccl_common.h:320
cl_bool ccl_program_build(CCLProgram *prg, const char *options, CCLErr **err)
Utility function which builds (compiles and links) a program executable from the program source or bi...
Common header file for _cf4ocl utilities.
#define ccl_program_get_build_info_scalar(prg, dev, param_name, param_type, err)
Macro which returns a scalar program build information value.
#define ccl_context_new_from_menu(err)
Creates a context wrapper from a device selected by the user from a menu.
#define ccl_device_get_info_array(dev, param_name, param_type, err)
Macro which returns an array device information value.
Invalid function arguments.
Definition: ccl_common.h:302
CCLProgram * ccl_program_link(CCLContext *ctx, cl_uint num_devices, CCLDevice *const *devs, const char *options, cl_uint num_input_programs, CCLProgram **input_prgs, ccl_program_callback pfn_notify, void *user_data, CCLErr **err)
Link a set of compiled programs and create an executable program wrapper.
void ccl_c_kernel_info_show(CCLProgram *prg, CCLDevice *dev, const char *kernel, CCLErr **err)
Show kernel information.
Definition: ccl_c.c:233
Program wrapper class.
CCLProgram * ccl_program_new_from_source_files(CCLContext *ctx, cl_uint count, const char **filenames, CCLErr **err)
Create a new program wrapper object from several source files.
Kernel wrapper class.
cl_bool ccl_program_compile(CCLProgram *prg, cl_uint num_devices, CCLDevice *const *devs, const char *options, cl_uint num_input_headers, CCLProgram **prg_input_headers, const char **header_include_names, ccl_program_callback pfn_notify, void *user_data, CCLErr **err)
Compile a program's source code.
GError CCLErr
Error handling class.
Definition: ccl_common.h:291
cl_bool ccl_program_save_binary(CCLProgram *prg, CCLDevice *dev, const char *filename, CCLErr **err)
Save the program binary code for a specified device to a file.
void ccl_devsel_print_device_strings(CCLErr **err)
Print to stdout a device description string for each device in the system.
CCLKernel * ccl_program_get_kernel(CCLProgram *prg, const char *kernel_name, CCLErr **err)
Get the kernel wrapper object for the given program kernel function.
#define ccl_kernel_get_workgroup_info_array(krnl, dev, param_name, param_type, err)
Macro which returns an array kernel workgroup information value.
cl_bool ccl_wrapper_memcheck()
Debug function which checks if memory allocated by wrappers has been properly freed.
#define ccl_context_new_from_device_index(data, err)
Creates a context wrapper using a device selected by its index.
void ccl_program_destroy(CCLProgram *prg)
Decrements the reference count of the program wrapper object.
Device wrapper class.