Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
2d89df18
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,发现更多精彩内容 >>
提交
2d89df18
编写于
8月 27, 2014
作者:
E
Elena Gvozdeva
提交者:
ElenaGvozdeva
10月 27, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use local memory
上级
d78bc3c3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
11 deletion
+31
-11
modules/core/src/matmul.cpp
modules/core/src/matmul.cpp
+5
-3
modules/core/src/opencl/gemm.cl
modules/core/src/opencl/gemm.cl
+25
-7
modules/ts/src/ocl_test.cpp
modules/ts/src/ocl_test.cpp
+1
-1
未找到文件。
modules/core/src/matmul.cpp
浏览文件 @
2d89df18
...
...
@@ -782,6 +782,7 @@ static bool ocl_gemm( InputArray matA, InputArray matB, double alpha,
{
int
depth
=
matA
.
depth
(),
cn
=
matA
.
channels
();
int
type
=
CV_MAKETYPE
(
depth
,
cn
);
const
int
block_size
=
16
;
CV_Assert
(
type
==
matB
.
type
()
&&
(
type
==
CV_32FC1
||
type
==
CV_64FC1
||
type
==
CV_32FC2
||
type
==
CV_64FC2
)
);
...
...
@@ -807,8 +808,8 @@ static bool ocl_gemm( InputArray matA, InputArray matB, double alpha,
CV_Assert
(
matB
.
type
()
==
type
&&
(
!
haveC
||
matC
.
type
()
==
type
)
);
CV_Assert
(
sizeA
.
width
==
sizeB
.
height
&&
(
!
haveC
||
sizeC
==
sizeD
)
);
String
opts
=
format
(
"-D T=%s -D T1=%s -D cn=%d %s %s"
,
ocl
::
typeToStr
(
type
),
ocl
::
typeToStr
(
depth
),
cn
,
String
opts
=
format
(
"-D T=%s -D T1=%s -D cn=%d
-D LOCAL_SIZE=%d
%s %s"
,
ocl
::
typeToStr
(
type
),
ocl
::
typeToStr
(
depth
),
cn
,
block_size
,
haveC
?
"-D HAVE_C"
:
""
,
doubleSupport
?
" -D DOUBLE_SUPPORT"
:
""
);
...
...
@@ -843,7 +844,8 @@ static bool ocl_gemm( InputArray matA, InputArray matB, double alpha,
sizeA
.
width
,
(
float
)
alpha
,
(
float
)
beta
);
size_t
globalsize
[
2
]
=
{
sizeD
.
width
,
sizeD
.
height
};
return
k
.
run
(
2
,
globalsize
,
NULL
,
false
);
size_t
localsize
[
2
]
=
{
block_size
,
block_size
};
return
k
.
run
(
2
,
globalsize
,
localsize
,
false
);
}
#endif
...
...
modules/core/src/opencl/gemm.cl
浏览文件 @
2d89df18
...
...
@@ -28,7 +28,7 @@
sum.y
+=
fma
(
a.x,
b.y,
a.y
*
b.x
)
;\
}
#
else
#
define
MUL
(
i,
a,
b
)
sum
+=
a
*
b
#
define
MUL
(
i,
a,
b
)
sum
=
fma
(
a,
b,
sum
)
;
#
endif
...
...
@@ -40,16 +40,34 @@ __kernel void gemm(__global const uchar * A_ptr, int A_step, int A_offset,
int
x
=
get_global_id
(
0
)
;
int
y
=
get_global_id
(
1
)
;
if
(
x
<
D_cols
&&
y
<
D_rows
)
int
lidx
=
get_local_id
(
0
)
;
int
lidy
=
get_local_id
(
1
)
;
__global
const
T*
A
=
(
__global
const
T*
)(
A_ptr
+
IND_A
)
;
__global
const
T*
B
=
(
__global
const
T*
)(
B_ptr
+
IND_B
)
;
T
sum
=
(
T
)(
0
)
;
__local
T
a_local[LOCAL_SIZE*LOCAL_SIZE]
;
__local
T
b_local[LOCAL_SIZE*LOCAL_SIZE]
;
for
(
int
p
=
0
; p < (n+LOCAL_SIZE-1)/LOCAL_SIZE; ++p)
{
__global
const
T*
A
=
(
__global
const
T*
)(
A_ptr
+
IND_A
)
;
__global
const
T*
B
=
(
__global
const
T*
)(
B_ptr
+
IND_B
)
;
a_local[mad24
(
lidy,
LOCAL_SIZE,
lidx
)
]
=
A[mad24
(
p,
LOCAL_SIZE,
lidx
)
]
;
b_local[mad24
(
lidy,
LOCAL_SIZE,
lidx
)
]
=
B[mad24
(
p,
LOCAL_SIZE,
lidy
)
*STEP_B]
;
T
sum
=
(
T
)(
0
)
;
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
for
(
int
i
=
0
; i < n; ++i)
MUL
(
i,
A[i*STEP_A],
B[i*STEP_B]
)
;
if
(
x
<
D_cols
&&
y
<
D_rows
)
{
for
(
int
i
=
0
; i < LOCAL_SIZE && p * LOCAL_SIZE + i < n; ++i)
MUL
(
i,
a_local[mad24
(
lidy,
LOCAL_SIZE,
i
)
],
b_local[mad24
(
i,
LOCAL_SIZE,
lidx
)
]
)
;
}
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
}
if
(
x
<
D_cols
&&
y
<
D_rows
)
{
__global
T*
D
=
(
__global
T*
)(
D_ptr
+
mad24
(
y,
D_step,
mad24
(
x,
TSIZE,
D_offset
)))
;
#
if
HAVE_C
D[0]
=
mad
(
alpha,
sum,
D[0]*beta
)
;
...
...
modules/ts/src/ocl_test.cpp
浏览文件 @
2d89df18
...
...
@@ -48,7 +48,7 @@ namespace ocl {
using
namespace
cv
;
int
test_loop_times
=
1
;
// TODO Read from command line / environment
int
test_loop_times
=
1
0
;
// TODO Read from command line / environment
#ifdef HAVE_OPENCL
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录