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

Function anyCtrlMultiSwapBetweenPrefixAndSuffix

quest/src/core/localiser.cpp:912–938  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

910
911
912void anyCtrlMultiSwapBetweenPrefixAndSuffix(Qureg qureg, vector<int> ctrls, vector<int> ctrlStates, vector<int> targsA, vector<int> targsB) {
913
914 // this is an internal function called by the below routines which require
915 // performing a sequence of SWAPs to reorder qubits, or move them into suffix.
916 // the SWAPs act on unique qubit pairs and so commute.
917
918 /// @todo
919 /// - the sequence of pair-wise full-swaps should be more efficient as a
920 /// "single" sequence of smaller messages sending amps directly to their
921 /// final destination node. This could use a new "multiSwap" function.
922 /// - if the user has compiled cuQuantum, and Qureg is GPU-accelerated, the
923 /// multiSwap function should use custatevecSwapIndexBits() if local,
924 /// or custatevecDistIndexBitSwapSchedulerSetIndexBitSwaps() if distributed,
925 /// although the latter requires substantially more work like setting up
926 /// a communicator which may be inelegant alongside our own distribution scheme.
927
928 // perform necessary swaps to move all targets into suffix, each of which invokes communication
929 for (size_t i=0; i<targsA.size(); i++) {
930
931 if (targsA[i] == targsB[i])
932 continue;
933
934 int suffixTarg = std::min(targsA[i], targsB[i]);
935 int prefixTarg = std::max(targsA[i], targsB[i]);
936 anyCtrlSwapBetweenPrefixAndSuffix(qureg, ctrls, ctrlStates, suffixTarg, prefixTarg);
937 }
938}
939
940
941

Callers 2

partialTraceOnPrefixFunction · 0.85

Calls 1

Tested by

no test coverage detected