mirror of
https://github.com/opencv/opencv.git
synced 2025-06-12 12:22:51 +08:00
core(ocl): update isOpenCLActivated()
- reuse g_isOpenCLAvailable variable instead
This commit is contained in:
parent
68fb8dd873
commit
37e656082b
@ -830,13 +830,12 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
// true if we have initialized OpenCL subsystem with available platforms
|
// 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()
|
bool haveOpenCL()
|
||||||
{
|
{
|
||||||
CV_TRACE_FUNCTION();
|
CV_TRACE_FUNCTION();
|
||||||
static bool g_isOpenCLInitialized = false;
|
|
||||||
static bool g_isOpenCLAvailable = false;
|
|
||||||
|
|
||||||
if (!g_isOpenCLInitialized)
|
if (!g_isOpenCLInitialized)
|
||||||
{
|
{
|
||||||
@ -855,7 +854,7 @@ bool haveOpenCL()
|
|||||||
{
|
{
|
||||||
cl_uint n = 0;
|
cl_uint n = 0;
|
||||||
g_isOpenCLAvailable = ::clGetPlatformIDs(0, NULL, &n) == CL_SUCCESS;
|
g_isOpenCLAvailable = ::clGetPlatformIDs(0, NULL, &n) == CL_SUCCESS;
|
||||||
g_isOpenCVActivated = n > 0;
|
g_isOpenCLAvailable &= n > 0;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
@ -885,7 +884,7 @@ bool useOpenCL()
|
|||||||
|
|
||||||
bool isOpenCLActivated()
|
bool isOpenCLActivated()
|
||||||
{
|
{
|
||||||
if (!g_isOpenCVActivated)
|
if (!g_isOpenCLAvailable)
|
||||||
return false; // prevent unnecessary OpenCL activation via useOpenCL()->haveOpenCL() calls
|
return false; // prevent unnecessary OpenCL activation via useOpenCL()->haveOpenCL() calls
|
||||||
return useOpenCL();
|
return useOpenCL();
|
||||||
}
|
}
|
||||||
@ -5773,7 +5772,6 @@ public:
|
|||||||
static OpenCLAllocator* getOpenCLAllocator_() // call once guarantee
|
static OpenCLAllocator* getOpenCLAllocator_() // call once guarantee
|
||||||
{
|
{
|
||||||
static OpenCLAllocator* g_allocator = new OpenCLAllocator(); // avoid destructor call (using of this object is too wide)
|
static OpenCLAllocator* g_allocator = new OpenCLAllocator(); // avoid destructor call (using of this object is too wide)
|
||||||
g_isOpenCVActivated = true;
|
|
||||||
return g_allocator;
|
return g_allocator;
|
||||||
}
|
}
|
||||||
MatAllocator* getOpenCLAllocator()
|
MatAllocator* getOpenCLAllocator()
|
||||||
|
Loading…
Reference in New Issue
Block a user