Function copyStateFromGPU

Source
pub unsafe extern "C" fn copyStateFromGPU(qureg: Qureg)
Expand description

In GPU mode, this copies the state-vector (or density matrix) from GPU memory (qureg.deviceStateVec) to RAM (qureg.stateVec), where it can be accessed/modified by the user. In CPU mode, this function has no effect. In conjunction with copyStateToGPU(), this allows a user to directly modify the state-vector in a harware agnostic way. Note though that users should instead use setAmps() if possible.

For example, to set the first real element to 1, one could do:

    copyStateFromGPU(qureg);
    qureg.stateVec.real[0] = 1;
    copyStateToGPU(qureg);

Note users should never access qureg.deviceStateVec directly.

@see

  • copyStateToGPU()
  • copySubstateFromGPU()
  • copySubstateToGPU()

@ingroup debug @param[in, out] qureg the qureg of which to copy .deviceStateVec to .stateVec in GPU mode @author Ania Brown @author Tyson Jones (doc)