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

416 {
417 validate_quregFields(qureg, __func__);
418
419 // permit this to be called even in non-GPU mode
420 if (qureg.isGpuAccelerated)
421 gpu_copyGpuToCpu(qureg); // syncs then overwrites all local CPU amps
422}

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

409 {
410 validate_quregFields(qureg, __func__);
411
412 // permit this to be called even in non-GPU mode
413 if (qureg.isGpuAccelerated)
414 gpu_copyCpuToGpu(qureg); // syncs then overwrites all local GPU amps
415}

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

444 {
445 validate_quregFields(qureg, __func__);
446 validate_localAmpIndices(qureg, localStartInd, numLocalAmps, __func__);
447
448 // the above validation communicates for node consensus in
449 // distributed settings, because params can differ per-node.
450 // note also this function accepts statevectors AND density
451 // matrices, because the latter does not need a bespoke
452 // (row,col) interface, because the user can only access/modify
453 // local density matrix amps via a flat index anyway!
454
455 // we permit this function to do nothing when not GPU-accelerated
456 if (!qureg.isGpuAccelerated)
457 return;
458
459 // otherwise, every node merely copies its local subset, which
460 // may differ per-node, in an embarrassingly parallel manner
461 gpu_copyGpuToCpu(&qureg.gpuAmps[localStartInd], &qureg.cpuAmps[localStartInd], numLocalAmps);
462}

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

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