29 #include "_ccl_abstract_dev_container_wrapper.h"
46 ccl_dev_container_get_cldevices get_devices,
CCLErr **err) {
49 g_return_if_fail(err == NULL || *err == NULL);
52 g_return_if_fail(devcon != NULL);
55 g_return_if_fail(devcon->devices == NULL);
58 CCLErr* err_internal = NULL;
61 info_devs = get_devices(devcon, &err_internal);
65 devcon->num_devices = (cl_uint) (info_devs->
size /
sizeof(cl_device_id));
68 devcon->devices = g_slice_alloc(
69 devcon->num_devices *
sizeof(
CCLDevice*));
72 for (guint i = 0; i < devcon->num_devices; ++i) {
76 ((cl_device_id*) info_devs->
value)[i]);
80 g_assert(err == NULL || *err == NULL);
85 g_assert(err == NULL || *err != NULL);
106 g_return_if_fail(devcon != NULL);
109 if (devcon->devices != NULL) {
112 for (guint i = 0; i < devcon->num_devices; ++i) {
113 if (devcon->devices[i])
118 g_slice_free1(devcon->num_devices *
sizeof(
CCLDevice*),
138 CCLDevice*
const* ccl_dev_container_get_all_devices(
140 ccl_dev_container_get_cldevices get_devices,
CCLErr** err) {
143 g_return_val_if_fail(err == NULL || *err == NULL, NULL);
146 g_return_val_if_fail(devcon != NULL, NULL);
149 if (devcon->devices == NULL) {
152 ccl_dev_container_init_devices(devcon, get_devices, err);
157 return (
CCLDevice*
const*) devcon->devices;
179 ccl_dev_container_get_cldevices get_devices, cl_uint index,
183 g_return_val_if_fail(err == NULL || *err == NULL, NULL);
186 g_return_val_if_fail(devcon != NULL, NULL);
192 CCLErr* err_internal = NULL;
195 if (devcon->devices == NULL) {
198 ccl_dev_container_init_devices(
199 devcon, get_devices, &err_internal);
209 "%s: device index (%d) out of bounds (%d devices in list).",
210 CCL_STRD, index, devcon->num_devices);
213 g_assert(err == NULL || *err == NULL);
214 device_ret = devcon->devices[index];
220 g_assert(err == NULL || *err != NULL);
244 cl_uint ccl_dev_container_get_num_devices(
246 ccl_dev_container_get_cldevices get_devices,
CCLErr** err) {
249 g_return_val_if_fail(devcon != NULL, 0);
252 g_return_val_if_fail(err == NULL || *err == NULL, 0);
255 if (devcon->devices == NULL) {
258 ccl_dev_container_init_devices(devcon, get_devices, err);
263 return devcon->num_devices;
#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...
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.
The requested OpenCL device was not found.
size_t size
Size in bytes of object information.
#define ccl_device_unref(dev)
Alias to ccl_device_destroy().
void * value
Object information.
Class which represents information about a wrapped OpenCL object.
GError CCLErr
Error handling class.
CCLDevice * ccl_device_new_wrap(cl_device_id device)
Get the device wrapper for the given OpenCL device.