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

Method DeviceManager

src/backend/cuda/device_manager.cpp:574–689  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

572}
573
574DeviceManager::DeviceManager()
575 : logger(common::loggerFactory("platform"))
576 , cuDevices(0)
577 , nDevices(0)
578 , fgMngr(new arrayfire::common::ForgeManager()) {
579 try {
580 checkCudaVsDriverVersion();
581
582 CUDA_CHECK(cudaGetDeviceCount(&nDevices));
583 AF_TRACE("Found {} CUDA devices", nDevices);
584 if (nDevices == 0) {
585 AF_ERROR("No CUDA capable devices found", AF_ERR_DRIVER);
586 return;
587 }
588 cuDevices.reserve(nDevices);
589
590 int cudaRtVer = 0;
591 CUDA_CHECK(cudaRuntimeGetVersion(&cudaRtVer));
592 int cudaMajorVer = cudaRtVer / 1000;
593
594 for (int i = 0; i < nDevices; i++) {
595 cudaDevice_t dev{};
596 CUDA_CHECK(cudaGetDeviceProperties(&dev.prop, i));
597 if (dev.prop.major < getMinSupportedCompute(cudaMajorVer)) {
598 AF_TRACE("Unsuppored device: {}", dev.prop.name);
599 continue;
600 } else {
601 dev.flops = static_cast<size_t>(dev.prop.multiProcessorCount) *
602 compute2cores(dev.prop.major, dev.prop.minor) *
603 dev.prop.clockRate;
604 dev.nativeId = i;
605 AF_TRACE(
606 "Found device: {} (sm_{}{}) ({:0.3} GB | ~{} GFLOPs | {} "
607 "SMs)",
608 dev.prop.name, dev.prop.major, dev.prop.minor,
609 dev.prop.totalGlobalMem / 1024. / 1024. / 1024.,
610 dev.flops / 1024. / 1024. * 2,
611 dev.prop.multiProcessorCount);
612 cuDevices.push_back(dev);
613 }
614 }
615 } catch (const AfError &err) {
616 // If one of the CUDA functions threw an exception. catch it and wrap it
617 // into a more informative ArrayFire exception.
618 if (err.getError() == AF_ERR_INTERNAL) {
619 AF_ERROR(
620 "Error initializing CUDA runtime. Check your CUDA device is "
621 "visible to the OS and you have installed the correct driver. "
622 "Try running the nvidia-smi utility to debug any driver "
623 "issues.",
624 AF_ERR_RUNTIME);
625 } else {
626 throw;
627 }
628 }
629 nDevices = cuDevices.size();
630
631 sortDevices();

Callers

nothing calls this directly

Calls 9

loggerFactoryFunction · 0.85
getMinSupportedComputeFunction · 0.85
compute2coresFunction · 0.85
checkAndSetDevMaxComputeFunction · 0.85
getEnvVarFunction · 0.85
initNvrtcFunction · 0.85
getErrorMethod · 0.80
getLoggerFunction · 0.70
getActiveDeviceIdFunction · 0.70

Tested by

no test coverage detected