From c0a108bf4a96101551742154eb826ffc0278b976 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Sun, 8 Nov 2020 06:47:47 +0100 Subject: [PATCH] nvidia/cuda/stream: Add synchronize function --- source/nvidia/cuda/nvidia-cuda-stream.cpp | 8 ++++++++ source/nvidia/cuda/nvidia-cuda-stream.hpp | 2 ++ 2 files changed, 10 insertions(+) diff --git a/source/nvidia/cuda/nvidia-cuda-stream.cpp b/source/nvidia/cuda/nvidia-cuda-stream.cpp index b2e58e85..f1acccc5 100644 --- a/source/nvidia/cuda/nvidia-cuda-stream.cpp +++ b/source/nvidia/cuda/nvidia-cuda-stream.cpp @@ -64,3 +64,11 @@ nvidia::cuda::stream::~stream() { return _stream; } + +void nvidia::cuda::stream::synchronize() +{ + D_LOG_DEBUG("Synchronizing... (Addr: 0x%" PRIuPTR ")", this); + if (auto res = _cuda->cuStreamSynchronize(_stream); res != ::nvidia::cuda::result::SUCCESS) { + throw ::nvidia::cuda::cuda_error(res); + } +} diff --git a/source/nvidia/cuda/nvidia-cuda-stream.hpp b/source/nvidia/cuda/nvidia-cuda-stream.hpp index ecbb8599..d7a01680 100644 --- a/source/nvidia/cuda/nvidia-cuda-stream.hpp +++ b/source/nvidia/cuda/nvidia-cuda-stream.hpp @@ -31,5 +31,7 @@ namespace nvidia::cuda { stream(::nvidia::cuda::stream_flags flags = ::nvidia::cuda::stream_flags::DEFAULT, int32_t priority = 0); ::nvidia::cuda::stream_t get(); + + void synchronize(); }; } // namespace nvidia::cuda