Hardware Locality (hwloc)
1.3.3
Main Page
Related Pages
Modules
Data Structures
include
hwloc
cudart.h
1
/*
2
* Copyright © 2010 inria. All rights reserved.
3
* Copyright © 2010 Université Bordeaux 1
4
* Copyright © 2011 Cisco Systems, Inc. All rights reserved.
5
* See COPYING in top-level directory.
6
*/
7
16
#ifndef HWLOC_CUDART_H
17
#define HWLOC_CUDART_H
18
19
#include <hwloc.h>
20
#include <hwloc/autogen/config.h>
21
#include <hwloc/linux.h>
22
23
#include <cuda_runtime_api.h>
24
25
26
#ifdef __cplusplus
27
extern
"C"
{
28
#endif
29
30
43
static
inline
int
44
hwloc_cudart_get_device_cpuset
(
hwloc_topology_t
topology ,
45
int
device,
hwloc_cpuset_t
set
)
46
{
47
#ifdef HWLOC_LINUX_SYS
48
/* If we're on Linux, use the sysfs mechanism to get the local cpus */
49
#define HWLOC_CUDART_DEVICE_SYSFS_PATH_MAX 128
50
cudaError_t cerr;
51
struct
cudaDeviceProp prop;
52
char
path[HWLOC_CUDART_DEVICE_SYSFS_PATH_MAX];
53
FILE *sysfile = NULL;
54
int
pciDomainID = 0;
55
56
cerr = cudaGetDeviceProperties(&prop, device);
57
if
(cerr) {
58
errno = ENOSYS;
59
return
-1;
60
}
61
62
#if CUDART_VERSION >= 4000
63
pciDomainID = prop.pciDomainID;
64
#endif
65
66
sprintf(path,
"/sys/bus/pci/devices/%04x:%02x:%02x.0/local_cpus"
, pciDomainID, prop.pciBusID, prop.pciDeviceID);
67
sysfile = fopen(path,
"r"
);
68
if
(!sysfile)
69
return
-1;
70
71
hwloc_linux_parse_cpumap_file
(sysfile,
set
);
72
73
fclose(sysfile);
74
#else
75
/* Non-Linux systems simply get a full cpuset */
76
hwloc_bitmap_copy
(
set
,
hwloc_topology_get_complete_cpuset
(topology));
77
#endif
78
return
0;
79
}
80
84
#ifdef __cplusplus
85
}
/* extern "C" */
86
#endif
87
88
89
#endif
/* HWLOC_CUDART_H */
Generated on Sun Feb 24 2013 15:44:19 for Hardware Locality (hwloc) by
1.8.3.1