[clfft] 09/23: fixing event leak issues that caused seg fault of client with 14.502 driver, this problem did not affect standalone library usage
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Tue Aug 18 16:08:20 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/sid
in repository clfft.
commit 5faf9ede1d2273695f843f0dbaa3449db3a91bbc
Author: bragadeesh <bragadeesh.natarajan at amd>
Date: Wed Aug 5 19:42:06 2015 -0500
fixing event leak issues that caused seg fault of client with 14.502 driver, this problem did not affect standalone library usage
---
src/client/client.cpp | 26 ++++++++++++++++----------
src/client/openCL.misc.cpp | 7 +++++--
src/statTimer/statisticalTimer.GPU.cpp | 29 +++++++++++++++++++++++++++++
src/statTimer/statisticalTimer.GPU.h | 2 ++
4 files changed, 52 insertions(+), 12 deletions(-)
diff --git a/src/client/client.cpp b/src/client/client.cpp
index df00405..1dfb5ed 100644
--- a/src/client/client.cpp
+++ b/src/client/client.cpp
@@ -73,7 +73,6 @@ int transform( size_t* lengths, const size_t *inStrides, const size_t *outStride
std::vector< cl_device_id > device_id;
cl_context context;
cl_command_queue queue;
- cl_event outEvent = NULL;
clfftPlanHandle plan_handle;
for (unsigned u = 0; u < max_dimensions; ++u) {
@@ -204,7 +203,7 @@ int transform( size_t* lengths, const size_t *inStrides, const size_t *outStride
OPENCL_V_THROW( clEnqueueWriteBuffer( queue, input_cl_mem_buffers[ 0 ], CL_TRUE, 0, size_of_input_buffers_in_bytes, &input[ 0 ],
- 0, NULL, &outEvent ),
+ 0, NULL, NULL ),
"clEnqueueWriteBuffer failed" );
}
@@ -252,10 +251,10 @@ int transform( size_t* lengths, const size_t *inStrides, const size_t *outStride
OPENCL_V_THROW( clEnqueueWriteBuffer( queue, input_cl_mem_buffers[ 0 ], CL_TRUE, 0, size_of_input_buffers_in_bytes, &real[ 0 ],
- 0, NULL, &outEvent ),
+ 0, NULL, NULL ),
"clEnqueueWriteBuffer failed" );
OPENCL_V_THROW( clEnqueueWriteBuffer( queue, input_cl_mem_buffers[ 1 ], CL_TRUE, 0, size_of_input_buffers_in_bytes, &imag[ 0 ],
- 0, NULL, &outEvent ),
+ 0, NULL, NULL ),
"clEnqueueWriteBuffer failed" );
}
break;
@@ -289,7 +288,7 @@ int transform( size_t* lengths, const size_t *inStrides, const size_t *outStride
OPENCL_V_THROW( clEnqueueWriteBuffer( queue, input_cl_mem_buffers[ 0 ], CL_TRUE, 0, size_of_input_buffers_in_bytes, &input[ 0 ],
- 0, NULL, &outEvent ),
+ 0, NULL, NULL ),
"clEnqueueWriteBuffer failed" );
}
break;
@@ -325,10 +324,10 @@ int transform( size_t* lengths, const size_t *inStrides, const size_t *outStride
OPENCL_V_THROW( clEnqueueWriteBuffer( queue, input_cl_mem_buffers[ 0 ], CL_TRUE, 0, size_of_input_buffers_in_bytes, &real[ 0 ],
- 0, NULL, &outEvent ),
+ 0, NULL, NULL ),
"clEnqueueWriteBuffer failed" );
OPENCL_V_THROW( clEnqueueWriteBuffer( queue, input_cl_mem_buffers[ 1 ], CL_TRUE, 0, size_of_input_buffers_in_bytes, &imag[ 0 ],
- 0, NULL, &outEvent ),
+ 0, NULL, NULL ),
"clEnqueueWriteBuffer failed" );
}
break;
@@ -373,7 +372,7 @@ int transform( size_t* lengths, const size_t *inStrides, const size_t *outStride
OPENCL_V_THROW( clEnqueueWriteBuffer( queue, input_cl_mem_buffers[ 0 ], CL_TRUE, 0, size_of_input_buffers_in_bytes, &real[ 0 ],
- 0, NULL, &outEvent ),
+ 0, NULL, NULL ),
"clEnqueueWriteBuffer failed" );
}
break;
@@ -518,11 +517,13 @@ int transform( size_t* lengths, const size_t *inStrides, const size_t *outStride
Timer tr;
tr.Start();
+ cl_event *outEvent = new cl_event[profile_count];
+
for( cl_uint i = 0; i < profile_count; ++i )
{
if( timer ) timer->Start( clFFTID );
- OPENCL_V_THROW( clfftEnqueueTransform( plan_handle, dir, 1, &queue, 0, NULL, &outEvent,
+ OPENCL_V_THROW( clfftEnqueueTransform( plan_handle, dir, 1, &queue, 0, NULL, &outEvent[i],
&input_cl_mem_buffers[ 0 ], BuffersOut, clMedBuffer ),
"clfftEnqueueTransform failed" );
@@ -553,6 +554,11 @@ int transform( size_t* lengths, const size_t *inStrides, const size_t *outStride
/*****************/
FreeSharedLibrary( timerLibHandle );
+ for( cl_uint i = 0; i < profile_count; ++i )
+ clReleaseEvent(outEvent[i]);
+
+ delete[] outEvent;
+
// Read and check output data
// This check is not valid if the FFT is executed multiple times inplace.
//
@@ -725,7 +731,7 @@ int transform( size_t* lengths, const size_t *inStrides, const size_t *outStride
OPENCL_V_THROW( clfftDestroyPlan( &plan_handle ), "clfftDestroyPlan failed" );
OPENCL_V_THROW( clfftTeardown( ), "clfftTeardown failed" );
- cleanupCL( &context, &queue, countOf( input_cl_mem_buffers ), input_cl_mem_buffers, countOf( output_cl_mem_buffers ), output_cl_mem_buffers, &outEvent );
+ cleanupCL( &context, &queue, countOf( input_cl_mem_buffers ), input_cl_mem_buffers, countOf( output_cl_mem_buffers ), output_cl_mem_buffers, NULL );
return 0;
}
diff --git a/src/client/openCL.misc.cpp b/src/client/openCL.misc.cpp
index cb5db29..21d4cbc 100644
--- a/src/client/openCL.misc.cpp
+++ b/src/client/openCL.misc.cpp
@@ -477,8 +477,11 @@ std::vector< cl_device_id > initializeCL( cl_device_type deviceType,
int cleanupCL( cl_context* context, cl_command_queue* commandQueue,
const cl_uint numBuffersIn, cl_mem inputBuffer[], const cl_uint numBuffersOut, cl_mem outputBuffer[], cl_event* outEvent )
{
- if( *outEvent != NULL )
- OPENCL_V_THROW( clReleaseEvent( *outEvent ), "Error: In clReleaseEvent\n" );
+ if(outEvent != NULL)
+ {
+ if( *outEvent != NULL )
+ OPENCL_V_THROW( clReleaseEvent( *outEvent ), "Error: In clReleaseEvent\n" );
+ }
releaseOpenCLMemBuffer( numBuffersIn, inputBuffer);
releaseOpenCLMemBuffer( numBuffersOut, outputBuffer);
diff --git a/src/statTimer/statisticalTimer.GPU.cpp b/src/statTimer/statisticalTimer.GPU.cpp
index 269378e..bdd3bd4 100644
--- a/src/statTimer/statisticalTimer.GPU.cpp
+++ b/src/statTimer/statisticalTimer.GPU.cpp
@@ -176,6 +176,7 @@ GpuStatTimer::Reset( )
if( nEvents == 0 || nSamples == 0 )
throw std::runtime_error( "StatisticalTimer::Reserve( ) was not called before Reset( )" );
+ ReleaseEvents();
Reserve( nEvents, nSamples );
return;
@@ -203,9 +204,17 @@ void
GpuStatTimer::AddSample( clfftPlanHandle plHandle, FFTPlan* plan, cl_kernel kern, cl_uint numEvents, cl_event* ev,
const std::vector< size_t >& gWorkSize )
{
+ if(ev == NULL)
+ return;
+
if( timerData.empty( ) )
return;
+ for( size_t i = 0; i < numEvents; ++i )
+ {
+ ::clRetainEvent(ev[i]);
+ }
+
if( currRecord == 0 )
{
timerData.at( currID ).push_back( StatDataVec( ) );
@@ -242,6 +251,26 @@ GpuStatTimer::getUniqueID( const std::string& label, cl_uint groupID )
}
+void GpuStatTimer::ReleaseEvents()
+{
+ for( cl_uint id = 0; id < labelID.size( ); ++id )
+ {
+ for( size_t s = 0; s < timerData.at( id ).size( ); ++s )
+ {
+ for( size_t n = 0; n < timerData.at( id ).at( s ).size( ); ++n )
+ {
+ StatData& sd = timerData[ id ][ s ][ n ];
+
+ for( size_t i = 0; i < sd.outEvents.size( ); ++i )
+ {
+ ::clReleaseEvent(sd.outEvents[ i ]);
+ }
+
+ }
+ }
+ }
+}
+
void GpuStatTimer::queryOpenCL( size_t id )
{
for( size_t s = 0; s < timerData.at( id ).size( ); ++s )
diff --git a/src/statTimer/statisticalTimer.GPU.h b/src/statTimer/statisticalTimer.GPU.h
index 62e3c29..8a09956 100644
--- a/src/statTimer/statisticalTimer.GPU.h
+++ b/src/statTimer/statisticalTimer.GPU.h
@@ -182,6 +182,8 @@ class GpuStatTimer : public baseStatTimer
void queryOpenCL( size_t id );
+ void ReleaseEvents();
+
public:
/**
* \fn getInstance()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/clfft.git
More information about the debian-science-commits
mailing list