Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
FORMUS3IC_LAS3
/
embb
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
92301c6e
authored
Mar 23, 2015
by
Marcus Winter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mtapi_opencl_c: removed gcc compiler warnings
parent
c1bb107a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
6 deletions
+60
-6
mtapi_opencl_c/src/embb_mtapi_opencl.c
+60
-6
No files found.
mtapi_opencl_c/src/embb_mtapi_opencl.c
View file @
92301c6e
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include <CL/cl.h>
#include <CL/cl.h>
#include <string.h>
#include <string.h>
#include <assert.h>
#include <embb/base/c/memory_allocation.h>
#include <embb/base/c/memory_allocation.h>
#include <embb/mtapi/c/mtapi_ext.h>
#include <embb/mtapi/c/mtapi_ext.h>
...
@@ -90,6 +91,7 @@ static void CL_API_CALL opencl_task_complete(
...
@@ -90,6 +91,7 @@ static void CL_API_CALL opencl_task_complete(
EMBB_UNUSED
(
status
);
EMBB_UNUSED
(
status
);
cl_int
err
;
cl_int
err
;
EMBB_UNUSED_IN_RELEASE
(
err
);
embb_mtapi_opencl_task_t
*
opencl_task
=
(
embb_mtapi_opencl_task_t
*
)
data
;
embb_mtapi_opencl_task_t
*
opencl_task
=
(
embb_mtapi_opencl_task_t
*
)
data
;
if
(
embb_mtapi_node_is_initialized
())
{
if
(
embb_mtapi_node_is_initialized
())
{
...
@@ -102,12 +104,15 @@ static void CL_API_CALL opencl_task_complete(
...
@@ -102,12 +104,15 @@ static void CL_API_CALL opencl_task_complete(
node
->
task_pool
,
opencl_task
->
task
);
node
->
task_pool
,
opencl_task
->
task
);
err
=
clWaitForEvents
(
1
,
&
opencl_task
->
kernel_finish_event
);
err
=
clWaitForEvents
(
1
,
&
opencl_task
->
kernel_finish_event
);
assert
(
CL_SUCCESS
==
err
);
if
(
NULL
!=
opencl_task
->
result_buffer
)
{
if
(
NULL
!=
opencl_task
->
result_buffer
)
{
err
=
clReleaseMemObject
(
opencl_task
->
result_buffer
);
err
=
clReleaseMemObject
(
opencl_task
->
result_buffer
);
assert
(
CL_SUCCESS
==
err
);
}
}
if
(
NULL
!=
opencl_task
->
arguments
)
{
if
(
NULL
!=
opencl_task
->
arguments
)
{
err
=
clReleaseMemObject
(
opencl_task
->
arguments
);
err
=
clReleaseMemObject
(
opencl_task
->
arguments
);
assert
(
CL_SUCCESS
==
err
);
}
}
embb_mtapi_task_set_state
(
local_task
,
MTAPI_TASK_COMPLETED
);
embb_mtapi_task_set_state
(
local_task
,
MTAPI_TASK_COMPLETED
);
...
@@ -217,6 +222,7 @@ static void opencl_action_finalize(
...
@@ -217,6 +222,7 @@ static void opencl_action_finalize(
)
{
)
{
mtapi_status_t
local_status
=
MTAPI_ERR_UNKNOWN
;
mtapi_status_t
local_status
=
MTAPI_ERR_UNKNOWN
;
cl_int
err
;
cl_int
err
;
EMBB_UNUSED_IN_RELEASE
(
err
);
if
(
embb_mtapi_node_is_initialized
())
{
if
(
embb_mtapi_node_is_initialized
())
{
embb_mtapi_node_t
*
node
=
embb_mtapi_node_get_instance
();
embb_mtapi_node_t
*
node
=
embb_mtapi_node_get_instance
();
...
@@ -227,12 +233,14 @@ static void opencl_action_finalize(
...
@@ -227,12 +233,14 @@ static void opencl_action_finalize(
embb_mtapi_opencl_action_t
*
opencl_action
=
embb_mtapi_opencl_action_t
*
opencl_action
=
(
embb_mtapi_opencl_action_t
*
)
local_action
->
plugin_data
;
(
embb_mtapi_opencl_action_t
*
)
local_action
->
plugin_data
;
if
(
NULL
!=
opencl_action
->
node_local_data
)
{
if
(
NULL
!=
opencl_action
->
node_local_data
)
{
cl_int
err
;
err
=
clReleaseMemObject
(
opencl_action
->
node_local_data
);
err
=
clReleaseMemObject
(
opencl_action
->
node_local_data
);
assert
(
CL_SUCCESS
==
err
);
}
}
err
=
clReleaseKernel
(
opencl_action
->
kernel
);
err
=
clReleaseKernel
(
opencl_action
->
kernel
);
assert
(
CL_SUCCESS
==
err
);
err
=
clReleaseProgram
(
opencl_action
->
program
);
err
=
clReleaseProgram
(
opencl_action
->
program
);
assert
(
CL_SUCCESS
==
err
);
embb_free
(
opencl_action
);
embb_free
(
opencl_action
);
local_status
=
MTAPI_SUCCESS
;
local_status
=
MTAPI_SUCCESS
;
...
@@ -253,20 +261,30 @@ void mtapi_opencl_plugin_initialize(
...
@@ -253,20 +261,30 @@ void mtapi_opencl_plugin_initialize(
embb_mtapi_opencl_link_at_runtime
();
embb_mtapi_opencl_link_at_runtime
();
err
=
clGetPlatformIDs
(
1
,
&
plugin
->
platform_id
,
NULL
);
err
=
clGetPlatformIDs
(
1
,
&
plugin
->
platform_id
,
NULL
);
if
(
CL_SUCCESS
==
err
)
{
err
=
clGetDeviceIDs
(
plugin
->
platform_id
,
CL_DEVICE_TYPE_DEFAULT
,
err
=
clGetDeviceIDs
(
plugin
->
platform_id
,
CL_DEVICE_TYPE_DEFAULT
,
1
,
&
plugin
->
device_id
,
NULL
);
1
,
&
plugin
->
device_id
,
NULL
);
}
if
(
CL_SUCCESS
==
err
)
{
plugin
->
context
=
clCreateContext
(
NULL
,
1
,
&
plugin
->
device_id
,
plugin
->
context
=
clCreateContext
(
NULL
,
1
,
&
plugin
->
device_id
,
NULL
,
NULL
,
&
err
);
NULL
,
NULL
,
&
err
);
}
if
(
CL_SUCCESS
==
err
)
{
err
=
clGetDeviceInfo
(
plugin
->
device_id
,
CL_DEVICE_MAX_WORK_GROUP_SIZE
,
err
=
clGetDeviceInfo
(
plugin
->
device_id
,
CL_DEVICE_MAX_WORK_GROUP_SIZE
,
sizeof
(
cl_uint
),
&
plugin
->
work_group_size
,
NULL
);
sizeof
(
cl_uint
),
&
plugin
->
work_group_size
,
NULL
);
}
if
(
CL_SUCCESS
==
err
)
{
err
=
clGetDeviceInfo
(
plugin
->
device_id
,
CL_DEVICE_MAX_WORK_ITEM_SIZES
,
err
=
clGetDeviceInfo
(
plugin
->
device_id
,
CL_DEVICE_MAX_WORK_ITEM_SIZES
,
3
*
sizeof
(
cl_uint
),
&
plugin
->
work_item_sizes
[
0
],
NULL
);
3
*
sizeof
(
cl_uint
),
&
plugin
->
work_item_sizes
[
0
],
NULL
);
}
if
(
CL_SUCCESS
==
err
)
{
plugin
->
command_queue
=
clCreateCommandQueue
(
plugin
->
context
,
plugin
->
command_queue
=
clCreateCommandQueue
(
plugin
->
context
,
plugin
->
device_id
,
0
,
&
err
);
plugin
->
device_id
,
0
,
&
err
);
}
if
(
CL_SUCCESS
==
err
)
{
local_status
=
MTAPI_SUCCESS
;
local_status
=
MTAPI_SUCCESS
;
}
mtapi_status_set
(
status
,
local_status
);
mtapi_status_set
(
status
,
local_status
);
}
}
...
@@ -275,11 +293,14 @@ void mtapi_opencl_plugin_finalize(
...
@@ -275,11 +293,14 @@ void mtapi_opencl_plugin_finalize(
mtapi_status_t
local_status
=
MTAPI_ERR_UNKNOWN
;
mtapi_status_t
local_status
=
MTAPI_ERR_UNKNOWN
;
cl_int
err
;
cl_int
err
;
EMBB_UNUSED_IN_RELEASE
(
err
);
embb_mtapi_opencl_plugin_t
*
plugin
=
&
embb_mtapi_opencl_plugin
;
embb_mtapi_opencl_plugin_t
*
plugin
=
&
embb_mtapi_opencl_plugin
;
/* finalization */
/* finalization */
err
=
clReleaseCommandQueue
(
plugin
->
command_queue
);
err
=
clReleaseCommandQueue
(
plugin
->
command_queue
);
assert
(
CL_SUCCESS
==
err
);
err
=
clReleaseContext
(
plugin
->
context
);
err
=
clReleaseContext
(
plugin
->
context
);
assert
(
CL_SUCCESS
==
err
);
local_status
=
MTAPI_SUCCESS
;
local_status
=
MTAPI_SUCCESS
;
mtapi_status_set
(
status
,
local_status
);
mtapi_status_set
(
status
,
local_status
);
...
@@ -301,8 +322,11 @@ mtapi_action_hndl_t mtapi_opencl_action_create(
...
@@ -301,8 +322,11 @@ mtapi_action_hndl_t mtapi_opencl_action_create(
embb_mtapi_opencl_action_t
*
action
=
embb_mtapi_opencl_action_t
*
action
=
(
embb_mtapi_opencl_action_t
*
)
embb_alloc
(
(
embb_mtapi_opencl_action_t
*
)
embb_alloc
(
sizeof
(
embb_mtapi_opencl_action_t
));
sizeof
(
embb_mtapi_opencl_action_t
));
mtapi_action_hndl_t
action_hndl
;
mtapi_action_hndl_t
action_hndl
=
{
0
,
0
};
// invalid handle
size_t
kernel_length
=
strlen
(
kernel_source
);
size_t
kernel_length
=
strlen
(
kernel_source
);
mtapi_boolean_t
free_program_on_error
=
MTAPI_FALSE
;
mtapi_boolean_t
free_kernel_on_error
=
MTAPI_FALSE
;
mtapi_boolean_t
free_node_local_data_on_error
=
MTAPI_FALSE
;
action
->
local_work_size
=
local_work_size
;
action
->
local_work_size
=
local_work_size
;
action
->
element_size
=
element_size
;
action
->
element_size
=
element_size
;
...
@@ -310,31 +334,49 @@ mtapi_action_hndl_t mtapi_opencl_action_create(
...
@@ -310,31 +334,49 @@ mtapi_action_hndl_t mtapi_opencl_action_create(
/* initialization */
/* initialization */
action
->
program
=
clCreateProgramWithSource
(
plugin
->
context
,
action
->
program
=
clCreateProgramWithSource
(
plugin
->
context
,
1
,
&
kernel_source
,
&
kernel_length
,
&
err
);
1
,
&
kernel_source
,
&
kernel_length
,
&
err
);
if
(
CL_SUCCESS
==
err
)
{
free_program_on_error
=
MTAPI_TRUE
;
err
=
clBuildProgram
(
action
->
program
,
1
,
&
plugin
->
device_id
,
err
=
clBuildProgram
(
action
->
program
,
1
,
&
plugin
->
device_id
,
NULL
,
NULL
,
NULL
);
NULL
,
NULL
,
NULL
);
if
(
CL_SUCCESS
!=
err
)
{
}
else
{
err
=
clGetProgramBuildInfo
(
action
->
program
,
plugin
->
device_id
,
err
=
clGetProgramBuildInfo
(
action
->
program
,
plugin
->
device_id
,
CL_PROGRAM_BUILD_LOG
,
1024
,
buffer
,
NULL
);
CL_PROGRAM_BUILD_LOG
,
1024
,
buffer
,
NULL
);
}
}
if
(
CL_SUCCESS
==
err
)
{
action
->
kernel
=
clCreateKernel
(
action
->
program
,
kernel_name
,
&
err
);
action
->
kernel
=
clCreateKernel
(
action
->
program
,
kernel_name
,
&
err
);
if
(
CL_SUCCESS
==
err
)
{
free_kernel_on_error
=
MTAPI_TRUE
;
}
}
if
(
0
<
node_local_data_size
)
{
if
(
0
<
node_local_data_size
)
{
action
->
node_local_data
=
clCreateBuffer
(
plugin
->
context
,
CL_MEM_READ_ONLY
,
action
->
node_local_data
=
clCreateBuffer
(
plugin
->
context
,
CL_MEM_READ_ONLY
,
node_local_data_size
,
NULL
,
&
err
);
node_local_data_size
,
NULL
,
&
err
);
if
(
CL_SUCCESS
==
err
)
{
free_node_local_data_on_error
=
MTAPI_TRUE
;
}
action
->
node_local_data_size
=
node_local_data_size
;
action
->
node_local_data_size
=
node_local_data_size
;
if
(
CL_SUCCESS
==
err
)
{
err
=
clEnqueueWriteBuffer
(
plugin
->
command_queue
,
err
=
clEnqueueWriteBuffer
(
plugin
->
command_queue
,
action
->
node_local_data
,
CL_TRUE
,
0
,
action
->
node_local_data
,
CL_TRUE
,
0
,
action
->
node_local_data_size
,
node_local_data
,
0
,
NULL
,
NULL
);
action
->
node_local_data_size
,
node_local_data
,
0
,
NULL
,
NULL
);
}
}
else
{
}
else
{
action
->
node_local_data
=
NULL
;
action
->
node_local_data
=
NULL
;
action
->
node_local_data_size
=
0
;
action
->
node_local_data_size
=
0
;
}
}
if
(
CL_SUCCESS
==
err
)
{
err
=
clSetKernelArg
(
action
->
kernel
,
4
,
sizeof
(
cl_mem
),
err
=
clSetKernelArg
(
action
->
kernel
,
4
,
sizeof
(
cl_mem
),
(
const
void
*
)
&
action
->
node_local_data
);
(
const
void
*
)
&
action
->
node_local_data
);
}
if
(
CL_SUCCESS
==
err
)
{
err
=
clSetKernelArg
(
action
->
kernel
,
5
,
sizeof
(
cl_int
),
err
=
clSetKernelArg
(
action
->
kernel
,
5
,
sizeof
(
cl_int
),
(
const
void
*
)
&
action
->
node_local_data_size
);
(
const
void
*
)
&
action
->
node_local_data_size
);
}
if
(
CL_SUCCESS
==
err
)
{
action_hndl
=
mtapi_ext_plugin_action_create
(
action_hndl
=
mtapi_ext_plugin_action_create
(
job_id
,
job_id
,
opencl_task_start
,
opencl_task_start
,
...
@@ -345,6 +387,18 @@ mtapi_action_hndl_t mtapi_opencl_action_create(
...
@@ -345,6 +387,18 @@ mtapi_action_hndl_t mtapi_opencl_action_create(
node_local_data_size
,
node_local_data_size
,
MTAPI_NULL
,
MTAPI_NULL
,
&
local_status
);
&
local_status
);
}
else
{
if
(
free_node_local_data_on_error
)
{
clReleaseMemObject
(
action
->
node_local_data
);
}
if
(
free_kernel_on_error
)
{
clReleaseKernel
(
action
->
kernel
);
}
if
(
free_program_on_error
)
{
clReleaseProgram
(
action
->
program
);
}
embb_free
(
action
);
}
mtapi_status_set
(
status
,
local_status
);
mtapi_status_set
(
status
,
local_status
);
...
...
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