开发者

OpenMP and STL-style for

I'm trying to parallelize my program with openMP. The program is using STL-iterators heavily. It is said that openMP 3.0 can deal with this:

std::vector<int> N(2*N_max+1);

std::vector&开发者_开发百科lt;int>::const_iterator n,m;
#pragma omp parallel for
for (n=N.begin(); n!=N.end(); ++n){
     //Task to be in parallel
};

But I got the following error:

error: invalid controlling predicate

I'm using gcc 4.5.0, (openMP3 implemented in 4.4.0) and my build string is:

g++  -O0 -g3 -Wall -c -fmessage-length=0 -fopenmp -MMD -MP  


Standard OpenMP doesn't bear with C++ iterators in general. The standard requires iterators to be random access iterators with constant time for random access. It also only permits < and <= or > and >= in test expressions of for loops, but not !=.

If you are using iterators and STL heavily, you might be better off with Thread building blocks.


Unfortunately the OpenMP V3.0 spec didn't include "!=" as part of the legal syntax for a canonical for loop. However, if you have access to a recent Intel compiler they allowed it as an extension.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜