CPU mask to bind threads to cores

Specifies how CPLEX binds threads to cores

Purpose

Specifies whether and how CPLEX binds threads to cores

API Parameter Name
C CPXPARAM_CPUmask
C++ IloCplex::Param::CPUmask
Java IloCplex.Param.CPUmask
.NET Cplex.Param.CPUmask
OPL
Python parameters.cpumask
MATLAB Cplex.Param.cpumask
Interactive cpumask
Identifier 1144

Description

This parameter specifies how CPLEX should bind threads to cores on platforms where CPLEX supports binding threads to cores. Currently, CPLEX supports CPU binding of threads to cores on AIX and Linux platforms.

This feature is known as CPU binding. It is also sometimes known as processor affinity.

  • If the value is "off" in lower case, then CPLEX does not bind threads to cores.

  • If the value is "auto" in lower case, then by default CPLEX decides whether or not to bind threads to cores.

  • Otherwise, CPLEX treats the value of this parameter as a hexadecimal number without the usual 0x prefix. Thus a valid string consists of these elements:

    • any digit from 0 (zero) through 9 (inclusive)
    • any lower case character in the range a through f (inclusive)
    • any upper case character in the range A through F (inclusive)

    CPLEX rejects a string containing any other digits or characters than those.

When the value of this parameter is a valid string (that is, a hexadecimal number, not "off" and not "auto"), it serves as a mask to specify which cores CPLEX is allowed to use. Each bit of this hexadecimal number corresponds to a core. CPLEX uses the ith core if and only if the ith bit of this string is set to 1 (one). For example,
  • 00000001 designates core #0.
  • 00000003 designates cores #0 and #1.
  • FFFFFFFF designates all cores #0 through #31.

Note that the CPU mask can designate non-existent logical cores; for example, FFFFFFFF is a valid value on a 4-core machine. In such cases, CPLEX disregards the bits corresponding to non-existent logical cores.

Tip: For GNU/Linux users, this parameter behaves like the taskset command (except that values of this parameter lack the prefix 0x).

Examples

  • For example, if a user sets this CPU mask parameter to the hexadecimal value "f" on a 16-core machine, and the user sets the global thread count parameter 8, then CPLEX binds two threads to each of the first four cores, resulting in a total of 8 threads. CPLEX will not use any of the remaining 12 cores.

  • For example, on a 16 core machine, consider the difference between the value "off" and the value "ffff". If the value of this parameter is "off" CPLEX does no binding. If the value of this parameter is "ffff", CPLEX binds threads to cores.

Terminology

The description of this parameter observes the following conventions in terminology.

The term CPU (that is, central processing unit) corresponds to a single chip; that chip may include multiple physical cores.

The term logical core is synonymous with the term virtual core; the operating system reports the number of these logical cores as the number of cores present on the machine. This number can be different from the number of physical cores in the machine when features such as hyperthreading are enabled in the CPU.

Round-robin refers to the algorithm that repeats the cycle of assigning one thread to each core until all threads are assigned to a core.

Table 1. Values
String Meaning
"off" CPLEX performs no binding.
"auto" Default CPLEX decides whether to bind threads to cores.

A string consisting of digits or characters from the set {0-9, a-f, A-F}

CPLEX binds the threads in round-robin fashion to the cores specified by the mask.