33 #include "_ccl_abstract_wrapper.h"
54 GSList* subdev_arrays;
69 static void ccl_device_release_subdev_arrays(gpointer data) {
72 g_return_if_fail(data != NULL);
78 for (cl_uint i = 0; subdevs[i] != NULL; ++i)
94 static void ccl_device_release_fields(
CCLDevice* dev) {
97 g_return_if_fail(dev != NULL);
100 g_slist_free_full(dev->subdev_arrays,
101 ccl_device_release_subdev_arrays);
147 #ifdef CL_VERSION_1_2
157 (ccl_wrapper_release_fields) ccl_device_release_fields,
158 (ccl_wrapper_release_cl_object) clReleaseDevice, NULL);
196 g_return_val_if_fail(dev != NULL, 0);
198 g_return_val_if_fail(err == NULL || *err == NULL, 0);
205 dev, CL_DEVICE_VERSION,
char*, err);
207 if (ver_str != NULL) {
209 atoi(ver_str + 7) * 100 +
210 atoi(ver_str + 9) * 10;
237 g_return_val_if_fail(dev != NULL, 0);
239 g_return_val_if_fail(err == NULL || *err == NULL, 0);
246 dev, CL_DEVICE_OPENCL_C_VERSION,
char*, err);
248 if (ver_str != NULL) {
250 atoi(ver_str + 9) * 100 +
251 atoi(ver_str + 11) * 10;
279 const cl_device_partition_property *properties,
280 cl_uint *num_devs_ret,
CCLErr** err) {
283 g_return_val_if_fail(dev != NULL, NULL);
290 void** subdevs = NULL;
292 #ifndef CL_VERSION_1_2
302 "%s: Sub-device creation requires cf4ocl to be deployed with "
303 "support for OpenCL version 1.2 or newer.",
309 ocl_status = clCreateSubDevices(
312 CL_SUCCESS != ocl_status, ocl_status, error_handler,
313 "%s: unable to determine how many sub-devices can be created " \
314 "(OpenCL error %d: %s).",
315 CCL_STRD, ocl_status,
ccl_err(ocl_status));
319 subdevs = g_new0(
void*, num_devs + 1);
322 ocl_status = clCreateSubDevices(
324 (cl_device_id*) subdevs, NULL);
326 CL_SUCCESS != ocl_status, ocl_status, error_handler,
327 "%s: unable to create sub-devices (OpenCL error %d: %s).",
328 CCL_STRD, ocl_status,
ccl_err(ocl_status));
331 for (cl_uint i = 0; subdevs[i] != NULL; ++i)
335 if (num_devs_ret != NULL) *num_devs_ret = num_devs;
338 dev->subdev_arrays = g_slist_prepend(dev->subdev_arrays, subdevs);
343 g_assert(err == NULL || *err == NULL);
348 g_assert(err == NULL || *err != NULL);
351 if (num_devs_ret != NULL) *num_devs_ret = 0;
352 if (subdevs != NULL) g_free(subdevs);
#define CCL_OCL_ERROR
Resolves to error category identifying string, in this case an error in the OpenCL library...
Definition of a wrapper class and its methods for OpenCL device objects.
#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.
const char * ccl_err(int code)
Convert OpenCL error code to a readable string.
#define CCL_ERROR
Resolves to error category identifying string, in this case an error in cf4ocl.
Base class for all OpenCL wrappers.
#define ccl_device_unwrap(dev)
Get the OpenCL device_id object.
void ccl_device_destroy(CCLDevice *dev)
Decrements the reference count of the device wrapper object.
#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.
CCLDevice *const * ccl_device_create_subdevices(CCLDevice *dev, const cl_device_partition_property *properties, cl_uint *num_devs_ret, CCLErr **err)
Creates a NULL-terminated array of sub-devices that each reference a non-intersecting set of compute ...
cl_uint ccl_device_get_opencl_c_version(CCLDevice *dev, CCLErr **err)
Get the OpenCL C version supported by the device.
GError CCLErr
Error handling class.
cl_uint ccl_device_get_opencl_version(CCLDevice *dev, CCLErr **err)
Get the OpenCL version supported by the device.
The operation is not supported by the version of the selected OpenCL platform.
CCLDevice * ccl_device_new_wrap(cl_device_id device)
Get the device wrapper for the given OpenCL device.