Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
7f554f3c
Commit
7f554f3c
authored
Nov 27, 2017
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10155 from alalek:ocl_update_loader
parents
91c1d769
c38620e9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
22 deletions
+34
-22
opencl_core.cpp
modules/core/src/opencl/runtime/opencl_core.cpp
+34
-22
No files found.
modules/core/src/opencl/runtime/opencl_core.cpp
View file @
7f554f3c
...
...
@@ -63,6 +63,20 @@ CV_SUPPRESS_DEPRECATED_END
#define ERROR_MSG_CANT_LOAD "Failed to load OpenCL runtime\n"
#define ERROR_MSG_INVALID_VERSION "Failed to load OpenCL runtime (expected version 1.1+)\n"
static
const
char
*
getRuntimePath
(
const
char
*
defaultPath
)
{
const
char
*
envPath
=
getenv
(
"OPENCV_OPENCL_RUNTIME"
);
if
(
envPath
)
{
static
const
char
disabled_str
[]
=
"disabled"
;
if
((
strlen
(
envPath
)
==
sizeof
(
disabled_str
)
-
1
)
&&
(
memcmp
(
envPath
,
disabled_str
,
sizeof
(
disabled_str
)
-
1
)
==
0
))
return
NULL
;
return
envPath
;
}
return
defaultPath
;
}
#if defined(__APPLE__)
#include <dlfcn.h>
...
...
@@ -75,14 +89,13 @@ static void* AppleCLGetProcAddress(const char* name)
cv
::
AutoLock
lock
(
cv
::
getInitializationMutex
());
if
(
!
initialized
)
{
const
char
*
path
=
"/System/Library/Frameworks/OpenCL.framework/Versions/Current/OpenCL"
;
const
char
*
envPath
=
getenv
(
"OPENCV_OPENCL_RUNTIME"
);
if
(
envPath
)
path
=
envPath
;
handle
=
dlopen
(
oclpath
,
RTLD_LAZY
|
RTLD_GLOBAL
);
const
char
*
defaultPath
=
"/System/Library/Frameworks/OpenCL.framework/Versions/Current/OpenCL"
;
const
char
*
path
=
getRuntimePath
(
defaultPath
);
if
(
path
)
handle
=
dlopen
(
path
,
RTLD_LAZY
|
RTLD_GLOBAL
);
if
(
handle
==
NULL
)
{
if
(
env
Path
)
if
(
path
!=
NULL
&&
path
!=
default
Path
)
fprintf
(
stderr
,
ERROR_MSG_CANT_LOAD
);
}
else
if
(
dlsym
(
handle
,
OPENCL_FUNC_TO_CHECK_1_1
)
==
NULL
)
...
...
@@ -115,14 +128,13 @@ static void* WinGetProcAddress(const char* name)
handle
=
GetModuleHandleA
(
"OpenCL.dll"
);
if
(
!
handle
)
{
const
char
*
path
=
"OpenCL.dll"
;
const
char
*
envPath
=
getenv
(
"OPENCV_OPENCL_RUNTIME"
);
if
(
envPath
)
path
=
envPath
;
handle
=
LoadLibraryA
(
path
);
const
char
*
defaultPath
=
"OpenCL.dll"
;
const
char
*
path
=
getRuntimePath
(
defaultPath
);
if
(
path
)
handle
=
LoadLibraryA
(
path
);
if
(
!
handle
)
{
if
(
env
Path
)
if
(
path
!=
NULL
&&
path
!=
default
Path
)
fprintf
(
stderr
,
ERROR_MSG_CANT_LOAD
);
}
else
if
(
GetProcAddress
(
handle
,
OPENCL_FUNC_TO_CHECK_1_1
)
==
NULL
)
...
...
@@ -173,18 +185,18 @@ static void* GetProcAddress(const char* name)
cv
::
AutoLock
lock
(
cv
::
getInitializationMutex
());
if
(
!
initialized
)
{
const
char
*
envPath
=
getenv
(
"OPENCV_OPENCL_RUNTIME"
);
if
(
envPath
)
{
handle
=
GetHandle
(
envPath
);
if
(
!
handle
)
fprintf
(
stderr
,
ERROR_MSG_CANT_LOAD
);
}
else
const
char
*
defaultPath
=
"libOpenCL.so"
;
const
char
*
path
=
getRuntimePath
(
defaultPath
);
if
(
path
)
{
handle
=
GetHandle
(
"libOpenCL.so"
);
handle
=
GetHandle
(
path
);
if
(
!
handle
)
handle
=
GetHandle
(
"libOpenCL.so.1"
);
{
if
(
path
==
defaultPath
)
handle
=
GetHandle
(
"libOpenCL.so.1"
);
else
fprintf
(
stderr
,
ERROR_MSG_CANT_LOAD
);
}
}
initialized
=
true
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment