/* Copyright (C) 2012, 2013 fmaj7b5.info This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef FM7b5_CUDA_EVENT_H #define FM7b5_CUDA_EVENT_H #include #include class Event { public: Event(); Event(unsigned int flags); ~Event(); operator cudaEvent_t(); cudaError_t query() const; cudaError_t record(cudaStream_t stream = (cudaStream_t)0) const; cudaError_t synchronize() const; protected: cudaEvent_t m_event; }; Event::Event() { cudaError_t status; status = cudaEventCreate(&m_event); if (status != cudaSuccess) { throw std::runtime_error(cudaGetErrorString(status)); } } Event::Event(unsigned int flags) { cudaError_t status; status = cudaEventCreateWithFlags(&m_event, flags); if (status != cudaSuccess) { throw std::runtime_error(cudaGetErrorString(status)); } } Event::~Event() { cudaError_t status; status = cudaEventDestroy(m_event); if (status != cudaSuccess) { throw std::runtime_error(cudaGetErrorString(status)); } } Event::operator cudaEvent_t() { return m_event; } cudaError_t Event::query() const { return cudaEventQuery(m_event); } cudaError_t Event::record(cudaStream_t stream) const { return cudaEventRecord(m_event, stream); } cudaError_t Event::synchronize() const { return cudaEventSynchronize(m_event); } #endif /* FM7b5_CUDA_EVENT_H */