This is related to

Marwan (CC'ed) is working on adding interoperability between OpenGL displays and hwloc. The idea is that you can get the locality of the GPU that handles a screen so as to place rendering tasks on the CPUs nearby. This would be used in  for instance.

The code is available at

We discussed this recently in private. Here's what I think is worth being noted:
* The code currently only works NVIDIA GPU's but Marwan thinks the API could be ported to AMD too.
* The code uses NVIDIA's apparently-open-source nvctrl library. The lib is unfortunately only built as a static lib in at least debian and ubuntu (without -fPIC), which is annoying. So Marwan would like to bundle it inside hwloc. I don't think that's a good idea for maintenance and portability reasons (assuming copyrights are okay) but I am open to opinions.
* We get new "display" objects in the topology
* We also get some new helpers that convert between displays and cpusets

There's still some work/cleanup before this can be merged
* His institution should sign the contributor licensing agreement
* Some functions likely need renaming/prefixing
* We need to cleanup the proposed API (make the busid an actual generic PCI bus id, find good function names and filenames, make sure display_info is ok, ...)
* We need to check where the current X model is going with displays and multiple GPUs. Dave Airlie is working on sharing memory objects between GPUs (to switch between integrated and discrete GPUs) so we could have multiple GPUs for a single X display. We need to make sure we won't have problem if we can ever port the new API to such cases.