C++ list

General OpenMP discussion

C++ list

Postby chameleon » Tue Feb 14, 2012 1:42 pm

How can handle the following code with OpenMP?

Code: Select all
list<T> l;
for (list<T>::iterator z = l.begin(); z != l.end(); z++)
   create_a_thread_and_process(*z);
// barrier
chameleon
 
Posts: 8
Joined: Mon Jan 23, 2012 6:37 pm

Re: C++ list

Postby MarkB » Fri Feb 17, 2012 3:16 am

Provided z is a random access iterator, you can use a #pragma omp parallel for directive for this example. However, this will not create a separate thread for each iteration: it will create a fixed number of threads and share out the iterations amongst these threads.
MarkB
 
Posts: 452
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh


Return to Using OpenMP

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 9 guests