Sorry I want to change the 5th issue like the below.
: Implicit event should be removed in the loop.
-->
: Implicit event should be included in the loop.
Regards,
Lee Ki-ju
From: Kiju Lee
Sent: September-22-14 11:53 AM
To: '[email protected]'
Cc: Christina Xu
Subject: Questions about Memory leaks in POCL 0.10
Dear POCL developers,
My name is Lee Ki-Ju.
I'm working on porting OpenCL using POCL 0.10.
Could I ask some questions?
Because I found some issues related with memory leaks, and allocations in the
POCL 0.10
1. All Malloc/calloc and free function should be replaced with
pocl_aligned_malloc/pocl_aligned_free
Some cases, free() is used for the buffer, which was allocated by
pocl_aligned_malloc. That could make a trouble in the de-allocation.
2. Function "clReleaseProgram" in \lib\CL\clReleaseProgram.c
: There is no de-allocation for the object of "device"
The original in the official POCL 0.10
Recommendation to be added
POname(clReleaseProgram)(cl_program program) CL_API_SUFFIX__VERSION_1_0
{
~~
POCL_RELEASE_OBJECT(program->context, new_refcount);
free (program->source);
if (program->binaries != NULL)
POname(clReleaseProgram)(cl_program program) CL_API_SUFFIX__VERSION_1_0
{
~~
POCL_RELEASE_OBJECT(program->context, new_refcount);
free (program->source);
free (program->devices);
if (program->binaries != NULL)
3. Function "pocl_init_devices" in \lib\CL\devices\devices.c
: There is no allocation for the semaphore of pocl_init_lock
The original in the official POCL 0.10
Recommendation to be added
void
pocl_init_devices()
{
~~
POCL_LOCK(pocl_init_lock);
~~
}
void
pocl_init_devices()
{
~~
if (init_done == 0)
POCL_INIT_LOCK(pocl_init_lock);
POCL_LOCK(pocl_init_lock);
~~
}
4. Funciton "pocl_init_mem_manager" in \lib\CL\pocl_mem_management.c
The original in the official POCL 0.10
Recommendation to be added
void pocl_init_mem_manager (void)
{
static unsigned int init_done = 0;
static pocl_lock_t pocl_init_lock = POCL_LOCK_INITIALIZER;
POCL_LOCK(pocl_init_lock);
if (!mm)
{
mm = calloc (1, sizeof (pocl_mem_manager));
POCL_INIT_LOCK (mm->event_lock);
POCL_INIT_LOCK (mm->cmd_lock);
}
POCL_UNLOCK(pocl_init_lock);
}
void pocl_init_mem_manager (void)
{
static unsigned int init_done = 0;
static pocl_lock_t pocl_init_lock = POCL_LOCK_INITIALIZER;
if(!init_done)
{
POCL_INIT_LOCK(pocl_init_lock);
init_done = 1;
}
POCL_LOCK(pocl_init_lock);
if (!mm)
{
mm = calloc (1, sizeof (pocl_mem_manager));
POCL_INIT_LOCK (mm->event_lock);
POCL_INIT_LOCK (mm->cmd_lock);
}
POCL_UNLOCK(pocl_init_lock);
}
5. Funciton "exec_commands" in \lib\CL\clFinish.c
: Implicit event should be included in the loop.
: event wait list should be de-allocated.
The original in the official POCL 0.10
Recommendation to be added
static void exec_commands (_cl_command_node *node_list)
{
~~
LL_FOREACH (node_list, node)
{
~~
}
if (event)
{
~~
}
// free the queue contents
node = node_list;
node_list = NULL;
while (node)
{
_cl_command_node *tmp;
tmp = node->next;
pocl_mem_manager_free_command (node);
node = tmp;
}
}
static void exec_commands (_cl_command_node *node_list)
{
~~
LL_FOREACH (node_list, node)
{
~~
if (event) // Should be included in the loop
{
~~
}
}
// free the queue contents
node = node_list;
node_list = NULL;
while (node)
{
_cl_command_node *tmp;
tmp = node->next;
pocl_mem_manager_free_command (node);
if(node->event_wait_list != NULL)
free(node->event_wait_list);
node = tmp;
}
}
6. Funciton "clEnqueueNDRangeKernel" in \lib\CL\clEnqueueNDRangeKernel.c
: POname(clRetainCommandQueue) (command_queue); should be removed.
: Because clRetainCommandQueue is not called in the functions, which has
the prefix "clEnqueue~" except clEnqueueNDRangeKernel
The original in the official POCL 0.10
Recommendation to be added
CL_API_ENTRY cl_int CL_API_CALL
POname(clEnqueueNDRangeKernel)(,,,) CL_API_SUFFIX__VERSION_1_0
{
POname(clRetainCommandQueue) (command_queue);
}
CL_API_ENTRY cl_int CL_API_CALL
POname(clEnqueueNDRangeKernel) (,,,)
CL_API_SUFFIX__VERSION_1_0
{
//POname(clRetainCommandQueue) (command_queue);
}
Regards,
Lee Ki-ju
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
pocl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pocl-devel