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

Functions for copying memory between a Qureg's CPU (RAM) and GPU (VRAM) memory. More...

Functions

void syncQuregFromGpu (Qureg qureg)
 
void syncQuregToGpu (Qureg qureg)
 
void syncSubQuregFromGpu (Qureg qureg, qindex localStartInd, qindex numLocalAmps)
 
void syncSubQuregToGpu (Qureg qureg, qindex localStartInd, qindex numLocalAmps)
 

Detailed Description

Functions for copying memory between a Qureg's CPU (RAM) and GPU (VRAM) memory.

These functions are only necessary when the user wishes to manually probe or modify the Qureg amplitudes (rather than use functions like getQuregAmps() and setQuregAmps()), to ensure that the CPU and GPU copies of the Qureg are identical. These functions have no effect when running without GPU-acceleration, but remain legal and harmless to call, to achieve platform agnosticism.

Function Documentation

◆ syncQuregFromGpu()

void syncQuregFromGpu ( Qureg qureg)
Note
Documentation for this function or struct is under construction!
Warning
This function has not yet been unit tested and may contain bugs. Please use with caution!

Definition at line 403 of file qureg.cpp.

403 {
404 validate_quregFields(qureg, __func__);
405
406 // permit this to be called even in non-GPU mode
407 if (qureg.isGpuAccelerated)
408 gpu_copyGpuToCpu(qureg); // syncs then overwrites all local CPU amps
409}

Referenced by TEST_CASE(), and TEST_CASE().

◆ syncQuregToGpu()

void syncQuregToGpu ( Qureg qureg)
Note
Documentation for this function or struct is under construction!
Warning
This function has not yet been unit tested and may contain bugs. Please use with caution!

Definition at line 396 of file qureg.cpp.

396 {
397 validate_quregFields(qureg, __func__);
398
399 // permit this to be called even in non-GPU mode
400 if (qureg.isGpuAccelerated)
401 gpu_copyCpuToGpu(qureg); // syncs then overwrites all local GPU amps
402}

◆ syncSubQuregFromGpu()

void syncSubQuregFromGpu ( Qureg qureg,
qindex localStartInd,
qindex numLocalAmps )
Note
Documentation for this function or struct is under construction!
Warning
This function has not yet been unit tested and may contain bugs. Please use with caution!

Definition at line 431 of file qureg.cpp.

431 {
432 validate_quregFields(qureg, __func__);
433 validate_localAmpIndices(qureg, localStartInd, numLocalAmps, __func__);
434
435 // the above validation communicates for node consensus in
436 // distributed settings, because params can differ per-node.
437 // note also this function accepts statevectors AND density
438 // matrices, because the latter does not need a bespoke
439 // (row,col) interface, because the user can only access/modify
440 // local density matrix amps via a flat index anyway!
441
442 // we permit this function to do nothing when not GPU-accelerated
443 if (!qureg.isGpuAccelerated)
444 return;
445
446 // otherwise, every node merely copies its local subset, which
447 // may differ per-node, in an embarrassingly parallel manner
448 gpu_copyGpuToCpu(&qureg.gpuAmps[localStartInd], &qureg.cpuAmps[localStartInd], numLocalAmps);
449}

◆ syncSubQuregToGpu()

void syncSubQuregToGpu ( Qureg qureg,
qindex localStartInd,
qindex numLocalAmps )
Note
Documentation for this function or struct is under construction!
Warning
This function has not yet been unit tested and may contain bugs. Please use with caution!

Definition at line 412 of file qureg.cpp.

412 {
413 validate_quregFields(qureg, __func__);
414 validate_localAmpIndices(qureg, localStartInd, numLocalAmps, __func__);
415
416 // the above validation communicates for node consensus in
417 // distributed settings, because params can differ per-node.
418 // note also this function accepts statevectors AND density
419 // matrices, because the latter does not need a bespoke
420 // (row,col) interface, because the user can only access/modify
421 // local density matrix amps via a flat index anyway!
422
423 // we permit this function to do nothing when not GPU-accelerated
424 if (!qureg.isGpuAccelerated)
425 return;
426
427 // otherwise, every node merely copies its local subset, which
428 // may differ per-node, in an embarrassingly parallel manner
429 gpu_copyCpuToGpu(&qureg.cpuAmps[localStartInd], &qureg.gpuAmps[localStartInd], numLocalAmps);
430}