31 #include "_ccl_abstract_wrapper.h"
32 #include "_ccl_abstract_dev_container_wrapper.h"
68 g_return_val_if_fail(err == NULL || *err == NULL, NULL);
71 g_return_val_if_fail(devcon != NULL, NULL);
78 ocl_status = clGetDeviceIDs(devcon->base.cl_object,
79 CL_DEVICE_TYPE_ALL, 0, NULL, &devcon->num_devices);
81 CL_SUCCESS != ocl_status, ocl_status, error_handler,
82 "%s: get number of devices (OpenCL error %d: %s).",
83 CCL_STRD, ocl_status,
ccl_err(ocl_status));
86 info = ccl_wrapper_info_new(
87 sizeof(cl_device_id) * devcon->num_devices);
90 ocl_status = clGetDeviceIDs(devcon->base.cl_object,
91 CL_DEVICE_TYPE_ALL, devcon->num_devices, info->
value, NULL);
93 CL_SUCCESS != ocl_status, ocl_status, error_handler,
94 "%s: get device IDs (OpenCL error %d: %s).",
95 CCL_STRD, ocl_status,
ccl_err(ocl_status));
101 ccl_wrapper_add_info(
102 (
CCLWrapper*) devcon, CL_CONTEXT_DEVICES, info);
105 g_assert(err == NULL || *err == NULL);
110 g_assert(err == NULL || *err != NULL);
113 if (info != NULL) ccl_wrapper_info_destroy(info);
167 g_return_val_if_fail(dev != NULL, NULL);
169 g_return_val_if_fail(err == NULL || *err == NULL, NULL);
172 cl_platform_id platform_id;
176 CCLErr* err_internal = NULL;
180 dev, CL_DEVICE_PLATFORM, cl_platform_id, &err_internal);
187 g_assert(err == NULL || *err == NULL);
192 g_assert(err == NULL || *err != NULL);
213 (ccl_wrapper_release_fields) ccl_dev_container_release_devices,
241 g_return_val_if_fail(platf != NULL, 0);
243 g_return_val_if_fail(err == NULL || *err == NULL, 0);
250 platf, CL_PLATFORM_VERSION, err);
252 if (ver_str != NULL) {
254 atoi(ver_str + 7) * 100 +
255 atoi(ver_str + 9) * 10;
278 return ccl_dev_container_get_all_devices(
299 ccl_platform_get_cldevices, index, err);
318 ccl_platform_get_cldevices, err);
#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.
#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...
Useful definitions used internally by cf4ocl.
#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...
const char * ccl_err(int code)
Convert OpenCL error code to a readable string.
Base class for wrappers which contain devices, i.e., CCLPlatform, CCLProgram and CCLContext.
Base class for all OpenCL wrappers.
CCLPlatform * ccl_platform_new_from_device(CCLDevice *dev, CCLErr **err)
Get the platform wrapper for the given device wrapper.
CCLPlatform * ccl_platform_new_wrap(cl_platform_id platform)
Get the platform wrapper for the given OpenCL platform.
CCLDevice *const * ccl_platform_get_all_devices(CCLPlatform *platf, CCLErr **err)
Get all device wrappers in platform.
#define ccl_device_get_info_scalar(dev, param_name, param_type, err)
Macro which returns a scalar device information value.
void * value
Object information.
cl_uint ccl_platform_get_num_devices(CCLPlatform *platf, CCLErr **err)
Return number of devices in platform.
void ccl_platform_destroy(CCLPlatform *platf)
Decrements the reference count of the platform wrapper object.
Class which represents information about a wrapped OpenCL object.
GError CCLErr
Error handling class.
CCLDevice * ccl_platform_get_device(CCLPlatform *platf, cl_uint index, CCLErr **err)
Get CCLDevice wrapper at given index.
cl_uint ccl_platform_get_opencl_version(CCLPlatform *platf, CCLErr **err)
Get the OpenCL version of this platform.