1
0
Fork 0
raii-safe-cuda/safe_cuda/stream_related.h

22 lines
625 B
C++

#ifndef RAIISAFECUDA_STREAM_RELATED_H
#define RAIISAFECUDA_STREAM_RELATED_H
#include <memory>
#include <cuda_runtime_api.h>
#include <variant>
namespace safe_cuda {
template<typename T>
using returnType = std::variant<T, cudaError_t>;
using streamDestroyType = decltype(&cudaStreamDestroy);
/**
* \brief It tries to create a stream, putting it in a smart pointer with its correct destructor.
* \return smart pointer if creation is OK, else the CUDA error
*/
returnType<std::unique_ptr<CUstream_st, streamDestroyType>> create_stream() noexcept;
}
#endif //RAIISAFECUDA_STREAM_RELATED_H