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

409 {
410 validate_envIsInit(__func__);
411
412 // NOTE:
413 // calling this will not automatically
414 // free the memory of existing Quregs
415
416 if (globalEnvPtr->isGpuAccelerated)
417 gpu_clearCache(); // syncs first
418
419 if (globalEnvPtr->isGpuAccelerated && gpu_isCuQuantumCompiled())
420 gpu_finalizeCuQuantum();
421
422 if (globalEnvPtr->isDistributed) {
423 comm_sync();
424 comm_end();
425 }
426
427 // free global env's heap memory and flag it as unallocated
428 free(globalEnvPtr);
429 globalEnvPtr = nullptr;
430
431 // flag that the environment was finalised, to ensure it is never re-initialised
432 hasEnvBeenFinalized = true;
433}

◆ getQuESTEnv()

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

Definition at line 401 of file environment.cpp.

401 {
402 validate_envIsInit(__func__);
403
404 // returns a copy, so cheeky users calling memcpy() upon const struct still won't mutate
405 return *globalEnvPtr;
406}

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 383 of file environment.cpp.

383 {
384
385 validateAndInitCustomQuESTEnv(useDistrib, useGpuAccel, useMultithread, __func__);
386}

◆ initQuESTEnv()

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

Definition at line 389 of file environment.cpp.

389 {
390
391 validateAndInitCustomQuESTEnv(modeflag::USE_AUTO, modeflag::USE_AUTO, modeflag::USE_AUTO, __func__);
392}

Referenced by TEST_CASE().

◆ isQuESTEnvInit()

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

Definition at line 395 of file environment.cpp.

395 {
396
397 return (int) (globalEnvPtr != nullptr);
398}

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 447 of file environment.cpp.

447 {
448 validate_envIsInit(__func__);
449 validate_numReportedNewlinesAboveZero(__func__); // because trailing newline mandatory
450
451 /// @todo add function to write this output to file (useful for HPC debugging)
452
453 print_label("QuEST execution environment");
454
455 bool statevec = false;
456 bool densmatr = true;
457
458 // we attempt to report properties of available hardware facilities
459 // (e.g. number of CPU cores, number of GPUs) even if the environment is not
460 // making use of them, to inform the user how they might change deployment.
461 printPrecisionInfo();
462 printCompilationInfo();
463 printDeploymentInfo();
464 printCpuInfo();
465 printGpuInfo();
466 printDistributionInfo();
467 printQuregSizeLimits(statevec);
468 printQuregSizeLimits(densmatr);
469 printQuregAutoDeployments(statevec);
470 printQuregAutoDeployments(densmatr);
471
472 // exclude mandatory newline above
473 print_oneFewerNewlines();
474}

◆ syncQuESTEnv()

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

Definition at line 436 of file environment.cpp.

436 {
437 validate_envIsInit(__func__);
438
439 if (globalEnvPtr->isGpuAccelerated)
440 gpu_sync();
441
442 if (globalEnvPtr->isDistributed)
443 comm_sync();
444}

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