Page 1 of 1

parallelized for_each

PostPosted: Fri Apr 25, 2008 6:45 am
by philski
Good Morning,

I wrote a parallelized version of for_each in c++. My problem is, it works successfully under MSVC and gcc compliers, but for some reason the code fails using an Intel compiler.

template<class T, class Function>
Function parallel_for_each(std::vector< T> & obj, Function f)
int size = obj.size();
#pragma omp parallel for firstprivate(f) shared(obj)
for (int i = 0; i < size; i++)
return f;

My understanding is that the firstprivate directive will initialize a copy of f that is identical to the copy of f I throw at it for each thread. However, what is happening is that some of the values which are initialized in the constructor do not get initialized in the other threads. Is there some other directive I am supposed to use?

Again, the code works fine under MSVC (2008 edition) and gcc (4.0). Fails under Intel 10.1 compiler.



Re: parallelized for_each

PostPosted: Wed Aug 13, 2008 1:29 am
by lfm
This is a bug in the Intel compiler. If you have a support arrangement with Intel then you should report it. We have reproduced it with a similar test case and will file it as a bug internally. If you have a more complete example we'd appreciate that, and if you would like to provide me with some customer information (probably by private message, then I can give you my Intel e-mail address) then I can add it to the bug report.

Sorry for the trouble.

-- Larry