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.

References device_.

Referenced by set().

36 { return device_; }

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

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

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  }
void throwIfNoStream() const
Definition: ContextState.cc:11
SharedStreamPtr stream_
Definition: ContextState.h:55
def move(src, dest)
Definition: eostools.py:511

◆ set()

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

Definition at line 30 of file ContextState.h.

References device(), device_, eostools::move(), cms::cuda::stream, stream_, and throwIfStream().

Referenced by cms::cuda::ScopedContextAcquire::~ScopedContextAcquire().

30  {
31  throwIfStream();
32  device_ = device;
34  }
SharedStreamPtr stream_
Definition: ContextState.h:55
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
void throwIfStream() const
Definition: ContextState.cc:5
def move(src, dest)
Definition: eostools.py:511

◆ streamPtr()

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

Definition at line 38 of file ContextState.h.

References stream_, and throwIfNoStream().

38  {
40  return stream_;
41  }
void throwIfNoStream() const
Definition: ContextState.cc:11
SharedStreamPtr stream_
Definition: ContextState.h:55

◆ throwIfNoStream()

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

Definition at line 11 of file ContextState.cc.

References Exception, and stream_.

Referenced by releaseStreamPtr(), and streamPtr().

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

◆ throwIfStream()

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

Definition at line 5 of file ContextState.cc.

References Exception, and stream_.

Referenced by set().

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

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