HOME
| OPENMP API Specification: Version 5.0 November 2018

6.14  OMP_AFFINITY_FORMAT

The OMP_AFFINITY_FORMAT environment variable sets the initial value of the affinity-format-var ICV which defines the format when displaying OpenMP thread affinity information.

The value of this environment variable is a character string that may contain as substrings one or more field specifiers, in addition to other characters. The format of each field specifier is  

 
%[[[0].] size ] type  

where an individual field specifier must contain the percent symbol (%) and a type. The type can be a single character short name or its corresponding long name delimited with curly braces, such as %n or %{thread_num}. A literal percent is specified as %%. Field specifiers can be provided in any order.

The 0 modifier indicates whether or not to add leading zeros to the output, following any indication of sign or base. The . modifier indicates the output should be right justified when size is specified. By default, output is left justified. The minimum field length is size, which is a decimal digit string with a non-zero first digit. If no size is specified, the actual length needed to print the field will be used. If the 0 modifier is used with type of A, {thread_affinity}, H, {host}, or a type that is not printed as a number, the result is unspecified. Any other characters in the format string that are not part of a field specifier will be included literally in the output.


Table 6.2: Available Field Types for Formatting OpenMP Thread Affinity Information



Short Name Long Name Meaning



t team_num The value returned by omp_get_team_num().
T num_teams The value returned by omp_get_num_teams().
L nesting_level The value returned by omp_get_level().
n thread_num The value returned by omp_get_thread_num().
N num_threads The value returned by omp_get_num_threads().
a ancestor_tnum The value returned by omp_get_ancestor_thread_num(level), where level is omp_get_level() minus 1.
H host The name for the host machine on which the OpenMP program is running.
P process_id The process identifier used by the implementation.
i native_thread_id The native thread identifier used by the implementation.
A thread_affinity The list of numerical identifiers, in the format of a comma-separated list of integers or integer ranges, that represent processors on which a thread may execute, subject to OpenMP thread affinity control and/or other external affinity mechanisms.



Implementations may define additional field types. If an implementation does not have information for a field type, "undefined" is printed for this field when displaying the OpenMP thread affinity information.

Example:  

 
setenv OMP_AFFINITY_FORMAT 
       "Thread Affinity: %0.3L %.8n %.15{thread_affinity} %.12H"  

The above example causes an OpenMP implementation to display OpenMP thread affinity information in the following form:  

 
Thread Affinity: 001        0      0-1,16-17      nid003 
Thread Affinity: 001        1      2-3,18-19      nid003  

Cross References