Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
63a022dc
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,发现更多精彩内容 >>
提交
63a022dc
编写于
11月 26, 2012
作者:
V
Vladislav Vinogradov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added explicit unroll to reduce implementation
上级
11c6eb63
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
68 addition
and
62 deletion
+68
-62
modules/gpu/include/opencv2/gpu/device/detail/reduce.hpp
modules/gpu/include/opencv2/gpu/device/detail/reduce.hpp
+34
-31
modules/gpu/include/opencv2/gpu/device/detail/reduce_key_val.hpp
.../gpu/include/opencv2/gpu/device/detail/reduce_key_val.hpp
+34
-31
未找到文件。
modules/gpu/include/opencv2/gpu/device/detail/reduce.hpp
浏览文件 @
63a022dc
...
...
@@ -243,29 +243,46 @@ namespace cv { namespace gpu { namespace device
}
};
template
<
unsigned
int
I
,
typename
Pointer
,
typename
Reference
,
class
Op
>
struct
Unroll
{
static
__device__
void
loopShfl
(
Reference
val
,
Op
op
,
unsigned
int
N
)
{
mergeShfl
(
val
,
I
,
N
,
op
);
Unroll
<
I
/
2
,
Pointer
,
Reference
,
Op
>::
loopShfl
(
val
,
op
,
N
);
}
static
__device__
void
loop
(
Pointer
smem
,
Reference
val
,
unsigned
int
tid
,
Op
op
)
{
merge
(
smem
,
val
,
tid
,
I
,
op
);
Unroll
<
I
/
2
,
Pointer
,
Reference
,
Op
>::
loop
(
smem
,
val
,
tid
,
op
);
}
};
template
<
typename
Pointer
,
typename
Reference
,
class
Op
>
struct
Unroll
<
0
,
Pointer
,
Reference
,
Op
>
{
static
__device__
void
loopShfl
(
Reference
,
Op
,
unsigned
int
)
{
}
static
__device__
void
loop
(
Pointer
,
Reference
,
unsigned
int
,
Op
)
{
}
};
template
<
unsigned
int
N
>
struct
WarpOptimized
{
template
<
typename
Pointer
,
typename
Reference
,
class
Op
>
static
__device__
void
reduce
(
Pointer
smem
,
Reference
val
,
unsigned
int
tid
,
Op
op
)
{
#if __CUDA_ARCH >= 300
#if __CUDA_ARCH
__
>= 300
(
void
)
smem
;
(
void
)
tid
;
#pragma unroll
for
(
unsigned
int
i
=
N
/
2
;
i
>=
1
;
i
/=
2
)
mergeShfl
(
val
,
i
,
N
,
op
);
Unroll
<
N
/
2
,
Pointer
,
Reference
,
Op
>::
loopShfl
(
val
,
op
,
N
);
#else
loadToSmem
(
smem
,
val
,
tid
);
if
(
tid
<
N
/
2
)
{
#if __CUDA_ARCH__ >= 200
#pragma unroll
#endif
for
(
unsigned
int
i
=
N
/
2
;
i
>=
1
;
i
/=
2
)
merge
(
smem
,
val
,
tid
,
i
,
op
);
}
Unroll
<
N
/
2
,
Pointer
,
Reference
,
Op
>::
loop
(
smem
,
val
,
tid
,
op
);
#endif
}
};
...
...
@@ -279,10 +296,8 @@ namespace cv { namespace gpu { namespace device
{
const
unsigned
int
laneId
=
Warp
::
laneId
();
#if __CUDA_ARCH >= 300
#pragma unroll
for
(
int
i
=
16
;
i
>=
1
;
i
/=
2
)
mergeShfl
(
val
,
i
,
warpSize
,
op
);
#if __CUDA_ARCH__ >= 300
Unroll
<
16
,
Pointer
,
Reference
,
Op
>::
loopShfl
(
val
,
op
,
warpSize
);
if
(
laneId
==
0
)
loadToSmem
(
smem
,
val
,
tid
/
32
);
...
...
@@ -290,13 +305,7 @@ namespace cv { namespace gpu { namespace device
loadToSmem
(
smem
,
val
,
tid
);
if
(
laneId
<
16
)
{
#if __CUDA_ARCH__ >= 200
#pragma unroll
#endif
for
(
int
i
=
16
;
i
>=
1
;
i
/=
2
)
merge
(
smem
,
val
,
tid
,
i
,
op
);
}
Unroll
<
16
,
Pointer
,
Reference
,
Op
>::
loop
(
smem
,
val
,
tid
,
op
);
__syncthreads
();
...
...
@@ -310,16 +319,10 @@ namespace cv { namespace gpu { namespace device
if
(
tid
<
32
)
{
#if __CUDA_ARCH >= 300
#pragma unroll
for
(
int
i
=
M
/
2
;
i
>=
1
;
i
/=
2
)
mergeShfl
(
val
,
i
,
M
,
op
);
#if __CUDA_ARCH__ >= 300
Unroll
<
M
/
2
,
Pointer
,
Reference
,
Op
>::
loopShfl
(
val
,
op
,
M
);
#else
#if __CUDA_ARCH__ >= 200
#pragma unroll
#endif
for
(
int
i
=
M
/
2
;
i
>=
1
;
i
/=
2
)
merge
(
smem
,
val
,
tid
,
i
,
op
);
Unroll
<
M
/
2
,
Pointer
,
Reference
,
Op
>::
loop
(
smem
,
val
,
tid
,
op
);
#endif
}
}
...
...
modules/gpu/include/opencv2/gpu/device/detail/reduce_key_val.hpp
浏览文件 @
63a022dc
...
...
@@ -369,31 +369,48 @@ namespace cv { namespace gpu { namespace device
}
};
template
<
unsigned
int
I
,
class
KP
,
class
KR
,
class
VP
,
class
VR
,
class
Cmp
>
struct
Unroll
{
static
__device__
void
loopShfl
(
KR
key
,
VR
val
,
Cmp
cmp
,
unsigned
int
N
)
{
mergeShfl
(
key
,
val
,
cmp
,
I
,
N
);
Unroll
<
I
/
2
,
KP
,
KR
,
VP
,
VR
,
Cmp
>::
loopShfl
(
key
,
val
,
cmp
,
N
);
}
static
__device__
void
loop
(
KP
skeys
,
KR
key
,
VP
svals
,
VR
val
,
unsigned
int
tid
,
Cmp
cmp
)
{
merge
(
skeys
,
key
,
svals
,
val
,
cmp
,
tid
,
I
);
Unroll
<
I
/
2
,
KP
,
KR
,
VP
,
VR
,
Cmp
>::
loop
(
skeys
,
key
,
svals
,
val
,
tid
,
cmp
);
}
};
template
<
class
KP
,
class
KR
,
class
VP
,
class
VR
,
class
Cmp
>
struct
Unroll
<
0
,
KP
,
KR
,
VP
,
VR
,
Cmp
>
{
static
__device__
void
loopShfl
(
KR
,
VR
,
Cmp
,
unsigned
int
)
{
}
static
__device__
void
loop
(
KP
,
KR
,
VP
,
VR
,
unsigned
int
,
Cmp
)
{
}
};
template
<
unsigned
int
N
>
struct
WarpOptimized
{
template
<
class
KP
,
class
KR
,
class
VP
,
class
VR
,
class
Cmp
>
static
__device__
void
reduce
(
KP
skeys
,
KR
key
,
VP
svals
,
VR
val
,
unsigned
int
tid
,
Cmp
cmp
)
{
#if __CUDA_ARCH >= 300
#if __CUDA_ARCH
__
>= 300
(
void
)
skeys
;
(
void
)
svals
;
(
void
)
tid
;
#pragma unroll
for
(
unsigned
int
i
=
N
/
2
;
i
>=
1
;
i
/=
2
)
mergeShfl
(
key
,
val
,
cml
,
i
,
N
);
Unroll
<
N
/
2
,
KP
,
KR
,
VP
,
VR
,
Cmp
>::
loopShfl
(
key
,
val
,
cmp
,
N
);
#else
loadToSmem
(
skeys
,
key
,
tid
);
loadToSmem
(
svals
,
val
,
tid
);
if
(
tid
<
N
/
2
)
{
#if __CUDA_ARCH__ >= 200
#pragma unroll
#endif
for
(
unsigned
int
i
=
N
/
2
;
i
>=
1
;
i
/=
2
)
merge
(
skeys
,
key
,
svals
,
val
,
cmp
,
tid
,
i
);
}
Unroll
<
N
/
2
,
KP
,
KR
,
VP
,
VR
,
Cmp
>::
loop
(
skeys
,
key
,
svals
,
val
,
tid
,
cmp
);
#endif
}
};
...
...
@@ -407,10 +424,8 @@ namespace cv { namespace gpu { namespace device
{
const
unsigned
int
laneId
=
Warp
::
laneId
();
#if __CUDA_ARCH >= 300
#pragma unroll
for
(
unsigned
int
i
=
16
;
i
>=
1
;
i
/=
2
)
mergeShfl
(
key
,
val
,
cml
,
i
,
warpSize
);
#if __CUDA_ARCH__ >= 300
Unroll
<
16
,
KP
,
KR
,
VP
,
VR
,
Cmp
>::
loopShfl
(
key
,
val
,
cmp
,
warpSize
);
if
(
laneId
==
0
)
{
...
...
@@ -422,13 +437,7 @@ namespace cv { namespace gpu { namespace device
loadToSmem
(
svals
,
val
,
tid
);
if
(
laneId
<
16
)
{
#if __CUDA_ARCH__ >= 200
#pragma unroll
#endif
for
(
int
i
=
16
;
i
>=
1
;
i
/=
2
)
merge
(
skeys
,
key
,
svals
,
val
,
cmp
,
tid
,
i
);
}
Unroll
<
16
,
KP
,
KR
,
VP
,
VR
,
Cmp
>::
loop
(
skeys
,
key
,
svals
,
val
,
tid
,
cmp
);
__syncthreads
();
...
...
@@ -445,18 +454,12 @@ namespace cv { namespace gpu { namespace device
if
(
tid
<
32
)
{
#if __CUDA_ARCH >= 300
#if __CUDA_ARCH
__
>= 300
loadFromSmem
(
svals
,
val
,
tid
);
#pragma unroll
for
(
unsigned
int
i
=
M
/
2
;
i
>=
1
;
i
/=
2
)
mergeShfl
(
key
,
val
,
cml
,
i
,
M
);
Unroll
<
M
/
2
,
KP
,
KR
,
VP
,
VR
,
Cmp
>::
loopShfl
(
key
,
val
,
cmp
,
M
);
#else
#if __CUDA_ARCH__ >= 200
#pragma unroll
#endif
for
(
unsigned
int
i
=
M
/
2
;
i
>=
1
;
i
/=
2
)
merge
(
skeys
,
key
,
svals
,
val
,
cmp
,
tid
,
i
);
Unroll
<
M
/
2
,
KP
,
KR
,
VP
,
VR
,
Cmp
>::
loop
(
skeys
,
key
,
svals
,
val
,
tid
,
cmp
);
#endif
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录