From 4aa891e77384e88a4e809f92fa2bc9b50f67a07c Mon Sep 17 00:00:00 2001 From: Alexander Karsakov Date: Wed, 5 Mar 2014 17:57:06 +0400 Subject: [PATCH 1/2] Remove clReleaseDevice call (workaround for pure virtual call on Windows) --- modules/ocl/src/cl_context.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/ocl/src/cl_context.cpp b/modules/ocl/src/cl_context.cpp index 37d6bb33b8..4edf1f7ff8 100644 --- a/modules/ocl/src/cl_context.cpp +++ b/modules/ocl/src/cl_context.cpp @@ -596,9 +596,16 @@ protected: CV_Assert(this != currentContext); #ifdef CL_VERSION_1_2 - if (supportsFeature(FEATURE_CL_VER_1_2)) +#ifdef WIN32 + // if process is on termination stage (ExitProcess was called and other threads were terminated) + // then disable command queue release because it may cause program hang + if (!__termination) +#endif { - openCLSafeCall(clReleaseDevice(clDeviceID)); + if (supportsFeature(FEATURE_CL_VER_1_2)) + { + openCLSafeCall(clReleaseDevice(clDeviceID)); + } } #endif if (deviceInfoImpl._id < 0) // not in the global registry, so we should cleanup it From 806e9241a6c0255cde117e24e3a9de6fd315443e Mon Sep 17 00:00:00 2001 From: Alexander Karsakov Date: Thu, 6 Mar 2014 11:16:38 +0400 Subject: [PATCH 2/2] Clarifying comments --- modules/ocl/src/cl_context.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ocl/src/cl_context.cpp b/modules/ocl/src/cl_context.cpp index 4edf1f7ff8..156fa99168 100644 --- a/modules/ocl/src/cl_context.cpp +++ b/modules/ocl/src/cl_context.cpp @@ -598,7 +598,7 @@ protected: #ifdef CL_VERSION_1_2 #ifdef WIN32 // if process is on termination stage (ExitProcess was called and other threads were terminated) - // then disable command queue release because it may cause program hang + // then disable device release because it may cause program hang if (!__termination) #endif { @@ -624,7 +624,7 @@ protected: #ifdef WIN32 // if process is on termination stage (ExitProcess was called and other threads were terminated) - // then disable command queue release because it may cause program hang + // then disable context release because it may cause program hang if (!__termination) #endif {