The Quantum Exact Simulation Toolkit
v4.3.0
Loading...
Searching...
No Matches
modes.h
1
/** @file
2
* Constants related to configuring QuEST runtime modes,
3
* and documentation of environment variables
4
*
5
* @author Tyson Jones
6
*
7
* @defgroup modes Modes
8
* @ingroup api
9
* @brief Constants and environment variables for controlling QuEST execution.
10
* @{
11
*/
12
13
#ifndef MODES_H
14
#define MODES_H
15
16
17
18
// document environment variables
19
20
// spoof env-vars as consts to doc (hackily and hopefully temporarily)
21
#if 0
22
23
24
/** @envvardoc
25
*
26
* Specifies whether to permit multiple MPI processes to deploy to the same GPU.
27
*
28
* @attention
29
* This environment variable has no effect when either (or both) of distribution or
30
* GPU-acceleration are disabled.
31
*
32
* In multi-GPU execution, which combines distribution with GPU-acceleration, it is
33
* prudent to assign each GPU to at most one MPI process in order to avoid superfluous
34
* slowdown. Hence by default, initQuESTEnv() will forbid assigning multiple MPI processes
35
* to the same GPU. This environment variable can be set to `1` to disable this validation,
36
* permitting sharing of a single GPU, as is often useful for debugging or unit testing
37
* (for example, testing multi-GPU execution when only a single GPU is available).
38
*
39
* @warning
40
* Permitting GPU sharing may cause unintended behaviour when additionally using cuQuantum.
41
*
42
* @envvarvalues
43
* - forbid sharing: @p 0, @p '0', @p '', @p , (unspecified)
44
* - permit sharing: @p 1, @p '1'
45
*
46
* @constraints
47
* The function initQuESTEnv() will throw a validation error if any of the below are not satisfied.
48
* - The specified string does not evaluate to an integer @p 0 or @p 1.
49
*
50
* @author Tyson Jones
51
*/
52
const
int
QUEST_PERMIT_NODES_TO_SHARE_GPU
= 0;
53
54
55
/** @envvardoc
56
*
57
* Specifies the default validation epsilon.
58
*
59
* Specifying `QUEST_DEFAULT_VALIDATION_EPSILON` to a positive, real number overrides the
60
* precision-specific default (`1E-5`, `1E-12`, `1E-13` for single, double and quadruple
61
* precision respectively). The specified epsilon is used by QuEST for numerical validation
62
* unless overriden at runtime via setQuESTValidationEpsilon(), in which case it can be
63
* restored to that specified by this environment variable using setQuESTValidationEpsilonToDefault().
64
*
65
* @envvarvalues
66
* - setting @p QUEST_DEFAULT_VALIDATION_EPSILON=0 disables numerical validation, as if the value
67
* were instead infinity.
68
* - setting @p QUEST_DEFAULT_VALIDATION_EPSILON='' is equivalent to _not_ specifying the variable,
69
* adopting instead the precision-specific default above.
70
* - setting @p QUEST_DEFAULT_VALIDATION_EPSILON=x where `x` is a positive, valid `qreal` in any
71
* format accepted by `C` or `C++` (e.g. `0.01`, `1E-2`, `+1e-2`) will use `x` as the
72
* default validation epsilon.
73
*
74
* @constraints
75
* The function initQuESTEnv() will throw a validation error if any of the below are not satisfied.
76
* - The specified epsilon must be `0` or positive.
77
* - The specified epsilon must not exceed that maximum or minimum value which can be stored
78
* in a `qreal`, which is specific to its precision.
79
*
80
* @author Tyson Jones
81
*/
82
const
qreal
QUEST_DEFAULT_VALIDATION_EPSILON
= 0;
83
84
85
/** @envvardoc
86
*
87
* Specifies the default number of threads per block (or "block dimension") used by GPU acceleration.
88
*
89
* The number of dispatched CUDA threads per block controls the parallelisation granularity of
90
* QuEST's GPU backend, affecting performance.
91
* Specifying `QUEST_DEFAULT_NUM_GPU_THREADS_PER_BLOCK` to a valid, positive integer overrides
92
* QuEST's default otherwise set during compilation via a CMake option of the same name. If
93
* that CMake option was not set, the default is assumed to be @p 128.
94
*
95
* The number specified by this environment variable will be used as the block dimension by all of
96
* QuEST's GPU backend functions, unless overridden at runtime via setQuESTNumGpuThreadsPerBlock().
97
* The actual number of threads per block used at any time can be queried via
98
* getQuESTNumGpuThreadsPerBlock(), or reported by reportQuESTEnv().
99
*
100
* @envvarvalues
101
* - use internal default of `128`: @p '', @p , (unspecified)
102
* - use number `x`: @p x, @p 'x', @p '+x'
103
*
104
* @constraints
105
* The function initQuESTEnv() will throw a validation error if any of the below are not satisfied.
106
* - The specified number must be a positive integer.
107
* - The specified number must not exceed the minimum or maximum value which can be stored in an @p int.
108
* - The specified number must be divisible by the GPU warp size, which is 32 or 64, depending on
109
* whether deployed to an NVIDIA or AMD GPU. This restriction is imposed even when QuEST is not
110
* deployed with GPU-acceleration.
111
* - The specified number exceeds the maximum imposed by the available GPU hardware.
112
*
113
* @author Oliver Brown
114
* @author Tyson Jones
115
*/
116
const
qreal
QUEST_DEFAULT_NUM_GPU_THREADS_PER_BLOCK
= 0;
117
118
119
#endif
120
121
122
123
// user flags for choosing automatic deployment; only accessible by C++
124
// backend and C++ users; C users must hardcode -1
125
126
#ifdef __cplusplus
127
128
namespace
modeflag {
129
130
extern
int
USE_AUTO;
131
}
132
133
#endif
// __cplusplus
134
135
136
137
#endif
// MODES_H
138
139
/** @} */
// (end file-wide doxygen defgroup)
QUEST_PERMIT_NODES_TO_SHARE_GPU
const int QUEST_PERMIT_NODES_TO_SHARE_GPU
Definition
modes.h:52
QUEST_DEFAULT_VALIDATION_EPSILON
const qreal QUEST_DEFAULT_VALIDATION_EPSILON
Definition
modes.h:82
QUEST_DEFAULT_NUM_GPU_THREADS_PER_BLOCK
const qreal QUEST_DEFAULT_NUM_GPU_THREADS_PER_BLOCK
Definition
modes.h:116
quest
include
modes.h
Generated by
1.12.0