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
ce117715
Commit
ce117715
authored
Oct 11, 2013
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ocl: fix cleanup in static builds
parent
57120c1a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
24 deletions
+36
-24
util.hpp
modules/ocl/include/opencv2/ocl/private/util.hpp
+2
-0
cl_context.cpp
modules/ocl/src/cl_context.cpp
+26
-14
fft.cpp
modules/ocl/src/fft.cpp
+6
-7
gemm.cpp
modules/ocl/src/gemm.cpp
+2
-3
No files found.
modules/ocl/include/opencv2/ocl/private/util.hpp
View file @
ce117715
...
@@ -77,6 +77,8 @@ inline cl_command_queue getClCommandQueue(const Context *ctx)
...
@@ -77,6 +77,8 @@ inline cl_command_queue getClCommandQueue(const Context *ctx)
return
*
(
cl_command_queue
*
)(
ctx
->
getOpenCLCommandQueuePtr
());
return
*
(
cl_command_queue
*
)(
ctx
->
getOpenCLCommandQueuePtr
());
}
}
CV_EXPORTS
cv
::
Mutex
&
getInitializationMutex
();
enum
openCLMemcpyKind
enum
openCLMemcpyKind
{
{
clMemcpyHostToDevice
=
0
,
clMemcpyHostToDevice
=
0
,
...
...
modules/ocl/src/cl_context.cpp
View file @
ce117715
...
@@ -55,6 +55,21 @@
...
@@ -55,6 +55,21 @@
namespace
cv
{
namespace
cv
{
namespace
ocl
{
namespace
ocl
{
struct
__Module
{
__Module
();
~
__Module
();
cv
::
Mutex
initializationMutex
;
cv
::
Mutex
currentContextMutex
;
};
static
__Module
__module
;
cv
::
Mutex
&
getInitializationMutex
()
{
return
__module
.
initializationMutex
;
}
struct
PlatformInfoImpl
struct
PlatformInfoImpl
{
{
cl_platform_id
platform_id
;
cl_platform_id
platform_id
;
...
@@ -312,7 +327,6 @@ not_found:
...
@@ -312,7 +327,6 @@ not_found:
return
false
;
return
false
;
}
}
static
cv
::
Mutex
__initializedMutex
;
static
bool
__initialized
=
false
;
static
bool
__initialized
=
false
;
static
int
initializeOpenCLDevices
()
static
int
initializeOpenCLDevices
()
{
{
...
@@ -499,7 +513,6 @@ private:
...
@@ -499,7 +513,6 @@ private:
ContextImpl
&
operator
=
(
const
ContextImpl
&
);
// disabled
ContextImpl
&
operator
=
(
const
ContextImpl
&
);
// disabled
};
};
static
cv
::
Mutex
currentContextMutex
;
static
ContextImpl
*
currentContext
=
NULL
;
static
ContextImpl
*
currentContext
=
NULL
;
Context
*
Context
::
getContext
()
Context
*
Context
::
getContext
()
...
@@ -508,7 +521,7 @@ Context* Context::getContext()
...
@@ -508,7 +521,7 @@ Context* Context::getContext()
{
{
if
(
!
__initialized
||
!
__deviceSelected
)
if
(
!
__initialized
||
!
__deviceSelected
)
{
{
cv
::
AutoLock
lock
(
__initializedMutex
);
cv
::
AutoLock
lock
(
getInitializationMutex
()
);
if
(
!
__initialized
)
if
(
!
__initialized
)
{
{
if
(
initializeOpenCLDevices
()
==
0
)
if
(
initializeOpenCLDevices
()
==
0
)
...
@@ -604,7 +617,7 @@ void ContextImpl::cleanupContext(void)
...
@@ -604,7 +617,7 @@ void ContextImpl::cleanupContext(void)
fft_teardown
();
fft_teardown
();
clBlasTeardown
();
clBlasTeardown
();
cv
::
AutoLock
lock
(
currentContextMutex
);
cv
::
AutoLock
lock
(
__module
.
currentContextMutex
);
if
(
currentContext
)
if
(
currentContext
)
delete
currentContext
;
delete
currentContext
;
currentContext
=
NULL
;
currentContext
=
NULL
;
...
@@ -615,7 +628,7 @@ void ContextImpl::setContext(const DeviceInfo* deviceInfo)
...
@@ -615,7 +628,7 @@ void ContextImpl::setContext(const DeviceInfo* deviceInfo)
CV_Assert
(
deviceInfo
->
_id
>=
0
&&
deviceInfo
->
_id
<
(
int
)
global_devices
.
size
());
CV_Assert
(
deviceInfo
->
_id
>=
0
&&
deviceInfo
->
_id
<
(
int
)
global_devices
.
size
());
{
{
cv
::
AutoLock
lock
(
currentContextMutex
);
cv
::
AutoLock
lock
(
__module
.
currentContextMutex
);
if
(
currentContext
)
if
(
currentContext
)
{
{
if
(
currentContext
->
deviceInfo
.
_id
==
deviceInfo
->
_id
)
if
(
currentContext
->
deviceInfo
.
_id
==
deviceInfo
->
_id
)
...
@@ -640,7 +653,7 @@ void ContextImpl::setContext(const DeviceInfo* deviceInfo)
...
@@ -640,7 +653,7 @@ void ContextImpl::setContext(const DeviceInfo* deviceInfo)
ContextImpl
*
old
=
NULL
;
ContextImpl
*
old
=
NULL
;
{
{
cv
::
AutoLock
lock
(
currentContextMutex
);
cv
::
AutoLock
lock
(
__module
.
currentContextMutex
);
old
=
currentContext
;
old
=
currentContext
;
currentContext
=
ctx
;
currentContext
=
ctx
;
}
}
...
@@ -724,20 +737,19 @@ bool supportsFeature(FEATURE_TYPE featureType)
...
@@ -724,20 +737,19 @@ bool supportsFeature(FEATURE_TYPE featureType)
return
Context
::
getContext
()
->
supportsFeature
(
featureType
);
return
Context
::
getContext
()
->
supportsFeature
(
featureType
);
}
}
struct
__Module
__Module
::
__Module
()
{
/* moved to Context::getContext(): initializeOpenCLDevices(); */
}
__Module
::~
__Module
()
{
{
__Module
()
{
/* moved to Context::getContext(): initializeOpenCLDevices(); */
}
~
__Module
()
{
#if defined(WIN32) && defined(CVAPI_EXPORTS)
#if defined(WIN32) && defined(CVAPI_EXPORTS)
// nothing, see DllMain
// nothing, see DllMain
#else
#else
ContextImpl
::
cleanupContext
();
ContextImpl
::
cleanupContext
();
#endif
#endif
}
}
};
static
__Module
__module
;
}
// namespace ocl
}
// namespace ocl
}
// namespace cv
}
// namespace cv
...
...
modules/ocl/src/fft.cpp
View file @
ce117715
...
@@ -90,8 +90,7 @@ namespace cv
...
@@ -90,8 +90,7 @@ namespace cv
protected
:
protected
:
PlanCache
();
PlanCache
();
~
PlanCache
();
~
PlanCache
();
friend
class
auto_ptr
<
PlanCache
>
;
static
PlanCache
*
planCache
;
static
auto_ptr
<
PlanCache
>
planCache
;
bool
started
;
bool
started
;
vector
<
FftPlan
*>
planStore
;
vector
<
FftPlan
*>
planStore
;
...
@@ -102,9 +101,9 @@ namespace cv
...
@@ -102,9 +101,9 @@ namespace cv
static
PlanCache
*
getPlanCache
()
static
PlanCache
*
getPlanCache
()
{
{
if
(
NULL
==
planCache
.
get
()
)
if
(
NULL
==
planCache
)
planCache
.
reset
(
new
PlanCache
()
);
planCache
=
new
PlanCache
(
);
return
planCache
.
get
()
;
return
planCache
;
}
}
// return a baked plan->
// return a baked plan->
// if there is one matched plan, return it
// if there is one matched plan, return it
...
@@ -118,7 +117,7 @@ namespace cv
...
@@ -118,7 +117,7 @@ namespace cv
};
};
}
}
}
}
auto_ptr
<
PlanCache
>
PlanCache
::
planCache
;
PlanCache
*
PlanCache
::
planCache
=
NULL
;
void
cv
::
ocl
::
fft_setup
()
void
cv
::
ocl
::
fft_setup
()
{
{
...
@@ -138,13 +137,13 @@ void cv::ocl::fft_teardown()
...
@@ -138,13 +137,13 @@ void cv::ocl::fft_teardown()
{
{
return
;
return
;
}
}
delete
pCache
.
setupData
;
for
(
size_t
i
=
0
;
i
<
pCache
.
planStore
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
pCache
.
planStore
.
size
();
i
++
)
{
{
delete
pCache
.
planStore
[
i
];
delete
pCache
.
planStore
[
i
];
}
}
pCache
.
planStore
.
clear
();
pCache
.
planStore
.
clear
();
openCLSafeCall
(
clAmdFftTeardown
(
)
);
openCLSafeCall
(
clAmdFftTeardown
(
)
);
delete
pCache
.
setupData
;
pCache
.
setupData
=
NULL
;
pCache
.
started
=
false
;
pCache
.
started
=
false
;
}
}
...
...
modules/ocl/src/gemm.cpp
View file @
ce117715
...
@@ -76,13 +76,12 @@ void cv::ocl::clBlasTeardown()
...
@@ -76,13 +76,12 @@ void cv::ocl::clBlasTeardown()
using
namespace
cv
;
using
namespace
cv
;
static
bool
clBlasInitialized
=
false
;
static
bool
clBlasInitialized
=
false
;
static
Mutex
cs
;
void
cv
::
ocl
::
clBlasSetup
()
void
cv
::
ocl
::
clBlasSetup
()
{
{
if
(
!
clBlasInitialized
)
if
(
!
clBlasInitialized
)
{
{
AutoLock
al
(
cs
);
AutoLock
lock
(
getInitializationMutex
()
);
if
(
!
clBlasInitialized
)
if
(
!
clBlasInitialized
)
{
{
openCLSafeCall
(
clAmdBlasSetup
());
openCLSafeCall
(
clAmdBlasSetup
());
...
@@ -93,7 +92,7 @@ void cv::ocl::clBlasSetup()
...
@@ -93,7 +92,7 @@ void cv::ocl::clBlasSetup()
void
cv
::
ocl
::
clBlasTeardown
()
void
cv
::
ocl
::
clBlasTeardown
()
{
{
AutoLock
al
(
cs
);
AutoLock
lock
(
getInitializationMutex
()
);
if
(
clBlasInitialized
)
if
(
clBlasInitialized
)
{
{
clAmdBlasTeardown
();
clAmdBlasTeardown
();
...
...
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