The Quantum Exact Simulation Toolkit v4.3.0
Loading...
Searching...
No Matches
Synchronisation

Functions for overwriting a channel's GPU (VRAM) memory with its CPU (RAM) contents. More...

Functions

void syncKrausMap (KrausMap map)
 
void syncSuperOp (SuperOp op)
 

Detailed Description

Functions for overwriting a channel's GPU (VRAM) memory with its CPU (RAM) contents.

These functions are only necessary when the user wishes to manually modify the elements of a channel (in lieu of using the Setters), to thereafter synchronise the changes to the GPU copy of the channel. These functions have no effect when running without GPU-acceleration, but remain legal and harmless to call (to achieve platform agnosticism).

Function Documentation

◆ syncKrausMap()

void syncKrausMap ( KrausMap map)

Updates the internal state of map, necessary after manually modifying KrausMap::matrices.

Parameters
[in,out]mapthe KrausMap to synchronise.
Exceptions
error
  • if map is uninitialised.
See also
Author
Tyson Jones

Definition at line 236 of file channels.cpp.

236 {
237 validate_krausMapFields(map, __func__);
238
239 // re-compute and GPU-sync the superoperator from the modified matrices
240 util_setSuperoperator(map.superop.cpuElems, map.matrices, map.numMatrices, map.numQubits);
241 syncSuperOp(map.superop);
242
243 // indicate that we do not know whether the revised map is
244 // is CPTP; we defer establishing that until a CPTP check
245 util_setFlagToUnknown(map.isApproxCPTP);
246}
void syncSuperOp(SuperOp op)
Definition channels.cpp:223
SuperOp superop
Definition channels.h:278
qcomp *** matrices
Definition channels.h:266
int numQubits
Definition channels.h:231
int * isApproxCPTP
Definition channels.h:301
int numMatrices
Definition channels.h:239
qcomp ** cpuElems
Definition channels.h:139

Referenced by TEST_CASE().

◆ syncSuperOp()

void syncSuperOp ( SuperOp op)

Updates the internal state of op, necessary after manually modifying SuperOp::cpuElems or SuperOp::cpuElemsFlat.

Parameters
[in,out]opthe SuperOp to synchronise.
Exceptions
error
  • if op is uninitialised.
See also
Author
Tyson Jones

Definition at line 223 of file channels.cpp.

223 {
224 validate_superOpFields(op, __func__);
225
226 // optionally overwrite GPU elements with user-modified CPU elements
227 if (mem_isAllocated(util_getGpuMemPtr(op)))
228 gpu_copyCpuToGpu(op);
229
230 // indicate that the matrix is now permanently GPU synchronised, even
231 // if we are not in GPU-accelerated mode - it hardly matters
232 *(op.wasGpuSynced) = 1;
233}
int * wasGpuSynced
Definition channels.h:188

Referenced by syncKrausMap(), and TEST_CASE().