CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
ALPAKA_ACCELERATOR_NAMESPACE::AlpakaService Class Reference

#include <AlpakaService.h>

Public Member Functions

 AlpakaService (edm::ParameterSet const &config, edm::ActivityRegistry &)
 
bool enabled () const
 
 ~AlpakaService ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

bool enabled_ = false
 
bool verbose_ = false
 

Detailed Description

Definition at line 17 of file AlpakaService.h.

Constructor & Destructor Documentation

◆ AlpakaService()

ALPAKA_ACCELERATOR_NAMESPACE::AlpakaService::AlpakaService ( edm::ParameterSet const &  config,
edm::ActivityRegistry  
)

Definition at line 98 of file AlpakaService.cc.

References l1ct::clear(), cms::alpakatools::devices(), enabled_, ForwardName::getName(), dqmiodumpmetadata::n, Skims_PA_cff::name, or, MillePedeFileConverter_cfg::out, cms::alpakatools::platform(), AlCaHLTBitMon_QueryRunRegistry::string, ticlDumper_cff::suffix, and verbose_.

99  : enabled_(config.getUntrackedParameter<bool>("enabled")),
100  verbose_(config.getUntrackedParameter<bool>("verbose")) {
101 #ifdef ALPAKA_ACC_GPU_CUDA_ENABLED
102  // rely on the CUDAService to initialise the CUDA devices
104 #endif // ALPAKA_ACC_GPU_CUDA_ENABLED
105 #ifdef ALPAKA_ACC_GPU_HIP_ENABLED
106  // rely on the ROCmService to initialise the ROCm devices
108 #endif // ALPAKA_ACC_GPU_HIP_ENABLED
109 
110  // TODO from Andrea Bocci:
111  // - extract and print more information about the platform and devices
112 
113  if (not enabled_) {
114  edm::LogInfo("AlpakaService") << ALPAKA_TYPE_ALIAS_NAME(AlpakaService) << " disabled by configuration";
115  return;
116  }
117 
118 #ifdef ALPAKA_ACC_GPU_CUDA_ENABLED
119  if (not cuda or not cuda->enabled()) {
120  enabled_ = false;
121  edm::LogInfo("AlpakaService") << ALPAKA_TYPE_ALIAS_NAME(AlpakaService) << " disabled by CUDAService";
122  return;
123  }
124 #endif // ALPAKA_ACC_GPU_CUDA_ENABLED
125 #ifdef ALPAKA_ACC_GPU_HIP_ENABLED
126  if (not rocm or not rocm->enabled()) {
127  enabled_ = false;
128  edm::LogInfo("AlpakaService") << ALPAKA_TYPE_ALIAS_NAME(AlpakaService) << " disabled by ROCmService";
129  return;
130  }
131 #endif // ALPAKA_ACC_GPU_HIP_ENABLED
132 
133  // enumerate all devices on this platform
134  auto const& devices = cms::alpakatools::devices<Platform>();
135  if (devices.empty()) {
136  const std::string platform = boost::core::demangle(typeid(Platform).name());
137  edm::LogWarning("AlpakaService") << "Could not find any devices on platform " << platform << ".\n"
138  << "Disabling " << ALPAKA_TYPE_ALIAS_NAME(AlpakaService) << ".";
139  enabled_ = false;
140  return;
141  }
142 
143  {
144  const char* suffix[] = {"s.", ":", "s:"};
145  const auto n = devices.size();
146  edm::LogInfo out("AlpakaService");
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) {
150  out << "\n - " << alpaka::getName(device);
151  }
152  }
153 
154  // initialise the queue and event caches
155  cms::alpakatools::getQueueCache<Queue>().clear();
156  cms::alpakatools::getEventCache<Event>().clear();
157 
158  // initialise the caching memory allocators
159  cms::alpakatools::AllocatorConfig hostAllocatorConfig =
160  parseAllocatorConfig(config.getUntrackedParameter<edm::ParameterSet>("hostAllocator"));
161  cms::alpakatools::getHostCachingAllocator<Queue>(hostAllocatorConfig, verbose_);
162  cms::alpakatools::AllocatorConfig deviceAllocatorConfig =
163  parseAllocatorConfig(config.getUntrackedParameter<edm::ParameterSet>("deviceAllocator"));
164  for (auto const& device : devices)
165  cms::alpakatools::getDeviceCachingAllocator<Device, Queue>(device, deviceAllocatorConfig, verbose_);
166  }
AlpakaService(edm::ParameterSet const &config, edm::ActivityRegistry &)
Definition: config.py:1
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
Definition: Activities.doc:12
Log< level::Info, false > LogInfo
std::vector< alpaka::Dev< TPlatform > > const & devices()
Definition: devices.h:22
std::string getName(const G4String &)
Definition: ForwardName.cc:3
void clear(EGIsoObj &c)
Definition: egamma.h:82
Log< level::Warning, false > LogWarning
TPlatform const & platform()
Definition: devices.h:14

◆ ~AlpakaService()

ALPAKA_ACCELERATOR_NAMESPACE::AlpakaService::~AlpakaService ( )

Definition at line 168 of file AlpakaService.cc.

References l1ct::clear().

168  {
169  // clean up the caching memory allocators
170  cms::alpakatools::getHostCachingAllocator<Queue>().freeAllCached();
171  for (auto const& device : cms::alpakatools::devices<Platform>())
172  cms::alpakatools::getDeviceCachingAllocator<Device, Queue>(device).freeAllCached();
173 
174  // clean up the queue and event caches
175  cms::alpakatools::getQueueCache<Queue>().clear();
176  cms::alpakatools::getEventCache<Event>().clear();
177  }
void clear(EGIsoObj &c)
Definition: egamma.h:82

Member Function Documentation

◆ enabled()

bool ALPAKA_ACCELERATOR_NAMESPACE::AlpakaService::enabled ( ) const
inline

◆ fillDescriptions()

void ALPAKA_ACCELERATOR_NAMESPACE::AlpakaService::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 179 of file AlpakaService.cc.

References edm::ConfigurationDescriptions::add(), and submitPVResolutionJobs::desc.

179  {
181  desc.addUntracked<bool>("enabled", true);
182  desc.addUntracked<bool>("verbose", false);
183  desc.addUntracked<edm::ParameterSetDescription>("hostAllocator", createAllocatorConfig())
184  ->setComment("Configuration for the host's CachingAllocator");
185  desc.addUntracked<edm::ParameterSetDescription>("deviceAllocator", createAllocatorConfig())
186  ->setComment("Configuration for the devices' CachingAllocator");
187 
188  descriptions.add(ALPAKA_TYPE_ALIAS_NAME(AlpakaService), desc);
189  }
AlpakaService(edm::ParameterSet const &config, edm::ActivityRegistry &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ enabled_

bool ALPAKA_ACCELERATOR_NAMESPACE::AlpakaService::enabled_ = false
private

Definition at line 27 of file AlpakaService.h.

Referenced by AlpakaService(), and enabled().

◆ verbose_

bool ALPAKA_ACCELERATOR_NAMESPACE::AlpakaService::verbose_ = false
private

Definition at line 28 of file AlpakaService.h.

Referenced by AlpakaService().