| 468 | |
| 469 | |
| 470 | qcomp localiser_statevec_getAmp(Qureg qureg, qindex globalInd) { |
| 471 | |
| 472 | // this custom routine exists, in lieu of merely invoking |
| 473 | // getAmps() below, because it avoids the superfluous rank |
| 474 | // enumeration and is therefore locally faster; there |
| 475 | // may be applications where this is desirable (maybe) |
| 476 | |
| 477 | // when qureg not distributed (although env may be), every |
| 478 | // node returns their identical local amp |
| 479 | if (!qureg.isDistributed) { |
| 480 | qcomp amp; |
| 481 | accel_statevec_getAmps_sub(&, qureg, globalInd, 1); |
| 482 | return amp; |
| 483 | } |
| 484 | |
| 485 | // otherwise one node contains the target amp |
| 486 | qcomp amp = 0; |
| 487 | int sender = util_getRankContainingIndex(qureg, globalInd); |
| 488 | if (sender == qureg.rank) { |
| 489 | qindex localInd = util_getLocalIndexOfGlobalIndex(qureg, globalInd); |
| 490 | accel_statevec_getAmps_sub(&, qureg, localInd, 1); |
| 491 | } |
| 492 | |
| 493 | // which it shares with all other nodes |
| 494 | comm_broadcastAmp(sender, &); |
| 495 | return amp; |
| 496 | } |
| 497 | |
| 498 | |
| 499 | void localiser_statevec_getAmps(qcomp* outAmps, Qureg qureg, qindex globalStartInd, qindex globalNumAmps) { |
no test coverage detected