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
f2befa01
Commit
f2befa01
authored
Dec 16, 2013
by
Roman Donchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed build for the TLS-related stuff.
parent
9d8d70d6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
104 deletions
+20
-104
utility.hpp
modules/core/include/opencv2/core/utility.hpp
+4
-4
ocl.cpp
modules/core/src/ocl.cpp
+4
-4
precomp.hpp
modules/core/src/precomp.hpp
+6
-5
rand.cpp
modules/core/src/rand.cpp
+1
-1
system.cpp
modules/core/src/system.cpp
+5
-90
No files found.
modules/core/include/opencv2/core/utility.hpp
View file @
f2befa01
...
...
@@ -305,18 +305,18 @@ private:
AutoLock
&
operator
=
(
const
AutoLock
&
);
};
class
TLSDataContainer
class
CV_EXPORTS
TLSDataContainer
{
private
:
int
key_
;
protected
:
CV_EXPORTS
TLSDataContainer
();
CV_EXPORTS
~
TLSDataContainer
();
// virtual is not required
TLSDataContainer
();
virtual
~
TLSDataContainer
();
public
:
virtual
void
*
createDataInstance
()
const
=
0
;
virtual
void
deleteDataInstance
(
void
*
data
)
const
=
0
;
CV_EXPORTS
void
*
getData
()
const
;
void
*
getData
()
const
;
};
template
<
typename
T
>
...
...
modules/core/src/ocl.cpp
View file @
f2befa01
...
...
@@ -1338,7 +1338,7 @@ bool haveOpenCL()
bool
useOpenCL
()
{
TLSData
*
data
=
TLSData
::
get
();
CoreTLSData
*
data
=
coreTlsData
.
get
();
if
(
data
->
useOpenCL
<
0
)
data
->
useOpenCL
=
(
int
)
haveOpenCL
();
return
data
->
useOpenCL
>
0
;
...
...
@@ -1348,7 +1348,7 @@ void setUseOpenCL(bool flag)
{
if
(
haveOpenCL
()
)
{
TLSData
*
data
=
TLSData
::
get
();
CoreTLSData
*
data
=
coreTlsData
.
get
();
data
->
useOpenCL
=
flag
?
1
:
0
;
}
}
...
...
@@ -1765,7 +1765,7 @@ size_t Device::profilingTimerResolution() const
const
Device
&
Device
::
getDefault
()
{
const
Context2
&
ctx
=
Context2
::
getDefault
();
int
idx
=
TLSData
::
get
()
->
device
;
int
idx
=
coreTlsData
.
get
()
->
device
;
return
ctx
.
device
(
idx
);
}
...
...
@@ -2059,7 +2059,7 @@ void* Queue::ptr() const
Queue
&
Queue
::
getDefault
()
{
Queue
&
q
=
TLSData
::
get
()
->
oclQueue
;
Queue
&
q
=
coreTlsData
.
get
()
->
oclQueue
;
if
(
!
q
.
p
&&
haveOpenCL
()
)
q
.
create
(
Context2
::
getDefault
());
return
q
;
...
...
modules/core/src/precomp.hpp
View file @
f2befa01
...
...
@@ -106,7 +106,6 @@ extern const uchar g_Saturate8u[];
#if defined WIN32 || defined _WIN32
void
deleteThreadAllocData
();
void
deleteThreadData
();
#endif
template
<
typename
T1
,
typename
T2
=
T1
,
typename
T3
=
T1
>
struct
OpAdd
...
...
@@ -233,17 +232,19 @@ inline bool checkScalar(InputArray sc, int atype, int sckind, int akind)
void
convertAndUnrollScalar
(
const
Mat
&
sc
,
int
buftype
,
uchar
*
scbuf
,
size_t
blocksize
);
struct
TLSData
struct
Core
TLSData
{
TLSData
();
CoreTLSData
()
:
device
(
0
),
useOpenCL
(
-
1
)
{}
RNG
rng
;
int
device
;
ocl
::
Queue
oclQueue
;
int
useOpenCL
;
// 1 - use, 0 - do not use, -1 - auto/not initialized
static
TLSData
*
get
();
};
extern
TLSData
<
CoreTLSData
>
coreTlsData
;
#if defined(BUILD_SHARED_LIBS)
#if defined WIN32 || defined _WIN32 || defined WINCE
#define CL_RUNTIME_EXPORT __declspec(dllexport)
...
...
modules/core/src/rand.cpp
View file @
f2befa01
...
...
@@ -731,7 +731,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
cv
::
RNG
&
cv
::
theRNG
()
{
return
TLSData
::
get
()
->
rng
;
return
coreTlsData
.
get
()
->
rng
;
}
void
cv
::
randu
(
InputOutputArray
dst
,
InputArray
low
,
InputArray
high
)
...
...
modules/core/src/system.cpp
View file @
f2befa01
...
...
@@ -911,12 +911,13 @@ public:
BOOL
WINAPI
DllMain
(
HINSTANCE
,
DWORD
fdwReason
,
LPVOID
);
BOOL
WINAPI
DllMain
(
HINSTANCE
,
DWORD
fdwReason
,
LPVOID
)
BOOL
WINAPI
DllMain
(
HINSTANCE
,
DWORD
fdwReason
,
LPVOID
lpReserved
)
{
if
(
fdwReason
==
DLL_THREAD_DETACH
||
fdwReason
==
DLL_PROCESS_DETACH
)
{
if
(
lpReserved
!=
NULL
)
// called after ExitProcess() call
cv
::
__termination
=
true
;
cv
::
deleteThreadAllocData
();
cv
::
deleteThreadRNGData
();
cv
::
deleteThreadData
();
}
return
TRUE
;
...
...
@@ -1038,94 +1039,8 @@ TLSStorage::~TLSStorage()
tlsData_
.
clear
();
}
}
// namespace cv
//////////////////////////////// thread-local storage ////////////////////////////////
namespace
cv
{
TLSData
::
TLSData
()
{
device
=
0
;
useOpenCL
=
-
1
;
}
#ifdef WIN32
#ifdef HAVE_WINRT
// using C++11 thread attribute for local thread data
static
__declspec
(
thread
)
TLSData
*
g_tlsdata
=
NULL
;
static
void
deleteThreadRNGData
()
{
if
(
g_tlsdata
)
delete
g_tlsdata
;
}
TLSData
*
TLSData
::
get
()
{
if
(
!
g_tlsdata
)
{
g_tlsdata
=
new
TLSData
;
}
return
g_tlsdata
;
}
#else
#ifdef WINCE
# define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
#endif
static
DWORD
tlsKey
=
TLS_OUT_OF_INDEXES
;
void
deleteThreadData
()
{
if
(
tlsKey
!=
TLS_OUT_OF_INDEXES
)
delete
(
TLSData
*
)
TlsGetValue
(
tlsKey
);
}
TLSData
<
CoreTLSData
>
coreTlsData
;
TLSData
*
TLSData
::
get
()
{
if
(
tlsKey
==
TLS_OUT_OF_INDEXES
)
{
tlsKey
=
TlsAlloc
();
CV_Assert
(
tlsKey
!=
TLS_OUT_OF_INDEXES
);
}
TLSData
*
d
=
(
TLSData
*
)
TlsGetValue
(
tlsKey
);
if
(
!
d
)
{
d
=
new
TLSData
;
TlsSetValue
(
tlsKey
,
d
);
}
return
d
;
}
#endif //HAVE_WINRT
#else
static
pthread_key_t
tlsKey
=
0
;
static
pthread_once_t
tlsKeyOnce
=
PTHREAD_ONCE_INIT
;
static
void
deleteTLSData
(
void
*
data
)
{
delete
(
TLSData
*
)
data
;
}
static
void
makeKey
()
{
int
errcode
=
pthread_key_create
(
&
tlsKey
,
deleteTLSData
);
CV_Assert
(
errcode
==
0
);
}
TLSData
*
TLSData
::
get
()
{
pthread_once
(
&
tlsKeyOnce
,
makeKey
);
TLSData
*
d
=
(
TLSData
*
)
pthread_getspecific
(
tlsKey
);
if
(
!
d
)
{
d
=
new
TLSData
;
pthread_setspecific
(
tlsKey
,
d
);
}
return
d
;
}
#endif
}
}
// namespace cv
/* End of file. */
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