MUDA
Loading...
Searching...
No Matches
event.inl
1namespace muda
2{
3MUDA_INLINE Event::Event(Flags<Bit> flag)
4{
5 checkCudaErrors(cudaEventCreateWithFlags(&m_handle, static_cast<unsigned int>(flag)));
6}
7
8MUDA_INLINE auto Event::query() const -> QueryResult
9{
10 auto res = cudaEventQuery(m_handle);
11 if(res != cudaSuccess && res != cudaErrorNotReady)
12 checkCudaErrors(res);
13 return static_cast<QueryResult>(res);
14}
15
16MUDA_INLINE float muda::Event::elapsed_time(cudaEvent_t start, cudaEvent_t stop)
17{
18 float time;
19 checkCudaErrors(cudaEventElapsedTime(&time, start, stop));
20 return time;
21}
22
23MUDA_INLINE Event::~Event()
24{
25 if(m_handle)
26 checkCudaErrors(cudaEventDestroy(m_handle));
27}
28
29MUDA_INLINE Event::Event(Event&& o) MUDA_NOEXCEPT : m_handle(o.m_handle)
30{
31 o.m_handle = nullptr;
32}
33
34MUDA_INLINE Event& Event::operator=(Event&& o) MUDA_NOEXCEPT
35{
36 if(this == &o)
37 return *this;
38
39 if(m_handle)
40 checkCudaErrors(cudaEventDestroy(m_handle));
41
42 m_handle = o.m_handle;
43 o.m_handle = nullptr;
44 return *this;
45}
46} // namespace muda
QueryResult
Definition event.h:28