Control Parallel Processing with Pragmas (C Only)

Parallel processing operations are controlled by pragma directives in your program source. You can use either IBM or OpenMP parallel processng directives. Each have their own usage characteristics.

IBM Directives OpenMP Directives
Syntax:
#pragma ibm pragma_name_and_args
<countable for|while|do loop>

Pragma directives must appear immediately before the section of code to which they apply. For most parallel processing pragma directives this section of code must be a countable loop, and the compiler will report an error if one is not found.

More than one parallel processing pragma directive can be applied to a countable loop. For example:

#pragma ibm independent_loop
#pragma ibm independent_calls
#pragma ibm schedule(static,5)
<countable for|while|do loop>

Some pragma directives are mutually-exclusive of each other. If mutually-exclusive pragmas are specified for the same loop, the pragma last specified applies to the loop. In the example below, the parallel_loop pragma directive is applied to the loop, and the sequential_loop pragma directive is ignored.

#pragma ibm sequential_loop
#pragma ibm parallel_loop

Other pragmas, if specified repeatedly for a given loop, have an additive effect. For example:

#pragma ibm permutation (a,b)
#pragma ibm permutation (c)

is equivalent to:

#pragma ibm permutation (a,b,c)
Syntax:
#pragma omp pragma_name_and_args
statement_block

Pragma directives generally appear immediately before the section of code to which they apply.

The omp parallel directive is used to define the region of program code to be parallelized. Other OpenMP directives define visibility of data variables in the defined parallel region and how work within that region is shared and synchronized.

For example, the following example defines a parallel region in which iterations of a for loop can run in parallel:

#pragma omp parallel
{
  #pragma omp for 
    for (i=0; i<n; i++)
      ...
}

This example defines a parallel region in which two or more non-iterative sections of program code can run in parallel:

#pragma omp sections
{
  #pragma omp section 
     structured_block_1
           ...
  #pragma omp section 
     structured_block_2
           ...
      ....
}

 



Program Parallelization
Shared and Private Variables in a Parallel Environment
Countable Loops


#pragma Preprocessor Directives for Parallel Processing
smp Compiler Option
info Compiler Option