CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
cms::cuda::ScopedContextProduce Class Reference

#include <ScopedContext.h>

Inheritance diagram for cms::cuda::ScopedContextProduce:
cms::cuda::impl::ScopedContextGetterBase cms::cuda::impl::ScopedContextBase

Public Member Functions

template<typename T , typename... Args>
auto emplace (edm::Event &iEvent, edm::EDPutTokenT< T > token, Args &&...args)
 
 ScopedContextProduce (edm::StreamID streamID)
 Constructor to create a new CUDA stream (non-ExternalWork module) More...
 
 ScopedContextProduce (const ProductBase &data)
 Constructor to (possibly) re-use a CUDA stream (non-ExternalWork module) More...
 
 ScopedContextProduce (ContextState &state)
 Constructor to re-use the CUDA stream of acquire() (ExternalWork module) More...
 
template<typename T >
std::unique_ptr< Product< T > > wrap (T data)
 
 ~ScopedContextProduce ()
 Record the CUDA event, all asynchronous work must have been queued before the destructor. More...
 
- Public Member Functions inherited from cms::cuda::impl::ScopedContextGetterBase
template<typename T >
const Tget (const Product< T > &data)
 
template<typename T >
const Tget (const edm::Event &iEvent, edm::EDGetTokenT< Product< T >> token)
 
- Public Member Functions inherited from cms::cuda::impl::ScopedContextBase
int device () const
 
cudaStream_t stream () const
 
const SharedStreamPtrstreamPtr () const
 

Private Member Functions

 ScopedContextProduce (int device, SharedStreamPtr stream, SharedEventPtr event)
 

Private Attributes

SharedEventPtr event_ = getEventCache().get()
 

Friends

class cudatest::TestScopedContext
 

Additional Inherited Members

- Protected Member Functions inherited from cms::cuda::impl::ScopedContextGetterBase
template<typename... Args>
 ScopedContextGetterBase (Args &&...args)
 
void synchronizeStreams (int dataDevice, cudaStream_t dataStream, bool available, cudaEvent_t dataEvent)
 
- Protected Member Functions inherited from cms::cuda::impl::ScopedContextBase
 ScopedContextBase (edm::StreamID streamID)
 
 ScopedContextBase (const ProductBase &data)
 
 ScopedContextBase (int device, SharedStreamPtr stream)
 

Detailed Description

The aim of this class is to do necessary per-event "initialization" in ExternalWork produce() or normal produce():

Definition at line 149 of file ScopedContext.h.

Constructor & Destructor Documentation

cms::cuda::ScopedContextProduce::ScopedContextProduce ( edm::StreamID  streamID)
inlineexplicit

Constructor to create a new CUDA stream (non-ExternalWork module)

Definition at line 152 of file ScopedContext.h.

152 : ScopedContextGetterBase(streamID) {}
cms::cuda::ScopedContextProduce::ScopedContextProduce ( const ProductBase data)
inlineexplicit

Constructor to (possibly) re-use a CUDA stream (non-ExternalWork module)

Definition at line 155 of file ScopedContext.h.

char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
cms::cuda::ScopedContextProduce::ScopedContextProduce ( ContextState state)
inlineexplicit

Constructor to re-use the CUDA stream of acquire() (ExternalWork module)

Definition at line 158 of file ScopedContext.h.

159  : ScopedContextGetterBase(state.device(), state.releaseStreamPtr()) {}
cms::cuda::ScopedContextProduce::~ScopedContextProduce ( )

Record the CUDA event, all asynchronous work must have been queued before the destructor.

Definition at line 108 of file ScopedContext.cc.

References event_, and cms::cuda::impl::ScopedContextBase::stream().

108  {
109  // Intentionally not checking the return value to avoid throwing
110  // exceptions. If this call would fail, we should get failures
111  // elsewhere as well.
112  cudaEventRecord(event_.get(), stream());
113  }
cudaStream_t stream() const
Definition: ScopedContext.h:34
cms::cuda::ScopedContextProduce::ScopedContextProduce ( int  device,
SharedStreamPtr  stream,
SharedEventPtr  event 
)
inlineexplicitprivate

Member Function Documentation

template<typename T , typename... Args>
auto cms::cuda::ScopedContextProduce::emplace ( edm::Event iEvent,
edm::EDPutTokenT< T token,
Args &&...  args 
)
inline

Definition at line 171 of file ScopedContext.h.

References writedatasetfile::args, cms::cuda::impl::ScopedContextBase::device(), edm::Event::emplace(), event_, and cms::cuda::impl::ScopedContextBase::streamPtr().

171  {
172  return iEvent.emplace(token, device(), streamPtr(), event_, std::forward<Args>(args)...);
173  }
const SharedStreamPtr & streamPtr() const
Definition: ScopedContext.h:35
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
Definition: Event.h:433
template<typename T >
std::unique_ptr<Product<T> > cms::cuda::ScopedContextProduce::wrap ( T  data)
inline

Definition at line 165 of file ScopedContext.h.

References cms::cuda::impl::ScopedContextBase::device(), event_, eostools::move(), and cms::cuda::impl::ScopedContextBase::streamPtr().

165  {
166  // make_unique doesn't work because of private constructor
167  return std::unique_ptr<Product<T>>(new Product<T>(device(), streamPtr(), event_, std::move(data)));
168  }
const SharedStreamPtr & streamPtr() const
Definition: ScopedContext.h:35
def move
Definition: eostools.py:511
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79

Friends And Related Function Documentation

friend class cudatest::TestScopedContext
friend

Definition at line 176 of file ScopedContext.h.

Member Data Documentation

SharedEventPtr cms::cuda::ScopedContextProduce::event_ = getEventCache().get()
private

Definition at line 183 of file ScopedContext.h.

Referenced by emplace(), wrap(), and ~ScopedContextProduce().