Go to main content
Oracle® Developer Studio 12.5: OpenMP API User's Guide

Exit Print View

Updated: July 2016
 
 

5.1 Processor Binding Overview

With processor binding (also called thread affinity), the program instructs the operating system that a thread in the program should run on the same place on the machine throughout its execution, and should not be moved to other places. A place in this context refers to some grouping of sockets, cores, or hardware threads.

Processor binding can improve the performance of applications that exhibit a certain data reuse pattern where data accessed by a thread in a parallel or worksharing region will be in the local cache from a previous invocation of a parallel or worksharing region.

A computer system can be viewed as a hierarchy of sockets, cores, and hardware threads. Each socket contains one or more cores, and each core contains one or more hardware threads.

On Oracle Solaris platforms, the psrinfo(1M) command can be used to list available hardware threads. On Linux platforms, the text file /proc/cpuinfo provides information about available hardware threads.

When the operating system binds a thread to a processor, the thread will in effect be bound to a specific hardware thread or to a group of hardware threads.

To control the binding of OpenMP threads to processors, you can use the OpenMP 4.0 environment variables, OMP_PLACES and OMP_PROC_BIND. Alternatively, you can use the Oracle-specific environment variable SUNW_MP_PROCBIND. These two sets of environment variables should not be mixed. The environment variables are described in OMP_PLACES and OMP_PROC_BIND.


Note -  The OpenMP environment variables described in this chapter control the binding of OpenMP threads only (that is, any user threads recorded in the OpenMP runtime library, as well as helper threads that the library created). The environment variables do not control the binding of other user threads. The library records a user thread if the user thread encounters an OpenMP construct or calls an OpenMP runtime routine.