Parallelizing your programs

Note: This topic does not apply to the Clang-based front end of IBM® XL C/C++ for AIX®, which is invoked by xlclang/xlclang++.
The compiler offers you the following methods of implementing shared memory program parallelization:
  • Automatic parallelization of countable program loops, which are defined in Countable loops. An overview of the compiler's automatic parallelization capabilities is provided in Enabling automatic parallelization.
  • C only Explicit parallelization of countable loops using IBM SMP directives. An overview of the IBM SMP directives is provided in Using IBM SMP directives (C only).
  • Explicit parallelization of C and C++ program code using pragma directives compliant to the OpenMP Application Program Interface specification. An overview of the OpenMP directives is provided in Using OpenMP directives.

All methods of automatic program parallelization and optimization are enabled when the -qsmp option is in effect while the omp suboption is not. You can parallelize only program code that is explicitly annotated with SMP or OpenMP directives with the compiler option, but doing so disables automatic parallelization.

Note: The -qsmp option must only be used together with threadsafe compiler invocation modes (those that contain the _r suffix).

Parallel regions of program code are executed by multiple threads, possibly running on multiple processors. The number of threads created is determined by environment variables and calls to library functions. Work is distributed among available threads according to scheduling algorithms specified by the environment variables. For any of the methods of parallelization, you can use the XLSMPOPTS environment variable and its suboptions to control thread scheduling; for more information about this environment variable, see XLSMPOPTS in the XL C/C++ Compiler Reference. If you are using OpenMP constructs, you can use the OpenMP environment variables to control thread scheduling; for information about OpenMP environment variables, see OpenMP environment variables for parallel processing in the XL C/C++ Compiler Reference. For more information about both IBM SMP and OpenMP built-in functions, see Built-in functions for parallel processing in the XL C/C++ Compiler Reference.

For details about the OpenMP constructs, environment variables, and runtime routines, refer to the OpenMP Application Program Interface Specification, available at http://www.openmp.org.