Intel® C++ Compiler 16.0 User and Reference Guide
Requests cancellation of the innermost enclosing region of the type specified, and causes the encountering task to proceed to the end of the canceled construct.
#pragma omp cancel [construct-clause[if(expr)] |
structured-block
construct-clause |
Is one of: parallel, sections, for, taskgroup |
if (expression) |
Specifies a conditional statement: The expression is a scalar logical expression that evaluates to TRUE or FALSE. If expression evaluates to false, the CANCEL construct does not request cancellation. |
The cancel construct requests cancellation of the innermost enclosing region of the type specified and causes the encountering implicit and explicit task to proceed to the end of the canceled construct.
Cancellation points are implied at certain locations, as follows:
Implicit barriers
BARRIER regions
CANCEL regions
CANCELLATION POINT regions
When a thread reaches one of the above cancellation points and if the cancellation point is active, the thread immediately checks for cancellation and performs the cancellation if observed.
When cancellation of tasks is requested through the CANCEL construct, the innermost enclosing TASKGROUP will be canceled. Tasks encountering the CANCEL TASKGROUP construct jump to the end of its TASK region. Any task that belongs to the innermost enclosing TASKGROUP and has already begun execution must run to completion or until a cancellation point is reached. Upon reaching a cancellation point, if a cancellation request has been observed, the task must jump to the end of its TASK region and is considered completed. Any TASK that belongs to the innermost enclosing TASKGROUP and has not begun execution may be discarded, in which case it is considered completed.
When cancellation occurs for a PARALLEL region, each thread of the binding thread set resumes execution at the end of the canceled region and any tasks that have been created by a task construct and their descendants are canceled according to the above taskgroup cancellation semantics.
When cancellation occurs for a FOR or SECTIONS region, each thread of the binding thread set resumes execution at the end of the canceled region but no task cancellation occurs.
The expression is a scalar logical expression that evaluates to true or false. If the expression evaluates to false, the CANCEL construct does not request cancellation.
Restrictions
The behavior for concurrent cancellation of a region and a region nested within it is unspecified.
You must release locks and similar data structures that can cause a deadlock when a CANCEL construct is encountered and blocked threads cannot be canceled.
If the canceled construct contains a REDUCTION or LASTPRIVATE clause, the final value of the REDUCTION or LASTPRIVATE variable is undefined.
A SECTIONS construct that is being canceled must not have a NOWAIT or an ORDERED clause.
A construct that is being canceled must not have a NOWAIT clause.