parallelized for_each

General OpenMP discussion

parallelized for_each

Postby philski » Fri Apr 25, 2008 6:45 am

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

Postby lfm » Wed Aug 13, 2008 1:29 am

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
Posts: 135
Joined: Sun Oct 21, 2007 4:58 pm
Location: OpenMP ARB

Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 1 guest