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::ESProductResolverFactoryProducer edm::eventsetup::ESProductResolverProvider

Static Public Member Functions

static void prevalidate (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
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
ESConsumesInfoconsumesInfoPushBackNew ()
 
unsigned int consumesInfoSize () const
 
template<typename CallbackT , typename TList , typename TRecord >
void registerProducts (std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>> iCallback, const TList *, const TRecord *iRecord, const es::Label &iLabel)
 
template<typename CallbackT , typename TRecord >
void registerProducts (std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>>, const eventsetup::produce::Null *, const TRecord *, const es::Label &)
 
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 TDecorator >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TDecorator &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::ESProductResolverFactoryProducer
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::ESProductResolverFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedResolversVector registerResolvers (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::ESProductResolverProvider
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
 
 ESProducer (ESProducer &&)=delete
 
ESResolverIndex const * getTokenIndices (unsigned int iIndex) const
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProduceroperator= (const ESProducer &)=delete
 
ESProduceroperator= (ESProducer &&)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector< ESResolverIndex > > updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProductResolverFactoryProducer
 ESProductResolverFactoryProducer ()
 
 ESProductResolverFactoryProducer (const ESProductResolverFactoryProducer &)=delete
 
const ESProductResolverFactoryProduceroperator= (const ESProductResolverFactoryProducer &)=delete
 
 ~ESProductResolverFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
void createKeyedResolvers (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
const ComponentDescriptiondescription () const
 
 ESProductResolverProvider ()
 
 ESProductResolverProvider (const ESProductResolverProvider &)=delete
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedResolverskeyedResolvers (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const ESProductResolverProvideroperator= (const ESProductResolverProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~ESProductResolverProvider () noexcept(false)
 
- Protected Types inherited from edm::ESProductResolverFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::ESProductResolverProvider
using KeyedResolversVector = std::vector< std::pair< DataKey, std::shared_ptr< ESProductResolver > >>
 

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 27 of file ESProducer.h.

Member Typedef Documentation

◆ Base

Definition at line 28 of file ESProducer.h.

Constructor & Destructor Documentation

◆ ESProducer()

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

Member Function Documentation

◆ prevalidate()

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

Definition at line 31 of file ESProducer.h.

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

31  {
32  Base::prevalidate(descriptions);
34  }
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

Definition at line 40 of file ESProducer.h.

40  {}) {
41  return setWhatProduced(iThis, &T::produce, label);
42  }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
char const * label

◆ 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 45 of file ESProducer.h.

45  {}) {
46  auto cc = Base::setWhatProduced(iThis, iMethod, label);
48  if constexpr (not detail::useESProductDirectly<TProduct>) {
49  // for device backends add the copy to device
50  auto tokenPtr = std::make_shared<edm::ESGetToken<TProduct, TRecord>>();
51  auto ccDev = setWhatProducedDevice<TRecord>(
52  [tokenPtr](device::Record<TRecord> const& iRecord) {
54  try {
55  auto handle = iRecord.getTransientHandle(*tokenPtr);
56  return std::optional{CopyT::copyAsync(iRecord.queue(), *handle)};
58  return std::optional<decltype(CopyT::copyAsync(std::declval<Queue&>(), std::declval<TProduct>()))>();
59  }
60  },
61  label);
62  *tokenPtr = ccDev.consumes(edm::ESInputTag{moduleLabel_, label.default_ + appendToDataLabel_});
63  }
64  return cc;
65  }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
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:239

◆ 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 68 of file ESProducer.h.

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

◆ setWhatProducedDevice()

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

Definition at line 90 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(), and SequenceTypes::wait().

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

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 141 of file ESProducer.h.

◆ moduleLabel_

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