forked from cms-patatrack/pixeltrack-standalone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetCachingHostAllocator.h
46 lines (40 loc) · 1.89 KB
/
getCachingHostAllocator.h
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
#ifndef HeterogeneousCore_CUDACore_src_getCachingHostAllocator
#define HeterogeneousCore_CUDACore_src_getCachingHostAllocator
#include <iomanip>
#include <iostream>
#include "CUDACore/cudaCheck.h"
#include "CachingHostAllocator.h"
#include "getCachingDeviceAllocator.h"
namespace cms::cuda::allocator {
inline notcub::CachingHostAllocator& getCachingHostAllocator() {
if (debug) {
std::cout << "cub::CachingHostAllocator settings\n"
<< " bin growth " << binGrowth << "\n"
<< " min bin " << minBin << "\n"
<< " max bin " << maxBin << "\n"
<< " resulting bins:\n";
for (auto bin = minBin; bin <= maxBin; ++bin) {
auto binSize = notcub::CachingDeviceAllocator::IntPow(binGrowth, bin);
if (binSize >= (1 << 30) and binSize % (1 << 30) == 0) {
std::cout << " " << std::setw(8) << (binSize >> 30) << " GB\n";
} else if (binSize >= (1 << 20) and binSize % (1 << 20) == 0) {
std::cout << " " << std::setw(8) << (binSize >> 20) << " MB\n";
} else if (binSize >= (1 << 10) and binSize % (1 << 10) == 0) {
std::cout << " " << std::setw(8) << (binSize >> 10) << " kB\n";
} else {
std::cout << " " << std::setw(9) << binSize << " B\n";
}
}
std::cout << " maximum amount of cached memory: " << (minCachedBytes() >> 20) << " MB\n";
}
// the public interface is thread safe
static notcub::CachingHostAllocator allocator{binGrowth,
minBin,
maxBin,
minCachedBytes(),
false, // do not skip cleanup
debug};
return allocator;
}
} // namespace cms::cuda::allocator
#endif