2
#pragma omp parallel for reduction(+ : numOfVecs)
for(itc=clus.begin() ; itc!=clus.end() ; itc++)
{
    numOfVecs += (*itc)->getNumOfVecs();

}

I have a couple of codes like the code above where I need iterators in the loop. But I get the error 'invalid controlling predicate'. Is there any way to overcome this?

Thanks in advance


By the way I'm using the latest versions of code::blocks and mingw. I'm new to this but I think they support openmp3.0 by default after -fopenmp. The iterator I'm using is list iterator.

serkank
  • 79
  • 1
  • 7
  • 2
    The problem is that the current OpenMP specification doesn't allow the operator "!=". The Intel compiler currently does allow "!=", so there is an example that this can be implemented. In a future OpenMP spec, it will most likely be changed. Until then you are going to be limited to <, <=, >, and >= as the relational operators you can use. – ejd Jun 08 '11 at 01:07

1 Answers1

2

std::list<T>::iterator is a bidirectional iterator. Afaik, openmp3 parallel for loop works with random access iterators only (and no !=, as ejd mentioned). Maybe you can use a std::vector instead.

hansmaad
  • 18,417
  • 9
  • 53
  • 94