OMP_AFFINITY_FORMAT (GNU libgomp)

### 4.2 `OMP_AFFINITY_FORMAT` – Set the format string used for affinity display ¶

ICV: affinity-format-var
Scope: device
Description:

  Sets the format string used when displaying OpenMP thread affinity information. Special values are output using `%` followed by an optional size specification and then either the single-character field type or its long name enclosed in curly braces; using `%%` displays a literal percent. The size specification consists of an optional `0.` or `.` followed by a positive integer, specifying the minimal width of the output. With `0.` and numerical values, the output is padded with zeros on the left; with `.`, the output is padded by spaces on the left; otherwise, the output is padded by spaces on the right. If unset, the value is “`level %L thread %i affinity %A`”.

  Supported field types are:

  t | team_num | value returned by `omp_get_team_num`
  T | num_teams | value returned by `omp_get_num_teams`
  L | nesting_level | value returned by `omp_get_level`
  n | thread_num | value returned by `omp_get_thread_num`
  N | num_threads | value returned by `omp_get_num_threads`
  a | ancestor_tnum | value returned by `omp_get_ancestor_thread_num(omp_get_level()-1)`
  H | host | name of the host that executes the thread
  P | process_id | process identifier
  i | native_thread_id | native thread identifier
  A | thread_affinity | comma separated list of integer values or ranges, representing the processors on which a process might execute, subject to affinity mechanisms

  For instance, after setting

      OMP_AFFINITY_FORMAT="%0.2a!%n!%.4L!%N;%.2t;%0.2T;%{team_num};%{num_teams};%A"

  with either `OMP_DISPLAY_AFFINITY` being set or when calling `omp_display_affinity` with `NULL` or an empty string, the program might display the following:

      00!0!   1!4; 0;01;0;1;0-11
      00!3!   1!4; 0;01;0;1;0-11
      00!2!   1!4; 0;01;0;1;0-11
      00!1!   1!4; 0;01;0;1;0-11

See also:

  `OMP_DISPLAY_AFFINITY` – Display thread affinity information

Reference:

  OpenMP specification v5.0, Section 6.14