CMS 3D CMS Logo

List of all members | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes
ALPAKA_ACCELERATOR_NAMESPACE::ESProducer Class Reference

#include <ESProducer.h>

Inheritance diagram for ALPAKA_ACCELERATOR_NAMESPACE::ESProducer:
edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider ALPAKA_ACCELERATOR_NAMESPACE::TestAlpakaESProducerA ALPAKA_ACCELERATOR_NAMESPACE::TestAlpakaESProducerB ALPAKA_ACCELERATOR_NAMESPACE::TestAlpakaESProducerC ALPAKA_ACCELERATOR_NAMESPACE::TestAlpakaESProducerD

Static Public Member Functions

static void prevalidate (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 

Protected Member Functions

 ESProducer (edm::ParameterSet const &iConfig)
 
template<typename T >
auto setWhatProduced (T *iThis, edm::es::Label const &label={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(TRecord const &), edm::es::Label const &label={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(device::Record< TRecord > const &), edm::es::Label const &label={})
 
- Protected Member Functions inherited from edm::ESProducer
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &iLabel={})
 
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
auto setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
template<typename TFunc >
auto setWhatProduced (TFunc &&func, const es::Label &iLabel={})
 
template<typename TReturn , typename TRecord , typename TFunc , typename TDecorator >
ESConsumesCollectorT< TRecord > setWhatProduced (TFunc &&func, TDecorator &&iDec, const es::Label &iLabel={})
 
void usesResources (std::vector< std::string > const &)
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedProxiesVector registerProxies (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &key)
 

Private Types

using Base = edm::ESProducer
 

Private Member Functions

template<typename TRecord , typename TFunc >
auto setWhatProducedDevice (TFunc &&func, const edm::es::Label &label)
 

Static Private Member Functions

static void throwSomeNullException ()
 

Private Attributes

std::string const appendToDataLabel_
 
std::string const moduleLabel_
 

Additional Inherited Members

- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ESProducer (const ESProducer &)=delete
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProducer const & operator= (const ESProducer &)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector< ESProxyIndex > > updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
 ESProxyFactoryProducer (const ESProxyFactoryProducer &)=delete
 
const ESProxyFactoryProduceroperator= (const ESProxyFactoryProducer &)=delete
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
void createKeyedProxies (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
 DataProxyProvider ()
 
 DataProxyProvider (const DataProxyProvider &)=delete
 
const ComponentDescriptiondescription () const
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const DataProxyProvideroperator= (const DataProxyProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () noexcept(false)
 
- Protected Types inherited from edm::ESProxyFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::DataProxyProvider
using KeyedProxiesVector = std::vector< std::pair< DataKey, std::shared_ptr< DataProxy > >>
 

Detailed Description

The ESProducer is a base class for modules producing data into the host memory space and/or the device memory space defined by the backend (i.e. ALPAKA_ACCELERATOR_NAMESPACE). The interface looks similar to the normal edm::ESProducer.

When producing a host product, the produce function should have the the usual Record argument. For producing a device product, the produce funtion should have device::Record<Record> argument.

Definition at line 26 of file ESProducer.h.

Member Typedef Documentation

◆ Base

Definition at line 27 of file ESProducer.h.

Constructor & Destructor Documentation

◆ ESProducer()

ALPAKA_ACCELERATOR_NAMESPACE::ESProducer::ESProducer ( edm::ParameterSet const &  iConfig)
protected

Definition at line 5 of file ESProducer.cc.

6  : moduleLabel_(iConfig.getParameter<std::string>("@module_label")),
7  appendToDataLabel_(iConfig.getParameter<std::string>("appendToDataLabel")) {}

Member Function Documentation

◆ prevalidate()

static void ALPAKA_ACCELERATOR_NAMESPACE::ESProducer::prevalidate ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 30 of file ESProducer.h.

References cms::alpakatools::module_backend_config(), and edm::eventsetup::DataProxyProvider::prevalidate().

30  {
31  Base::prevalidate(descriptions);
33  }
void module_backend_config(edm::ConfigurationDescriptions &iDesc)
static void prevalidate(ConfigurationDescriptions &)

◆ setWhatProduced() [1/3]

template<typename T >
auto ALPAKA_ACCELERATOR_NAMESPACE::ESProducer::setWhatProduced ( T iThis,
edm::es::Label const &  label = {} 
)
inlineprotected

◆ setWhatProduced() [2/3]

template<typename T , typename TReturn , typename TRecord >
auto ALPAKA_ACCELERATOR_NAMESPACE::ESProducer::setWhatProduced ( T iThis,
TReturn(T ::*)(TRecord const &)  iMethod,
edm::es::Label const &  label = {} 
)
inlineprotected

Definition at line 44 of file ESProducer.h.

44  {}) {
45  auto cc = Base::setWhatProduced(iThis, iMethod, label);
47  if constexpr (not detail::useESProductDirectly<TProduct>) {
48  // for device backends add the copy to device
49  auto tokenPtr = std::make_shared<edm::ESGetToken<TProduct, TRecord>>();
50  auto ccDev = setWhatProducedDevice<TRecord>(
51  [tokenPtr](device::Record<TRecord> const& iRecord) {
52  auto handle = iRecord.getTransientHandle(*tokenPtr);
54  return std::optional{CopyT::copyAsync(iRecord.queue(), *handle)};
55  },
56  label);
57  *tokenPtr = ccDev.consumes(edm::ESInputTag{moduleLabel_, label.default_ + appendToDataLabel_});
58  }
59  return cc;
60  }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
char const * label
void copyAsync(device::unique_ptr< T > &dst, const host::unique_ptr< T > &src, cudaStream_t stream)
Definition: copyAsync.h:20
optional
Definition: Types.py:198

◆ setWhatProduced() [3/3]

template<typename T , typename TReturn , typename TRecord >
auto ALPAKA_ACCELERATOR_NAMESPACE::ESProducer::setWhatProduced ( T iThis,
TReturn(T ::*)(device::Record< TRecord > const &)  iMethod,
edm::es::Label const &  label = {} 
)
inlineprotected

Definition at line 63 of file ESProducer.h.

65  {}) {
67  if constexpr (detail::useESProductDirectly<TProduct>) {
68  return Base::setWhatProduced(
69  [iThis, iMethod](TRecord const& record) {
70  auto const& devices = cms::alpakatools::devices<Platform>();
71  assert(devices.size() == 1);
72  device::Record<TRecord> const deviceRecord(record, devices.front());
73  return std::invoke(iMethod, iThis, deviceRecord);
74  },
75  label);
76  } else {
77  return setWhatProducedDevice<TRecord>(
78  [iThis, iMethod](device::Record<TRecord> const& record) { return std::invoke(iMethod, iThis, record); },
79  label);
80  }
81  }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
assert(be >=bs)
char const * label
std::vector< alpaka::Dev< TPlatform > > const & devices()
Definition: devices.h:35

◆ setWhatProducedDevice()

template<typename TRecord , typename TFunc >
auto ALPAKA_ACCELERATOR_NAMESPACE::ESProducer::setWhatProducedDevice ( TFunc &&  func,
const edm::es::Label label 
)
inlineprivate

Definition at line 85 of file ESProducer.h.

References cms::alpakatools::devices(), EcalMonitorTask_cff::func, label, eostools::move(), dumpMFGeometry_cfg::prod, ALPAKA_ACCELERATOR_NAMESPACE::device::Record< TRecord >::queuePtr(), AlCaHarvesting_cff::record, runTheMatrix::ret, edm::ESProducer::setWhatProduced(), throwSomeNullException(), and SequenceTypes::wait().

85  {
87  using TReturn = typename Types::return_type;
89  using ProductType = ESDeviceProduct<TProduct>;
90  using ReturnType = detail::ESDeviceProductWithStorage<TProduct, TReturn>;
91  return Base::setWhatProduced(
92  [function = std::forward<TFunc>(func)](TRecord const& record) -> std::unique_ptr<ProductType> {
93  // TODO: move the multiple device support into EventSetup system itself
94  auto const& devices = cms::alpakatools::devices<Platform>();
95  std::vector<std::shared_ptr<Queue>> queues;
96  queues.reserve(devices.size());
97  auto ret = std::make_unique<ReturnType>(devices.size());
98  bool allnull = true;
99  bool anynull = false;
100  for (auto const& dev : devices) {
101  device::Record<TRecord> const deviceRecord(record, dev);
102  auto prod = function(deviceRecord);
103  if (prod) {
104  allnull = false;
105  ret->insert(dev, std::move(prod));
106  } else {
107  anynull = true;
108  }
109  queues.push_back(deviceRecord.queuePtr());
110  }
111  // TODO: to be changed asynchronous later
112  for (auto& queuePtr : queues) {
113  alpaka::wait(*queuePtr);
114  }
115  if (allnull) {
116  return nullptr;
117  } else if (anynull) {
118  // TODO: throwing an exception if the iMethod() returns
119  // null for some of th devices of one backend is
120  // suboptimal. On the other hand, in the near term
121  // multiple devices per backend is useful only for
122  // private tests (not production), and the plan is to
123  // make the EventSetup system itself aware of multiple
124  // devies (or memory spaces). I hope this exception
125  // would be good-enough until we get there.
127  }
128  return ret;
129  },
130  label);
131  }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
ret
prodAgent to be discontinued
char const * label
std::map< DetId, double > ReturnType
Definition: Types.py:1
std::vector< alpaka::Dev< TPlatform > > const & devices()
Definition: devices.h:35
def move(src, dest)
Definition: eostools.py:511

◆ throwSomeNullException()

void ALPAKA_ACCELERATOR_NAMESPACE::ESProducer::throwSomeNullException ( )
staticprivate

Definition at line 9 of file ESProducer.cc.

References Exception, and edm::errors::UnimplementedFeature.

Referenced by setWhatProducedDevice().

9  {
11  << "The Alpaka backend has multiple devices. The device-specific produce() function returned a null product "
12  "for some of the devices of the backend, but not all. This is not currently supported.";
13  }

Member Data Documentation

◆ appendToDataLabel_

std::string const ALPAKA_ACCELERATOR_NAMESPACE::ESProducer::appendToDataLabel_
private

Definition at line 136 of file ESProducer.h.

◆ moduleLabel_

std::string const ALPAKA_ACCELERATOR_NAMESPACE::ESProducer::moduleLabel_
private