Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
5cf4d94a
Commit
5cf4d94a
authored
Jul 10, 2018
by
MORITA Kazutaka
Committed by
Tianqi Chen
Jul 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[RUNTIME][OPENCL] Create program lazily when the program is built (#1408)
parent
0ec70800
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
+19
-19
src/runtime/opencl/opencl_module.cc
+19
-19
No files found.
src/runtime/opencl/opencl_module.cc
View file @
5cf4d94a
...
...
@@ -162,25 +162,6 @@ void OpenCLModuleNode::Init() {
workspace_
=
GetGlobalWorkspace
();
workspace_
->
Init
();
CHECK
(
workspace_
->
context
!=
nullptr
)
<<
"No OpenCL device"
;
if
(
fmt_
==
"cl"
)
{
const
char
*
s
=
data_
.
c_str
();
size_t
len
=
data_
.
length
();
cl_int
err
;
program_
=
clCreateProgramWithSource
(
workspace_
->
context
,
1
,
&
s
,
&
len
,
&
err
);
OPENCL_CHECK_ERROR
(
err
);
}
else
if
(
fmt_
==
"xclbin"
||
fmt_
==
"awsxclbin"
)
{
const
unsigned
char
*
s
=
(
const
unsigned
char
*
)
data_
.
c_str
();
size_t
len
=
data_
.
length
();
cl_int
err
;
program_
=
clCreateProgramWithBinary
(
workspace_
->
context
,
1
,
&
(
workspace_
->
devices
[
0
]),
&
len
,
&
s
,
NULL
,
&
err
);
if
(
err
!=
CL_SUCCESS
)
{
LOG
(
ERROR
)
<<
"OpenCL Error: "
<<
cl
::
CLGetErrorString
(
err
);
}
}
else
{
LOG
(
FATAL
)
<<
"Unknown OpenCL format "
<<
fmt_
;
}
device_built_flag_
.
resize
(
workspace_
->
devices
.
size
(),
false
);
// initialize the kernel id, need to lock global table.
std
::
lock_guard
<
std
::
mutex
>
lock
(
workspace_
->
mu
);
...
...
@@ -205,6 +186,25 @@ cl_kernel OpenCLModuleNode::InstallKernel(cl::OpenCLWorkspace* w,
std
::
lock_guard
<
std
::
mutex
>
lock
(
build_lock_
);
int
device_id
=
t
->
context
.
device_id
;
if
(
!
device_built_flag_
[
device_id
])
{
// create program
if
(
fmt_
==
"cl"
)
{
if
(
program_
==
nullptr
)
{
const
char
*
s
=
data_
.
c_str
();
size_t
len
=
data_
.
length
();
cl_int
err
;
program_
=
clCreateProgramWithSource
(
w
->
context
,
1
,
&
s
,
&
len
,
&
err
);
OPENCL_CHECK_ERROR
(
err
);
}
}
else
if
(
fmt_
==
"xclbin"
||
fmt_
==
"awsxclbin"
)
{
const
unsigned
char
*
s
=
(
const
unsigned
char
*
)
data_
.
c_str
();
size_t
len
=
data_
.
length
();
cl_int
err
;
cl_device_id
dev
=
w
->
devices
[
device_id
];
program_
=
clCreateProgramWithBinary
(
w
->
context
,
1
,
&
dev
,
&
len
,
&
s
,
NULL
,
&
err
);
OPENCL_CHECK_ERROR
(
err
);
}
else
{
LOG
(
FATAL
)
<<
"Unknown OpenCL format "
<<
fmt_
;
}
// build program
cl_int
err
;
cl_device_id
dev
=
w
->
devices
[
device_id
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment