collapse

Purpose

Specifying the collapse clause allows you to parallelize multiple loops in a nest without introducing nested parallelism. This clause is used with the for and parallel for pragmas.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-COLLAPSE--(--n--)-------------------------------------------><

Rules

Ordered construct
During execution of an iteration of a loop or a loop nest within a loop region, the executing thread must not execute more than one ordered region which binds to the same loop region. As a consequence, if multiple loops are associated to the loop construct by a collapse clause, the ordered construct has to be located inside all associated loops.
Lastprivate clause
When a lastprivate clause appears on the pragma that identifies a work-sharing construct, the value of each new list item from the sequentially last iteration of the associated loops, is assigned to the original list item even if a collapse clause is associated with the loop
Other SMP and performance pragmas
stream_unroll,unroll,unrollandfuse,nounrollandfuse pragmas cannot be used for any of the loops associated with the collapse clause loop nest.