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

Function localiser_statevec_getAmp

quest/src/core/localiser.cpp:470–496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

468
469
470qcomp 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(&amp, 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(&amp, qureg, localInd, 1);
491 }
492
493 // which it shares with all other nodes
494 comm_broadcastAmp(sender, &amp);
495 return amp;
496}
497
498
499void localiser_statevec_getAmps(qcomp* outAmps, Qureg qureg, qindex globalStartInd, qindex globalNumAmps) {

Callers 3

getQuregAmpFunction · 0.85
getDensityQuregAmpFunction · 0.85
calcProbOfBasisStateFunction · 0.85

Calls 4

comm_broadcastAmpFunction · 0.85

Tested by

no test coverage detected