| 368 | |
| 369 | |
| 370 | void gpu_bindLocalGPUsToNodes() { |
| 371 | #if COMPILE_CUDA |
| 372 | |
| 373 | // distribute local MPI processes across local GPUs; |
| 374 | int numLocalGpus = gpu_getNumberOfLocalGpus(); |
| 375 | int localGpuInd = comm_getRank() % numLocalGpus; |
| 376 | CUDA_CHECK( cudaSetDevice(localGpuInd) ); |
| 377 | |
| 378 | // note it is possible for multiple MPI processes |
| 379 | // to bind to the same local GPU (as can be assessed |
| 380 | // with gpu_doAnyMpiProcessesShareLocalGpu()), but |
| 381 | // this will incur slowdowns due to context-switching |
| 382 | // and has no benefit - is if further illegal when |
| 383 | // using cuStateVec, as the caller will validate |
| 384 | |
| 385 | // indicate that other GPU-queries are now legal |
| 386 | hasGpuBeenBound = true; |
| 387 | |
| 388 | #else |
| 389 | error_gpuQueriedButGpuNotCompiled(); |
| 390 | #endif |
| 391 | } |
| 392 | |
| 393 | |
| 394 | bool gpu_areAnyNodesBoundToSameGpu() { |
no test coverage detected