core(ocl): update isOpenCLActivated()

- reuse g_isOpenCLAvailable variable instead
pull/19385/head
Alexander Alekhin 4 years ago
parent 68fb8dd873
commit 37e656082b
  1. 10
      modules/core/src/ocl.cpp

@ -830,13 +830,12 @@ public:
// true if we have initialized OpenCL subsystem with available platforms
static bool g_isOpenCVActivated = false;
static bool g_isOpenCLInitialized = false;
static bool g_isOpenCLAvailable = false;
bool haveOpenCL()
{
CV_TRACE_FUNCTION();
static bool g_isOpenCLInitialized = false;
static bool g_isOpenCLAvailable = false;
if (!g_isOpenCLInitialized)
{
@ -855,7 +854,7 @@ bool haveOpenCL()
{
cl_uint n = 0;
g_isOpenCLAvailable = ::clGetPlatformIDs(0, NULL, &n) == CL_SUCCESS;
g_isOpenCVActivated = n > 0;
g_isOpenCLAvailable &= n > 0;
}
catch (...)
{
@ -885,7 +884,7 @@ bool useOpenCL()
bool isOpenCLActivated()
{
if (!g_isOpenCVActivated)
if (!g_isOpenCLAvailable)
return false; // prevent unnecessary OpenCL activation via useOpenCL()->haveOpenCL() calls
return useOpenCL();
}
@ -5773,7 +5772,6 @@ public:
static OpenCLAllocator* getOpenCLAllocator_() // call once guarantee
{
static OpenCLAllocator* g_allocator = new OpenCLAllocator(); // avoid destructor call (using of this object is too wide)
g_isOpenCVActivated = true;
return g_allocator;
}
MatAllocator* getOpenCLAllocator()

Loading…
Cancel
Save