The Quantum Exact Simulation Toolkit v4.0.0
Loading...
Searching...
No Matches
debug.h
1/** @file
2 * API signatures for debugging QuEST behaviour,
3 * controlling input validation, changing reporter
4 * parameters or seeding random generation.
5 *
6 * @author Tyson Jones
7 *
8 * @defgroup debug Debug
9 * @ingroup api
10 * @brief Utilities for controlling QuEST behaviour such as seeding, input validation and printing.
11 * @{
12 */
13
14#ifndef DEBUG_H
15#define DEBUG_H
16
17#include "quest/include/types.h"
18
19
20
21/*
22 * C AND C++ AGNOSTIC FUNCTIONS
23 */
24
25// enable invocation by both C and C++ binaries
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30
31
32/**
33 * @defgroup debug_seed Seeding
34 * @brief Functions for seeding QuEST's random generators.
35 * @details Re-seeding with identical seeds will determine all of QuEST's subsequent
36 * random outputs (such as measurement and random state preparation), and can
37 * be done at any stage of execution. When seeding is not explicitly performed,
38 * QuEST will attempt to use a cryptographically secure pseudorandom number generator
39 * (CSPRNG) if locally available, else fall back to a standard PRNG, via using
40 * the standard C++ `random_device` class.
41 * @{
42 */
43
44
45/// @notdoced
46void setSeeds(unsigned* seeds, int numSeeds);
47
48
49/// @notdoced
51
52
53/// @notdoced
54void getSeeds(unsigned* seeds);
55
56
57/// @notdoced
58int getNumSeeds();
59
60
61/** @} */
62
63
64
65/**
66 * @defgroup debug_validation Validation
67 * @brief Functions to control QuEST's user-input validation.
68 * @details These can be used to adjust the precision with which properties like unitarity
69 * are checked/enforced, or otherwise disable all input validation (e.g. is the
70 * given qubit index valid?). Note passing erroneous input while validation is
71 * disabled can result in runtime errors like segmentation faults.
72 * @{
73 */
74
75
76/// @notdoced
77void setInputErrorHandler(void (*callback)(const char* func, const char* msg));
78
79
80/// @notdoced
81void setValidationOn();
82
83
84/// @notdoced
85void setValidationOff();
86
87
88/// @notdoced
90
91
92/// @notdoced
93void setValidationEpsilon(qreal eps);
94
95
96/// @notdoced
98
99
100/** @} */
101
102
103
104/**
105 * @defgroup debug_reporting Reporting
106 * @brief Functions to control how QuEST's reporters display and truncate information.
107 * @{
108 */
109
110
111/// @notdoced
112/// @nottested
113void setMaxNumReportedItems(qindex numRows, qindex numCols);
114
115
116/// @notdoced
117void setMaxNumReportedSigFigs(int numSigFigs);
118
119
120/// @notdoced
121void setNumReportedNewlines(int numNewlines);
122
123
124/** @} */
125
126
127
128/**
129 * @defgroup debug_cache Caching
130 * @brief Functions to control temporary memory used by the QuEST process.
131 * @{
132 */
133
134
135/// @notdoced
136qindex getGpuCacheSize();
137
138
139/// @notdoced
140void clearGpuCache();
141
142
143/** @} */
144
145
146
147/**
148 * @defgroup debug_info Info
149 * @brief Functions for getting debugging information.
150 * @{
151 */
152
153
154/// @notdoced
155/// @nottested
156void getEnvironmentString(char str[200]);
157
158
159/** @} */
160
161
162
163// end de-mangler
164#ifdef __cplusplus
165}
166#endif
167
168
169
170/*
171 * C++ OVERLOADS
172 *
173 * which are only accessible to C++ binaries, and accept
174 * arguments more natural to C++ (e.g. std::vector). We
175 * manually add these to their respective Doxygen doc groups.
176 */
177
178#ifdef __cplusplus
179
180#include <vector>
181
182
183/// @ingroup debug_seed
184/// @nottested
185/// @notdoced
186/// @cpponly
187void setSeeds(std::vector<unsigned> seeds);
188
189
190/// @ingroup debug_seed
191/// @nottested
192/// @notdoced
193/// @cpponly
194std::vector<unsigned> getSeeds();
195
196
197#endif // __cplusplus
198
199
200
201#endif // DEBUG_H
202
203/** @} */ // (end file-wide doxygen defgroup)
qindex getGpuCacheSize()
Definition debug.cpp:164
void clearGpuCache()
Definition debug.cpp:175
void getEnvironmentString(char str[200])
void setMaxNumReportedItems(qindex numRows, qindex numCols)
Definition debug.cpp:128
void setMaxNumReportedSigFigs(int numSigFigs)
Definition debug.cpp:142
void setNumReportedNewlines(int numNewlines)
Definition debug.cpp:150
std::vector< unsigned > getSeeds()
Definition debug.cpp:197
void setSeedsToDefault()
Definition debug.cpp:45
int getNumSeeds()
Definition debug.cpp:52
void setSeeds(unsigned *seeds, int numSeeds)
Definition debug.cpp:37
void setInputErrorHandler(void(*callback)(const char *func, const char *msg))
Definition debug.cpp:74
void setValidationOff()
Definition debug.cpp:86
void setValidationEpsilonToDefault()
Definition debug.cpp:108
void setValidationOn()
Definition debug.cpp:80
qreal getValidationEpsilon()
Definition debug.cpp:115
void setValidationEpsilon(qreal eps)
Definition debug.cpp:100