CMS 3D CMS Logo

ContextState.h
Go to the documentation of this file.
1 #ifndef HeterogeneousCore_CUDACore_ContextState_h
2 #define HeterogeneousCore_CUDACore_ContextState_h
3 
5 
6 #include <memory>
7 
8 namespace cms {
9  namespace cuda {
15  class ContextState {
16  public:
17  ContextState() = default;
18  ~ContextState() = default;
19 
20  ContextState(const ContextState&) = delete;
21  ContextState& operator=(const ContextState&) = delete;
22  ContextState(ContextState&&) = delete;
24 
25  private:
26  friend class ScopedContextAcquire;
27  friend class ScopedContextProduce;
28  friend class ScopedContextTask;
29 
31  throwIfStream();
32  device_ = device;
34  }
35 
36  int device() const { return device_; }
37 
38  const SharedStreamPtr& streamPtr() const {
40  return stream_;
41  }
42 
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  }
51 
52  void throwIfStream() const;
53  void throwIfNoStream() const;
54 
56  int device_;
57  };
58  } // namespace cuda
59 } // namespace cms
60 
61 #endif
cms::cuda::ContextState::releaseStreamPtr
SharedStreamPtr releaseStreamPtr()
Definition: ContextState.h:43
cms::cuda::ScopedContextProduce
Definition: ScopedContext.h:149
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
cms::cuda::SharedStreamPtr
std::shared_ptr< std::remove_pointer_t< cudaStream_t > > SharedStreamPtr
Definition: SharedStreamPtr.h:14
cms::cuda::ContextState::stream_
SharedStreamPtr stream_
Definition: ContextState.h:55
cms::cuda::ContextState::~ContextState
~ContextState()=default
cms::cuda::ContextState::device_
int device_
Definition: ContextState.h:56
prod1Switch_cff.cuda
cuda
Definition: prod1Switch_cff.py:11
trackingPlots.other
other
Definition: trackingPlots.py:1467
cms::cuda::ContextState::device
int device() const
Definition: ContextState.h:36
cms::cuda::ContextState
Definition: ContextState.h:15
cms::cuda::ContextState::set
void set(int device, SharedStreamPtr stream)
Definition: ContextState.h:30
SharedStreamPtr.h
cms::cuda::ContextState::streamPtr
const SharedStreamPtr & streamPtr() const
Definition: ContextState.h:38
cms::cuda::ContextState::operator=
ContextState & operator=(const ContextState &)=delete
cms::cuda::ScopedContextAcquire
Definition: ScopedContext.h:101
eostools.move
def move(src, dest)
Definition: eostools.py:511
cms::cuda::ScopedContextTask
Definition: ScopedContext.h:192
cms::cuda::ContextState::throwIfNoStream
void throwIfNoStream() const
Definition: ContextState.cc:11
cms::cuda::ContextState::ContextState
ContextState()=default
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
cms::cuda::ContextState::throwIfStream
void throwIfStream() const
Definition: ContextState.cc:5