- Can be any of the following:
- always [assert]
- Overrides compiler heuristics that estimate whether parallelizing a loop would increase performance. Using this clause on a loop that the compiler finds to be parallelizable tells the compiler to parallelize the loop even if doing so might not improve performance.Ifassertis added, the compiler will generate an error-level assertion test to display a message saying that the compiler efficiency heuristics indicate that the loop cannot be vectorized.
- firstprivate(var[ :expr] ... )text
- Provides a superset of the functionality provided by theprivateclause. Variables that appear in afirstprivatelist are subject toprivateclause semantics. In addition, its initial value is broadcast to all private instances upon entering the parallel loop.
- lastprivate(var[ :expr] ... )
- Provides a superset of the functionality provided by theprivateclause. Variables that appear in alastprivatelist are subject to private clause semantics. In addition, when the parallel region is exited, each variable has the value that results from the sequentially last iteration of the loop up exiting the parallel loop.
- Parallelizes the loop acrossnthreads, wherenis an integer.
- private(var[ :expr] ...)
- Specifies a list of scalar and array variables (var) to privatize. An array or pointer variable can take an optional argument (expr) which is an int32 or int64 expression denoting the number of array elements to privatize.
- Like theprivateclause, both thefirstprivate, and thelastprivateclauses specify a list of scalar and array variables (var) to privatize. An array or pointer variable can take an optional argument (expr) which is an int32 or int64 expression denoting the number of array elements to privatize.The samevaris not allowed to appear in both theprivateand thelastprivateclauses for the same loop.The samevaris not allowed to appear in both theprivateand thefirstprivateclauses for the same loop.Whenexpris absent, therules onrules to be observed are as follows:varare the same as with OpenMP. The
Whenexpris present, the same rules apply, butvarmust be an array or a pointer variable.
- varmust not be part of another variable (as an array or structure element)
- varmust not have aconst-qualified type unless it is of class type with a mutable member
- varmust not have an incomplete type or a reference type
- ifvaris of class type (or array thereof), then it requires an accessible, unambiguous default constructor for the class type. Furthermore, if thisvaris in alastprivateclause, then it also requires an accessible, unambiguous copy assignment operator for the class type.
- Ifis an array, then only its firstvarexprelements are privatized. Withoutexpr, the entire array is privatized.
- Ifvaris a pointer, then the firstexprelements are privatized (element size given by the pointer’s target type). Withoutexpr, only the pointer variable itself is privatized.
- Program behavior is undefined ifexprevaluates to a non-positive value, or if it exceeds the array size.
Example: Using the