Using shared-memory parallelism (SMP)

You can compile your program with the SMP option to generate threaded code that exploits shared-memory parallelism. The SMP option implies the HOT option and an optimization level of OPTIMIZE(2).

The following table lists the suboptions of the SMP option. For descriptions and syntax of the suboptions, see the SMP option in z/OS XL C/C++ User's Guide.

Table 1. SMP suboptions
suboption Behavior
EXPLICIT Enables directives that control explicit parallelization of loops.
NOEXPLICIT Disables the directives that control explicit parallelization of loops.
OPT Instructs the compiler to optimize as well as parallelize. The optimization is equivalent to OPTIMIZE(2) and HOT in the absence of other optimization options.
NOOPT Instructs the compiler to do the smallest amount of optimization that is required to parallelize the code. During development, it can be useful to turn off optimization to facilitate debugging.

Tips for using the SMP option

Here are some suggestions for using the SMP option:
  • Before using the SMP option, test your programs using OPTIMIZATION and HOT in a single-threaded manner.
  • Use the thread-safe version of system library routines inside the parallel regions.
  • By default, the runtime environment uses all available processors. Do not set the OMP_NUM_THREADS environment variable unless you want to use fewer than the number of available processors. You might want to set the number of executing threads to a small number or to 1 to ease debugging.
  • When debugging an OpenMP program, try using SMP(NOOPT) (without OPTIMIZE) to make the debugging information produced by the compiler more precise.