Go to main content
Oracle® Developer Studio 12.6: Performance Library User's Guide

Exit Print View

Updated: July 2017
 
 

Parallel Processing Examples

This section demonstrates how to use the OMP_NUM_THREADS environment variable along with compile and link options to create code that executes serially and in parallel.

To create a serial application:

  • Call one or more Oracle Developer Studio Performance Library routines

  • Link with -library=sunperf, placing the flag at the end of the command line. Do not compile or link with -xopenmp=parallel, or -xautopar

  • Unset OMP_NUM_THREADS environment variable or set it to 1

The following examples show how to compile and link with the shared Oracle Developer Studio Performance library libsunperf.so.

my_host% cc -xmemalign=8s -xarch=native any.c -library=sunperf
my_host% f95 -dalign -xarch=native any.f95 -library=sunperf

To create a parallel application that executes on multiple processors:

  • Call one or more Oracle Developer Studio Performance Library routines

  • Use the same parallelization option (-xopenmp=parallel or -xautopar) in the compile and link commands

  • Link with -library=sunperf, placing the flag at the end of the command line

  • Set OMP_NUM_THREADS to the number of available processors before running the executable

For example, to use 24 processors, type the following commands:

my_host% f95 -dalign -xarch=native my_app.f -library=sunperf
my_host% setenv OMP_NUM_THREADS 24
my_host% ./a.out

The previous example enables Oracle Developer Studio Performance Library routines to run in parallel, but no part of the user code my_app.f will run in parallel. For the compiler to attempt to parallelize my_app.f, either -xopenmp=parallel or -xautopar is required on the compile line:

my_host% f95 -dalign -xopenmp=parallel my_app.f -library=sunperf
my_host% setenv OMP_NUM_THREADS 24
my_host% ./a.out