| 332 | |
| 333 | |
| 334 | std::array<char,17> getBoundGpuUuid() { |
| 335 | #if COMPILE_CUDA |
| 336 | assert_gpuHasBeenBound(hasGpuBeenBound); |
| 337 | |
| 338 | constexpr int numUuidChars = 16; |
| 339 | constexpr int numOutChars = numUuidChars + 1; // terminal char |
| 340 | |
| 341 | std::array<char,numOutChars> out; |
| 342 | cudaUUID_t uuid; |
| 343 | |
| 344 | // ROCm v5's cudaDeviceProp doesn't have a uuid field |
| 345 | #if defined(__HIP__) |
| 346 | hipDevice_t device; |
| 347 | CUDA_CHECK( hipDeviceGet(&device, getBoundGpuId()) ); |
| 348 | CUDA_CHECK( hipDeviceGetUuid(&uuid, device) ); |
| 349 | #else |
| 350 | cudaDeviceProp prop; |
| 351 | CUDA_CHECK( cudaGetDeviceProperties(&prop, getBoundGpuId()) ); |
| 352 | uuid = prop.uuid; |
| 353 | #endif |
| 354 | |
| 355 | // copy char[16] to out[17] (not human readable) |
| 356 | std::copy_n(uuid.bytes, numUuidChars, out.begin()); |
| 357 | |
| 358 | // include terminal char so that subsequent to-string |
| 359 | // operations will succeed without knowing string length |
| 360 | out[numOutChars-1] = '\0'; |
| 361 | return out; |
| 362 | |
| 363 | #else |
| 364 | error_gpuQueriedButGpuNotCompiled(); |
| 365 | return {}; |
| 366 | #endif |
| 367 | } |
| 368 | |
| 369 | |
| 370 | void gpu_bindLocalGPUsToNodes() { |
no test coverage detected