From 0966b2dea9148d93c2077a4fcb24b0322c5b17f2 Mon Sep 17 00:00:00 2001 From: Oded Green Date: Thu, 5 Nov 2015 23:16:30 -0500 Subject: [PATCH] Removed openmp from code --- modules/ximgproc/src/estimated_covariance.cpp | 67 ++++--------------- 1 file changed, 13 insertions(+), 54 deletions(-) diff --git a/modules/ximgproc/src/estimated_covariance.cpp b/modules/ximgproc/src/estimated_covariance.cpp index dff44d995..9c380c9d1 100644 --- a/modules/ximgproc/src/estimated_covariance.cpp +++ b/modules/ximgproc/src/estimated_covariance.cpp @@ -50,11 +50,6 @@ A previous and less efficient version of the algorithm can be found: */ #include "precomp.hpp" -//#include - -#ifdef HAVE_OPENMP - #include -#endif using namespace cv; using namespace std; @@ -101,7 +96,6 @@ private: int nc; int pr; int pc; - int threads; std::vector combinationsTable; }; @@ -110,13 +104,6 @@ private: EstimateCovariance::EstimateCovariance(int pr_, int pc_){ pr=pr_; pc=pc_; - -#ifdef HAVE_OPENMP - threads=omp_get_num_procs(); - omp_set_num_threads(threads); -#else - threads=1; -#endif } EstimateCovariance::~EstimateCovariance(){ @@ -178,47 +165,19 @@ void EstimateCovariance::computeEstimateCovariance(Mat inputData,Mat outputData) void EstimateCovariance::iterateCombinations(Mat inputData,Mat outputData) { - int combsPerCPU = combinationCount()/threads; - int remainder = combinationCount()%threads; - if(remainder>0) - combsPerCPU++; - -#ifdef HAVE_OPENMP - #pragma omp parallel -#endif - { - int idx; - int combs; -#ifdef HAVE_OPENMP - int thread_id= omp_get_thread_num(); -#else - int thread_id=0; -#endif - int startComb; - if (remainder > thread_id){ - combs=combsPerCPU; - startComb=(thread_id)*combsPerCPU; - } - else{ - combs=combsPerCPU-1; - startComb=remainder*combsPerCPU+(thread_id-remainder)*(combsPerCPU-1); - } - - Mat outputVector(pr*pc,1, DataType >::type); - - std::vector finalMatPosR(pr*pc,0); - std::vector finalMatPosC(pr*pc,0); - - for (idx=0; idx >::type); + + std::vector finalMatPosR(pr*pc,0); + std::vector finalMatPosC(pr*pc,0); + int combs=combinationCount(); + for (int idx=0; idx