Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
0de61658
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0de61658
编写于
12月 08, 2015
作者:
V
Vadim Pisarevsky
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5660 from jet47:cuda-wrap-stream-3.0
上级
9c0a5523
39854ced
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
72 addition
and
16 deletion
+72
-16
modules/core/include/opencv2/core/cuda.hpp
modules/core/include/opencv2/core/cuda.hpp
+1
-0
modules/core/include/opencv2/core/cuda.inl.hpp
modules/core/include/opencv2/core/cuda.inl.hpp
+10
-0
modules/core/include/opencv2/core/cuda_stream_accessor.hpp
modules/core/include/opencv2/core/cuda_stream_accessor.hpp
+3
-4
modules/core/src/cuda_stream.cpp
modules/core/src/cuda_stream.cpp
+36
-12
modules/cudaarithm/test/test_stream.cpp
modules/cudaarithm/test/test_stream.cpp
+22
-0
未找到文件。
modules/core/include/opencv2/core/cuda.hpp
浏览文件 @
0de61658
...
...
@@ -528,6 +528,7 @@ public:
private:
Ptr
<
Impl
>
impl_
;
Event
(
const
Ptr
<
Impl
>&
impl
);
friend
struct
EventAccessor
;
};
...
...
modules/core/include/opencv2/core/cuda.inl.hpp
浏览文件 @
0de61658
...
...
@@ -540,6 +540,16 @@ Stream::Stream(const Ptr<Impl>& impl)
{
}
//===================================================================================
// Event
//===================================================================================
inline
Event
::
Event
(
const
Ptr
<
Impl
>&
impl
)
:
impl_
(
impl
)
{
}
//===================================================================================
// Initialization & Info
//===================================================================================
...
...
modules/core/include/opencv2/core/cuda_stream_accessor.hpp
浏览文件 @
0de61658
...
...
@@ -52,7 +52,7 @@
*/
#include <cuda_runtime.h>
#include "opencv2/core/c
vdef.h
"
#include "opencv2/core/c
uda.hpp
"
namespace
cv
{
...
...
@@ -62,14 +62,12 @@ namespace cv
//! @addtogroup cudacore_struct
//! @{
class
Stream
;
class
Event
;
/** @brief Class that enables getting cudaStream_t from cuda::Stream
*/
struct
StreamAccessor
{
CV_EXPORTS
static
cudaStream_t
getStream
(
const
Stream
&
stream
);
CV_EXPORTS
static
Stream
wrapStream
(
cudaStream_t
stream
);
};
/** @brief Class that enables getting cudaEvent_t from cuda::Event
...
...
@@ -77,6 +75,7 @@ namespace cv
struct
EventAccessor
{
CV_EXPORTS
static
cudaEvent_t
getEvent
(
const
Event
&
event
);
CV_EXPORTS
static
Event
wrapEvent
(
cudaEvent_t
event
);
};
//! @}
...
...
modules/core/src/cuda_stream.cpp
浏览文件 @
0de61658
...
...
@@ -280,32 +280,37 @@ class cv::cuda::Stream::Impl
{
public:
cudaStream_t
stream
;
Ptr
<
StackAllocator
>
stackAllocator_
;
bool
ownStream
;
Ptr
<
StackAllocator
>
stackAllocator
;
Impl
();
Impl
(
cudaStream_t
stream
);
explicit
Impl
(
cudaStream_t
stream
);
~
Impl
();
};
cv
::
cuda
::
Stream
::
Impl
::
Impl
()
:
stream
(
0
)
cv
::
cuda
::
Stream
::
Impl
::
Impl
()
:
stream
(
0
)
,
ownStream
(
false
)
{
cudaSafeCall
(
cudaStreamCreate
(
&
stream
)
);
ownStream
=
true
;
stackAllocator
_
=
makePtr
<
StackAllocator
>
(
stream
);
stackAllocator
=
makePtr
<
StackAllocator
>
(
stream
);
}
cv
::
cuda
::
Stream
::
Impl
::
Impl
(
cudaStream_t
stream_
)
:
stream
(
stream_
)
cv
::
cuda
::
Stream
::
Impl
::
Impl
(
cudaStream_t
stream_
)
:
stream
(
stream_
)
,
ownStream
(
false
)
{
stackAllocator
_
=
makePtr
<
StackAllocator
>
(
stream
);
stackAllocator
=
makePtr
<
StackAllocator
>
(
stream
);
}
cv
::
cuda
::
Stream
::
Impl
::~
Impl
()
{
stackAllocator
_
.
release
();
stackAllocator
.
release
();
if
(
stream
)
if
(
stream
&&
ownStream
)
{
cudaStreamDestroy
(
stream
);
}
}
#endif
...
...
@@ -516,6 +521,11 @@ cudaStream_t cv::cuda::StreamAccessor::getStream(const Stream& stream)
return
stream
.
impl_
->
stream
;
}
Stream
cv
::
cuda
::
StreamAccessor
::
wrapStream
(
cudaStream_t
stream
)
{
return
Stream
(
makePtr
<
Stream
::
Impl
>
(
stream
));
}
#endif
/////////////////////////////////////////////////////////////
...
...
@@ -660,7 +670,7 @@ void cv::cuda::setBufferPoolConfig(int deviceId, size_t stackSize, int stackCoun
#ifdef HAVE_CUDA
cv
::
cuda
::
BufferPool
::
BufferPool
(
Stream
&
stream
)
:
allocator_
(
stream
.
impl_
->
stackAllocator
_
.
get
())
cv
::
cuda
::
BufferPool
::
BufferPool
(
Stream
&
stream
)
:
allocator_
(
stream
.
impl_
->
stackAllocator
.
get
())
{
}
...
...
@@ -693,20 +703,29 @@ class cv::cuda::Event::Impl
{
public:
cudaEvent_t
event
;
bool
ownEvent
;
Impl
(
unsigned
int
flags
);
explicit
Impl
(
unsigned
int
flags
);
explicit
Impl
(
cudaEvent_t
event
);
~
Impl
();
};
cv
::
cuda
::
Event
::
Impl
::
Impl
(
unsigned
int
flags
)
:
event
(
0
)
cv
::
cuda
::
Event
::
Impl
::
Impl
(
unsigned
int
flags
)
:
event
(
0
)
,
ownEvent
(
false
)
{
cudaSafeCall
(
cudaEventCreateWithFlags
(
&
event
,
flags
)
);
ownEvent
=
true
;
}
cv
::
cuda
::
Event
::
Impl
::
Impl
(
cudaEvent_t
e
)
:
event
(
e
),
ownEvent
(
false
)
{
}
cv
::
cuda
::
Event
::
Impl
::~
Impl
()
{
if
(
event
)
if
(
event
&&
ownEvent
)
{
cudaEventDestroy
(
event
);
}
}
cudaEvent_t
cv
::
cuda
::
EventAccessor
::
getEvent
(
const
Event
&
event
)
...
...
@@ -714,6 +733,11 @@ cudaEvent_t cv::cuda::EventAccessor::getEvent(const Event& event)
return
event
.
impl_
->
event
;
}
Event
cv
::
cuda
::
EventAccessor
::
wrapEvent
(
cudaEvent_t
event
)
{
return
Event
(
makePtr
<
Event
::
Impl
>
(
event
));
}
#endif
cv
::
cuda
::
Event
::
Event
(
CreateFlags
flags
)
...
...
modules/cudaarithm/test/test_stream.cpp
浏览文件 @
0de61658
...
...
@@ -47,6 +47,7 @@
#include <cuda_runtime.h>
#include "opencv2/core/cuda.hpp"
#include "opencv2/core/cuda_stream_accessor.hpp"
#include "opencv2/ts/cuda_test.hpp"
using
namespace
cvtest
;
...
...
@@ -129,6 +130,27 @@ CUDA_TEST_P(Async, Convert)
stream
.
waitForCompletion
();
}
CUDA_TEST_P
(
Async
,
WrapStream
)
{
cudaStream_t
cuda_stream
=
NULL
;
ASSERT_EQ
(
cudaSuccess
,
cudaStreamCreate
(
&
cuda_stream
));
{
cv
::
cuda
::
Stream
stream
=
cv
::
cuda
::
StreamAccessor
::
wrapStream
(
cuda_stream
);
d_src
.
upload
(
src
,
stream
);
d_src
.
convertTo
(
d_dst
,
CV_32S
,
stream
);
d_dst
.
download
(
dst
,
stream
);
Async
*
test
=
this
;
stream
.
enqueueHostCallback
(
checkConvert
,
test
);
stream
.
waitForCompletion
();
}
ASSERT_EQ
(
cudaSuccess
,
cudaStreamDestroy
(
cuda_stream
));
}
CUDA_TEST_P
(
Async
,
HostMemAllocator
)
{
cv
::
cuda
::
Stream
stream
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录