00001
00002
00003
00004
00005
00006
00007
00008
00019 #ifndef HWLOC_OPENFABRICS_VERBS_H
00020 #define HWLOC_OPENFABRICS_VERBS_H
00021
00022 #include <hwloc.h>
00023 #include <hwloc/autogen/config.h>
00024 #include <hwloc/linux.h>
00025
00026 #include <infiniband/verbs.h>
00027
00028
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032
00033
00046 static __hwloc_inline int
00047 hwloc_ibv_get_device_cpuset(hwloc_topology_t topology __hwloc_attribute_unused,
00048 struct ibv_device *ibdev, hwloc_cpuset_t set)
00049 {
00050 #ifdef HWLOC_LINUX_SYS
00051
00052
00053 #define HWLOC_OPENFABRICS_VERBS_SYSFS_PATH_MAX 128
00054 char path[HWLOC_OPENFABRICS_VERBS_SYSFS_PATH_MAX];
00055 FILE *sysfile = NULL;
00056
00057 sprintf(path, "/sys/class/infiniband/%s/device/local_cpus",
00058 ibv_get_device_name(ibdev));
00059 sysfile = fopen(path, "r");
00060 if (!sysfile)
00061 return -1;
00062
00063 hwloc_linux_parse_cpumap_file(sysfile, set);
00064 if (hwloc_bitmap_iszero(set))
00065 hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
00066
00067 fclose(sysfile);
00068 #else
00069
00070 hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
00071 #endif
00072 return 0;
00073 }
00074
00078 #ifdef __cplusplus
00079 }
00080 #endif
00081
00082
00083 #endif