| 415 | |
| 416 | |
| 417 | void exchangeGpuSubBuffers(Qureg qureg, qindex numAmps, int pairRank) { |
| 418 | |
| 419 | auto [sendInd, recvInd] = getSubBufferSendRecvInds(qureg); |
| 420 | |
| 421 | // exchange GPU memory directly if possible |
| 422 | if (gpu_isDirectGpuCommPossible()) { |
| 423 | |
| 424 | // ensure GPU is finished modifying gpuCommBuffer |
| 425 | gpu_sync(); |
| 426 | |
| 427 | // communicate via GPUDirect or Peer-to-Peer |
| 428 | exchangeArrays(&qureg.gpuCommBuffer[sendInd], &qureg.gpuCommBuffer[recvInd], numAmps, pairRank); |
| 429 | |
| 430 | // otherwise route the memory through the CPU |
| 431 | } else { |
| 432 | |
| 433 | // copy GPU memory (buffer) into CPU memory (amps), preserving offset |
| 434 | gpu_copyGpuToCpu(qureg, &qureg.gpuCommBuffer[sendInd], &qureg.cpuAmps[sendInd], numAmps); |
| 435 | |
| 436 | // exchange CPU memory (amps) to other node's CPU memory (buffer), receiving at index 0 |
| 437 | exchangeArrays(&qureg.cpuAmps[sendInd], &qureg.cpuCommBuffer[recvInd], numAmps, pairRank); |
| 438 | |
| 439 | // copy CPU memory (buffer) to GPU memory (buffer), receiving at index 0 |
| 440 | gpu_copyCpuToGpu(qureg, &qureg.cpuCommBuffer[recvInd], &qureg.gpuCommBuffer[recvInd], numAmps); |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | |
| 445 | void asynchSendGpuSubBuffer(Qureg qureg, qindex numElems, int pairRank) { |
no test coverage detected