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
a482dcce
Commit
a482dcce
authored
Jun 11, 2015
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix support for pthreads parallel_for
parent
1f983ec3
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
24 deletions
+46
-24
CMakeLists.txt
CMakeLists.txt
+22
-7
OpenCVFindLibsPerf.cmake
cmake/OpenCVFindLibsPerf.cmake
+9
-5
cvconfig.h.in
cmake/templates/cvconfig.h.in
+6
-0
parallel.cpp
modules/core/src/parallel.cpp
+8
-5
parallel_pthreads.cpp
modules/core/src/parallel_pthreads.cpp
+1
-1
precomp.hpp
modules/core/src/precomp.hpp
+0
-6
No files found.
CMakeLists.txt
View file @
a482dcce
...
...
@@ -188,7 +188,7 @@ OCV_OPTION(WITH_QUICKTIME "Use QuickTime for Video I/O insted of QTKit" OFF
OCV_OPTION
(
WITH_TBB
"Include Intel TBB support"
OFF
IF
(
NOT IOS AND NOT WINRT
)
)
OCV_OPTION
(
WITH_OPENMP
"Include OpenMP support"
OFF
)
OCV_OPTION
(
WITH_CSTRIPES
"Include C= support"
OFF
IF
(
WIN32 AND NOT WINRT
)
)
OCV_OPTION
(
WITH_PTHREADS_PF
"Use pthreads-based parallel_for"
O
FF
IF
(
NOT WIN32
)
)
OCV_OPTION
(
WITH_PTHREADS_PF
"Use pthreads-based parallel_for"
O
N
IF
(
NOT WIN32
)
)
OCV_OPTION
(
WITH_TIFF
"Include TIFF support"
ON
IF
(
NOT IOS
)
)
OCV_OPTION
(
WITH_UNICAP
"Include Unicap support (GPL)"
OFF
IF
(
UNIX AND NOT APPLE AND NOT ANDROID
)
)
OCV_OPTION
(
WITH_V4L
"Include Video 4 Linux support"
ON
IF
(
UNIX AND NOT ANDROID
)
)
...
...
@@ -1026,6 +1026,27 @@ if(DEFINED WITH_GPHOTO2)
endif
(
DEFINED WITH_GPHOTO2
)
# Order is similar to CV_PARALLEL_FRAMEWORK in core/src/parallel.cpp
ocv_clear_vars
(
CV_PARALLEL_FRAMEWORK
)
if
(
HAVE_TBB
)
set
(
CV_PARALLEL_FRAMEWORK
"TBB (ver
${
TBB_VERSION_MAJOR
}
.
${
TBB_VERSION_MINOR
}
interface
${
TBB_INTERFACE_VERSION
}
)"
)
elseif
(
HAVE_CSTRIPES
)
set
(
CV_PARALLEL_FRAMEWORK
"C="
)
elseif
(
HAVE_OPENMP
)
set
(
CV_PARALLEL_FRAMEWORK
"OpenMP"
)
elseif
(
HAVE_GCD
)
set
(
CV_PARALLEL_FRAMEWORK
"GCD"
)
elseif
(
WINRT OR HAVE_CONCURRENCY
)
set
(
CV_PARALLEL_FRAMEWORK
"Concurrency"
)
elseif
(
HAVE_PTHREADS_PF
)
set
(
CV_PARALLEL_FRAMEWORK
"pthreads"
)
else
()
set
(
CV_PARALLEL_FRAMEWORK
"none"
)
endif
()
status
(
""
)
status
(
" Parallel framework:"
TRUE THEN
"
${
CV_PARALLEL_FRAMEWORK
}
"
ELSE NO
)
# ========================== Other third-party libraries ==========================
status
(
""
)
status
(
" Other third-party libraries:"
)
...
...
@@ -1045,12 +1066,6 @@ status(" Use IPP Async:" HAVE_IPP_A THEN "YES" ELSE NO)
endif
(
DEFINED WITH_IPP_A
)
status
(
" Use Eigen:"
HAVE_EIGEN THEN
"YES (ver
${
EIGEN_WORLD_VERSION
}
.
${
EIGEN_MAJOR_VERSION
}
.
${
EIGEN_MINOR_VERSION
}
)"
ELSE NO
)
status
(
" Use TBB:"
HAVE_TBB THEN
"YES (ver
${
TBB_VERSION_MAJOR
}
.
${
TBB_VERSION_MINOR
}
interface
${
TBB_INTERFACE_VERSION
}
)"
ELSE NO
)
status
(
" Use OpenMP:"
HAVE_OPENMP THEN YES ELSE NO
)
status
(
" Use GCD"
HAVE_GCD THEN YES ELSE NO
)
status
(
" Use Concurrency"
HAVE_CONCURRENCY THEN YES ELSE NO
)
status
(
" Use C=:"
HAVE_CSTRIPES THEN YES ELSE NO
)
status
(
" Use pthreads for parallel for:"
HAVE_PTHREADS_PF THEN YES ELSE NO
)
status
(
" Use Cuda:"
HAVE_CUDA THEN
"YES (ver
${
CUDA_VERSION_STRING
}
)"
ELSE NO
)
status
(
" Use OpenCL:"
HAVE_OPENCL THEN YES ELSE NO
)
...
...
cmake/OpenCVFindLibsPerf.cmake
View file @
a482dcce
...
...
@@ -120,12 +120,16 @@ if(WITH_OPENMP)
set
(
HAVE_OPENMP
"
${
OPENMP_FOUND
}
"
)
endif
()
if
(
UNIX OR ANDROID
)
if
(
NOT APPLE AND NOT HAVE_TBB AND NOT HAVE_OPENMP
)
set
(
HAVE_PTHREADS_PF 1
)
else
(
)
set
(
HAVE_PTHREADS_PF 0
)
if
(
NOT MSVC AND NOT DEFINED HAVE_PTHREADS
)
set
(
_fname
"
${
CMAKE_BINARY_DIR
}${
CMAKE_FILES_DIRECTORY
}
/CMakeTmp/pthread_test.cpp"
)
file
(
WRITE
"
${
_fname
}
"
"#include <pthread.h>
\n
int main() { (void)pthread_self(); return 0; }
\n
"
)
try_compile
(
HAVE_PTHREADS
"
${
CMAKE_BINARY_DIR
}
"
"
${
_fname
}
"
)
file
(
REMOVE
"
${
_fname
}
"
)
endif
()
ocv_clear_vars
(
HAVE_PTHREADS_PF
)
if
(
WITH_PTHREADS_PF
)
set
(
HAVE_PTHREADS_PF
${
HAVE_PTHREADS
}
)
else
()
set
(
HAVE_PTHREADS_PF 0
)
endif
()
cmake/templates/cvconfig.h.in
View file @
a482dcce
...
...
@@ -139,6 +139,12 @@
/* PNG codec */
#cmakedefine HAVE_PNG
/* Posix threads (pthreads) */
#cmakedefine HAVE_PTHREADS
/* parallel_for with pthreads */
#cmakedefine HAVE_PTHREADS_PF
/* Qt support */
#cmakedefine HAVE_QT
...
...
modules/core/src/parallel.cpp
View file @
a482dcce
...
...
@@ -80,6 +80,7 @@
4. HAVE_GCD - system wide, used automatically (APPLE only)
5. WINRT - system wide, used automatically (Windows RT only)
6. HAVE_CONCURRENCY - part of runtime, used automatically (Windows only - MSVS 10, MSVS 11)
7. HAVE_PTHREADS_PF - pthreads if available
*/
#if defined HAVE_TBB
...
...
@@ -125,14 +126,14 @@
# define CV_PARALLEL_FRAMEWORK "winrt-concurrency"
#elif defined HAVE_CONCURRENCY
# define CV_PARALLEL_FRAMEWORK "ms-concurrency"
#elif defined HAVE_PTHREADS
#elif defined HAVE_PTHREADS
_PF
# define CV_PARALLEL_FRAMEWORK "pthreads"
#endif
namespace
cv
{
ParallelLoopBody
::~
ParallelLoopBody
()
{}
#if
defined HAVE_PTHREADS && HAVE_PTHREADS
#if
def HAVE_PTHREADS_PF
void
parallel_for_pthreads
(
const
cv
::
Range
&
range
,
const
cv
::
ParallelLoopBody
&
body
,
double
nstripes
);
size_t
parallel_pthreads_get_threads_num
();
void
parallel_pthreads_set_threads_num
(
int
num
);
...
...
@@ -306,7 +307,7 @@ void cv::parallel_for_(const cv::Range& range, const cv::ParallelLoopBody& body,
Concurrency
::
CurrentScheduler
::
Detach
();
}
#elif defined HAVE_PTHREADS
#elif defined HAVE_PTHREADS
_PF
parallel_for_pthreads
(
range
,
body
,
nstripes
);
...
...
@@ -365,7 +366,7 @@ int cv::getNumThreads(void)
?
Concurrency
::
CurrentScheduler
::
Get
()
->
GetNumberOfVirtualProcessors
()
:
pplScheduler
->
GetNumberOfVirtualProcessors
());
#elif defined HAVE_PTHREADS
#elif defined HAVE_PTHREADS
_PF
return
parallel_pthreads_get_threads_num
();
...
...
@@ -426,7 +427,7 @@ void cv::setNumThreads( int threads )
Concurrency
::
MaxConcurrency
,
threads
-
1
));
}
#elif defined HAVE_PTHREADS
#elif defined HAVE_PTHREADS
_PF
parallel_pthreads_set_threads_num
(
threads
);
...
...
@@ -452,6 +453,8 @@ int cv::getThreadNum(void)
return
0
;
#elif defined HAVE_CONCURRENCY
return
std
::
max
(
0
,
(
int
)
Concurrency
::
Context
::
VirtualProcessorId
());
// zero for master thread, unique number for others but not necessary 1,2,3,...
#elif defined HAVE_PTHREADS_PF
return
(
int
)(
size_t
)(
void
*
)
pthread_self
();
// no zero-based indexing
#else
return
0
;
#endif
...
...
modules/core/src/parallel_pthreads.cpp
View file @
a482dcce
...
...
@@ -42,7 +42,7 @@
#include "precomp.hpp"
#if
defined HAVE_PTHREADS && HAVE_PTHREADS
#if
def HAVE_PTHREADS_PF
#include <algorithm>
#include <pthread.h>
...
...
modules/core/src/precomp.hpp
View file @
a482dcce
...
...
@@ -292,12 +292,6 @@ TLSData<CoreTLSData>& getCoreTlsData();
#define CL_RUNTIME_EXPORT
#endif
#ifndef HAVE_PTHREADS
#if !(defined WIN32 || defined _WIN32 || defined WINCE || defined HAVE_WINRT)
#define HAVE_PTHREADS 1
#endif
#endif
extern
bool
__termination
;
// skip some cleanups, because process is terminating
// (for example, if ExitProcess() was already called)
...
...
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