<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/111809>111809</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [openmp] Missing physical_package_id not handled
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            openmp:libomp
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          nikic
      </td>
    </tr>
</table>

<pre>
    On some powerpc systems, the following affinity tests fail:
```
  libomp :: affinity/kmp-abs-hw-subset.c
  libomp :: affinity/kmp-affinity.c
 libomp :: affinity/kmp-hw-subset.c
  libomp :: affinity/omp-places.c
```
The reason is that `/sys/devices/system/cpu/cpuN/topology/physical_package_id` returns `-1`. This is checked in https://github.com/llvm/llvm-project/blob/3645c64d87a0e4576c1195281efa005e90b529b7/openmp/runtime/src/kmp_affinity.cpp#L3560 and we then fall back to flat topology.

As far as I can tell, the behavior of returning `-1` is intentional on the side of the Linux kernel, which reports the `"ibm,chip-id"` property here, if it exists. (Rather than doing something useful, and matching `/sys/devices/system/node/nodeN`.)

The needed information could be reconstructed from `/sys/devices/system/cpu/cpuN/topology/core_siblings_list` (which is what the tests do) or `/sys/devices/system/node/nodeN/cpulist`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyclF2L4zYXxz-NfHNIsOXYsS98Mc8Ohge2Wyh7P8jScaRGloSOPNl8-yLHmZZSlk5JsCV8Xv_6HQkic3GIA2v-x5rXQqxJ-zg4czWymLy6D786IL8gBH_DGCTQnRIuxPgXSBph9tb6m3EXEPNsnEl3SEiJYBbGsvqFla-sfGFtuf-3LYA1k18CZIP65cOV8fG6hIOY6KBvB1onwnSU_85n336Y_9T6M9H9Eg7BCon0NP5bN981QkRB3oEhSFokyN_4SHdifFT4biTSY59wYXyUYX08vzE-Jh-89ZecKug7GSnsWxDyKi74ZhRrS4iY1ugoRz1UrC2P8F0bysmkRnlFBcaBTilQrp6PjI8Xk_Q6HaXP6ax9f74OIfrfUSbGx8n6ifGxbk-NbE-qO4sST825lVXVN7yrcBZl2WBfTg3vp3NWIqBbAuNjXF0yC-aWonxI-vbnAYTAeP21btoShFNwwwyKg1lYC5OQV0geZisSPDs_7rJuz5eMTgRB8H-QwkFCa5-wTajFu_ER_LyLksF7ypIFMS6hS8Y7YcG7zYmMwuyQ11-NW3_AFaPDLehNG6khYvAx0WaxnRw308L4F6lNOBjFOM_RQ_QBY7qDxojZ2cxgEuAPQ4mOwHj3m0gaYybAgfK5tDw5SefVSjivW86sySKS1HvtPwPFeYX761s-eMb7v2qVyXOIaiNg9nERuXWQfrUKpkyl9I5SXGVCBXP0y38lU_qIb2Qma9yF3qyhlCVhvHsoaAhumfus4GP8lWe8Bx8_1eGWeQ9-LNRQq77uRYFDdeZd05ybtiv0cG7atq6lEG3Xl7Lu664ppZJq6tSJC3UqzMBLfqrK_Gv4qTvy6tyj6pqmaqoJZ8VOJS7C2GMeiaOPl8IQrThUVdWVfWHFhJa2K5HzHfr65XFBZBia1yIO2zRN64XYqbQbAh_Bkkl2u1F33-YVfjFE-bz_YcLB-QRaOGVRFWu0w6cneSs-q7rX_z7wPwIAAP__0xDlQw">