-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_map.hpp
38 lines (29 loc) · 1000 Bytes
/
test_map.hpp
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
#include <unordered_map>
using namespace std;
#define MB_1 (1024 * 1024)
#define KEY_INVALID 0
#define DIE(assertion, call_description) \
do \
{ \
if (assertion) \
{ \
fprintf(stderr, "(%s, %d): ", \
__FILE__, __LINE__); \
perror(call_description); \
exit(1); \
} \
} while (0)
class GpuAllocator
{
long long int allocMax;
long long int allocCurrent;
std::unordered_map<void *, int> allocMap;
public:
GpuAllocator(long long int allocMax);
cudaError_t _cudaMalloc(void **devPtr, size_t size);
cudaError_t _cudaMallocManaged(void **devPtr, size_t size);
cudaError_t _cudaFree(void *devPtr);
float _loadFactor(void);
long long int _used(void);
};
extern GpuAllocator *glbGpuAllocator;