MCPcopy Create free account
hub / github.com/QuEST-Kit/QuEST / gpu_bindLocalGPUsToNodes

Function gpu_bindLocalGPUsToNodes

quest/src/gpu/gpu_config.cpp:370–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

368
369
370void 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
394bool gpu_areAnyNodesBoundToSameGpu() {

Callers 1

Calls 3

gpu_getNumberOfLocalGpusFunction · 0.85
comm_getRankFunction · 0.85

Tested by

no test coverage detected