Intel® C++ Compiler 16.0 User and Reference Guide

omp cancel

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.

Syntax

#pragma omp cancel [construct-clause[if(expr)]

structured-block

Arguments

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.

Description

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:

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

See Also