| 296 | } |
| 297 | |
| 298 | cl_device_id |
| 299 | getDevice( |
| 300 | cl_platform_id platform, |
| 301 | const char *name) |
| 302 | { |
| 303 | |
| 304 | cl_int err; |
| 305 | cl_uint nrDevices, i; |
| 306 | cl_device_id *list, device; |
| 307 | char deviceName[64]; |
| 308 | |
| 309 | err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, 0, NULL, &nrDevices); |
| 310 | if (err != CL_SUCCESS) { |
| 311 | return NULL; |
| 312 | } |
| 313 | list = (cl_device_id*)calloc(nrDevices, sizeof(*list)); |
| 314 | if (list == NULL) { |
| 315 | return NULL; |
| 316 | } |
| 317 | |
| 318 | err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, nrDevices, list, NULL); |
| 319 | if (err != CL_SUCCESS) { |
| 320 | free(list); |
| 321 | return NULL; |
| 322 | } |
| 323 | |
| 324 | device = NULL; |
| 325 | for (i = 0; i < nrDevices; i++) { |
| 326 | err = clGetDeviceInfo(list[i], CL_DEVICE_NAME, |
| 327 | sizeof(deviceName), deviceName, NULL); |
| 328 | if ((err == CL_SUCCESS) && (strcmp(deviceName, name) == 0)) { |
| 329 | device = list[i]; |
| 330 | break; |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | free(list); |
| 335 | return device; |
| 336 | } |
no outgoing calls