| 76 | } |
| 77 | |
| 78 | std::vector<Ref<PhysicalDevice>> CUDADevice::getPhysicalDevices() |
| 79 | { |
| 80 | int numDevices = 0; |
| 81 | if (cudaGetDeviceCount(&numDevices) != cudaSuccess) |
| 82 | return {}; |
| 83 | |
| 84 | std::vector<Ref<PhysicalDevice>> devices; |
| 85 | for (int deviceID = 0; deviceID < numDevices; ++deviceID) |
| 86 | { |
| 87 | cudaDeviceProp prop{}; |
| 88 | if (cudaGetDeviceProperties(&prop, deviceID) != cudaSuccess) |
| 89 | continue; |
| 90 | |
| 91 | if (isSupported(prop)) |
| 92 | { |
| 93 | int score = (19 << 16) - 1 - deviceID; |
| 94 | devices.push_back(makeRef<CUDAPhysicalDevice>(deviceID, prop, score)); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | return devices; |
| 99 | } |
| 100 | |
| 101 | bool CUDADevice::isSupported(const cudaDeviceProp& prop) |
| 102 | { |
nothing calls this directly
no test coverage detected