Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/31/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

CANCEL

OpenMP* Fortran Compiler Directive: Requests cancellation of the innermost enclosing region of the construct specified, and causes the encountering implicit or explicit task to proceed to the end of the canceled construct.

Syntax

!$OMP CANCEL construct-clause [[,] if-clause]

construct-clause

Is one of the following:

if-clause

(Optional) IF (scalar-logical-expression)

The binding thread set of a CANCEL construct is the current team. The cancel region binds to the innermost enclosing construct of the type corresponding to the construct-clause specified in the directive specifying the innermost DO, PARALLEL, SECTIONS, or TASKGROUP construct.

This is a stand-alone directive, so there are some restrictions on its placement within a program:

  • It can only be placed at a point where a Fortran executable statement is allowed.

  • It cannot be used as the action statement in an IF statement, or as the executable statement following a label, if the label is referenced in the program.

If construct-clause is TASKGROUP, the CANCEL construct must be closely nested inside a TASK construct. Otherwise, the CANCEL construct must be closely nested inside an OpenMP construct that matches the type specified in construct-clause.

The CANCEL construct requests cancellation of the innermost enclosing region of the type specified. The request is checked at a cancellation point. When a cancellation is observed, execution jumps to the end of the canceled region.

Cancellation points are implied at certain locations, as follows:

  • Implicit barriers

  • BARRIER regions

  • CANCEL regions

  • CANCELLATION POINT regions

When cancellation of tasks occurs with a CANCEL TASKGROUP construct, the encountering task jumps to the end of its task region and is considered complete. Any task that belongs to the innermost enclosing taskgroup and has already begun execution, must run to completion or run until a cancellation point is reached. Any task that belongs to the innermost enclosing taskgroup and has not begun execution may be discarded and 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 DO or SECTIONS region, each thread of the binding thread set resumes execution at the end of the canceled region but no task cancellation occurs.

A DO construct that is being canceled must not have a NOWAIT or an ORDERED clause. A SECTIONS construct that is being canceled must not have a NOWAIT clause.

The behavior for concurrent cancellation of a region and a region nested within it is unspecified.

NOTE:

You must release locks and similar data structures that can cause a deadlock when a CANCEL construct is encountered; 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.

All private objects or subobjects with the ALLOCATABLE attribute that are allocated inside the canceled construct are deallocated.