#pragma omp single

Purpose

The omp single directive identifies a section of code that must be run by a single available thread.

Syntax

Read syntax diagramSkip visual syntax diagram
                          .-+---+------.   
                          | '-,-'      |   
                          V            |   
>>-#--pragma--omp single----+--------+-+-----------------------><
                            '-clause-'     

Parameters

clause is any of the following:

private (list)
Declares the scope of the data variables in list to be private to each thread. Data variables in list are separated by commas.

A variable in the private clause must not also appear in a copyprivate clause for the same omp single directive.

copyprivate (list)
Broadcasts the values of variables specified in list from one member of the team to other members. This occurs after the execution of the structured block associated with the omp single directive, and before any of the threads leave the barrier at the end of the construct. For all other threads in the team, each variable in the list becomes defined with the value of the corresponding variable in the thread that executed the structured block. Data variables in list are separated by commas. Usage restrictions for this clause are:
  • A variable in the copyprivate clause must not also appear in a private or firstprivate clause for the same omp single directive.
  • If an omp single directive with a copyprivate clause is encountered in the dynamic extent of a parallel region, all variables specified in the copyprivate clause must be private in the enclosing context.
  • Variables specified in copyprivate clause within dynamic extent of a parallel region must be private in the enclosing context.
  • A variable that is specified in the copyprivate clause must have an accessible and unambiguous copy assignment operator.
  • The copyprivate clause must not be used together with the nowait clause.
firstprivate (list)
Declares the scope of the data variables in list to be private to each thread. Each new private object is initialized as if there was an implied declaration within the statement block. Data variables in list are separated by commas.

A variable in the firstprivate clause must not also appear in a copyprivate clause for the same omp single directive.

nowait
Use this clause to avoid the implied barrier at the end of the single directive. Only one nowait clause can appear on a given single directive. The nowait clause must not be used together with the copyprivate clause.

Usage

An implied barrier exists at the end of a parallelized statement block unless the nowait clause is specified.



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us