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::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

cms::cuda::ContextState::ContextState ( )
default
cms::cuda::ContextState::~ContextState ( )
default
cms::cuda::ContextState::ContextState ( const ContextState )
delete
cms::cuda::ContextState::ContextState ( ContextState &&  )
delete

Member Function Documentation

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

Definition at line 36 of file ContextState.h.

References device_.

Referenced by set().

36 { return device_; }
ContextState& cms::cuda::ContextState::operator= ( const ContextState )
delete
ContextState& cms::cuda::ContextState::operator= ( ContextState &&  other)
delete
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  }
SharedStreamPtr stream_
Definition: ContextState.h:55
def move
Definition: eostools.py:511
void throwIfNoStream() const
Definition: ContextState.cc:11
void cms::cuda::ContextState::set ( int  device,
SharedStreamPtr  stream 
)
inlineprivate

Definition at line 30 of file ContextState.h.

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

friend class ScopedContextAcquire
friend

Definition at line 26 of file ContextState.h.

friend class ScopedContextProduce
friend

Definition at line 27 of file ContextState.h.

friend class ScopedContextTask
friend

Definition at line 28 of file ContextState.h.

Member Data Documentation

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

Definition at line 56 of file ContextState.h.

Referenced by device(), and set().

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

Definition at line 55 of file ContextState.h.

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