muda
event.h
1 #pragma once
2 #include <muda/tools/flag.h>
3 #include <cuda.h>
4 #include <cuda_runtime.h>
5 #include <cuda_runtime_api.h>
6 #include <device_launch_parameters.h>
7 #include <muda/check/check_cuda_errors.h>
8 
9 namespace muda
10 {
14 class Event
15 {
16  cudaEvent_t m_handle = nullptr;
17 
18  public:
19  enum class Bit : unsigned int
20  {
21  eDefault = cudaEventDefault,
22  eBlockingSync = cudaEventBlockingSync,
23  eDisableTiming = cudaEventDisableTiming,
24  eInterprocess = cudaEventInterprocess
25  };
26 
27  enum class QueryResult
28  {
29  eFinished = cudaSuccess,
30  eNotReady = cudaErrorNotReady,
31  };
32 
34  ~Event();
35 
36  QueryResult query() const;
37  // elapsed time (in ms) between two events
38  static float elapsed_time(cudaEvent_t start, cudaEvent_t stop);
39 
40  operator cudaEvent_t() { return m_handle; }
41  cudaEvent_t viewer() const { return m_handle; }
42 
43  // delete copy constructor and assignment operator
44  Event(const Event&) = delete;
45  Event& operator=(const Event&) = delete;
46 
47  // allow move constructor
48  Event(Event&& o) MUDA_NOEXCEPT;
49  // delete move assignment operator
50  Event& operator=(Event&& o) MUDA_NOEXCEPT;
51 };
52 } // namespace muda
53 
54 #include "details/event.inl"
Event uses blocking synchronization.
Definition: assert.h:13
Bit
Definition: event.h:19
Default event flag.
RAII wrapper for cudaEvent
Definition: event.h:14
Definition: flag.h:8
Event will not record timing data.
Event is suitable for interprocess use.
QueryResult
Definition: event.h:27