16 #ifndef HWLOC_CUDART_H
17 #define HWLOC_CUDART_H
20 #include <hwloc/autogen/config.h>
21 #include <hwloc/helper.h>
22 #ifdef HWLOC_LINUX_SYS
23 #include <hwloc/linux.h>
27 #include <cuda_runtime_api.h>
47 static __hwloc_inline
int
49 int idx,
int *domain,
int *bus,
int *dev)
52 struct cudaDeviceProp prop;
54 cerr = cudaGetDeviceProperties(&prop, idx);
60 #if CUDA_VERSION >= 4000
61 *domain = prop.pciDomainID;
67 *dev = prop.pciDeviceID;
88 static __hwloc_inline
int
92 #ifdef HWLOC_LINUX_SYS
94 #define HWLOC_CUDART_DEVICE_SYSFS_PATH_MAX 128
95 char path[HWLOC_CUDART_DEVICE_SYSFS_PATH_MAX];
107 sprintf(path,
"/sys/bus/pci/devices/%04x:%02x:%02x.0/local_cpus", (
unsigned) domain, (
unsigned) bus, (
unsigned) dev);
108 sysfile = fopen(path,
"r");
137 int domain, bus, dev;
169 && !strncmp(
"cuda", osdev->
name, 4)
170 && atoi(osdev->
name + 4) == (
int) idx)