MCPcopy Create free account
hub / github.com/clMathLibraries/clBLAS / getDevice

Function getDevice

src/library/tools/ktest/main.cpp:298–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296}
297
298cl_device_id
299getDevice(
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}

Callers 3

getMasterStepFunction · 0.70
auxFunctionsMethod · 0.70
SetUpMethod · 0.50

Calls

no outgoing calls

Tested by 2

auxFunctionsMethod · 0.56
SetUpMethod · 0.40