Parallel and Multi-Core Computing with C/C++

1 Posts tagged with the memory_model tag
0

This was one of the question asked at SC 08. I will try to answer that here. I will start and add more as I move through the various topics.

OpenMP 3.0 had better support for C++ in the following areas:

  • Parallelization of RandomAccess Iterator loops with strict canonical operators
  • Threadprivatization of static class members
  • Unsigned loop control variable support
  • Fully specify constructor call requirement in private/first/lastprivate/threadprivate
  • better match with the C++0x memory model

For-Worksharing with Iterator loops:

We specifically enabled C++ RandomAccess iterators and C pointeres to be parallelized with explicit directives.

#include <vector>
void iterator_example()
{
   std::vector<int> vec(23);
   std::vector<int>::iterator it;
   #pragma omp parallel for default(none) shared(vec)
   for (it = vec.begin(); it < vec.end(); it++)
   {
   // do work with *it //
   }
}

I will follow up with more examples.

0 Comments Permalink
Bottom Banner