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 (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 (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 ()
 
- Public Member Functions inherited from cms::cuda::impl::ScopedContextGetterBase
template<typename T >
const Tget (const edm::Event &iEvent, edm::EDGetTokenT< Product< T >> token)
 
template<typename T >
const Tget (const Product< T > &data)
 
- 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 (const ProductBase &data)
 
 ScopedContextBase (edm::StreamID streamID)
 
 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.

105  : ScopedContextGetterBase(streamID), holderHelper_{std::move(waitingTaskHolder)} {}

References eostools::move().

◆ 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.

111  : ScopedContextGetterBase(streamID), holderHelper_{std::move(waitingTaskHolder)}, contextState_{&state} {}

References eostools::move().

◆ 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.

115  : ScopedContextGetterBase(data), holderHelper_{std::move(waitingTaskHolder)} {}

References eostools::move().

◆ 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().

◆ ~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.

126  {
127  if (contextState_ == nullptr)
128  throwNoState();
129  holderHelper_.pushNextTask(std::forward<F>(f), contextState_);
130  }

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

◆ replaceWaitingTaskHolder()

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

◆ throwNoState()

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

Definition at line 100 of file ScopedContext.cc.

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  }

References Exception.

Referenced by pushNextTask().

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().

cms::cuda::ScopedContextAcquire::holderHelper_
impl::ScopedContextHolderHelper holderHelper_
Definition: ScopedContext.h:139
cms::cuda::ScopedContextAcquire::throwNoState
void throwNoState()
Definition: ScopedContext.cc:100
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
cms::cuda::impl::ScopedContextBase::stream
cudaStream_t stream() const
Definition: ScopedContext.h:34
cms::cuda::impl::ScopedContextHolderHelper::enqueueCallback
void enqueueCallback(int device, cudaStream_t stream)
Definition: ScopedContext.cc:85
cms::cuda::impl::ScopedContextHolderHelper::replaceWaitingTaskHolder
void replaceWaitingTaskHolder(edm::WaitingTaskWithArenaHolder waitingTaskHolder)
Definition: ScopedContext.h:83
cms::cuda::ScopedContextAcquire::contextState_
ContextState * contextState_
Definition: ScopedContext.h:140
cms::cuda::impl::ScopedContextHolderHelper::pushNextTask
void pushNextTask(F &&f, ContextState const *state)
Definition: ScopedContext.h:230
cms::cuda::impl::ScopedContextGetterBase::ScopedContextGetterBase
ScopedContextGetterBase(Args &&... args)
Definition: ScopedContext.h:70
cms::cuda::impl::ScopedContextBase::streamPtr
const SharedStreamPtr & streamPtr() const
Definition: ScopedContext.h:35
cms::cuda::ContextState::set
void set(int device, SharedStreamPtr stream)
Definition: ContextState.h:30
eostools.move
def move(src, dest)
Definition: eostools.py:511
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
Exception
Definition: hltDiff.cc:246
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
cms::cuda::impl::ScopedContextBase::device
int device() const
Definition: ScopedContext.h:28