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 24 of file AlpakaService.cc.

References l1ct::clear(), cms::alpakatools::devices(), CUDAService::enabled(), enabled_, ForwardName::getName(), dqmiodumpmetadata::n, Skims_PA_cff::name, MillePedeFileConverter_cfg::out, AlCaHLTBitMon_QueryRunRegistry::string, and makePlotsFromDump::suffix.

25  : enabled_(config.getUntrackedParameter<bool>("enabled")),
26  verbose_(config.getUntrackedParameter<bool>("verbose")) {
27 #ifdef ALPAKA_ACC_GPU_CUDA_ENABLED
28  // rely on the CUDAService to initialise the CUDA devices
29  edm::Service<CUDAService> cudaService;
30 #endif // ALPAKA_ACC_GPU_CUDA_ENABLED
31 
32  // TODO from Andrea Bocci:
33  // - handle alpaka caching allocators ?
34  // - extract and print more information about the platform and devices
35 
36  if (not enabled_) {
37  edm::LogInfo("AlpakaService") << ALPAKA_TYPE_ALIAS_NAME(AlpakaService) << " disabled by configuration";
38  return;
39  }
40 
41 #ifdef ALPAKA_ACC_GPU_CUDA_ENABLED
42  if (not cudaService->enabled()) {
43  enabled_ = false;
44  edm::LogInfo("AlpakaService") << ALPAKA_TYPE_ALIAS_NAME(AlpakaService) << " disabled by CUDAService";
45  return;
46  }
47 #endif // ALPAKA_ACC_GPU_CUDA_ENABLED
48 
49  // enumerate all devices on this platform
50  auto const& devices = cms::alpakatools::devices<Platform>();
51  if (devices.empty()) {
52  const std::string platform = boost::core::demangle(typeid(Platform).name());
53  edm::LogWarning("AlpakaService") << "Could not find any devices on platform " << platform << ".\n"
54  << "Disabling " << ALPAKA_TYPE_ALIAS_NAME(AlpakaService) << ".";
55  enabled_ = false;
56  return;
57  }
58 
59  {
60  const char* suffix[] = {"s.", ":", "s:"};
61  const auto n = devices.size();
62  edm::LogInfo out("AlpakaService");
63  out << ALPAKA_TYPE_ALIAS_NAME(AlpakaService) << " succesfully initialised.\n";
64  out << "Found " << n << " device" << suffix[n < 2 ? n : 2];
65  for (auto const& device : devices) {
66  out << "\n - " << alpaka::getName(device);
67  }
68  }
69 
70  // initialise the queue and event caches
71  cms::alpakatools::getQueueCache<Queue>().clear();
72  cms::alpakatools::getEventCache<Event>().clear();
73 
74  // initialise the caching memory allocators
75  cms::alpakatools::getHostCachingAllocator<Queue>();
76  for (auto const& device : devices)
77  cms::alpakatools::getDeviceCachingAllocator<Device, Queue>(device);
78  }
AlpakaService(edm::ParameterSet const &config, edm::ActivityRegistry &)
Definition: config.py:1
Log< level::Info, false > LogInfo
bool enabled() const
Definition: CUDAService.h:22
std::vector< alpaka::Dev< TPlatform > > const & devices()
Definition: devices.h:36
std::string getName(const G4String &)
Definition: ForwardName.cc:3
void clear(EGIsoObj &c)
Definition: egamma.h:82
Log< level::Warning, false > LogWarning

◆ ~AlpakaService()

ALPAKA_ACCELERATOR_NAMESPACE::AlpakaService::~AlpakaService ( )

Definition at line 80 of file AlpakaService.cc.

References l1ct::clear().

80  {
81  // clean up the caching memory allocators
82  cms::alpakatools::getHostCachingAllocator<Queue>().freeAllCached();
83  for (auto const& device : cms::alpakatools::devices<Platform>())
84  cms::alpakatools::getDeviceCachingAllocator<Device, Queue>(device).freeAllCached();
85 
86  // clean up the queue and event caches
87  cms::alpakatools::getQueueCache<Queue>().clear();
88  cms::alpakatools::getEventCache<Event>().clear();
89  }
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 91 of file AlpakaService.cc.

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

91  {
93  desc.addUntracked<bool>("enabled", true);
94  desc.addUntracked<bool>("verbose", false);
95 
96  descriptions.add(ALPAKA_TYPE_ALIAS_NAME(AlpakaService), desc);
97  }
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.