CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Friends
ALPAKA_ACCELERATOR_NAMESPACE::ProducerBase< BaseT, Args > Class Template Reference

#include <ProducerBase.h>

Inheritance diagram for ALPAKA_ACCELERATOR_NAMESPACE::ProducerBase< BaseT, Args >:

Public Member Functions

template<edm::Transition Tr = edm::Transition::Event>
auto produces () noexcept
 
template<edm::Transition Tr = edm::Transition::Event>
auto produces (std::string instanceName) noexcept
 

Static Public Member Functions

static void prevalidate (edm::ConfigurationDescriptions &descriptions)
 

Private Types

using Base = BaseT< Args..., edm::Transformer >
 

Private Member Functions

template<typename TProduct , typename TToken , edm::Transition Tr>
edm::EDPutTokenT< TToken > deviceProduces (std::string instanceName)
 
template<typename TProduct , edm::Transition Tr>
edm::EDPutTokenT< TProduct > produces (std::string instanceName)
 

Friends

template<typename TProducer , edm::Transition Tr>
class ProducerBaseAdaptor
 

Detailed Description

template<template< typename... > class BaseT, typename... Args>
class ALPAKA_ACCELERATOR_NAMESPACE::ProducerBase< BaseT, Args >

The ProducerBase acts as a common base class for all Alpaka EDProducers. The main benefit is to have a single place for the definition of produces() functions.

The produces() functions return a custom ProducerBaseAdaptor in order to call the deviceProduces(). For device or asynchronous backends the deviceProduces() registers the automatic copy to host and a transformation from edm::DeviceProduct<T> to U, where U is the host-equivalent of T. The transformation from T to U is done by a specialization of cms::alpakatools::CopyToHost<T> class template, that should be provided in the same file where T is defined

TODO: add "override" for labelsForToken()

Definition at line 40 of file ProducerBase.h.

Member Typedef Documentation

◆ Base

template<template< typename... > class BaseT, typename... Args>
using ALPAKA_ACCELERATOR_NAMESPACE::ProducerBase< BaseT, Args >::Base = BaseT<Args..., edm::Transformer>
private

Definition at line 44 of file ProducerBase.h.

Member Function Documentation

◆ deviceProduces()

template<template< typename... > class BaseT, typename... Args>
template<typename TProduct , typename TToken , edm::Transition Tr>
edm::EDPutTokenT<TToken> ALPAKA_ACCELERATOR_NAMESPACE::ProducerBase< BaseT, Args >::deviceProduces ( std::string  instanceName)
inlineprivate

Definition at line 80 of file ProducerBase.h.

80  {
81  if constexpr (detail::useProductDirectly<TProduct>) {
82  return Base::template produces<TToken, Tr>(std::move(instanceName));
83  } else {
84  edm::EDPutTokenT<TToken> token = Base::template produces<TToken, Tr>(instanceName);
85  this->registerTransformAsync(
86  token,
87  [](TToken const& deviceProduct, edm::WaitingTaskWithArenaHolder holder) {
88  auto const& device = alpaka::getDev(deviceProduct.template metadata<EDMetadata>().queue());
89  detail::EDMetadataAcquireSentry sentry(device, std::move(holder));
90  auto metadataPtr = sentry.metadata();
91  constexpr bool tryReuseQueue = true;
92  TProduct const& productOnDevice =
93  deviceProduct.template getSynchronized<EDMetadata>(*metadataPtr, tryReuseQueue);
94 
96  auto productOnHost = CopyT::copyAsync(metadataPtr->queue(), productOnDevice);
97 
98  // Need to keep the EDMetadata object from sentry.finish()
99  // alive until the synchronization
100  using TplType = std::tuple<decltype(productOnHost), std::shared_ptr<EDMetadata>>;
101  // Wrap possibly move-only type into a copyable type
102  return std::make_shared<TplType>(std::move(productOnHost), sentry.finish());
103  },
104  [](auto tplPtr) { return std::move(std::get<0>(*tplPtr)); },
105  std::move(instanceName));
106  return token;
107  }
108  }
void copyAsync(device::unique_ptr< T > &dst, const host::unique_ptr< T > &src, cudaStream_t stream)
Definition: copyAsync.h:20
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
def move(src, dest)
Definition: eostools.py:511

◆ prevalidate()

template<template< typename... > class BaseT, typename... Args>
static void ALPAKA_ACCELERATOR_NAMESPACE::ProducerBase< BaseT, Args >::prevalidate ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 57 of file ProducerBase.h.

57  {
58  Base::prevalidate(descriptions);
60  }
void module_backend_config(edm::ConfigurationDescriptions &iDesc)

◆ produces() [1/3]

template<template< typename... > class BaseT, typename... Args>
template<edm::Transition Tr = edm::Transition::Event>
auto ALPAKA_ACCELERATOR_NAMESPACE::ProducerBase< BaseT, Args >::produces ( )
inlinenoexcept

Definition at line 48 of file ProducerBase.h.

48  {
49  return ProducerBaseAdaptor<ProducerBase, Tr>(*this);
50  }

◆ produces() [2/3]

template<template< typename... > class BaseT, typename... Args>
template<edm::Transition Tr = edm::Transition::Event>
auto ALPAKA_ACCELERATOR_NAMESPACE::ProducerBase< BaseT, Args >::produces ( std::string  instanceName)
inlinenoexcept

Definition at line 53 of file ProducerBase.h.

53  {
54  return ProducerBaseAdaptor<ProducerBase, Tr>(*this, std::move(instanceName));
55  }
def move(src, dest)
Definition: eostools.py:511

◆ produces() [3/3]

template<template< typename... > class BaseT, typename... Args>
template<typename TProduct , edm::Transition Tr>
edm::EDPutTokenT<TProduct> ALPAKA_ACCELERATOR_NAMESPACE::ProducerBase< BaseT, Args >::produces ( std::string  instanceName)
inlineprivate

Definition at line 71 of file ProducerBase.h.

71  {
72  return Base::template produces<TProduct, Tr>(std::move(instanceName));
73  }
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
def move(src, dest)
Definition: eostools.py:511

Friends And Related Function Documentation

◆ ProducerBaseAdaptor

template<template< typename... > class BaseT, typename... Args>
template<typename TProducer , edm::Transition Tr>
friend class ProducerBaseAdaptor
friend

Definition at line 64 of file ProducerBase.h.