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
0def2dbb
Commit
0def2dbb
authored
Jan 18, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10605 from alalek:ocl_fix_deadlock
parents
1b0ff575
cec70052
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
15 deletions
+78
-15
mat.hpp
modules/core/include/opencv2/core/mat.hpp
+0
-8
mat.inl.hpp
modules/core/include/opencv2/core/mat.inl.hpp
+0
-3
ocl.cpp
modules/core/src/ocl.cpp
+3
-2
umatrix.cpp
modules/core/src/umatrix.cpp
+55
-2
umatrix.hpp
modules/core/src/umatrix.hpp
+20
-0
No files found.
modules/core/include/opencv2/core/mat.hpp
View file @
0def2dbb
...
...
@@ -545,14 +545,6 @@ struct CV_EXPORTS UMatData
};
struct
CV_EXPORTS
UMatDataAutoLock
{
explicit
UMatDataAutoLock
(
UMatData
*
u
);
~
UMatDataAutoLock
();
UMatData
*
u
;
};
struct
CV_EXPORTS
MatSize
{
explicit
MatSize
(
int
*
_p
);
...
...
modules/core/include/opencv2/core/mat.inl.hpp
View file @
0def2dbb
...
...
@@ -3911,9 +3911,6 @@ inline void UMatData::markDeviceCopyObsolete(bool flag)
flags
&=
~
DEVICE_COPY_OBSOLETE
;
}
inline
UMatDataAutoLock
::
UMatDataAutoLock
(
UMatData
*
_u
)
:
u
(
_u
)
{
u
->
lock
();
}
inline
UMatDataAutoLock
::~
UMatDataAutoLock
()
{
u
->
unlock
();
}
//! @endcond
}
//cv
...
...
modules/core/src/ocl.cpp
View file @
0def2dbb
...
...
@@ -123,6 +123,8 @@
#include "opencv2/core/opencl/opencl_svm.hpp"
#endif
#include "umatrix.hpp"
namespace
cv
{
namespace
ocl
{
#define IMPLEMENT_REFCOUNTABLE() \
...
...
@@ -5424,8 +5426,7 @@ public:
srcrawofs
,
new_srcofs
,
new_srcstep
,
dstrawofs
,
new_dstofs
,
new_dststep
);
UMatDataAutoLock
src_autolock
(
src
);
UMatDataAutoLock
dst_autolock
(
dst
);
UMatDataAutoLock
src_autolock
(
src
,
dst
);
if
(
!
src
->
handle
||
(
src
->
data
&&
src
->
hostCopyObsolete
()
<
src
->
deviceCopyObsolete
())
)
{
...
...
modules/core/src/umatrix.cpp
View file @
0def2dbb
...
...
@@ -41,6 +41,7 @@
#include "precomp.hpp"
#include "opencl_kernels_core.hpp"
#include "umatrix.hpp"
///////////////////////////////// UMat implementation ///////////////////////////////
...
...
@@ -127,14 +128,66 @@ UMatData::~UMatData()
}
}
static
size_t
getUMatDataLockIndex
(
const
UMatData
*
u
)
{
size_t
idx
=
((
size_t
)(
void
*
)
u
)
%
UMAT_NLOCKS
;
return
idx
;
}
void
UMatData
::
lock
()
{
umatLocks
[(
size_t
)(
void
*
)
this
%
UMAT_NLOCKS
].
lock
();
size_t
idx
=
getUMatDataLockIndex
(
this
);
//printf("%d lock(%d)\n", cv::utils::getThreadID(), (int)idx);
umatLocks
[
idx
].
lock
();
}
void
UMatData
::
unlock
()
{
umatLocks
[(
size_t
)(
void
*
)
this
%
UMAT_NLOCKS
].
unlock
();
size_t
idx
=
getUMatDataLockIndex
(
this
);
//printf("%d unlock(%d)\n", cv::utils::getThreadID(), (int)idx);
umatLocks
[
idx
].
unlock
();
}
struct
UMatDataAutoLockUsage
{
int
count
;
UMatDataAutoLockUsage
()
:
count
(
0
)
{
}
};
static
TLSData
<
UMatDataAutoLockUsage
>&
getUMatDataAutoLockUsageTLS
()
{
CV_SINGLETON_LAZY_INIT_REF
(
TLSData
<
UMatDataAutoLockUsage
>
,
new
TLSData
<
UMatDataAutoLockUsage
>
());
}
static
int
&
getUMatDataAutoLockUsage
()
{
return
getUMatDataAutoLockUsageTLS
().
get
()
->
count
;
}
UMatDataAutoLock
::
UMatDataAutoLock
(
UMatData
*
u
)
:
u1
(
u
),
u2
(
NULL
)
{
int
&
usage_count
=
getUMatDataAutoLockUsage
();
CV_Assert
(
usage_count
==
0
);
// UMatDataAutoLock can't be used multiple times from the same thread
usage_count
=
1
;
u1
->
lock
();
}
UMatDataAutoLock
::
UMatDataAutoLock
(
UMatData
*
u1_
,
UMatData
*
u2_
)
:
u1
(
u1_
),
u2
(
u2_
)
{
int
&
usage_count
=
getUMatDataAutoLockUsage
();
CV_Assert
(
usage_count
==
0
);
// UMatDataAutoLock can't be used multiple times from the same thread
usage_count
=
1
;
if
(
getUMatDataLockIndex
(
u1
)
>
getUMatDataLockIndex
(
u2
))
{
std
::
swap
(
u1
,
u2
);
}
u1
->
lock
();
u2
->
lock
();
}
UMatDataAutoLock
::~
UMatDataAutoLock
()
{
int
&
usage_count
=
getUMatDataAutoLockUsage
();
CV_Assert
(
usage_count
==
1
);
usage_count
=
0
;
u1
->
unlock
();
if
(
u2
)
u2
->
unlock
();
}
...
...
modules/core/src/umatrix.hpp
0 → 100644
View file @
0def2dbb
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#ifndef OPENCV_CORE_SRC_UMATRIX_HPP
#define OPENCV_CORE_SRC_UMATRIX_HPP
namespace
cv
{
struct
CV_EXPORTS
UMatDataAutoLock
{
explicit
UMatDataAutoLock
(
UMatData
*
u
);
UMatDataAutoLock
(
UMatData
*
u1
,
UMatData
*
u2
);
~
UMatDataAutoLock
();
UMatData
*
u1
;
UMatData
*
u2
;
};
}
#endif // OPENCV_CORE_SRC_UMATRIX_HPP
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