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 29 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, and makePlotsFromDump::suffix.

30  : enabled_(config.getUntrackedParameter<bool>("enabled")),
31  verbose_(config.getUntrackedParameter<bool>("verbose")) {
32 #ifdef ALPAKA_ACC_GPU_CUDA_ENABLED
33  // rely on the CUDAService to initialise the CUDA devices
35 #endif // ALPAKA_ACC_GPU_CUDA_ENABLED
36 #ifdef ALPAKA_ACC_GPU_HIP_ENABLED
37  // rely on the ROCmService to initialise the ROCm devices
39 #endif // ALPAKA_ACC_GPU_HIP_ENABLED
40 
41  // TODO from Andrea Bocci:
42  // - handle alpaka caching allocators ?
43  // - extract and print more information about the platform and devices
44 
45  if (not enabled_) {
46  edm::LogInfo("AlpakaService") << ALPAKA_TYPE_ALIAS_NAME(AlpakaService) << " disabled by configuration";
47  return;
48  }
49 
50 #ifdef ALPAKA_ACC_GPU_CUDA_ENABLED
51  if (not cuda or not cuda->enabled()) {
52  enabled_ = false;
53  edm::LogInfo("AlpakaService") << ALPAKA_TYPE_ALIAS_NAME(AlpakaService) << " disabled by CUDAService";
54  return;
55  }
56 #endif // ALPAKA_ACC_GPU_CUDA_ENABLED
57 #ifdef ALPAKA_ACC_GPU_HIP_ENABLED
58  if (not rocm or not rocm->enabled()) {
59  enabled_ = false;
60  edm::LogInfo("AlpakaService") << ALPAKA_TYPE_ALIAS_NAME(AlpakaService) << " disabled by ROCmService";
61  return;
62  }
63 #endif // ALPAKA_ACC_GPU_HIP_ENABLED
64 
65  // enumerate all devices on this platform
66  auto const& devices = cms::alpakatools::devices<Platform>();
67  if (devices.empty()) {
68  const std::string platform = boost::core::demangle(typeid(Platform).name());
69  edm::LogWarning("AlpakaService") << "Could not find any devices on platform " << platform << ".\n"
70  << "Disabling " << ALPAKA_TYPE_ALIAS_NAME(AlpakaService) << ".";
71  enabled_ = false;
72  return;
73  }
74 
75  {
76  const char* suffix[] = {"s.", ":", "s:"};
77  const auto n = devices.size();
78  edm::LogInfo out("AlpakaService");
79  out << ALPAKA_TYPE_ALIAS_NAME(AlpakaService) << " succesfully initialised.\n";
80  out << "Found " << n << " device" << suffix[n < 2 ? n : 2];
81  for (auto const& device : devices) {
82  out << "\n - " << alpaka::getName(device);
83  }
84  }
85 
86  // initialise the queue and event caches
87  cms::alpakatools::getQueueCache<Queue>().clear();
88  cms::alpakatools::getEventCache<Event>().clear();
89 
90  // initialise the caching memory allocators
91  cms::alpakatools::getHostCachingAllocator<Queue>();
92  for (auto const& device : devices)
93  cms::alpakatools::getDeviceCachingAllocator<Device, Queue>(device);
94  }
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 96 of file AlpakaService.cc.

References l1ct::clear().

96  {
97  // clean up the caching memory allocators
98  cms::alpakatools::getHostCachingAllocator<Queue>().freeAllCached();
99  for (auto const& device : cms::alpakatools::devices<Platform>())
100  cms::alpakatools::getDeviceCachingAllocator<Device, Queue>(device).freeAllCached();
101 
102  // clean up the queue and event caches
103  cms::alpakatools::getQueueCache<Queue>().clear();
104  cms::alpakatools::getEventCache<Event>().clear();
105  }
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 107 of file AlpakaService.cc.

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

107  {
109  desc.addUntracked<bool>("enabled", true);
110  desc.addUntracked<bool>("verbose", false);
111 
112  descriptions.add(ALPAKA_TYPE_ALIAS_NAME(AlpakaService), desc);
113  }
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.