Next: Reduction
Up: OpenMPLab
Previous: Data Parallelism Example
- Copy omp_workshare2.c from section 3 of https://computing.llnl.gov/tutorials/openMP/exercise.html.
- Review the source code to understand the control parallelism introduced by the section directive.
- Compile it and run it several times with 4 threads and observe any differences
in output.
- Reflect: Because there are only two sections, you should notice
that some threads do not do any work. You may/may not notice that
the threads doing work can vary. For example, the first time thread
0 and thread 1 may do the work, and the next time it may be thread 0
and thread 3. It is even possible for one thread to do all of the
work. Note that the result computed is always the same, but
which threads do the work is non-deterministic.
Phil Trinder
2013-02-28