Developer Guide and Reference

Contents

Thread Affinity Interface (Linux* and Windows*)

The Intel® runtime library has the ability to bind OpenMP* threads to physical processing units. The interface is controlled using the
KMP_AFFINITY
environment variable. Depending on the system (machine) topology, application, and operating system, thread affinity can have a dramatic effect on the application speed.
Thread affinity
restricts execution of certain threads (virtual execution units) to a subset of the physical processing units in a multiprocessor computer. Depending upon the topology of the machine, thread affinity can have a dramatic effect on the execution speed of a program.
Thread affinity is supported on Windows* systems and versions of Linux* systems that have kernel support for thread affinity
, but is not supported by
macOS*
.
The Intel OpenMP runtime library has the ability to bind OpenMP* threads to physical processing units. There are three types of interfaces you can use to specify this binding, which are collectively referred to as the Intel OpenMP Thread Affinity Interface:
  • The high-level affinity interface uses an environment variable to determine the machine topology and assigns OpenMP* threads to the processors based upon their physical location in the machine. This interface is controlled entirely by the
    KMP_AFFINITY
    environment variable
    .
  • The mid-level affinity interface uses an environment variable to explicitly specifies which processors (labeled with integer IDs) are bound to OpenMP* threads. This interface provides compatibility with the gcc*
    GOMP_AFFINITY
    environment variable, but you can also invoke it by using the
    KMP_AFFINITY
    environment variable. The
    GOMP_AFFINITY
    environment variable is supported on Linux* systems only, but users on Windows* or Linux* systems can use the similar functionality provided by the
    KMP_AFFINITY
    environment variable.
  • The low-level affinity interface uses APIs to enable OpenMP* threads to make calls into the OpenMP* runtime library to explicitly specify the set of processors on which they are to be run. This interface is similar in nature to
    sched_setaffinity
    and related functions on Linux* systems or to
    SetThreadAffinityMask
    and related functions on Windows* systems. In addition, you can specify certain options of the
    KMP_AFFINITY
    environment variable to aff