0

Disclamer: as you will see (in my opinion) this question is not related to this or this.

I have this code:

std::vector<Wrapper> localWrappers;
std::vector<float> pixelDistancesNew;
std::vector<float> curSigmas;
//fill the 3 vectors
#pragma omp parallel for collapse(2) schedule(dynamic, 1)
for(int i=0; i<localWrappers.size(); i++)
  for (int r = par.border; r < (localWrappers[i].cur.rows - par.border); r++)
    for (int c = par.border; c < (localWrappers[i].cur.cols - par.border); c++) {
      const float val = localWrappers[i].cur.at<float>(r,c);
      if ( (val > positiveThreshold && (isMax(val, localWrappers[i].cur, r, c) && isMax(val, localWrappers[i].low, r, c) && isMax(val, localWrappers[i].high, r, c))) ||
        (val < negativeThreshold && (isMin(val, localWrappers[i].cur, r, c) && isMin(val, localWrappers[i].low, r, c) && isMin(val, localWrappers[i].high, r, c))) )
        // either positive -> local max. or negative -> local min.
        localizeKeypoint(r, c, curSigmas[i], pixelDistancesNew[i], localWrappers[i]);
    }

And I get this error:

error: parallel loops with collapse must be perfectly nested
    for(int i=0; i<localWrappers.size(); i++)
            ^

Error: the OpenMP "single" pragma must not be enclosed by the "for" pragma

Reading this, I think that the error is given by the fact that we I'm using size(). However, I don't know how could I get const for this or implementing any kind of solution for this problem.

Can someone help me with this?

Community
  • 1
  • 1
justHelloWorld
  • 6,478
  • 8
  • 58
  • 138
  • Pretty sure the problem is in `localWrappers[i].cur.rows` and it's dependency on the outer loop variable. If that is constant for all `i`, then use an expression that doesn't depend on `i`. If it is not, you probably need to collapse the loops manually. – Zulan Apr 17 '17 at 09:27
  • @Zulan well the problem is that that's not constant for all i – justHelloWorld Apr 17 '17 at 09:49
  • @Zulan What do you suggest to solve the problem? – justHelloWorld Apr 17 '17 at 18:38
  • @Zulan could you please give a look at [this](http://stackoverflow.com/questions/43844396/how-should-i-interpreter-these-vtune-results) question? – justHelloWorld May 08 '17 at 09:45

0 Answers0