13 lines
432 B
C++
13 lines
432 B
C++
#include "stream_related.hpp"
|
|
|
|
namespace safe_cuda {
|
|
std::variant<std::unique_ptr<CUstream_st, streamDestroyType>, cudaError_t> create_stream() noexcept {
|
|
cudaStream_t stream = nullptr;
|
|
const cudaError_t error = cudaStreamCreate(&stream);
|
|
if (error != cudaSuccess) {
|
|
return error;
|
|
}
|
|
return std::unique_ptr<CUstream_st, streamDestroyType>{ stream, cudaStreamDestroy };
|
|
}
|
|
|
|
} |