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
50b453e5
Commit
50b453e5
authored
Jun 29, 2015
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4150 from alalek:opencv_org_issue_4428
parents
d0c43f16
53fc5440
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
72 additions
and
61 deletions
+72
-61
dxt.cpp
modules/core/src/dxt.cpp
+2
-4
matop.cpp
modules/core/src/matop.cpp
+1
-2
matrix.cpp
modules/core/src/matrix.cpp
+1
-6
ocl.cpp
modules/core/src/ocl.cpp
+35
-41
precomp.hpp
modules/core/src/precomp.hpp
+16
-0
system.cpp
modules/core/src/system.cpp
+17
-8
No files found.
modules/core/src/dxt.cpp
View file @
50b453e5
...
...
@@ -2026,8 +2026,7 @@ class OCL_FftPlanCache
public
:
static
OCL_FftPlanCache
&
getInstance
()
{
static
OCL_FftPlanCache
planCache
;
return
planCache
;
CV_SINGLETON_LAZY_INIT_REF
(
OCL_FftPlanCache
,
new
OCL_FftPlanCache
())
}
Ptr
<
OCL_FftPlan
>
getFftPlan
(
int
dft_size
,
int
depth
)
...
...
@@ -2291,8 +2290,7 @@ class PlanCache
public
:
static
PlanCache
&
getInstance
()
{
static
PlanCache
planCache
;
return
planCache
;
CV_SINGLETON_LAZY_INIT_REF
(
PlanCache
,
new
PlanCache
())
}
clAmdFftPlanHandle
getPlanHandle
(
const
Size
&
dft_size
,
int
src_step
,
int
dst_step
,
bool
doubleFP
,
...
...
modules/core/src/matop.cpp
View file @
50b453e5
...
...
@@ -205,8 +205,7 @@ public:
static
MatOp_Initializer
*
getGlobalMatOpInitializer
()
{
static
MatOp_Initializer
initializer
;
return
&
initializer
;
CV_SINGLETON_LAZY_INIT
(
MatOp_Initializer
,
new
MatOp_Initializer
())
}
static
inline
bool
isIdentity
(
const
MatExpr
&
e
)
{
return
e
.
op
==
&
g_MatOp_Identity
;
}
...
...
modules/core/src/matrix.cpp
View file @
50b453e5
...
...
@@ -222,14 +222,9 @@ public:
}
};
static
StdMatAllocator
*
mat_allocator
=
NULL
;
MatAllocator
*
Mat
::
getStdAllocator
()
{
if
(
mat_allocator
==
NULL
)
{
mat_allocator
=
new
StdMatAllocator
();
}
return
mat_allocator
;
CV_SINGLETON_LAZY_INIT
(
MatAllocator
,
new
StdMatAllocator
())
}
void
swap
(
Mat
&
a
,
Mat
&
b
)
...
...
modules/core/src/ocl.cpp
View file @
50b453e5
...
...
@@ -1510,8 +1510,7 @@ class AmdBlasHelper
public
:
static
AmdBlasHelper
&
getInstance
()
{
static
AmdBlasHelper
amdBlas
;
return
amdBlas
;
CV_SINGLETON_LAZY_INIT_REF
(
AmdBlasHelper
,
new
AmdBlasHelper
())
}
bool
isAvailable
()
const
...
...
@@ -1533,35 +1532,36 @@ protected:
{
if
(
!
g_isAmdBlasInitialized
)
{
AutoLock
lock
(
m
);
AutoLock
lock
(
getInitializationMutex
()
);
if
(
!
g_isAmdBlasInitialized
&&
haveOpenCL
()
)
if
(
!
g_isAmdBlasInitialized
)
{
try
if
(
haveOpenCL
())
{
g_isAmdBlasAvailable
=
clAmdBlasSetup
()
==
clAmdBlasSuccess
;
try
{
g_isAmdBlasAvailable
=
clAmdBlasSetup
()
==
clAmdBlasSuccess
;
}
catch
(...)
{
g_isAmdBlasAvailable
=
false
;
}
}
catch
(...)
{
else
g_isAmdBlasAvailable
=
false
;
}
}
else
g_isAmdBlasAvailable
=
false
;
g_isAmdBlasInitialized
=
true
;
g_isAmdBlasInitialized
=
true
;
}
}
}
private
:
static
Mutex
m
;
static
bool
g_isAmdBlasInitialized
;
static
bool
g_isAmdBlasAvailable
;
};
bool
AmdBlasHelper
::
g_isAmdBlasAvailable
=
false
;
bool
AmdBlasHelper
::
g_isAmdBlasInitialized
=
false
;
Mutex
AmdBlasHelper
::
m
;
bool
haveAmdBlas
()
{
...
...
@@ -1584,8 +1584,7 @@ class AmdFftHelper
public
:
static
AmdFftHelper
&
getInstance
()
{
static
AmdFftHelper
amdFft
;
return
amdFft
;
CV_SINGLETON_LAZY_INIT_REF
(
AmdFftHelper
,
new
AmdFftHelper
())
}
bool
isAvailable
()
const
...
...
@@ -1607,34 +1606,36 @@ protected:
{
if
(
!
g_isAmdFftInitialized
)
{
AutoLock
lock
(
m
);
AutoLock
lock
(
getInitializationMutex
()
);
if
(
!
g_isAmdFftInitialized
&&
haveOpenCL
()
)
if
(
!
g_isAmdFftInitialized
)
{
try
if
(
haveOpenCL
())
{
cl_uint
major
,
minor
,
patch
;
CV_Assert
(
clAmdFftInitSetupData
(
&
setupData
)
==
CLFFT_SUCCESS
);
try
{
cl_uint
major
,
minor
,
patch
;
CV_Assert
(
clAmdFftInitSetupData
(
&
setupData
)
==
CLFFT_SUCCESS
);
// it throws exception in case AmdFft binaries are not found
CV_Assert
(
clAmdFftGetVersion
(
&
major
,
&
minor
,
&
patch
)
==
CLFFT_SUCCESS
);
g_isAmdFftAvailable
=
true
;
// it throws exception in case AmdFft binaries are not found
CV_Assert
(
clAmdFftGetVersion
(
&
major
,
&
minor
,
&
patch
)
==
CLFFT_SUCCESS
);
g_isAmdFftAvailable
=
true
;
}
catch
(
const
Exception
&
)
{
g_isAmdFftAvailable
=
false
;
}
}
catch
(
const
Exception
&
)
{
else
g_isAmdFftAvailable
=
false
;
}
}
else
g_isAmdFftAvailable
=
false
;
g_isAmdFftInitialized
=
true
;
g_isAmdFftInitialized
=
true
;
}
}
}
private
:
static
clAmdFftSetupData
setupData
;
static
Mutex
m
;
static
bool
g_isAmdFftInitialized
;
static
bool
g_isAmdFftAvailable
;
};
...
...
@@ -1642,7 +1643,6 @@ private:
clAmdFftSetupData
AmdFftHelper
::
setupData
;
bool
AmdFftHelper
::
g_isAmdFftAvailable
=
false
;
bool
AmdFftHelper
::
g_isAmdFftInitialized
=
false
;
Mutex
AmdFftHelper
::
m
;
bool
haveAmdFft
()
{
...
...
@@ -5237,15 +5237,9 @@ public:
MatAllocator
*
matStdAllocator
;
};
// This line should not force OpenCL runtime initialization! (don't put "new OpenCLAllocator()" here)
static
MatAllocator
*
ocl_allocator
=
NULL
;
MatAllocator
*
getOpenCLAllocator
()
{
if
(
ocl_allocator
==
NULL
)
{
ocl_allocator
=
new
OpenCLAllocator
();
}
return
ocl_allocator
;
CV_SINGLETON_LAZY_INIT
(
MatAllocator
,
new
OpenCLAllocator
())
}
}}
// namespace cv::ocl
...
...
modules/core/src/precomp.hpp
View file @
50b453e5
...
...
@@ -295,6 +295,22 @@ TLSData<CoreTLSData>& getCoreTlsData();
extern
bool
__termination
;
// skip some cleanups, because process is terminating
// (for example, if ExitProcess() was already called)
cv
::
Mutex
&
getInitializationMutex
();
// TODO Memory barriers?
#define CV_SINGLETON_LAZY_INIT_(TYPE, INITIALIZER, RET_VALUE) \
static TYPE* volatile instance = NULL; \
if (instance == NULL) \
{ \
cv::AutoLock lock(cv::getInitializationMutex()); \
if (instance == NULL) \
instance = INITIALIZER; \
} \
return RET_VALUE;
#define CV_SINGLETON_LAZY_INIT(TYPE, INITIALIZER) CV_SINGLETON_LAZY_INIT_(TYPE, INITIALIZER, instance)
#define CV_SINGLETON_LAZY_INIT_REF(TYPE, INITIALIZER) CV_SINGLETON_LAZY_INIT_(TYPE, INITIALIZER, *instance)
}
#include "opencv2/hal/intrin.hpp"
...
...
modules/core/src/system.cpp
View file @
50b453e5
...
...
@@ -43,6 +43,20 @@
#include "precomp.hpp"
namespace
cv
{
static
Mutex
*
__initialization_mutex
=
NULL
;
Mutex
&
getInitializationMutex
()
{
if
(
__initialization_mutex
==
NULL
)
__initialization_mutex
=
new
Mutex
();
return
*
__initialization_mutex
;
}
// force initialization (single-threaded environment)
Mutex
*
__initialization_mutex_initializer
=
&
getInitializationMutex
();
}
// namespace cv
#ifdef _MSC_VER
# if _MSC_VER >= 1700
# pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
...
...
@@ -1108,8 +1122,7 @@ public:
// For more information: http://www.parashift.com/c++-faq/static-init-order-on-first-use.html
static
TLSContainerStorage
&
getTLSContainerStorage
()
{
static
TLSContainerStorage
*
tlsContainerStorage
=
new
TLSContainerStorage
();
return
*
tlsContainerStorage
;
CV_SINGLETON_LAZY_INIT_REF
(
TLSContainerStorage
,
new
TLSContainerStorage
())
}
TLSDataContainer
::
TLSDataContainer
()
...
...
@@ -1153,20 +1166,16 @@ TLSStorage::~TLSStorage()
}
TLSData
<
CoreTLSData
>&
getCoreTlsData
()
{
static
TLSData
<
CoreTLSData
>
*
value
=
new
TLSData
<
CoreTLSData
>
();
return
*
value
;
CV_SINGLETON_LAZY_INIT_REF
(
TLSData
<
CoreTLSData
>
,
new
TLSData
<
CoreTLSData
>
())
}
#ifdef CV_COLLECT_IMPL_DATA
ImplCollector
&
getImplData
()
{
static
ImplCollector
*
value
=
new
ImplCollector
();
return
*
value
;
CV_SINGLETON_LAZY_INIT_REF
(
ImplCollector
,
new
ImplCollector
())
}
void
setImpl
(
int
flags
)
...
...
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