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

Data structures for managing the QuEST execution environment. More...

Classes

struct  QuESTEnv
 

Functions

void finalizeQuESTEnv ()
 
QuESTEnv getQuESTEnv ()
 
void initCustomQuESTEnv (int useDistrib, int useGpuAccel, int useMultithread)
 
void initQuESTEnv ()
 
int isQuESTEnvInit ()
 
void reportQuESTEnv ()
 
void syncQuESTEnv ()
 

Detailed Description

Data structures for managing the QuEST execution environment.

Function Documentation

◆ finalizeQuESTEnv()

void finalizeQuESTEnv ( )
Note
Documentation for this function or struct is under construction!

Definition at line 424 of file environment.cpp.

424 {
425 validate_envIsInit(__func__);
426
427 // NOTE:
428 // calling this will not automatically
429 // free the memory of existing Quregs
430
431 if (globalEnvPtr->isGpuAccelerated)
432 gpu_clearCache(); // syncs first
433
434 if (globalEnvPtr->isGpuAccelerated && gpu_isCuQuantumCompiled())
435 gpu_finalizeCuQuantum();
436
437 if (globalEnvPtr->isDistributed) {
438 comm_sync();
439 comm_end();
440 }
441
442 // free global env's heap memory and flag it as unallocated
443 free(globalEnvPtr);
444 globalEnvPtr = nullptr;
445
446 // flag that the environment was finalised, to ensure it is never re-initialised
447 hasEnvBeenFinalized = true;
448}

◆ getQuESTEnv()

QuESTEnv getQuESTEnv ( )
Note
Documentation for this function or struct is under construction!

Definition at line 416 of file environment.cpp.

416 {
417 validate_envIsInit(__func__);
418
419 // returns a copy, so cheeky users calling memcpy() upon const struct still won't mutate
420 return *globalEnvPtr;
421}

Referenced by clearGpuCache(), createCompMatr(), createDiagMatr(), createForcedDensityQureg(), createForcedQureg(), deleteFilesWithPrefixSynch(), getEnvironmentString(), getGpuCacheSize(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and writeToFileSynch().

◆ initCustomQuESTEnv()

void initCustomQuESTEnv ( int useDistrib,
int useGpuAccel,
int useMultithread )
Note
Documentation for this function or struct is under construction!
See also
  • C and C++ examples

Definition at line 398 of file environment.cpp.

398 {
399
400 validateAndInitCustomQuESTEnv(useDistrib, useGpuAccel, useMultithread, __func__);
401}

◆ initQuESTEnv()

void initQuESTEnv ( )
Note
Documentation for this function or struct is under construction!

Definition at line 404 of file environment.cpp.

404 {
405
406 validateAndInitCustomQuESTEnv(modeflag::USE_AUTO, modeflag::USE_AUTO, modeflag::USE_AUTO, __func__);
407}

Referenced by TEST_CASE().

◆ isQuESTEnvInit()

int isQuESTEnvInit ( )
Note
Documentation for this function or struct is under construction!

Definition at line 410 of file environment.cpp.

410 {
411
412 return (int) (globalEnvPtr != nullptr);
413}

Referenced by setRandomTestStateSeeds().

◆ reportQuESTEnv()

void reportQuESTEnv ( )
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!
See also
  • C and C++ examples

Definition at line 462 of file environment.cpp.

462 {
463 validate_envIsInit(__func__);
464 validate_numReportedNewlinesAboveZero(__func__); // because trailing newline mandatory
465
466 /// @todo add function to write this output to file (useful for HPC debugging)
467
468 print_label("QuEST execution environment");
469
470 bool statevec = false;
471 bool densmatr = true;
472
473 // we attempt to report properties of available hardware facilities
474 // (e.g. number of CPU cores, number of GPUs) even if the environment is not
475 // making use of them, to inform the user how they might change deployment.
476 printPrecisionInfo();
477 printCompilationInfo();
478 printDeploymentInfo();
479 printCpuInfo();
480 printGpuInfo();
481 printDistributionInfo();
482 printQuregSizeLimits(statevec);
483 printQuregSizeLimits(densmatr);
484 printQuregAutoDeployments(statevec);
485 printQuregAutoDeployments(densmatr);
486
487 // exclude mandatory newline above
488 print_oneFewerNewlines();
489}

◆ syncQuESTEnv()

void syncQuESTEnv ( )
Note
Documentation for this function or struct is under construction!

Definition at line 451 of file environment.cpp.

451 {
452 validate_envIsInit(__func__);
453
454 if (globalEnvPtr->isGpuAccelerated)
455 gpu_sync();
456
457 if (globalEnvPtr->isDistributed)
458 comm_sync();
459}

Referenced by areEqual(), areEqual(), areEqual(), deleteFilesWithPrefixSynch(), toQMatrix(), toQureg(), toQureg(), toQVector(), and writeToFileSynch().