Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00016 #ifndef HWLOC_CUDART_H
00017 #define HWLOC_CUDART_H
00018
00019 #include <hwloc.h>
00020 #include <hwloc/autogen/config.h>
00021 #include <hwloc/linux.h>
00022
00023 #include <cuda_runtime_api.h>
00024
00025
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif
00029
00030
00043 static inline int
00044 hwloc_cudart_get_device_cpuset(hwloc_topology_t topology ,
00045 int device, hwloc_cpuset_t set)
00046 {
00047 #ifdef HWLOC_LINUX_SYS
00048
00049 #define HWLOC_CUDART_DEVICE_SYSFS_PATH_MAX 128
00050 cudaError_t cerr;
00051 struct cudaDeviceProp prop;
00052 char path[HWLOC_CUDART_DEVICE_SYSFS_PATH_MAX];
00053 FILE *sysfile = NULL;
00054
00055 cerr = cudaGetDeviceProperties(&prop, device);
00056 if (cerr) {
00057 errno = ENOSYS;
00058 return -1;
00059 }
00060
00061 sprintf(path, "/sys/bus/pci/devices/0000:%02x:%02x.0/local_cpus", prop.pciBusID, prop.pciDeviceID);
00062 sysfile = fopen(path, "r");
00063 if (!sysfile)
00064 return -1;
00065
00066 hwloc_linux_parse_cpumap_file(sysfile, set);
00067
00068 fclose(sysfile);
00069 #else
00070
00071 hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
00072 #endif
00073 return 0;
00074 }
00075
00079 #ifdef __cplusplus
00080 }
00081 #endif
00082
00083
00084 #endif