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

Method setDevice

src/library/tools/ktest/config.cpp:281–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279}
280
281bool
282Config::setDevice(const std::string& name)
283{
284 cl_int err;
285 cl_uint nrDevices;
286 cl_device_id *devices;
287 bool found;
288 size_t sz;
289 char *dname;
290
291 if ((platform_ == NULL) && !setPlatform("")) {
292 return false;
293 }
294
295 err = clGetDeviceIDs(platform_, CL_DEVICE_TYPE_ALL, 0, NULL, &nrDevices);
296 if ((err != CL_SUCCESS) || (nrDevices == 0)) {
297 return false;
298 }
299 devices = new cl_device_id[nrDevices];
300 err = clGetDeviceIDs(platform_, CL_DEVICE_TYPE_ALL, nrDevices, devices, NULL);
301 if (err != CL_SUCCESS) {
302 delete[] devices;
303 return false;
304 }
305
306 found = false;
307 for (cl_uint i = 0; i < nrDevices; i++) {
308 err = clGetDeviceInfo(devices[i], CL_DEVICE_NAME, 0, NULL, &sz);
309 if (err != CL_SUCCESS) {
310 continue;
311 }
312 dname = new char[sz + 1];
313 err = clGetDeviceInfo(devices[i], CL_DEVICE_NAME, sz, dname, NULL);
314 if (err != CL_SUCCESS) {
315 delete[] dname;
316 continue;
317 }
318 if (name.empty()) {
319 found = true;
320 }
321 else {
322 found = (strcmp(dname, name.c_str()) == 0);
323 }
324 delete[] dname;
325 if (found) {
326 device_ = devices[i];
327 break;
328 }
329 }
330
331 delete[] devices;
332 return found;
333}
334
335void
336Config::setBuildOptions(const std::string& options)

Callers

nothing calls this directly

Calls 1

setPlatformFunction · 0.85

Tested by

no test coverage detected