|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* Copyright © 2012 Blue Brain Project, EPFL. All rights reserved.
|
|
Packit Service |
c5cf8c |
* Copyright © 2012-2013 Inria. All rights reserved.
|
|
Packit Service |
c5cf8c |
* See COPYING in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/** \file
|
|
Packit Service |
c5cf8c |
* \brief Macros to help interaction between hwloc and OpenGL displays.
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* Applications that use both hwloc and OpenGL may want to include
|
|
Packit Service |
c5cf8c |
* this file so as to get topology information for OpenGL displays.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifndef HWLOC_GL_H
|
|
Packit Service |
c5cf8c |
#define HWLOC_GL_H
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include <hwloc.h>
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include <stdio.h>
|
|
Packit Service |
c5cf8c |
#include <string.h>
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifdef __cplusplus
|
|
Packit Service |
c5cf8c |
extern "C" {
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/** \defgroup hwlocality_gl Interoperability with OpenGL displays
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* This interface offers ways to retrieve topology information about
|
|
Packit Service |
c5cf8c |
* OpenGL displays.
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* Only the NVIDIA display locality information is currently available,
|
|
Packit Service |
c5cf8c |
* using the NV-CONTROL X11 extension and the NVCtrl library.
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* @{
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/** \brief Get the hwloc OS device object corresponding to the
|
|
Packit Service |
c5cf8c |
* OpenGL display given by port and device index.
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* Return the OS device object describing the OpenGL display
|
|
Packit Service |
c5cf8c |
* whose port (server) is \p port and device (screen) is \p device.
|
|
Packit Service |
c5cf8c |
* Return NULL if there is none.
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* The topology \p topology does not necessarily have to match the current
|
|
Packit Service |
c5cf8c |
* machine. For instance the topology may be an XML import of a remote host.
|
|
Packit Service |
c5cf8c |
* I/O devices detection and the GL component must be enabled in the topology.
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* \note The corresponding PCI device object can be obtained by looking
|
|
Packit Service |
c5cf8c |
* at the OS device parent object (unless PCI devices are filtered out).
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
static __hwloc_inline hwloc_obj_t
|
|
Packit Service |
c5cf8c |
hwloc_gl_get_display_osdev_by_port_device(hwloc_topology_t topology,
|
|
Packit Service |
c5cf8c |
unsigned port, unsigned device)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
unsigned x = (unsigned) -1, y = (unsigned) -1;
|
|
Packit Service |
c5cf8c |
hwloc_obj_t osdev = NULL;
|
|
Packit Service |
c5cf8c |
while ((osdev = hwloc_get_next_osdev(topology, osdev)) != NULL) {
|
|
Packit Service |
c5cf8c |
if (HWLOC_OBJ_OSDEV_GPU == osdev->attr->osdev.type
|
|
Packit Service |
c5cf8c |
&& osdev->name
|
|
Packit Service |
c5cf8c |
&& sscanf(osdev->name, ":%u.%u", &x, &y) == 2
|
|
Packit Service |
c5cf8c |
&& port == x && device == y)
|
|
Packit Service |
c5cf8c |
return osdev;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
errno = EINVAL;
|
|
Packit Service |
c5cf8c |
return NULL;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/** \brief Get the hwloc OS device object corresponding to the
|
|
Packit Service |
c5cf8c |
* OpenGL display given by name.
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* Return the OS device object describing the OpenGL display
|
|
Packit Service |
c5cf8c |
* whose name is \p name, built as ":port.device" such as ":0.0" .
|
|
Packit Service |
c5cf8c |
* Return NULL if there is none.
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* The topology \p topology does not necessarily have to match the current
|
|
Packit Service |
c5cf8c |
* machine. For instance the topology may be an XML import of a remote host.
|
|
Packit Service |
c5cf8c |
* I/O devices detection and the GL component must be enabled in the topology.
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* \note The corresponding PCI device object can be obtained by looking
|
|
Packit Service |
c5cf8c |
* at the OS device parent object (unless PCI devices are filtered out).
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
static __hwloc_inline hwloc_obj_t
|
|
Packit Service |
c5cf8c |
hwloc_gl_get_display_osdev_by_name(hwloc_topology_t topology,
|
|
Packit Service |
c5cf8c |
const char *name)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
hwloc_obj_t osdev = NULL;
|
|
Packit Service |
c5cf8c |
while ((osdev = hwloc_get_next_osdev(topology, osdev)) != NULL) {
|
|
Packit Service |
c5cf8c |
if (HWLOC_OBJ_OSDEV_GPU == osdev->attr->osdev.type
|
|
Packit Service |
c5cf8c |
&& osdev->name
|
|
Packit Service |
c5cf8c |
&& !strcmp(name, osdev->name))
|
|
Packit Service |
c5cf8c |
return osdev;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
errno = EINVAL;
|
|
Packit Service |
c5cf8c |
return NULL;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/** \brief Get the OpenGL display port and device corresponding
|
|
Packit Service |
c5cf8c |
* to the given hwloc OS object.
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* Return the OpenGL display port (server) in \p port and device (screen)
|
|
Packit Service |
c5cf8c |
* in \p screen that correspond to the given hwloc OS device object.
|
|
Packit Service |
c5cf8c |
* Return \c -1 if there is none.
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* The topology \p topology does not necessarily have to match the current
|
|
Packit Service |
c5cf8c |
* machine. For instance the topology may be an XML import of a remote host.
|
|
Packit Service |
c5cf8c |
* I/O devices detection and the GL component must be enabled in the topology.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
static __hwloc_inline int
|
|
Packit Service |
c5cf8c |
hwloc_gl_get_display_by_osdev(hwloc_topology_t topology __hwloc_attribute_unused,
|
|
Packit Service |
c5cf8c |
hwloc_obj_t osdev,
|
|
Packit Service |
c5cf8c |
unsigned *port, unsigned *device)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
unsigned x = -1, y = -1;
|
|
Packit Service |
c5cf8c |
if (HWLOC_OBJ_OSDEV_GPU == osdev->attr->osdev.type
|
|
Packit Service |
c5cf8c |
&& sscanf(osdev->name, ":%u.%u", &x, &y) == 2) {
|
|
Packit Service |
c5cf8c |
*port = x;
|
|
Packit Service |
c5cf8c |
*device = y;
|
|
Packit Service |
c5cf8c |
return 0;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
errno = EINVAL;
|
|
Packit Service |
c5cf8c |
return -1;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/** @} */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifdef __cplusplus
|
|
Packit Service |
c5cf8c |
} /* extern "C" */
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#endif /* HWLOC_GL_H */
|
|
Packit Service |
c5cf8c |
|