event.h 471 Bytes
Newer Older
Nianchen Deng's avatar
sync    
Nianchen Deng committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <cuda_runtime.h>
#include <memory>

namespace utils::cuda {
    class Event {
    public:
        Event() : _p_event(std::make_shared<cudaEvent_t>()) { cudaEventCreate(_p_event.get()); }

        virtual ~Event() {
            if (_p_event.use_count() == 1)
                cudaEventDestroy(*_p_event);
        }

        operator cudaEvent_t() { return *_p_event; }

    private:
        std::shared_ptr<cudaEvent_t> _p_event;
    };
} // namespace utils::cuda