The Quantum Exact Simulation Toolkit v4.1.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 402 of file qureg.cpp.

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

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 395 of file qureg.cpp.

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

◆ 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 430 of file qureg.cpp.

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

◆ 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 411 of file qureg.cpp.

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