-
Notifications
You must be signed in to change notification settings - Fork 197
Expand file tree
/
Copy pathmemory.hpp
More file actions
125 lines (69 loc) · 3.09 KB
/
Copy pathmemory.hpp
File metadata and controls
125 lines (69 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/** @file
* Internal signatures which query available CPU memory (in an
* attemptedly OS-agnostic way), and provide needed memory
* querents. Note GPU memory querying is performed by
* the dedicated GPU backend, though this file is always
* compiled (even in GPU mode) because GPU-acceleration still
* requires accompanying CPU memory arrays. This file does not
* perform any allocation of memory; that is instead performed
* by cpu_config.cpp, to be symmetric with the GPU-memory
* allocators in gpu_config.cpp, and use NUMA strategies.
*
* @author Tyson Jones
*/
#ifndef MEMORY_HPP
#define MEMORY_HPP
#include "quest/include/types.h"
#include "quest/include/qureg.h"
#include "quest/include/paulis.h"
/*
* HARDWARE QUERYING
*/
namespace mem { typedef bool COULD_NOT_QUERY_RAM; }
qindex mem_tryGetLocalRamCapacityInBytes();
/*
* MEMORY USAGE
*/
int mem_getEffectiveNumStateVecQubitsPerNode(int numQubits, bool isDensMatr, int numNodes);
qindex mem_getTotalGlobalMemoryUsed(Qureg qureg);
/*
* MEMORY REQUIRED
*/
size_t mem_getLocalQuregMemoryRequired(int numQubits, bool isDensityMatr, int numNodes);
size_t mem_getLocalQuregMemoryRequired(qindex numAmpsPerNode);
size_t mem_getLocalMatrixMemoryRequired(int numQubits, bool isDenseMatrix, int numNodes);
size_t mem_getLocalSuperOpMemoryRequired(int numQubits);
/*
* QUBIT BOUNDS
*/
int mem_getMaxNumQuregQubitsWhichCanFitInMemory(bool isDensityMatrix, int numNodes, qindex memBytesPerNode);
int mem_getMaxNumMatrixQubitsWhichCanFitInMemory(bool isDenseMatrix, int numNodes, qindex memBytesPerNode);
int mem_getMaxNumSuperOpQubitsWhichCanFitInMemory(qindex memBytesPerNode);
int mem_getMinNumQubitsForDistribution(int numNodes);
int mem_getMaxNumQuregQubitsBeforeIndexOverflow(bool isDensityMatrix);
int mem_getMaxNumMatrixQubitsBeforeIndexOverflow(bool isDenseMatrix);
int mem_getMaxNumSuperOpQubitsBeforeIndexOverflow();
qindex mem_getMaxNumKrausMapMatricesBeforeIndexOverflow(int numQubits);
int mem_getMaxNumQuregQubitsBeforeGlobalMemSizeofOverflow(bool isDensityMatrix, int numNodes);
int mem_getMaxNumMatrixQubitsBeforeGlobalMemSizeofOverflow(bool isDenseMatrix, int numNodes);
int mem_getMaxNumSuperOpQubitsBeforeGlobalMemSizeofOverflow();
qindex mem_getMaxNumKrausMapMatricesBeforeLocalMemSizeofOverflow(int numQubits);
/*
* SUFFICIENT MEMORY QUERYING
*/
bool mem_canQuregFitInMemory(int numQubits, bool isDensMatr, int numNodes, qindex memBytesPerNode);
bool mem_canMatrixFitInMemory(int numQubits, bool isDense, int numNodes, qindex memBytesPerNode);
bool mem_canSuperOpFitInMemory(int numQubits, qindex numBytesPerNode);
bool mem_canPauliStrSumFitInMemory(qindex numTerms, qindex numBytesPerNode);
/*
* MEMORY ALLOCATION SUCCESS
*/
bool mem_isAllocated(int* heapflag);
bool mem_isAllocated(PauliStr* array);
bool mem_isAllocated(qcomp* array);
bool mem_isAllocated(qcomp** matrix, qindex numRows);
bool mem_isAllocated(qcomp*** matrixList, qindex numRows, int numMatrices);
bool mem_isOuterAllocated(qcomp* ptr);
bool mem_isOuterAllocated(qcomp** ptr);
bool mem_isOuterAllocated(qcomp*** ptr);
#endif // MEMORY_HPP