Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
af0be6e0
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
af0be6e0
编写于
10月 15, 2018
作者:
R
Ray Liu
提交者:
GitHub
10月 15, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1088 from codeWorm2015/opencl
update cl sope
上级
05144e7f
71b426e3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
55 addition
and
29 deletion
+55
-29
src/framework/cl/cl_engine.cpp
src/framework/cl/cl_engine.cpp
+6
-2
src/framework/cl/cl_engine.h
src/framework/cl/cl_engine.h
+6
-7
src/framework/cl/cl_scope.h
src/framework/cl/cl_scope.h
+1
-2
src/operators/kernel/cl/cl_kernel/conv_kernel.cl
src/operators/kernel/cl/cl_kernel/conv_kernel.cl
+6
-2
src/operators/kernel/cl/conv_kernel.cpp
src/operators/kernel/cl/conv_kernel.cpp
+36
-16
未找到文件。
src/framework/cl/cl_engine.cpp
浏览文件 @
af0be6e0
...
@@ -23,12 +23,15 @@ namespace paddle_mobile {
...
@@ -23,12 +23,15 @@ namespace paddle_mobile {
namespace
framework
{
namespace
framework
{
bool
CLEngine
::
Init
()
{
bool
CLEngine
::
Init
()
{
if
(
initialized_
)
{
return
true
;
}
cl_int
status
;
cl_int
status
;
SetPlatform
();
SetPlatform
();
SetClDeviceId
();
SetClDeviceId
();
initialized_
=
true
;
// setClContext();
initialized_
=
true
;
return
initialized_
;
// setClCommandQueue();
// setClCommandQueue();
// std::string filename = "./HelloWorld_Kernel.cl";
// std::string filename = "./HelloWorld_Kernel.cl";
// loadKernelFromFile(filename.c_str());
// loadKernelFromFile(filename.c_str());
...
@@ -37,6 +40,7 @@ bool CLEngine::Init() {
...
@@ -37,6 +40,7 @@ bool CLEngine::Init() {
CLEngine
*
CLEngine
::
Instance
()
{
CLEngine
*
CLEngine
::
Instance
()
{
static
CLEngine
cl_engine_
;
static
CLEngine
cl_engine_
;
cl_engine_
.
Init
();
return
&
cl_engine_
;
return
&
cl_engine_
;
}
}
...
...
src/framework/cl/cl_engine.h
浏览文件 @
af0be6e0
...
@@ -33,18 +33,21 @@ class CLEngine {
...
@@ -33,18 +33,21 @@ class CLEngine {
bool
Init
();
bool
Init
();
std
::
unique_ptr
<
_cl_context
,
CLContextDeleter
>
CreateContext
()
{
std
::
unique_ptr
<
_cl_context
,
CLContextDeleter
>
CreateContext
()
{
cl_context
c
=
clCreateContext
(
NULL
,
1
,
devices_
,
NULL
,
NULL
,
NULL
);
cl_int
status
;
cl_context
c
=
clCreateContext
(
NULL
,
1
,
devices_
,
NULL
,
NULL
,
&
status
);
std
::
unique_ptr
<
_cl_context
,
CLContextDeleter
>
context_ptr
(
c
);
std
::
unique_ptr
<
_cl_context
,
CLContextDeleter
>
context_ptr
(
c
);
CL_CHECK_ERRORS
(
status
);
return
std
::
move
(
context_ptr
);
return
std
::
move
(
context_ptr
);
}
}
std
::
unique_ptr
<
_cl_command_queue
,
CLCommQueueDeleter
>
std
::
unique_ptr
<
_cl_command_queue
,
CLCommQueueDeleter
>
CreateClCommandQueue
()
{
CreateClCommandQueue
(
cl_context
context
)
{
cl_int
status
;
cl_int
status
;
cl_command_queue
queue
=
cl_command_queue
queue
=
clCreateCommandQueue
(
context
_
.
get
()
,
devices_
[
0
],
0
,
&
status
);
clCreateCommandQueue
(
context
,
devices_
[
0
],
0
,
&
status
);
std
::
unique_ptr
<
_cl_command_queue
,
CLCommQueueDeleter
>
command_queue_ptr
(
std
::
unique_ptr
<
_cl_command_queue
,
CLCommQueueDeleter
>
command_queue_ptr
(
queue
);
queue
);
CL_CHECK_ERRORS
(
status
);
return
std
::
move
(
command_queue_ptr
);
return
std
::
move
(
command_queue_ptr
);
}
}
...
@@ -100,10 +103,6 @@ class CLEngine {
...
@@ -100,10 +103,6 @@ class CLEngine {
cl_int
status_
;
cl_int
status_
;
std
::
unique_ptr
<
_cl_context
,
CLContextDeleter
>
context_
;
std
::
unique_ptr
<
_cl_command_queue
,
CLCommQueueDeleter
>
command_queue_
;
std
::
unique_ptr
<
_cl_program
,
CLProgramDeleter
>
program_
;
std
::
unique_ptr
<
_cl_program
,
CLProgramDeleter
>
program_
;
// bool SetClContext();
// bool SetClContext();
...
...
src/framework/cl/cl_scope.h
浏览文件 @
af0be6e0
...
@@ -30,9 +30,8 @@ class CLScope {
...
@@ -30,9 +30,8 @@ class CLScope {
public:
public:
CLScope
()
{
CLScope
()
{
CLEngine
*
engin
=
CLEngine
::
Instance
();
CLEngine
*
engin
=
CLEngine
::
Instance
();
engin
->
Init
();
context_
=
engin
->
CreateContext
();
context_
=
engin
->
CreateContext
();
command_queue_
=
engin
->
CreateClCommandQueue
();
command_queue_
=
engin
->
CreateClCommandQueue
(
context_
.
get
()
);
}
}
cl_command_queue
CommandQueue
()
{
return
command_queue_
.
get
();
}
cl_command_queue
CommandQueue
()
{
return
command_queue_
.
get
();
}
...
...
src/operators/kernel/cl/cl_kernel/conv_kernel.cl
浏览文件 @
af0be6e0
...
@@ -12,6 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,6 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See
the
License
for
the
specific
language
governing
permissions
and
See
the
License
for
the
specific
language
governing
permissions
and
limitations
under
the
License.
*/
limitations
under
the
License.
*/
//#include
"conv_kernel.inc.cl"
__kernel
void
conv_3x3
()
{}
__kernel
void
conv_3x3
()
{
\ No newline at end of file
}
src/operators/kernel/cl/conv_kernel.cpp
浏览文件 @
af0be6e0
...
@@ -93,32 +93,52 @@ void ConvKernel<GPU_CL, float>::Compute(const ConvParam<GPU_CL> ¶m) {
...
@@ -93,32 +93,52 @@ void ConvKernel<GPU_CL, float>::Compute(const ConvParam<GPU_CL> ¶m) {
DLOG
<<
" begin set kernel arg "
;
DLOG
<<
" begin set kernel arg "
;
status
=
clSetKernelArg
(
kernel
,
0
,
sizeof
(
int
),
&
c_block
);
// status = clSetKernelArg(kernel, 0, sizeof(int), &c_block);
status
=
clSetKernelArg
(
kernel
,
1
,
sizeof
(
int
),
&
w
);
// CL_CHECK_ERRORS(status);
status
=
clSetKernelArg
(
kernel
,
2
,
sizeof
(
int
),
&
nh
);
//
status
=
clSetKernelArg
(
kernel
,
3
,
sizeof
(
cl_mem
),
&
input
);
// status = clSetKernelArg(kernel, 1, sizeof(int), &w);
status
=
clSetKernelArg
(
kernel
,
4
,
sizeof
(
cl_mem
),
&
filter
);
// CL_CHECK_ERRORS(status);
status
=
clSetKernelArg
(
kernel
,
5
,
sizeof
(
cl_mem
),
&
output
);
//
status
=
clSetKernelArg
(
kernel
,
6
,
sizeof
(
int
),
&
stride
);
// status = clSetKernelArg(kernel, 2, sizeof(int), &nh);
status
=
clSetKernelArg
(
kernel
,
7
,
sizeof
(
int
),
&
offset
);
// CL_CHECK_ERRORS(status);
status
=
clSetKernelArg
(
kernel
,
8
,
sizeof
(
int
),
&
input_c
);
//
status
=
clSetKernelArg
(
kernel
,
9
,
sizeof
(
int
),
&
dilation
);
// status = clSetKernelArg(kernel, 3, sizeof(cl_mem), &input);
status
=
clSetKernelArg
(
kernel
,
10
,
sizeof
(
int
),
&
input_width
);
// CL_CHECK_ERRORS(status);
status
=
clSetKernelArg
(
kernel
,
11
,
sizeof
(
int
),
&
input_height
);
//
// status = clSetKernelArg(kernel, 4, sizeof(cl_mem), &filter);
// CL_CHECK_ERRORS(status);
//
// status = clSetKernelArg(kernel, 5, sizeof(cl_mem), &output);
// CL_CHECK_ERRORS(status);
//
// status = clSetKernelArg(kernel, 6, sizeof(int), &stride);
// CL_CHECK_ERRORS(status);
//
// status = clSetKernelArg(kernel, 7, sizeof(int), &offset);
// CL_CHECK_ERRORS(status);
//
// status = clSetKernelArg(kernel, 8, sizeof(int), &input_c);
// CL_CHECK_ERRORS(status);
//
// status = clSetKernelArg(kernel, 9, sizeof(int), &dilation);
// CL_CHECK_ERRORS(status);
//
// status = clSetKernelArg(kernel, 10, sizeof(int), &input_width);
// CL_CHECK_ERRORS(status);
//
// status = clSetKernelArg(kernel, 11, sizeof(int), &input_height);
// CL_CHECK_ERRORS(status);
DLOG
<<
" end set kernel arg "
;
DLOG
<<
" end set kernel arg "
;
CL_CHECK_ERRORS
(
status
);
DLOG
<<
" begin enqueue "
;
DLOG
<<
" begin enqueue "
;
status
=
status
=
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
3
,
NULL
,
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
3
,
NULL
,
default_work_size
.
data
(),
NULL
,
0
,
NULL
,
NULL
);
default_work_size
.
data
(),
NULL
,
0
,
NULL
,
NULL
);
CL_CHECK_ERRORS
(
status
);
DLOG
<<
" end enqueue "
;
DLOG
<<
" end enqueue "
;
CL_CHECK_ERRORS
(
status
);
}
}
template
class
ConvKernel
<
GPU_CL
,
float
>;
template
class
ConvKernel
<
GPU_CL
,
float
>;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录