2 Copyright (C) 2012, 2013 fmaj7b5.info
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef FM7b5_CUDA_EVENT_H
19 #define FM7b5_CUDA_EVENT_H
22 #include <cuda_runtime.h>
28 Event(unsigned int flags);
30 operator cudaEvent_t();
32 cudaError_t query() const;
33 cudaError_t record(cudaStream_t stream = (cudaStream_t)0) const;
34 cudaError_t synchronize() const;
45 status = cudaEventCreate(&m_event);
47 if (status != cudaSuccess) {
48 throw std::runtime_error(cudaGetErrorString(status));
52 Event::Event(unsigned int flags)
56 status = cudaEventCreateWithFlags(&m_event, flags);
58 if (status != cudaSuccess) {
59 throw std::runtime_error(cudaGetErrorString(status));
67 status = cudaEventDestroy(m_event);
69 if (status != cudaSuccess) {
70 throw std::runtime_error(cudaGetErrorString(status));
74 Event::operator cudaEvent_t()
82 return cudaEventQuery(m_event);
86 Event::record(cudaStream_t stream) const
88 return cudaEventRecord(m_event, stream);
92 Event::synchronize() const
94 return cudaEventSynchronize(m_event);
97 #endif /* FM7b5_CUDA_EVENT_H */