CMS 3D CMS Logo

getCachingDeviceAllocator.h
Go to the documentation of this file.
1 #ifndef HeterogeneousCore_CUDACore_src_getCachingDeviceAllocator
2 #define HeterogeneousCore_CUDACore_src_getCachingDeviceAllocator
3 
8 
10 #include "cachingAllocatorCommon.h"
11 
12 #include <iomanip>
13 
14 namespace cms::cuda::allocator {
16  LogDebug("CachingDeviceAllocator").log([](auto& log) {
17  log << "cub::CachingDeviceAllocator settings\n"
18  << " bin growth " << binGrowth << "\n"
19  << " min bin " << minBin << "\n"
20  << " max bin " << maxBin << "\n"
21  << " resulting bins:\n";
22  for (auto bin = minBin; bin <= maxBin; ++bin) {
24  if (binSize >= (1 << 30) and binSize % (1 << 30) == 0) {
25  log << " " << std::setw(8) << (binSize >> 30) << " GB\n";
26  } else if (binSize >= (1 << 20) and binSize % (1 << 20) == 0) {
27  log << " " << std::setw(8) << (binSize >> 20) << " MB\n";
28  } else if (binSize >= (1 << 10) and binSize % (1 << 10) == 0) {
29  log << " " << std::setw(8) << (binSize >> 10) << " kB\n";
30  } else {
31  log << " " << std::setw(9) << binSize << " B\n";
32  }
33  }
34  log << " maximum amount of cached memory: " << (minCachedBytes() >> 20) << " MB\n";
35  });
36 
37  // the public interface is thread safe
39  minBin,
40  maxBin,
42  false, // do not skip cleanup
43  debug};
44  return allocator;
45  }
46 } // namespace cms::cuda::allocator
47 
48 #endif
constexpr unsigned int maxBin
A simple caching allocator for device memory allocations.
static unsigned int IntPow(unsigned int base, unsigned int exp)
#define CMS_THREAD_SAFE
notcub::CachingDeviceAllocator & getCachingDeviceAllocator()
constexpr unsigned int binGrowth
constexpr unsigned int minBin
#define LogDebug(id)