30 #include "_ccl_abstract_dev_container_wrapper.h"
34 #define CCL_VALIDFILECHARS "abcdefghijklmnopqrstuvwxyzABCDEFGH" \
35 "IJKLMNOPQRSTUVWXYZ0123456789_."
66 GHashTable* build_logs;
72 gchar* build_logs_concat;
103 static void ccl_program_clear_build_logs(
CCLProgram* prg) {
106 g_return_if_fail(prg != NULL);
109 if (prg->build_logs != NULL) {
112 g_hash_table_destroy(prg->build_logs);
115 prg->build_logs = NULL;
129 static void ccl_program_release_fields(
CCLProgram* prg) {
132 g_return_if_fail(prg != NULL);
138 if (prg->krnls != NULL) {
144 g_hash_table_destroy(prg->krnls);
149 if (prg->binaries != NULL) {
152 g_hash_table_destroy(prg->binaries);
157 ccl_program_clear_build_logs(prg);
160 if (prg->build_logs_concat != NULL) {
163 g_free(prg->build_logs_concat);
199 unsigned char* data,
size_t size) {
221 g_return_if_fail(pbin != NULL);
235 #define ccl_program_binary_new_empty() ccl_program_binary_new(NULL, 0)
279 (ccl_wrapper_release_fields) ccl_program_release_fields,
280 (ccl_wrapper_release_cl_object) clReleaseProgram, NULL);
299 const char* filename,
CCLErr** err) {
321 cl_uint count,
const char** filenames,
CCLErr** err) {
324 g_return_val_if_fail(ctx != NULL, NULL);
326 g_return_val_if_fail(err == NULL || *err == NULL, NULL);
328 g_return_val_if_fail(filenames != NULL, NULL);
330 g_return_val_if_fail(count > 0, NULL);
333 CCLErr* err_internal = NULL;
337 gchar** strings = NULL;
341 strings = g_slice_alloc0(count *
sizeof(gchar*));
344 for (cl_uint i = 0; i < count; ++i) {
347 filenames[i], &strings[i], NULL, &err_internal);
354 (
const char**) strings, NULL, &err_internal);
358 g_assert(err == NULL || *err == NULL);
364 g_assert(err == NULL || *err != NULL);
369 if (strings != NULL) {
370 for (cl_uint i = 0; i < count; ++i) {
371 if (strings[i] != NULL) {
375 g_slice_free1(count *
sizeof(gchar*), strings);
399 const char*
string,
CCLErr** err) {
424 cl_uint count,
const char** strings,
const size_t* lengths,
428 g_return_val_if_fail(ctx != NULL, NULL);
430 g_return_val_if_fail(err == NULL || *err == NULL, NULL);
433 cl_program program = NULL;
437 program = clCreateProgramWithSource(
440 CL_SUCCESS != ocl_status, ocl_status, error_handler,
441 "%s: unable to create cl_program with source (OpenCL error %d: %s).",
442 CCL_STRD, ocl_status,
ccl_err(ocl_status));
448 g_assert(err == NULL || *err == NULL);
454 g_assert(err == NULL || *err != NULL);
483 CCLDevice* dev,
const char* filename, cl_int *binary_status,
487 ctx, 1, &(dev), &(filename), binary_status, err);
511 cl_uint num_devices,
CCLDevice*
const* devs,
const char** filenames,
512 cl_int *binary_status,
CCLErr** err) {
515 g_return_val_if_fail(err == NULL || *err == NULL, NULL);
517 g_return_val_if_fail(ctx != NULL, NULL);
519 g_return_val_if_fail(devs != NULL, NULL);
521 g_return_val_if_fail(filenames != NULL, NULL);
523 g_return_val_if_fail(num_devices > 0, NULL);
525 CCLErr* err_internal = NULL;
531 for (cl_uint i = 0; i < num_devices; ++i) {
532 bins[i] = ccl_program_binary_new_empty();
533 g_file_get_contents(filenames[i], (
char**) &bins[i]->data,
534 &bins[i]->size, &err_internal);
540 ctx, num_devices, devs, bins, binary_status, &err_internal);
544 g_assert(err == NULL || *err == NULL);
550 g_assert(err == NULL || *err != NULL);
556 for (cl_uint i = 0; i < num_devices; ++i) {
557 if (bins[i] != NULL) {
558 ccl_program_binary_destroy(bins[i]);
617 cl_int *binary_status,
CCLErr** err) {
620 g_return_val_if_fail(err == NULL || *err == NULL, NULL);
622 g_return_val_if_fail(ctx != NULL, NULL);
624 g_return_val_if_fail(devs != NULL, NULL);
626 g_return_val_if_fail(num_devices > 0, NULL);
630 cl_program program = NULL;
631 cl_device_id* device_list = NULL;
632 size_t* lengths = NULL;
633 unsigned char** bins_raw = NULL;
636 device_list = g_slice_alloc(num_devices *
sizeof(cl_device_id));
637 lengths = g_slice_alloc(num_devices *
sizeof(
size_t));
638 bins_raw = g_slice_alloc(num_devices *
sizeof(
unsigned char*));
639 for (guint i = 0; i < num_devices; ++i) {
641 lengths[i] = bins[i]->size;
642 bins_raw[i] = (
unsigned char*) bins[i]->data;
647 num_devices, device_list, lengths,
648 (
const unsigned char**) bins_raw,
649 binary_status, &ocl_status);
651 CL_SUCCESS != ocl_status, ocl_status, error_handler,
652 "%s: unable to create cl_program from binaries (OpenCL error %d: %s).",
653 CCL_STRD, ocl_status,
ccl_err(ocl_status));
659 g_assert(err == NULL || *err == NULL);
665 g_assert(err == NULL || *err != NULL);
670 if (device_list != NULL)
671 g_slice_free1(num_devices *
sizeof(cl_device_id), device_list);
673 g_slice_free1(num_devices *
sizeof(
size_t), lengths);
674 if (bins_raw != NULL)
675 g_slice_free1(num_devices *
sizeof(
unsigned char*), bins_raw);
702 cl_uint num_devices,
CCLDevice*
const* devs,
const char *kernel_names,
706 g_return_val_if_fail(ctx != NULL, NULL);
708 g_return_val_if_fail(err == NULL || *err == NULL, NULL);
710 g_return_val_if_fail(num_devices > 0, NULL);
715 cl_program program = NULL;
719 cl_device_id* device_list = NULL;
723 CCLErr* err_internal = NULL;
725 #ifndef CL_VERSION_1_2
739 "%s: Program creation from built-in kernels requires cf4ocl to be "
740 "deployed with support for OpenCL version 1.2 or newer.",
752 "%s: Program creation with built-in kernels requires OpenCL " \
753 "version 1.2 or newer.", CCL_STRD);
756 device_list = g_slice_alloc(num_devices *
sizeof(cl_device_id));
757 for (guint i = 0; i < num_devices; ++i) {
762 program = clCreateProgramWithBuiltInKernels(
768 CL_SUCCESS != ocl_status, ocl_status, error_handler,
769 "%s: unable to create cl_program from built-in kernels "
770 "(OpenCL error %d: %s).",
771 CCL_STRD, ocl_status,
ccl_err(ocl_status));
779 g_assert(err == NULL || *err == NULL);
785 g_assert(err == NULL || *err != NULL);
790 if (device_list != NULL)
791 g_slice_free1(num_devices *
sizeof(cl_device_id), device_list);
822 prg, 0, NULL, options, NULL, NULL, err);
851 cl_uint num_devices,
CCLDevice*
const* devs,
const char *options,
855 g_return_val_if_fail(prg != NULL, CL_FALSE);
857 g_return_val_if_fail(err == NULL || *err == NULL, CL_FALSE);
860 cl_device_id* cl_devices = NULL;
867 ccl_program_clear_build_logs(prg);
870 if ((devs != NULL) && (num_devices > 0)) {
871 cl_devices = g_slice_alloc0(
sizeof(cl_device_id) * num_devices);
873 for (guint i = 0; i < num_devices; ++i)
879 num_devices, cl_devices, options, pfn_notify, user_data);
883 CL_SUCCESS != ocl_status, ocl_status, error_handler,
884 "%s: unable to build program (OpenCL error %d: %s).",
885 CCL_STRD, ocl_status,
ccl_err(ocl_status));
888 g_assert(err == NULL || *err == NULL);
895 g_assert(err == NULL || *err != NULL);
903 if (cl_devices != NULL) {
904 g_slice_free1(
sizeof(cl_device_id) * num_devices, cl_devices);
931 g_return_val_if_fail(prg != NULL, NULL);
933 g_return_val_if_fail((err) == NULL || *(err) == NULL, NULL);
938 cl_uint num_devs = 0;
944 const char* build_log;
946 CCLErr* err_internal = NULL;
949 GString* build_log_obj = g_string_new(
"");
952 if (prg->build_logs_concat) {
953 g_free(prg->build_logs_concat);
954 prg->build_logs_concat = NULL;
962 for (i = 0; i < num_devs; i++) {
973 dev, CL_DEVICE_NAME,
char*, &err_internal);
978 prg, dev, &err_internal);
982 g_string_append_printf(build_log_obj,
"\n### Build log "
983 "for device '%s'\n\n%s\n\n", dev_name,
984 build_log != NULL ? build_log :
"Not available");
989 prg->build_logs_concat = build_log_obj->str;
992 g_string_free(build_log_obj, FALSE);
995 g_assert(err == NULL || *err == NULL);
1001 g_assert(err == NULL || *err != NULL);
1006 return (
const char*) prg->build_logs_concat;
1026 g_return_val_if_fail(prg != NULL, NULL);
1028 g_return_val_if_fail(dev != NULL, NULL);
1030 g_return_val_if_fail(err == NULL || *err == NULL, NULL);
1033 char* build_log_dev = NULL;
1035 CCLErr* err_internal = NULL;
1038 if ((prg->build_logs == NULL) || ((build_log_dev = (
char*)
1039 g_hash_table_lookup(prg->build_logs, (gconstpointer) dev)) == NULL)) {
1043 prg, dev, CL_PROGRAM_BUILD_LOG,
char*, &err_internal);
1047 if ((build_log_dev != NULL) && (strlen(build_log_dev) > 0)) {
1051 if (!prg->build_logs) {
1052 prg->build_logs = g_hash_table_new(
1053 g_direct_hash, g_direct_equal);
1058 g_hash_table_insert(prg->build_logs,
1060 (gpointer) build_log_dev);
1066 g_assert(err == NULL || *err == NULL);
1072 g_assert(err == NULL || *err != NULL);
1077 return build_log_dev;
1116 CCLDevice*
const* devs,
const char* options, cl_uint num_input_headers,
1117 CCLProgram** prg_input_headers,
const char** header_include_names,
1121 g_return_val_if_fail(prg != NULL, CL_FALSE);
1123 g_return_val_if_fail(err == NULL || *err == NULL, CL_FALSE);
1126 cl_device_id* cl_devices = NULL;
1128 cl_program* input_headers = NULL;
1136 CCLErr* err_internal = NULL;
1138 #ifndef CL_VERSION_1_2
1155 "%s: Program compilation requires cf4ocl to be deployed with support "
1156 "for OpenCL version 1.2 or newer.",
1168 "%s: Program compilation requires OpenCL version 1.2 or newer.",
1172 ccl_program_clear_build_logs(prg);
1175 if ((devs != NULL) && (num_devices > 0)) {
1176 cl_devices = g_slice_alloc0(
sizeof(cl_device_id) * num_devices);
1178 for (guint i = 0; i < num_devices; ++i)
1183 if ((prg_input_headers != NULL) && (num_input_headers > 0)) {
1185 g_slice_alloc0(
sizeof(cl_program) * num_input_headers);
1187 for (guint i = 0; i < num_input_headers; ++i)
1193 (
const cl_device_id*) cl_devices, options, num_input_headers,
1194 (
const cl_program*) input_headers, header_include_names,
1195 pfn_notify, user_data);
1199 CL_SUCCESS != ocl_status, ocl_status, error_handler,
1200 "%s: unable to compile program (OpenCL error %d: %s).",
1201 CCL_STRD, ocl_status,
ccl_err(ocl_status));
1206 g_assert(err == NULL || *err == NULL);
1213 g_assert(err == NULL || *err != NULL);
1221 if (cl_devices != NULL) {
1222 g_slice_free1(
sizeof(cl_device_id) * num_devices, cl_devices);
1225 if (input_headers != NULL) {
1227 sizeof(cl_program) * num_input_headers, input_headers);
1267 CCLDevice*
const* devs,
const char* options, cl_uint num_input_programs,
1269 void* user_data,
CCLErr** err) {
1272 g_return_val_if_fail(ctx != NULL, CL_FALSE);
1274 g_return_val_if_fail(err == NULL || *err == NULL, CL_FALSE);
1277 cl_device_id* cl_devices = NULL;
1279 cl_program* input_programs = NULL;
1285 cl_program program = NULL;
1289 CCLErr* err_internal = NULL;
1291 #ifndef CL_VERSION_1_2
1308 "%s: Program linking requires cf4ocl to be deployed with support "
1309 "for OpenCL version 1.2 or newer.",
1321 "%s: Program linking requires OpenCL version 1.2 or newer.",
1325 if ((devs != NULL) && (num_devices > 0)) {
1326 cl_devices = g_slice_alloc0(
sizeof(cl_device_id) * num_devices);
1328 for (guint i = 0; i < num_devices; ++i)
1333 if ((input_prgs != NULL) && (num_input_programs > 0)) {
1335 g_slice_alloc0(
sizeof(cl_program) * num_input_programs);
1337 for (guint i = 0; i < num_input_programs; ++i)
1343 (
const cl_device_id*) cl_devices, options, num_input_programs,
1344 (
const cl_program*) input_programs, pfn_notify, user_data,
1349 CL_SUCCESS != ocl_status, ocl_status, error_handler,
1350 "%s: unable to link program (OpenCL error %d: %s).",
1351 CCL_STRD, ocl_status,
ccl_err(ocl_status));
1359 g_assert(err == NULL || *err == NULL);
1365 g_assert(err == NULL || *err != NULL);
1370 if (cl_devices != NULL) {
1371 g_slice_free1(
sizeof(cl_device_id) * num_devices, cl_devices);
1374 if (input_programs != NULL) {
1376 sizeof(cl_program) * num_input_programs, input_programs);
1407 g_return_val_if_fail(prg != NULL, 0);
1409 g_return_val_if_fail(err == NULL || *err == NULL, 0);
1413 CCLErr* err_internal = NULL;
1418 prg, CL_PROGRAM_CONTEXT, cl_context, &err_internal);
1432 g_assert(err == NULL || *err == NULL);
1438 g_assert(err == NULL || *err != NULL);
1474 g_return_val_if_fail((err) == NULL || *(err) == NULL, NULL);
1476 g_return_val_if_fail(prg != NULL, NULL);
1478 g_return_val_if_fail(kernel_name != NULL, NULL);
1481 CCLErr* err_internal = NULL;
1487 if (prg->krnls == NULL) {
1488 prg->krnls = g_hash_table_new_full(g_str_hash, g_str_equal,
1494 if (g_hash_table_contains(
1495 prg->krnls, kernel_name)) {
1498 krnl = g_hash_table_lookup(
1499 prg->krnls, kernel_name);
1508 g_hash_table_insert(prg->krnls, (gpointer) kernel_name, krnl);
1513 g_assert(err == NULL || *err == NULL);
1519 g_assert(err == NULL || *err != NULL);
1573 const char* kernel_name,
CCLQueue* cq, cl_uint work_dim,
1574 const size_t* global_work_offset,
const size_t* global_work_size,
1583 void** args_array = NULL;
1590 va_start(args_va, err);
1593 aux_arg = va_arg(args_va,
void*);
1597 if (aux_arg != NULL) {
1601 while (aux_arg != NULL) {
1603 aux_arg = va_arg(args_va,
void*);
1609 args_array = g_slice_alloc((num_args + 1) *
sizeof(
void*));
1610 va_start(args_va, err);
1612 for (guint i = 0; i < num_args; ++i) {
1613 aux_arg = va_arg(args_va,
void*);
1614 args_array[i] = aux_arg;
1617 args_array[num_args] = NULL;
1624 global_work_offset, global_work_size, local_work_size,
1625 evt_wait_lst, args_array, err);
1631 g_slice_free1((num_args + 1) *
sizeof(
void*), args_array);
1684 const char* kernel_name,
CCLQueue* cq, cl_uint work_dim,
1685 const size_t* global_work_offset,
const size_t* global_work_size,
1687 void** args,
CCLErr** err) {
1690 g_return_val_if_fail((err) == NULL || *(err) == NULL, NULL);
1696 if (krnl == NULL)
return NULL;
1699 global_work_offset, global_work_size, local_work_size,
1700 evt_wait_lst, args, err);
1718 g_return_if_fail((err) == NULL || *(err) == NULL);
1721 g_return_if_fail(prg != NULL);
1724 g_return_if_fail(prg->binaries != NULL);
1726 cl_uint num_devices;
1727 cl_device_id* devices;
1728 size_t* binary_sizes;
1730 unsigned char** bins_raw;
1731 CCLErr* err_internal = NULL;
1737 num_devices = *((cl_uint*) info->
value);
1742 devices = (cl_device_id*) info->
value;
1747 binary_sizes = (
size_t*) info->
value;
1750 bins_raw = g_slice_alloc0(num_devices *
sizeof(
unsigned char*));
1751 for (guint i = 0; i < num_devices; i++) {
1752 if (binary_sizes[i] > 0) {
1753 bins_raw[i] = g_malloc(binary_sizes[i]);
1759 CL_PROGRAM_BINARIES, num_devices *
sizeof(
unsigned char*),
1762 CL_SUCCESS != ocl_status, ocl_status, error_handler,
1763 "%s: unable to get binaries from program (OpenCL error %d: %s).",
1764 CCL_STRD, ocl_status,
ccl_err(ocl_status));
1768 for (guint i = 0; i < num_devices; ++i) {
1771 bin->size = binary_sizes[i];
1772 bin->data = bins_raw[i];
1774 g_hash_table_replace(prg->binaries, devices[i], bin);
1778 g_slice_free1(num_devices *
sizeof(
unsigned char*), bins_raw);
1781 g_assert(err == NULL || *err == NULL);
1787 g_assert(err == NULL || *err != NULL);
1810 g_return_val_if_fail((err) == NULL || *(err) == NULL, NULL);
1812 g_return_val_if_fail(prg != NULL, NULL);
1814 g_return_val_if_fail(dev != NULL, NULL);
1817 CCLErr* err_internal = NULL;
1822 if (prg->binaries == NULL) {
1825 prg->binaries = g_hash_table_new_full(
1826 g_direct_hash, g_direct_equal, NULL,
1827 (GDestroyNotify) ccl_program_binary_destroy);
1830 ccl_program_load_binaries(prg, &err_internal);
1838 binary = g_hash_table_lookup(
1843 ccl_program_load_binaries(prg, &err_internal);
1848 binary = g_hash_table_lookup(
1856 error_handler,
"%s: device is not part of program devices.",
1861 g_assert(err == NULL || *err == NULL);
1867 g_assert(err == NULL || *err != NULL);
1891 const char* filename,
CCLErr** err) {
1894 g_return_val_if_fail((err) == NULL || *(err) == NULL, CL_FALSE);
1896 g_return_val_if_fail(prg != NULL, CL_FALSE);
1898 g_return_val_if_fail(filename != NULL, CL_FALSE);
1903 CCLErr* err_internal = NULL;
1914 "%s: binary for given device has size 0.", CCL_STRD);
1917 g_file_set_contents(filename, (
const gchar*) binary->data,
1918 binary->size, &err_internal);
1922 g_assert(err == NULL || *err == NULL);
1929 g_assert(err == NULL || *err != NULL);
1973 const char* file_prefix,
const char* file_suffix,
char*** filenames,
1977 g_return_val_if_fail((err) == NULL || *(err) == NULL, CL_FALSE);
1979 g_return_val_if_fail(prg != NULL, CL_FALSE);
1981 g_return_val_if_fail(
1982 (file_prefix != NULL) && (file_suffix != NULL), CL_FALSE);
1985 CCLErr* err_internal = NULL;
1996 if (filenames != NULL)
1997 *filenames = g_malloc((num_devices + 1) *
sizeof(
char**));
2001 for (guint i = 0; i < num_devices; ++i) {
2008 gchar* file_middle = NULL;
2017 file_middle = g_strdup(
2019 dev, CL_DEVICE_NAME,
char*, &err_internal));
2022 g_strcanon(file_middle, CCL_VALIDFILECHARS,
'_');
2025 filename = g_strdup_printf(
"%s%s_%02d%s",
2026 file_prefix, file_middle, i, file_suffix);
2034 if (filenames != NULL) {
2035 (*filenames)[i] = filename;
2041 g_free(file_middle);
2046 if (filenames != NULL)
2047 (*filenames)[num_devices] = NULL;
2050 g_assert(err == NULL || *err == NULL);
2057 g_assert(err == NULL || *err != NULL);
2084 return ccl_dev_container_get_device(
2102 return ccl_dev_container_get_num_devices(
2127 ccl_program_get_cldevices, err);
void ccl_kernel_destroy(CCLKernel *krnl)
Decrements the reference count of the kernel wrapper object.
Invalid data passed to a function or returned from function.
CCLEvent * ccl_kernel_set_args_and_enqueue_ndrange_v(CCLKernel *krnl, CCLQueue *cq, cl_uint work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, CCLEventWaitList *evt_wait_lst, void **args, CCLErr **err)
Set kernel arguments and enqueue it for execution on a device.
#define CCL_OCL_ERROR
Resolves to error category identifying string, in this case an error in the OpenCL library...
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.
CCLDevice *const * ccl_program_get_all_devices(CCLProgram *prg, CCLErr **err)
Get all device wrappers in program.
CCLEvent * ccl_program_enqueue_kernel(CCLProgram *prg, const char *kernel_name, CCLQueue *cq, cl_uint work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, CCLEventWaitList *evt_wait_lst, CCLErr **err,...)
Enqueues a program kernel function for execution on a device.
CCLEvent * ccl_program_enqueue_kernel_v(CCLProgram *prg, const char *kernel_name, CCLQueue *cq, cl_uint work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, CCLEventWaitList *evt_wait_lst, void **args, CCLErr **err)
Enqueues a program kernel function for execution on a device.
#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...
#define ccl_context_unwrap(ctx)
Get the OpenCL context object.
GPtrArray * CCLEventWaitList
A list of event objects on which enqueued commands can wait.
Useful definitions used internally by cf4ocl.
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...
CCLProgram * ccl_program_new_from_built_in_kernels(CCLContext *ctx, cl_uint num_devices, CCLDevice *const *devs, const char *kernel_names, CCLErr **err)
Create a new program wrapper object from device built-in kernels.
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...
CCLProgram * ccl_program_new_from_source(CCLContext *ctx, const char *string, CCLErr **err)
Create a new program wrapper object from a null-terminated source string.
Command queue wrapper class.
const char * ccl_err(int code)
Convert OpenCL error code to a readable string.
CCLContext * ccl_context_new_wrap(cl_context context)
Get the context wrapper for the given OpenCL context.
cl_uint ccl_context_get_opencl_version(CCLContext *ctx, CCLErr **err)
Get the OpenCL version of the platform associated with this context.
cl_uint ccl_program_get_opencl_version(CCLProgram *prg, CCLErr **err)
Get the OpenCL version of the platform associated with this program.
CCLProgram * ccl_program_new_wrap(cl_program program)
Get the program wrapper for the given OpenCL program.
CCLProgramBinary * ccl_program_get_binary(CCLProgram *prg, CCLDevice *dev, CCLErr **err)
Get the program binary object for the specified device.
CCLProgram * ccl_program_new_from_binaries(CCLContext *ctx, cl_uint num_devices, CCLDevice *const *devs, CCLProgramBinary **bins, cl_int *binary_status, CCLErr **err)
Create a new program wrapper object from a list of binary code strings executable on the given device...
Base class for wrappers which contain devices, i.e., CCLPlatform, CCLProgram and CCLContext.
#define CCL_ERROR
Resolves to error category identifying string, in this case an error in cf4ocl.
#define ccl_program_get_info(prg, param_name, err)
Get a CCLWrapperInfo program information object.
The requested OpenCL device was not found.
Definition of a wrapper class and its methods for OpenCL program objects.
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...
Base class for all OpenCL wrappers.
cl_bool ccl_program_save_all_binaries(CCLProgram *prg, const char *file_prefix, const char *file_suffix, char ***filenames, CCLErr **err)
Save the program binaries for all associated devices to files, one file per device.
#define ccl_device_unwrap(dev)
Get the OpenCL device_id object.
#define ccl_context_unref(ctx)
Alias to ccl_context_destroy().
#define CCL_UNUSED(x)
Macro to avoid warning in unused variables.
#define ccl_device_get_info_array(dev, param_name, param_type, err)
Macro which returns an array device information value.
const char * ccl_program_get_build_log(CCLProgram *prg, CCLErr **err)
Get a general build log of most recent build, compile or link, for all devices.
CCLProgram * ccl_program_new_from_source_file(CCLContext *ctx, const char *filename, CCLErr **err)
Create a new program wrapper object from a source file.
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 * value
Object information.
CCLProgram * ccl_program_new_from_binary(CCLContext *ctx, CCLDevice *dev, CCLProgramBinary *binary, cl_int *binary_status, CCLErr **err)
Create a new program wrapper object from binary code executable on a specific device.
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.
void(* ccl_program_callback)(cl_program program, void *user_data)
Prototype of callback functions for program build, compile and link.
CCLProgram * ccl_program_new_from_binary_files(CCLContext *ctx, cl_uint num_devices, CCLDevice *const *devs, const char **filenames, cl_int *binary_status, CCLErr **err)
Create a new program wrapper object from files containing binary code executable on the given device ...
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.
Class which represents information about a wrapped OpenCL object.
#define ccl_program_unwrap(prg)
Get the OpenCL program object.
#define ccl_program_get_build_info_array(prg, dev, param_name, param_type, err)
Macro which returns an array program build information value.
GError CCLErr
Error handling class.
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.
CCLDevice * ccl_program_get_device(CCLProgram *prg, cl_uint index, CCLErr **err)
Get CCLDevice wrapper at given index.
CCLKernel * ccl_program_get_kernel(CCLProgram *prg, const char *kernel_name, CCLErr **err)
Get the kernel wrapper object for the given program kernel function.
cl_bool ccl_program_build_full(CCLProgram *prg, cl_uint num_devices, CCLDevice *const *devs, const char *options, ccl_program_callback pfn_notify, void *user_data, CCLErr **err)
Builds (compiles and links) a program executable from the program source or binary.
void ccl_program_destroy(CCLProgram *prg)
Decrements the reference count of the program wrapper object.
Class which represents a binary object associated with a program and a device.
CCLProgram * ccl_program_new_from_sources(CCLContext *ctx, cl_uint count, const char **strings, const size_t *lengths, CCLErr **err)
Create a new program wrapper object from several source code strings.
#define ccl_program_get_info_scalar(prg, param_name, param_type, err)
Macro which returns a scalar program information value.
The operation is not supported by the version of the selected OpenCL platform.
cl_uint ccl_program_get_num_devices(CCLProgram *prg, CCLErr **err)
Return number of devices in program.
CCLKernel * ccl_kernel_new(CCLProgram *prg, const char *kernel_name, CCLErr **err)
Create a new kernel wrapper object.