Skip to content

Commit 283417d

Browse files
committed
guard from calling eventDestroy on NULL cuda events
1 parent b91df2c commit 283417d

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

taskflow/cuda/cuda_stream.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ struct cudaEventCreator {
185185
*/
186186
struct cudaEventDeleter {
187187
void operator () (cudaEvent_t event) const {
188-
cudaEventDestroy(event);
188+
if (event != nullptr) {
189+
cudaEventDestroy(event);
190+
}
189191
}
190192
};
191193

unittests/cuda/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ list(APPEND TF_CUDA_UNITTESTS
1515
test_cuda_merge
1616
test_cuda_basic_updates
1717
test_cuda_capturer_optimizer
18+
test_cuda_capture
1819

1920
#cuda_algorithms
2021
#cuda_algorithm_updates

unittests/cuda/test_cuda_capture.cu

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
2+
3+
#include <doctest.h>
4+
#include <taskflow/taskflow.hpp>
5+
#include <taskflow/cuda/cudaflow.hpp>
6+
7+
void __global__ testKernel() {}
8+
9+
TEST_CASE("cudaFlowCapturer.noEventError") {
10+
tf::cudaFlow f;
11+
f.capture([](tf::cudaFlowCapturer& cpt) {
12+
cpt.on([] (cudaStream_t stream) {
13+
testKernel<<<256,256,0,stream>>>();
14+
});
15+
REQUIRE((cudaGetLastError() == cudaSuccess));
16+
});
17+
REQUIRE((cudaGetLastError() == cudaSuccess));
18+
}

0 commit comments

Comments
 (0)