13.11.2016 Views

OpenMP Application Programming Interface Examples

2fZ58Wr

2fZ58Wr

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1<br />

2<br />

3<br />

1.14 Parallel Random Access Iterator Loop<br />

C++<br />

The following example shows a parallel random access iterator loop.<br />

Example pra_iterator.1.cpp<br />

S-1 #include <br />

S-2 void iterator_example()<br />

S-3 {<br />

S-4 std::vector vec(23);<br />

S-5 std::vector::iterator it;<br />

S-6 #pragma omp parallel for default(none) shared(vec)<br />

S-7 for (it = vec.begin(); it < vec.end(); it++)<br />

S-8 {<br />

S-9 // do work with *it //<br />

S-10 }<br />

S-11 }<br />

C++<br />

CHAPTER 1. PARALLEL EXECUTION 35

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!