CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
cms::cuda::ScopedContextAcquire Class Reference

#include <ScopedContext.h>

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

Public Member Functions

template<typename F >
void pushNextTask (F &&f)
 
void replaceWaitingTaskHolder (edm::WaitingTaskWithArenaHolder waitingTaskHolder)
 
 ScopedContextAcquire (edm::StreamID streamID, edm::WaitingTaskWithArenaHolder waitingTaskHolder)
 Constructor to create a new CUDA stream (no need for context beyond acquire()) More...
 
 ScopedContextAcquire (edm::StreamID streamID, edm::WaitingTaskWithArenaHolder waitingTaskHolder, ContextState &state)
 Constructor to create a new CUDA stream, and the context is needed after acquire() More...
 
 ScopedContextAcquire (const ProductBase &data, edm::WaitingTaskWithArenaHolder waitingTaskHolder)
 Constructor to (possibly) re-use a CUDA stream (no need for context beyond acquire()) More...
 
 ScopedContextAcquire (const ProductBase &data, edm::WaitingTaskWithArenaHolder waitingTaskHolder, ContextState &state)
 Constructor to (possibly) re-use a CUDA stream, and the context is needed after acquire() More...
 
 ~ScopedContextAcquire ()
 
- 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

void throwNoState ()
 

Private Attributes

ContextStatecontextState_ = nullptr
 
impl::ScopedContextHolderHelper holderHelper_
 

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 acquire():

Definition at line 101 of file ScopedContext.h.

Constructor & Destructor Documentation

◆ ScopedContextAcquire() [1/4]

cms::cuda::ScopedContextAcquire::ScopedContextAcquire ( edm::StreamID  streamID,
edm::WaitingTaskWithArenaHolder  waitingTaskHolder 
)
inlineexplicit

Constructor to create a new CUDA stream (no need for context beyond acquire())

Definition at line 104 of file ScopedContext.h.

References eostools::move().

105  : ScopedContextGetterBase(streamID), holderHelper_{std::move(waitingTaskHolder)} {}
impl::ScopedContextHolderHelper holderHelper_
def move(src, dest)
Definition: eostools.py:511

◆ ScopedContextAcquire() [2/4]

cms::cuda::ScopedContextAcquire::ScopedContextAcquire ( edm::StreamID  streamID,
edm::WaitingTaskWithArenaHolder  waitingTaskHolder,
ContextState state 
)
inlineexplicit

Constructor to create a new CUDA stream, and the context is needed after acquire()

Definition at line 108 of file ScopedContext.h.

References eostools::move().

111  : ScopedContextGetterBase(streamID), holderHelper_{std::move(waitingTaskHolder)}, contextState_{&state} {}
impl::ScopedContextHolderHelper holderHelper_
def move(src, dest)
Definition: eostools.py:511

◆ ScopedContextAcquire() [3/4]

cms::cuda::ScopedContextAcquire::ScopedContextAcquire ( const ProductBase data,
edm::WaitingTaskWithArenaHolder  waitingTaskHolder 
)
inlineexplicit

Constructor to (possibly) re-use a CUDA stream (no need for context beyond acquire())

Definition at line 114 of file ScopedContext.h.

References eostools::move().

115  : ScopedContextGetterBase(data), holderHelper_{std::move(waitingTaskHolder)} {}
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
impl::ScopedContextHolderHelper holderHelper_
def move(src, dest)
Definition: eostools.py:511

◆ ScopedContextAcquire() [4/4]

cms::cuda::ScopedContextAcquire::ScopedContextAcquire ( const ProductBase data,
edm::WaitingTaskWithArenaHolder  waitingTaskHolder,
ContextState state 
)
inlineexplicit

Constructor to (possibly) re-use a CUDA stream, and the context is needed after acquire()

Definition at line 118 of file ScopedContext.h.

References eostools::move().

char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
impl::ScopedContextHolderHelper holderHelper_
def move(src, dest)
Definition: eostools.py:511

◆ ~ScopedContextAcquire()

cms::cuda::ScopedContextAcquire::~ScopedContextAcquire ( )

Member Function Documentation

◆ pushNextTask()

template<typename F >
void cms::cuda::ScopedContextAcquire::pushNextTask ( F &&  f)
inline

Definition at line 126 of file ScopedContext.h.

References contextState_, f, holderHelper_, cms::cuda::impl::ScopedContextHolderHelper::pushNextTask(), and throwNoState().

126  {
127  if (contextState_ == nullptr)
128  throwNoState();
129  holderHelper_.pushNextTask(std::forward<F>(f), contextState_);
130  }
void pushNextTask(F &&f, ContextState const *state)
double f[11][100]
impl::ScopedContextHolderHelper holderHelper_

◆ replaceWaitingTaskHolder()

void cms::cuda::ScopedContextAcquire::replaceWaitingTaskHolder ( edm::WaitingTaskWithArenaHolder  waitingTaskHolder)
inline

Definition at line 132 of file ScopedContext.h.

References holderHelper_, eostools::move(), and cms::cuda::impl::ScopedContextHolderHelper::replaceWaitingTaskHolder().

132  {
134  }
void replaceWaitingTaskHolder(edm::WaitingTaskWithArenaHolder waitingTaskHolder)
Definition: ScopedContext.h:83
impl::ScopedContextHolderHelper holderHelper_
def move(src, dest)
Definition: eostools.py:511

◆ throwNoState()

void cms::cuda::ScopedContextAcquire::throwNoState ( )
private

Definition at line 100 of file ScopedContext.cc.

References Exception.

Referenced by pushNextTask().

100  {
101  throw cms::Exception("LogicError")
102  << "Calling ScopedContextAcquire::insertNextTask() requires ScopedContextAcquire to be constructed with "
103  "ContextState, but that was not the case";
104  }

Member Data Documentation

◆ contextState_

ContextState* cms::cuda::ScopedContextAcquire::contextState_ = nullptr
private

Definition at line 140 of file ScopedContext.h.

Referenced by pushNextTask(), and ~ScopedContextAcquire().

◆ holderHelper_

impl::ScopedContextHolderHelper cms::cuda::ScopedContextAcquire::holderHelper_
private

Definition at line 139 of file ScopedContext.h.

Referenced by pushNextTask(), replaceWaitingTaskHolder(), and ~ScopedContextAcquire().