CMS 3D CMS Logo

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

#include <ContextState.h>

Public Member Functions

 ContextState ()=default
 
 ContextState (const ContextState &)=delete
 
 ContextState (ContextState &&)=delete
 
ContextStateoperator= (const ContextState &)=delete
 
ContextStateoperator= (ContextState &&other)=delete
 
 ~ContextState ()=default
 

Private Member Functions

int device () const
 
SharedStreamPtr releaseStreamPtr ()
 
void set (int device, SharedStreamPtr stream)
 
const SharedStreamPtrstreamPtr () const
 
void throwIfNoStream () const
 
void throwIfStream () const
 

Private Attributes

int device_
 
SharedStreamPtr stream_
 

Friends

class ScopedContextAcquire
 
class ScopedContextProduce
 
class ScopedContextTask
 

Detailed Description

The purpose of this class is to deliver the device and CUDA stream information from ExternalWork's acquire() to producer() via a member/StreamCache variable.

Definition at line 15 of file ContextState.h.

Constructor & Destructor Documentation

◆ ContextState() [1/3]

cms::cuda::ContextState::ContextState ( )
default

◆ ~ContextState()

cms::cuda::ContextState::~ContextState ( )
default

◆ ContextState() [2/3]

cms::cuda::ContextState::ContextState ( const ContextState )
delete

◆ ContextState() [3/3]

cms::cuda::ContextState::ContextState ( ContextState &&  )
delete

Member Function Documentation

◆ device()

int cms::cuda::ContextState::device ( ) const
inlineprivate

Definition at line 36 of file ContextState.h.

36 { return device_; }

References device_.

Referenced by set().

◆ operator=() [1/2]

ContextState& cms::cuda::ContextState::operator= ( const ContextState )
delete

◆ operator=() [2/2]

ContextState& cms::cuda::ContextState::operator= ( ContextState &&  other)
delete

◆ releaseStreamPtr()

SharedStreamPtr cms::cuda::ContextState::releaseStreamPtr ( )
inlineprivate

Definition at line 43 of file ContextState.h.

43  {
45  // This function needs to effectively reset stream_ (i.e. stream_
46  // must be empty after this function). This behavior ensures that
47  // the SharedStreamPtr is not hold for inadvertedly long (i.e. to
48  // the next event), and is checked at run time.
49  return std::move(stream_);
50  }

References eostools::move(), stream_, and throwIfNoStream().

◆ set()

void cms::cuda::ContextState::set ( int  device,
SharedStreamPtr  stream 
)
inlineprivate

◆ streamPtr()

const SharedStreamPtr& cms::cuda::ContextState::streamPtr ( ) const
inlineprivate

Definition at line 38 of file ContextState.h.

38  {
40  return stream_;
41  }

References stream_, and throwIfNoStream().

◆ throwIfNoStream()

void cms::cuda::ContextState::throwIfNoStream ( ) const
private

Definition at line 11 of file ContextState.cc.

11  {
12  if (not stream_) {
13  throw cms::Exception("LogicError") << "Trying to get ContextState, but it did not have a valid state";
14  }
15  }

References Exception, and stream_.

Referenced by releaseStreamPtr(), and streamPtr().

◆ throwIfStream()

void cms::cuda::ContextState::throwIfStream ( ) const
private

Definition at line 5 of file ContextState.cc.

5  {
6  if (stream_) {
7  throw cms::Exception("LogicError") << "Trying to set ContextState, but it already had a valid state";
8  }
9  }

References Exception, and stream_.

Referenced by set().

Friends And Related Function Documentation

◆ ScopedContextAcquire

friend class ScopedContextAcquire
friend

Definition at line 26 of file ContextState.h.

◆ ScopedContextProduce

friend class ScopedContextProduce
friend

Definition at line 27 of file ContextState.h.

◆ ScopedContextTask

friend class ScopedContextTask
friend

Definition at line 28 of file ContextState.h.

Member Data Documentation

◆ device_

int cms::cuda::ContextState::device_
private

Definition at line 56 of file ContextState.h.

Referenced by device(), and set().

◆ stream_

SharedStreamPtr cms::cuda::ContextState::stream_
private

Definition at line 55 of file ContextState.h.

Referenced by releaseStreamPtr(), set(), streamPtr(), throwIfNoStream(), and throwIfStream().

cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
cms::cuda::ContextState::stream_
SharedStreamPtr stream_
Definition: ContextState.h:55
cms::cuda::ContextState::device_
int device_
Definition: ContextState.h:56
cms::cuda::ContextState::device
int device() const
Definition: ContextState.h:36
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:245
cms::cuda::ContextState::throwIfNoStream
void throwIfNoStream() const
Definition: ContextState.cc:11
cms::cuda::ContextState::throwIfStream
void throwIfStream() const
Definition: ContextState.cc:5