MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / devprop

Function devprop

src/backend/opencl/platform.cpp:452–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

450}
451
452void devprop(char* d_name, char* d_platform, char* d_toolkit, char* d_compute) {
453 unsigned nDevices = 0;
454 auto currActiveDevId = static_cast<unsigned>(getActiveDeviceId());
455 bool devset = false;
456
457 DeviceManager& devMngr = DeviceManager::getInstance();
458
459 {
460 common::lock_guard_t lock(devMngr.deviceMutex);
461
462 for (auto& context : devMngr.mContexts) {
463 vector<Device> devices = context->getInfo<CL_CONTEXT_DEVICES>();
464
465 for (auto& device : devices) {
466 const Platform platform(device.getInfo<CL_DEVICE_PLATFORM>());
467 string platStr = platform.getInfo<CL_PLATFORM_NAME>();
468
469 if (currActiveDevId == nDevices) {
470 string dev_str;
471 device.getInfo(CL_DEVICE_NAME, &dev_str);
472 string com_str = device.getInfo<CL_DEVICE_VERSION>();
473 com_str = com_str.substr(7, 3);
474
475 // strip out whitespace from the device string:
476 const string& whitespace = " \t";
477 const auto strBegin = dev_str.find_first_not_of(whitespace);
478 const auto strEnd = dev_str.find_last_not_of(whitespace);
479 const auto strRange = strEnd - strBegin + 1;
480 dev_str = dev_str.substr(strBegin, strRange);
481
482 // copy to output
483 snprintf(d_name, 64, "%s", dev_str.c_str());
484 snprintf(d_platform, 10, "OpenCL");
485 snprintf(d_toolkit, 64, "%s", platStr.c_str());
486 snprintf(d_compute, 10, "%s", com_str.c_str());
487 devset = true;
488 }
489 if (devset) { break; }
490 nDevices++;
491 }
492 if (devset) { break; }
493 }
494 }
495
496 // Sanitize input
497 for (int i = 0; i < 31; i++) {
498 if (d_name[i] == ' ') {
499 if (d_name[i + 1] == 0 || d_name[i + 1] == ' ') {
500 d_name[i] = 0;
501 } else {
502 d_name[i] = '_';
503 }
504 }
505 }
506}
507
508int setDevice(int device) {
509 DeviceManager& devMngr = DeviceManager::getInstance();

Callers

nothing calls this directly

Calls 2

getActiveDeviceIdFunction · 0.70
getInfoMethod · 0.45

Tested by

no test coverage detected