1 #include <boost/core/demangle.hpp> 3 #include <alpaka/alpaka.hpp> 17 #ifdef ALPAKA_ACC_GPU_CUDA_ENABLED 20 #endif // ALPAKA_ACC_GPU_CUDA_ENABLED 22 #ifdef ALPAKA_ACC_GPU_HIP_ENABLED 25 #endif // ALPAKA_ACC_GPU_HIP_ENABLED 34 desc.addUntracked<uint32_t>(
"binGrowth", alloc.binGrowth)
35 ->setComment(
"Bin growth factor (bin_growth in cub::CachingDeviceAllocator)");
36 desc.addUntracked<uint32_t>(
"minBin", alloc.minBin)
38 "Smallest bin, corresponds to binGrowth^minBin bytes (min_bin in cub::CachingDeviceAllocator).\n8 " 39 "corresponds to 256 bytes.");
40 desc.addUntracked<uint32_t>(
"maxBin", alloc.maxBin)
42 "Largest bin, corresponds to binGrowth^maxBin bytes (max_bin in cub::CachingDeviceAllocator).\n30 " 43 "corresponds do 1 GiB.\nNote that unlike in cub, allocations larger than binGrowth^maxBin are set to " 45 desc.addUntracked<
unsigned long long>(
"maxCachedBytes", alloc.maxCachedBytes)
46 ->setComment(
"Total storage for the allocator; 0 means no limit.");
47 desc.addUntracked<
double>(
"maxCachedFraction", alloc.maxCachedFraction)
49 "Fraction of total device memory taken for the allocator; 0 means no limit.\nIf both maxCachedBytes and " 50 "maxCachedFraction are non-zero, the smallest resulting value is used.");
51 desc.addUntracked<
bool>(
"fillAllocations", alloc.fillAllocations)
52 ->setComment(
"Fill all newly allocated or re-used memory blocks with fillAllocationValue.");
53 desc.addUntracked<uint32_t>(
"fillAllocationValue", alloc.fillAllocationValue)
54 ->setComment(
"Byte value used to fill all newly allocated or re-used memory blocks");
55 desc.addUntracked<
bool>(
"fillReallocations", alloc.fillReallocations)
57 "Fill only the re-used memory blocks with fillReallocationValue.\nIf both fillAllocations and " 58 "fillReallocations are true, fillAllocationValue is used for newly allocated blocks and " 59 "fillReallocationValue is used for re-allocated blocks.");
60 desc.addUntracked<uint32_t>(
"fillReallocationValue", alloc.fillReallocationValue)
61 ->setComment(
"Byte value used to fill all re-used memory blocks");
62 desc.addUntracked<
bool>(
"fillDeallocations", alloc.fillDeallocations)
63 ->setComment(
"Fill memory blocks with fillDeallocationValue before freeing or caching them for re-use");
64 desc.addUntracked<uint32_t>(
"fillDeallocationValue", alloc.fillDeallocationValue)
65 ->setComment(
"Byte value used to fill all deallocated or cached memory blocks");
66 desc.addUntracked<
bool>(
"fillCaches", alloc.fillCaches)
68 "Fill memory blocks with fillCacheValue before caching them for re-use.\nIf both fillDeallocations and " 69 "fillCaches are true, fillDeallocationValue is used for blocks about to be freed and fillCacheValue is " 70 "used for blocks about to be cached.");
71 desc.addUntracked<uint32_t>(
"fillCacheValue", alloc.fillCacheValue)
72 ->setComment(
"Byte value used to fill all cached memory blocks");
79 alloc.
minBin =
config.getUntrackedParameter<uint32_t>(
"minBin");
80 alloc.
maxBin =
config.getUntrackedParameter<uint32_t>(
"maxBin");
90 alloc.
fillCacheValue =
static_cast<uint8_t
>(
config.getUntrackedParameter<uint32_t>(
"fillCacheValue"));
99 : enabled_(
config.getUntrackedParameter<
bool>(
"enabled")),
100 verbose_(
config.getUntrackedParameter<
bool>(
"verbose")) {
101 #ifdef ALPAKA_ACC_GPU_CUDA_ENABLED 104 #endif // ALPAKA_ACC_GPU_CUDA_ENABLED 105 #ifdef ALPAKA_ACC_GPU_HIP_ENABLED 108 #endif // ALPAKA_ACC_GPU_HIP_ENABLED 118 #ifdef ALPAKA_ACC_GPU_CUDA_ENABLED 119 if (not cuda
or not cuda->enabled()) {
124 #endif // ALPAKA_ACC_GPU_CUDA_ENABLED 125 #ifdef ALPAKA_ACC_GPU_HIP_ENABLED 126 if (not rocm
or not rocm->enabled()) {
131 #endif // ALPAKA_ACC_GPU_HIP_ENABLED 134 auto const&
devices = cms::alpakatools::devices<Platform>();
138 <<
"Disabling " << ALPAKA_TYPE_ALIAS_NAME(
AlpakaService) <<
".";
144 const char*
suffix[] = {
"s.",
":",
"s:"};
147 out << ALPAKA_TYPE_ALIAS_NAME(
AlpakaService) <<
" succesfully initialised.\n";
148 out <<
"Found " <<
n <<
" device" <<
suffix[
n < 2 ?
n : 2];
149 for (
auto const& device :
devices) {
155 cms::alpakatools::getQueueCache<Queue>().
clear();
156 cms::alpakatools::getEventCache<Event>().
clear();
161 cms::alpakatools::getHostCachingAllocator<Queue>(hostAllocatorConfig,
verbose_);
164 for (
auto const& device :
devices)
165 cms::alpakatools::getDeviceCachingAllocator<Device, Queue>(device, deviceAllocatorConfig,
verbose_);
170 cms::alpakatools::getHostCachingAllocator<Queue>().freeAllCached();
171 for (
auto const& device : cms::alpakatools::devices<Platform>())
172 cms::alpakatools::getDeviceCachingAllocator<Device, Queue>(device).freeAllCached();
175 cms::alpakatools::getQueueCache<Queue>().
clear();
176 cms::alpakatools::getEventCache<Event>().
clear();
181 desc.addUntracked<
bool>(
"enabled",
true);
182 desc.addUntracked<
bool>(
"verbose",
false);
184 ->setComment(
"Configuration for the host's CachingAllocator");
186 ->setComment(
"Configuration for the devices' CachingAllocator");
AlpakaService(edm::ParameterSet const &config, edm::ActivityRegistry &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Log< level::Info, false > LogInfo
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::string getName(const G4String &)
Log< level::Warning, false > LogWarning