From: Vadim Pisarevsky Date: Wed, 10 Oct 2012 11:36:32 +0000 (+0400) Subject: added C= support; modified threading logic in threshold X-Git-Tag: accepted/2.0/20130307.220821~364^2~70 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e625d86485b405716013e02a15adf4219c2a6e30;p=profile%2Fivi%2Fopencv.git added C= support; modified threading logic in threshold --- diff --git a/CMakeLists.txt b/CMakeLists.txt index f1c6c57..83bea07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,6 +132,7 @@ OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" ON OCV_OPTION(WITH_QT "Build with Qt Backend support" OFF IF (NOT ANDROID AND NOT IOS) ) OCV_OPTION(WITH_QUICKTIME "Use QuickTime for Video I/O insted of QTKit" OFF IF APPLE ) OCV_OPTION(WITH_TBB "Include Intel TBB support" OFF IF (NOT IOS) ) +OCV_OPTION(WITH_CSTRIPES "Include C= support" OFF IF 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 APPLE AND NOT ANDROID) ) @@ -746,6 +747,10 @@ if(DEFINED WITH_TBB) status(" Use TBB:" HAVE_TBB THEN "YES (ver ${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR} interface ${TBB_INTERFACE_VERSION})" ELSE NO) endif(DEFINED WITH_TBB) +if(DEFINED WITH_CSTRIPES) + status(" Use C=:" HAVE_CSTRIPES THEN YES ELSE NO) +endif(DEFINED WITH_CSTRIPES) + if(DEFINED WITH_CUDA) status(" Use Cuda:" HAVE_CUDA THEN "YES (ver ${CUDA_VERSION_STRING})" ELSE NO) endif(DEFINED WITH_CUDA) diff --git a/cmake/OpenCVDetectCStripes.cmake b/cmake/OpenCVDetectCStripes.cmake new file mode 100644 index 0000000..0d5b6af --- /dev/null +++ b/cmake/OpenCVDetectCStripes.cmake @@ -0,0 +1,11 @@ +if(WIN32) + find_path( CSTRIPES_LIB_DIR + NAMES "С=.lib" + DOC "The path to C= lib and dll") + if(CSTRIPES_LIB_DIR) + ocv_include_directories("${CSTRIPES_LIB_DIR}/..") + link_directories("${CSTRIPES_LIB_DIR}") + set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} "С=") + set(HAVE_CSTRIPES 1) + endif() +endif() diff --git a/cmake/OpenCVFindLibsPerf.cmake b/cmake/OpenCVFindLibsPerf.cmake index 30b0ff9..4c12304 100644 --- a/cmake/OpenCVFindLibsPerf.cmake +++ b/cmake/OpenCVFindLibsPerf.cmake @@ -7,6 +7,11 @@ if(WITH_TBB) include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectTBB.cmake") endif(WITH_TBB) +# --- C= --- +if(WITH_CSTRIPES) + include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectCStripes.cmake") +endif(WITH_CSTRIPES) + # --- IPP --- ocv_clear_vars(IPP_FOUND) if(WITH_IPP) diff --git a/cmake/templates/cvconfig.h.cmake b/cmake/templates/cvconfig.h.cmake index fb779c8..efd3c95 100644 --- a/cmake/templates/cvconfig.h.cmake +++ b/cmake/templates/cvconfig.h.cmake @@ -166,6 +166,9 @@ /* Intel Threading Building Blocks */ #cmakedefine HAVE_TBB +/* C= */ +#cmakedefine HAVE_CSTRIPES + /* Eigen Matrix & Linear Algebra Library */ #cmakedefine HAVE_EIGEN diff --git a/modules/core/src/parallel.cpp b/modules/core/src/parallel.cpp index 9618afa..7f6cda9 100644 --- a/modules/core/src/parallel.cpp +++ b/modules/core/src/parallel.cpp @@ -42,7 +42,7 @@ #include "precomp.hpp" -#if !defined HAVE_TBB && !defined HAVE_OPENMP && !defined HAVE_GCD && !defined HAVE_CONCURRENCY +#if !defined HAVE_TBB && !defined HAVE_OPENMP && !defined HAVE_GCD && !defined HAVE_CONCURRENCY && !defined HAVE_CSTRIPES #ifdef __APPLE__ #define HAVE_GCD #elif defined _MSC_VER && _MSC_VER >= 1600 @@ -66,7 +66,10 @@ #else #undef HAVE_TBB #endif // end TBB version -#endif // HAVE_CONCURRENCY +#elif defined HAVE_CSTRIPES + #include "C=.h" + #undef shared +#endif /* HAVE_TBB - using TBB @@ -137,11 +140,22 @@ namespace cv for (int i = range.start; i < range.end; ++i) body(Range(i, i + 1)); -#elif defined (HAVE_GCD) +#elif defined HAVE_GCD dispatch_queue_t concurrent_queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_apply_f(range.end - range.start, concurrent_queue, &const_cast(body), block_function); +#elif defined HAVE_CSTRIPES + + parallel() + { + int offset = range.start; + int len = range.end - offset; + Range r(offset + CPX_RANGE_START(len), offset + CPX_RANGE_END(len)); + body(r); + barrier(); + } + #else body(range); diff --git a/modules/imgproc/src/thresh.cpp b/modules/imgproc/src/thresh.cpp index 06bd02a..c4b25aa 100644 --- a/modules/imgproc/src/thresh.cpp +++ b/modules/imgproc/src/thresh.cpp @@ -730,11 +730,6 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m _dst.create( src.size(), src.type() ); Mat dst = _dst.getMat(); - int nStripes = 1; -#if defined HAVE_TBB && defined ANDROID - nStripes = 4; -#endif - if( src.depth() == CV_8U ) { int ithresh = cvFloor(thresh); @@ -793,8 +788,10 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m ; else CV_Error( CV_StsUnsupportedFormat, "" ); - - parallel_for_(Range(0, nStripes), + + size_t nStripes = (src.total() + (1<<15)) >> 16; + nStripes = MAX(MIN(nStripes, (size_t)4), (size_t)1); + parallel_for_(Range(0, (int)nStripes), ThresholdRunner(src, dst, nStripes, thresh, maxval, type)); return thresh; }