File indexing completed on 2024-04-06 12:15:45
0001 #ifndef HeterogeneousCore_CUDACore_src_getCachingDeviceAllocator
0002 #define HeterogeneousCore_CUDACore_src_getCachingDeviceAllocator
0003
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include "FWCore/Utilities/interface/thread_safety_macros.h"
0006 #include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h"
0007 #include "HeterogeneousCore/CUDAUtilities/interface/cachingAllocators.h"
0008
0009 #include "CachingDeviceAllocator.h"
0010 #include "cachingAllocatorCommon.h"
0011
0012 #include <iomanip>
0013
0014 namespace cms::cuda::allocator {
0015 inline notcub::CachingDeviceAllocator& getCachingDeviceAllocator() {
0016 LogDebug("CachingDeviceAllocator").log([](auto& log) {
0017 log << "cub::CachingDeviceAllocator settings\n"
0018 << " bin growth " << binGrowth << "\n"
0019 << " min bin " << minBin << "\n"
0020 << " max bin " << maxBin << "\n"
0021 << " resulting bins:\n";
0022 for (auto bin = minBin; bin <= maxBin; ++bin) {
0023 auto binSize = notcub::CachingDeviceAllocator::IntPow(binGrowth, bin);
0024 if (binSize >= (1 << 30) and binSize % (1 << 30) == 0) {
0025 log << " " << std::setw(8) << (binSize >> 30) << " GB\n";
0026 } else if (binSize >= (1 << 20) and binSize % (1 << 20) == 0) {
0027 log << " " << std::setw(8) << (binSize >> 20) << " MB\n";
0028 } else if (binSize >= (1 << 10) and binSize % (1 << 10) == 0) {
0029 log << " " << std::setw(8) << (binSize >> 10) << " kB\n";
0030 } else {
0031 log << " " << std::setw(9) << binSize << " B\n";
0032 }
0033 }
0034 log << " maximum amount of cached memory: " << (minCachedBytes() >> 20) << " MB\n";
0035 });
0036
0037
0038 CMS_THREAD_SAFE static notcub::CachingDeviceAllocator allocator{binGrowth,
0039 minBin,
0040 maxBin,
0041 minCachedBytes(),
0042 false,
0043 debug};
0044 return allocator;
0045 }
0046 }
0047
0048 #endif