Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
f17b836d
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
f17b836d
编写于
4月 23, 2013
作者:
V
Vladislav Vinogradov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added Event class (wrapper for cudaEvent)
上级
2dab93c2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
164 addition
and
0 deletion
+164
-0
modules/core/include/opencv2/core/base.hpp
modules/core/include/opencv2/core/base.hpp
+1
-0
modules/core/include/opencv2/core/gpu.hpp
modules/core/include/opencv2/core/gpu.hpp
+37
-0
modules/core/include/opencv2/core/gpu_stream_accessor.hpp
modules/core/include/opencv2/core/gpu_stream_accessor.hpp
+6
-0
modules/core/src/gpu_stream.cpp
modules/core/src/gpu_stream.cpp
+120
-0
未找到文件。
modules/core/include/opencv2/core/base.hpp
浏览文件 @
f17b836d
...
...
@@ -495,6 +495,7 @@ namespace gpu
class
CV_EXPORTS
GpuMat
;
class
CV_EXPORTS
CudaMem
;
class
CV_EXPORTS
Stream
;
class
CV_EXPORTS
Event
;
}
}
// cv
...
...
modules/core/include/opencv2/core/gpu.hpp
浏览文件 @
f17b836d
...
...
@@ -359,6 +359,9 @@ public:
//! waits for stream tasks to complete
void
waitForCompletion
();
//! makes a compute stream wait on an event
void
waitEvent
(
const
Event
&
event
);
//! adds a callback to be called on the host after all currently enqueued items in the stream have completed
void
enqueueHostCallback
(
StreamCallback
callback
,
void
*
userData
);
...
...
@@ -390,6 +393,39 @@ private:
friend
struct
StreamAccessor
;
};
class
CV_EXPORTS
Event
{
public:
enum
CreateFlags
{
DEFAULT
=
0x00
,
/**< Default event flag */
BLOCKING_SYNC
=
0x01
,
/**< Event uses blocking synchronization */
DISABLE_TIMING
=
0x02
,
/**< Event will not record timing data */
INTERPROCESS
=
0x04
/**< Event is suitable for interprocess use. DisableTiming must be set */
};
explicit
Event
(
CreateFlags
flags
=
DEFAULT
);
//! records an event
void
record
(
Stream
&
stream
=
Stream
::
Null
());
//! queries an event's status
bool
queryIfComplete
()
const
;
//! waits for an event to complete
void
waitForCompletion
();
//! computes the elapsed time between events
static
float
elapsedTime
(
const
Event
&
start
,
const
Event
&
end
);
class
Impl
;
private:
Ptr
<
Impl
>
impl_
;
friend
struct
EventAccessor
;
};
//////////////////////////////// Initialization & Info ////////////////////////
//! this is the only function that do not throw exceptions if the library is compiled without CUDA
...
...
@@ -642,6 +678,7 @@ CV_EXPORTS void printShortCudaDeviceInfo(int device);
namespace
cv
{
template
<
>
CV_EXPORTS
void
Ptr
<
cv
::
gpu
::
Stream
::
Impl
>::
delete_obj
();
template
<
>
CV_EXPORTS
void
Ptr
<
cv
::
gpu
::
Event
::
Impl
>::
delete_obj
();
}
...
...
modules/core/include/opencv2/core/gpu_stream_accessor.hpp
浏览文件 @
f17b836d
...
...
@@ -60,11 +60,17 @@ namespace cv
namespace
gpu
{
class
Stream
;
class
Event
;
struct
StreamAccessor
{
CV_EXPORTS
static
cudaStream_t
getStream
(
const
Stream
&
stream
);
};
struct
EventAccessor
{
CV_EXPORTS
static
cudaEvent_t
getEvent
(
const
Event
&
event
);
};
}
}
...
...
modules/core/src/gpu_stream.cpp
浏览文件 @
f17b836d
...
...
@@ -45,6 +45,9 @@
using
namespace
cv
;
using
namespace
cv
::
gpu
;
////////////////////////////////////////////////////////////////
// Stream
#ifndef HAVE_CUDA
class
cv
::
gpu
::
Stream
::
Impl
...
...
@@ -126,6 +129,16 @@ void cv::gpu::Stream::waitForCompletion()
#endif
}
void
cv
::
gpu
::
Stream
::
waitEvent
(
const
Event
&
event
)
{
#ifndef HAVE_CUDA
(
void
)
event
;
throw_no_cuda
();
#else
cudaSafeCall
(
cudaStreamWaitEvent
(
impl_
->
stream
,
EventAccessor
::
getEvent
(
event
),
0
)
);
#endif
}
#if defined(HAVE_CUDA) && (CUDART_VERSION >= 5000)
namespace
...
...
@@ -186,3 +199,110 @@ template <> void cv::Ptr<Stream::Impl>::delete_obj()
{
if
(
obj
)
delete
obj
;
}
////////////////////////////////////////////////////////////////
// Stream
#ifndef HAVE_CUDA
class
cv
::
gpu
::
Event
::
Impl
{
public:
Impl
(
unsigned
int
)
{
throw_no_cuda
();
}
};
#else
class
cv
::
gpu
::
Event
::
Impl
{
public:
cudaEvent_t
event
;
Impl
(
unsigned
int
flags
);
~
Impl
();
};
cv
::
gpu
::
Event
::
Impl
::
Impl
(
unsigned
int
flags
)
:
event
(
0
)
{
cudaSafeCall
(
cudaEventCreateWithFlags
(
&
event
,
flags
)
);
}
cv
::
gpu
::
Event
::
Impl
::~
Impl
()
{
if
(
event
)
cudaEventDestroy
(
event
);
}
cudaEvent_t
cv
::
gpu
::
EventAccessor
::
getEvent
(
const
Event
&
event
)
{
return
event
.
impl_
->
event
;
}
#endif
cv
::
gpu
::
Event
::
Event
(
CreateFlags
flags
)
{
#ifndef HAVE_CUDA
(
void
)
flags
;
throw_no_cuda
();
#else
impl_
=
new
Impl
(
flags
);
#endif
}
void
cv
::
gpu
::
Event
::
record
(
Stream
&
stream
)
{
#ifndef HAVE_CUDA
(
void
)
stream
;
throw_no_cuda
();
#else
cudaSafeCall
(
cudaEventRecord
(
impl_
->
event
,
StreamAccessor
::
getStream
(
stream
))
);
#endif
}
bool
cv
::
gpu
::
Event
::
queryIfComplete
()
const
{
#ifndef HAVE_CUDA
throw_no_cuda
();
return
false
;
#else
cudaError_t
err
=
cudaEventQuery
(
impl_
->
event
);
if
(
err
==
cudaErrorNotReady
||
err
==
cudaSuccess
)
return
err
==
cudaSuccess
;
cudaSafeCall
(
err
);
return
false
;
#endif
}
void
cv
::
gpu
::
Event
::
waitForCompletion
()
{
#ifndef HAVE_CUDA
throw_no_cuda
();
#else
cudaSafeCall
(
cudaEventSynchronize
(
impl_
->
event
)
);
#endif
}
float
cv
::
gpu
::
Event
::
elapsedTime
(
const
Event
&
start
,
const
Event
&
end
)
{
#ifndef HAVE_CUDA
(
void
)
start
;
(
void
)
end
;
throw_no_cuda
();
return
0.0
f
;
#else
float
ms
;
cudaSafeCall
(
cudaEventElapsedTime
(
&
ms
,
start
.
impl_
->
event
,
end
.
impl_
->
event
)
);
return
ms
;
#endif
}
template
<
>
void
cv
::
Ptr
<
Event
::
Impl
>::
delete_obj
()
{
if
(
obj
)
delete
obj
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录