Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
e79c184b
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e79c184b
编写于
6月 16, 2015
作者:
V
Vadim Pisarevsky
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4116 from alalek:fix-pthread-pf
上级
424c2bdd
a482dcce
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
52 addition
and
28 deletion
+52
-28
CMakeLists.txt
CMakeLists.txt
+22
-7
cmake/OpenCVFindLibsPerf.cmake
cmake/OpenCVFindLibsPerf.cmake
+9
-5
cmake/templates/cvconfig.h.in
cmake/templates/cvconfig.h.in
+6
-0
modules/core/src/parallel.cpp
modules/core/src/parallel.cpp
+14
-9
modules/core/src/parallel_pthreads.cpp
modules/core/src/parallel_pthreads.cpp
+1
-1
modules/core/src/precomp.hpp
modules/core/src/precomp.hpp
+0
-6
未找到文件。
CMakeLists.txt
浏览文件 @
e79c184b
...
@@ -188,7 +188,7 @@ OCV_OPTION(WITH_QUICKTIME "Use QuickTime for Video I/O insted of QTKit" OFF
...
@@ -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_TBB
"Include Intel TBB support"
OFF
IF
(
NOT IOS AND NOT WINRT
)
)
OCV_OPTION
(
WITH_OPENMP
"Include OpenMP support"
OFF
)
OCV_OPTION
(
WITH_OPENMP
"Include OpenMP support"
OFF
)
OCV_OPTION
(
WITH_CSTRIPES
"Include C= support"
OFF
IF
(
WIN32 AND NOT WINRT
)
)
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_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_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
)
)
OCV_OPTION
(
WITH_V4L
"Include Video 4 Linux support"
ON
IF
(
UNIX AND NOT ANDROID
)
)
...
@@ -1026,6 +1026,27 @@ if(DEFINED WITH_GPHOTO2)
...
@@ -1026,6 +1026,27 @@ if(DEFINED WITH_GPHOTO2)
endif
(
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 ==========================
# ========================== Other third-party libraries ==========================
status
(
""
)
status
(
""
)
status
(
" Other third-party libraries:"
)
status
(
" Other third-party libraries:"
)
...
@@ -1045,12 +1066,6 @@ status(" Use IPP Async:" HAVE_IPP_A THEN "YES" ELSE NO)
...
@@ -1045,12 +1066,6 @@ status(" Use IPP Async:" HAVE_IPP_A THEN "YES" ELSE NO)
endif
(
DEFINED WITH_IPP_A
)
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 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 Cuda:"
HAVE_CUDA THEN
"YES (ver
${
CUDA_VERSION_STRING
}
)"
ELSE NO
)
status
(
" Use OpenCL:"
HAVE_OPENCL THEN YES ELSE NO
)
status
(
" Use OpenCL:"
HAVE_OPENCL THEN YES ELSE NO
)
...
...
cmake/OpenCVFindLibsPerf.cmake
浏览文件 @
e79c184b
...
@@ -120,12 +120,16 @@ if(WITH_OPENMP)
...
@@ -120,12 +120,16 @@ if(WITH_OPENMP)
set
(
HAVE_OPENMP
"
${
OPENMP_FOUND
}
"
)
set
(
HAVE_OPENMP
"
${
OPENMP_FOUND
}
"
)
endif
()
endif
()
if
(
UNIX OR ANDROID
)
if
(
NOT MSVC AND NOT DEFINED HAVE_PTHREADS
)
if
(
NOT APPLE AND NOT HAVE_TBB AND NOT HAVE_OPENMP
)
set
(
_fname
"
${
CMAKE_BINARY_DIR
}${
CMAKE_FILES_DIRECTORY
}
/CMakeTmp/pthread_test.cpp"
)
set
(
HAVE_PTHREADS_PF 1
)
file
(
WRITE
"
${
_fname
}
"
"#include <pthread.h>
\n
int main() { (void)pthread_self(); return 0; }
\n
"
)
else
(
)
try_compile
(
HAVE_PTHREADS
"
${
CMAKE_BINARY_DIR
}
"
"
${
_fname
}
"
)
set
(
HAVE_PTHREADS_PF 0
)
file
(
REMOVE
"
${
_fname
}
"
)
endif
()
endif
()
ocv_clear_vars
(
HAVE_PTHREADS_PF
)
if
(
WITH_PTHREADS_PF
)
set
(
HAVE_PTHREADS_PF
${
HAVE_PTHREADS
}
)
else
()
else
()
set
(
HAVE_PTHREADS_PF 0
)
set
(
HAVE_PTHREADS_PF 0
)
endif
()
endif
()
cmake/templates/cvconfig.h.in
浏览文件 @
e79c184b
...
@@ -139,6 +139,12 @@
...
@@ -139,6 +139,12 @@
/* PNG codec */
/* PNG codec */
#cmakedefine HAVE_PNG
#cmakedefine HAVE_PNG
/* Posix threads (pthreads) */
#cmakedefine HAVE_PTHREADS
/* parallel_for with pthreads */
#cmakedefine HAVE_PTHREADS_PF
/* Qt support */
/* Qt support */
#cmakedefine HAVE_QT
#cmakedefine HAVE_QT
...
...
modules/core/src/parallel.cpp
浏览文件 @
e79c184b
...
@@ -80,6 +80,7 @@
...
@@ -80,6 +80,7 @@
4. HAVE_GCD - system wide, used automatically (APPLE only)
4. HAVE_GCD - system wide, used automatically (APPLE only)
5. WINRT - system wide, used automatically (Windows RT only)
5. WINRT - system wide, used automatically (Windows RT only)
6. HAVE_CONCURRENCY - part of runtime, used automatically (Windows only - MSVS 10, MSVS 11)
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
#if defined HAVE_TBB
...
@@ -125,15 +126,21 @@
...
@@ -125,15 +126,21 @@
# define CV_PARALLEL_FRAMEWORK "winrt-concurrency"
# define CV_PARALLEL_FRAMEWORK "winrt-concurrency"
#elif defined HAVE_CONCURRENCY
#elif defined HAVE_CONCURRENCY
# define CV_PARALLEL_FRAMEWORK "ms-concurrency"
# define CV_PARALLEL_FRAMEWORK "ms-concurrency"
#elif defined HAVE_PTHREADS
#elif defined HAVE_PTHREADS
_PF
# define CV_PARALLEL_FRAMEWORK "pthreads"
# define CV_PARALLEL_FRAMEWORK "pthreads"
#endif
#endif
namespace
cv
namespace
cv
{
{
ParallelLoopBody
::~
ParallelLoopBody
()
{}
ParallelLoopBody
::~
ParallelLoopBody
()
{}
#ifdef 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
);
#endif
}
}
namespace
namespace
{
{
#ifdef CV_PARALLEL_FRAMEWORK
#ifdef CV_PARALLEL_FRAMEWORK
...
@@ -300,8 +307,8 @@ void cv::parallel_for_(const cv::Range& range, const cv::ParallelLoopBody& body,
...
@@ -300,8 +307,8 @@ void cv::parallel_for_(const cv::Range& range, const cv::ParallelLoopBody& body,
Concurrency
::
CurrentScheduler
::
Detach
();
Concurrency
::
CurrentScheduler
::
Detach
();
}
}
#elif defined HAVE_PTHREADS
#elif defined HAVE_PTHREADS
_PF
void
parallel_for_pthreads
(
const
Range
&
range
,
const
ParallelLoopBody
&
body
,
double
nstripes
);
parallel_for_pthreads
(
range
,
body
,
nstripes
);
parallel_for_pthreads
(
range
,
body
,
nstripes
);
#else
#else
...
@@ -359,9 +366,7 @@ int cv::getNumThreads(void)
...
@@ -359,9 +366,7 @@ int cv::getNumThreads(void)
?
Concurrency
::
CurrentScheduler
::
Get
()
->
GetNumberOfVirtualProcessors
()
?
Concurrency
::
CurrentScheduler
::
Get
()
->
GetNumberOfVirtualProcessors
()
:
pplScheduler
->
GetNumberOfVirtualProcessors
());
:
pplScheduler
->
GetNumberOfVirtualProcessors
());
#elif defined HAVE_PTHREADS
#elif defined HAVE_PTHREADS_PF
size_t
parallel_pthreads_get_threads_num
();
return
parallel_pthreads_get_threads_num
();
return
parallel_pthreads_get_threads_num
();
...
@@ -422,9 +427,7 @@ void cv::setNumThreads( int threads )
...
@@ -422,9 +427,7 @@ void cv::setNumThreads( int threads )
Concurrency
::
MaxConcurrency
,
threads
-
1
));
Concurrency
::
MaxConcurrency
,
threads
-
1
));
}
}
#elif defined HAVE_PTHREADS
#elif defined HAVE_PTHREADS_PF
void
parallel_pthreads_set_threads_num
(
int
num
);
parallel_pthreads_set_threads_num
(
threads
);
parallel_pthreads_set_threads_num
(
threads
);
...
@@ -450,6 +453,8 @@ int cv::getThreadNum(void)
...
@@ -450,6 +453,8 @@ int cv::getThreadNum(void)
return
0
;
return
0
;
#elif defined HAVE_CONCURRENCY
#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,...
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
#else
return
0
;
return
0
;
#endif
#endif
...
...
modules/core/src/parallel_pthreads.cpp
浏览文件 @
e79c184b
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
#include "precomp.hpp"
#include "precomp.hpp"
#if
defined HAVE_PTHREADS && HAVE_PTHREADS
#if
def HAVE_PTHREADS_PF
#include <algorithm>
#include <algorithm>
#include <pthread.h>
#include <pthread.h>
...
...
modules/core/src/precomp.hpp
浏览文件 @
e79c184b
...
@@ -292,12 +292,6 @@ TLSData<CoreTLSData>& getCoreTlsData();
...
@@ -292,12 +292,6 @@ TLSData<CoreTLSData>& getCoreTlsData();
#define CL_RUNTIME_EXPORT
#define CL_RUNTIME_EXPORT
#endif
#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
extern
bool
__termination
;
// skip some cleanups, because process is terminating
// (for example, if ExitProcess() was already called)
// (for example, if ExitProcess() was already called)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录