/*
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_STREAM_H
#define FM7b5_CUDA_STREAM_H
#include
#include
class Stream
{
public:
Stream();
~Stream();
operator cudaStream_t();
cudaError_t query() const;
cudaError_t synchronize() const;
cudaError_t wait_event(cudaEvent_t event, unsigned int flags) const;
protected:
cudaStream_t m_stream;
};
Stream::Stream()
{
cudaError_t status;
status = cudaStreamCreate(&m_stream);
if (status != cudaSuccess) {
throw std::runtime_error(cudaGetErrorString(status));
}
}
Stream::~Stream()
{
cudaError_t status;
status = cudaStreamDestroy(m_stream);
if (status != cudaSuccess) {
throw std::runtime_error(cudaGetErrorString(status));
}
}
Stream::operator cudaStream_t()
{
return m_stream;
}
cudaError_t
Stream::query() const
{
return cudaStreamQuery(m_stream);
}
cudaError_t
Stream::synchronize() const
{
return cudaStreamSynchronize(m_stream);
}
cudaError_t
Stream::wait_event(cudaEvent_t event, unsigned int flags) const
{
return cudaStreamWaitEvent(m_stream, event, flags);
}
#endif /* FM7b5_CUDA_STREAM_H */