Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
739d7caa
Commit
739d7caa
authored
Nov 19, 2015
by
Maksim Shabunin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5659 from jet47:cuda-wrap-stream-2.4
parents
6148c352
8d3850ac
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
1 deletion
+39
-1
stream_accessor.hpp
modules/gpu/include/opencv2/gpu/stream_accessor.hpp
+1
-0
cudastream.cpp
modules/gpu/src/cudastream.cpp
+17
-1
test_stream.cpp
modules/gpu/test/test_stream.cpp
+21
-0
No files found.
modules/gpu/include/opencv2/gpu/stream_accessor.hpp
View file @
739d7caa
...
...
@@ -57,6 +57,7 @@ namespace cv
struct
StreamAccessor
{
CV_EXPORTS
static
cudaStream_t
getStream
(
const
Stream
&
stream
);
CV_EXPORTS
static
Stream
wrapStream
(
cudaStream_t
stream
);
};
}
}
...
...
modules/gpu/src/cudastream.cpp
View file @
739d7caa
...
...
@@ -89,6 +89,7 @@ struct Stream::Impl
}
cudaStream_t
stream
;
bool
own_stream
;
int
ref_counter
;
};
...
...
@@ -335,6 +336,7 @@ void cv::gpu::Stream::create()
impl
=
(
Stream
::
Impl
*
)
fastMalloc
(
sizeof
(
Stream
::
Impl
));
impl
->
stream
=
stream
;
impl
->
own_stream
=
true
;
impl
->
ref_counter
=
1
;
}
...
...
@@ -342,9 +344,23 @@ void cv::gpu::Stream::release()
{
if
(
impl
&&
CV_XADD
(
&
impl
->
ref_counter
,
-
1
)
==
1
)
{
cudaSafeCall
(
cudaStreamDestroy
(
impl
->
stream
)
);
if
(
impl
->
own_stream
)
{
cudaSafeCall
(
cudaStreamDestroy
(
impl
->
stream
)
);
}
cv
::
fastFree
(
impl
);
}
}
Stream
StreamAccessor
::
wrapStream
(
cudaStream_t
stream
)
{
Stream
::
Impl
*
impl
=
(
Stream
::
Impl
*
)
fastMalloc
(
sizeof
(
Stream
::
Impl
));
impl
->
stream
=
stream
;
impl
->
own_stream
=
false
;
impl
->
ref_counter
=
1
;
return
Stream
(
impl
);
}
#endif
/* !defined (HAVE_CUDA) */
modules/gpu/test/test_stream.cpp
View file @
739d7caa
...
...
@@ -44,6 +44,8 @@
#ifdef HAVE_CUDA
#include "opencv2/gpu/stream_accessor.hpp"
using
namespace
cvtest
;
#if CUDART_VERSION >= 5000
...
...
@@ -125,6 +127,25 @@ GPU_TEST_P(Async, Convert)
stream
.
waitForCompletion
();
}
GPU_TEST_P
(
Async
,
WrapStream
)
{
cudaStream_t
cuda_stream
=
NULL
;
ASSERT_EQ
(
cudaSuccess
,
cudaStreamCreate
(
&
cuda_stream
));
cv
::
gpu
::
Stream
stream
=
cv
::
gpu
::
StreamAccessor
::
wrapStream
(
cuda_stream
);
stream
.
enqueueUpload
(
src
,
d_src
);
stream
.
enqueueConvert
(
d_src
,
d_dst
,
CV_32S
);
stream
.
enqueueDownload
(
d_dst
,
dst
);
Async
*
test
=
this
;
stream
.
enqueueHostCallback
(
checkConvert
,
test
);
stream
.
waitForCompletion
();
ASSERT_EQ
(
cudaSuccess
,
cudaStreamDestroy
(
cuda_stream
));
}
INSTANTIATE_TEST_CASE_P
(
GPU_Stream
,
Async
,
ALL_DEVICES
);
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment