Commit ba701a57 authored by Uldis Locans's avatar Uldis Locans

remove opencl event tracking since it causes memory leak

parent 74b12ebd
......@@ -675,17 +675,14 @@ cl_mem OpenCLBase::ocl_allocateMemory(size_t size, cl_int &ierr) {
/*
write data specified by in_data to device memory, device memory space defined by cl_mem
*/
int OpenCLBase::ocl_writeData(cl_mem mem_ptr, const void * in_data, size_t size, size_t offset, int blocking) {
int OpenCLBase::ocl_writeData(cl_mem mem_ptr, const void * in_data, size_t size,
size_t offset, int blocking)
{
cl_int ierr;
//std::cout << "Write: " << size*1e-9 << " gb of data" << std::endl;
ierr = clEnqueueWriteBuffer(m_command_queue, mem_ptr, blocking, offset, size, in_data, 0, NULL, &m_last_event);
//m_events[m_num_events] = m_last_event;
m_events.push_back(m_last_event);
ierr = clEnqueueWriteBuffer(m_command_queue, mem_ptr, blocking, offset, size,
in_data, 0, NULL, NULL);
if (ierr != CL_SUCCESS) {
DEBUG_MSG("Error writing data to device, OpenCL error: " << ierr);
......@@ -752,28 +749,16 @@ int OpenCLBase::ocl_executeKernel(cl_uint ndim, const size_t *work_items,
const size_t *work_group_size)
{
cl_int ierr;
cl_event tmp_event;
if (m_last_event == NULL) {
ierr = clEnqueueNDRangeKernel(m_command_queue, m_kernel, ndim, NULL,
work_items, work_group_size,
0, NULL, &tmp_event);
} else {
ierr = clEnqueueNDRangeKernel(m_command_queue, m_kernel, ndim, NULL,
work_items, work_group_size,
1, &m_last_event, &tmp_event);
}
clFlush(m_command_queue);
ierr = clEnqueueNDRangeKernel(m_command_queue, m_kernel, ndim, NULL,
work_items, work_group_size,
0, NULL, NULL);
if (ierr != CL_SUCCESS)
DEBUG_MSG("Error executing kernel, OpenCL error: " << ierr
<< " work items: " << *work_items << ", "
<< " work group: " << *work_group_size);
clReleaseEvent(tmp_event);
//m_last_event = tmp_event;
//m_events.push_back(m_last_event);
return ierr;
}
......@@ -781,12 +766,13 @@ int OpenCLBase::ocl_executeKernel(cl_uint ndim, const size_t *work_items,
read data from device, mem_ptr points to data on device out_data points to memory in host
blocking specifies wether the read operation is blocking (default CL_TRUE) or non blocking (CL_FALSE)
*/
int OpenCLBase::ocl_readData(cl_mem mem_ptr, void * out_data, size_t size, size_t offset, int blocking) {
int OpenCLBase::ocl_readData(cl_mem mem_ptr, void * out_data, size_t size,
size_t offset, int blocking)
{
cl_int ierr;
ierr = clEnqueueReadBuffer(m_command_queue, mem_ptr, blocking, offset, size, out_data, 0, NULL, &m_last_event);
m_events.push_back(m_last_event);
ierr = clEnqueueReadBuffer(m_command_queue, mem_ptr, blocking, offset, size,
out_data, 0, NULL, NULL);
if (ierr != CL_SUCCESS)
DEBUG_MSG("Error reading data from device, OpenCL error: " << ierr);
......
......@@ -98,7 +98,6 @@ double OpenCLChiSquareRuntime::calculateSum(cl_mem data, int length) {
tmp_ptr = m_oclbase->ocl_allocateMemory(work_groups * sizeof(double), ierr);
//execute sum kernel
//ocl_createKernel("parallelReductionSum");
m_oclbase->ocl_createKernel("parallelReductionTwoPhase");
m_oclbase->ocl_setKernelArg(0, sizeof(cl_mem), &data);
m_oclbase->ocl_setKernelArg(1, sizeof(cl_mem), &tmp_ptr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment