[Users] OpenMP "for collapse" directives

Erik Schnetter schnetter at cct.lsu.edu
Sun Feb 26 19:43:23 CST 2012


The OpenMP standard 3.0 (released almost four years ago, already
superseded by 3.1) introduced the concept of "collapsed for loop
parallelisation". This looks as follows:

#pragma omp parallel for collapse(3)
for (int k=0; ...)
for (int j=0; ...)
for (int i=0; ...) {
... loop body...

Without the "collapse" directive, only the outermost loop is
parallelised. The "collapse" directive specifies that all three loops
can be parallelised. This can improve performance, in particular if
there are many threads, if the k loop is small, or if the looping
region is a very deformed rectangle.

-erik

-- 
Erik Schnetter <schnetter at cct.lsu.edu>
http://www.perimeterinstitute.ca/personal/eschnetter/


More information about the Users mailing list