CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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;
23  ContextState& operator=(ContextState&& other) = delete;
24 
25  private:
26  friend class ScopedContextAcquire;
27  friend class ScopedContextProduce;
28  friend class ScopedContextTask;
29 
31  throwIfStream();
32  device_ = device;
33  stream_ = std::move(stream);
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
const SharedStreamPtr & streamPtr() const
Definition: ContextState.h:38
SharedStreamPtr stream_
Definition: ContextState.h:55
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
std::shared_ptr< std::remove_pointer_t< cudaStream_t >> SharedStreamPtr
def move
Definition: eostools.py:511
void set(int device, SharedStreamPtr stream)
Definition: ContextState.h:30
SharedStreamPtr releaseStreamPtr()
Definition: ContextState.h:43
ContextState & operator=(const ContextState &)=delete
void throwIfStream() const
Definition: ContextState.cc:5
void throwIfNoStream() const
Definition: ContextState.cc:11