Hardware Locality (hwloc)
1.7.2
Main Page
Related Pages
Modules
Data Structures
include
hwloc
gl.h
1
/*
2
* Copyright © 2012 Blue Brain Project, EPFL. All rights reserved.
3
* Copyright © 2012-2013 Inria. All rights reserved.
4
* See COPYING in top-level directory.
5
*/
6
17
#ifndef HWLOC_GL_H
18
#define HWLOC_GL_H
19
20
#include <hwloc.h>
21
22
#include <stdio.h>
23
#include <string.h>
24
25
26
#ifdef __cplusplus
27
extern
"C"
{
28
#endif
29
30
49
static
inline
hwloc_obj_t
50
hwloc_gl_get_display_osdev_by_port_device
(
hwloc_topology_t
topology,
51
unsigned
port,
unsigned
device)
52
{
53
unsigned
x = (unsigned) -1, y = (
unsigned
) -1;
54
hwloc_obj_t
osdev = NULL;
55
while
((osdev =
hwloc_get_next_osdev
(topology, osdev)) != NULL) {
56
if
(
HWLOC_OBJ_OSDEV_GPU
== osdev->
attr
->
osdev
.
type
57
&& osdev->
name
58
&& sscanf(osdev->
name
,
":%u.%u"
, &x, &y) == 2
59
&& port == x && device == y)
60
return
osdev;
61
}
62
errno = EINVAL;
63
return
NULL;
64
}
65
80
static
inline
hwloc_obj_t
81
hwloc_gl_get_display_osdev_by_name
(
hwloc_topology_t
topology,
82
const
char
*name)
83
{
84
hwloc_obj_t
osdev = NULL;
85
while
((osdev =
hwloc_get_next_osdev
(topology, osdev)) != NULL) {
86
if
(
HWLOC_OBJ_OSDEV_GPU
== osdev->
attr
->
osdev
.
type
87
&& osdev->
name
88
&& !strcmp(name, osdev->
name
))
89
return
osdev;
90
}
91
errno = EINVAL;
92
return
NULL;
93
}
94
106
static
inline
int
107
hwloc_gl_get_display_by_osdev
(
hwloc_topology_t
topology ,
108
hwloc_obj_t
osdev,
109
unsigned
*port,
unsigned
*device)
110
{
111
unsigned
x = -1, y = -1;
112
if
(
HWLOC_OBJ_OSDEV_GPU
== osdev->
attr
->
osdev
.
type
113
&& sscanf(osdev->
name
,
":%u.%u"
, &x, &y) == 2) {
114
*port = x;
115
*device = y;
116
return
0;
117
}
118
errno = EINVAL;
119
return
-1;
120
}
121
125
#ifdef __cplusplus
126
}
/* extern "C" */
127
#endif
128
129
130
#endif
/* HWLOC_GL_H */
131
Generated on Tue Sep 3 2013 10:24:21 for Hardware Locality (hwloc) by
1.8.4