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
00048 static __hwloc_inline int
00049 hwloc_ibv_get_device_cpuset(hwloc_topology_t topology __hwloc_attribute_unused,
00050 struct ibv_device *ibdev, hwloc_cpuset_t set)
00051 {
00052 #ifdef HWLOC_LINUX_SYS
00053
00054
00055 #define HWLOC_OPENFABRICS_VERBS_SYSFS_PATH_MAX 128
00056 char path[HWLOC_OPENFABRICS_VERBS_SYSFS_PATH_MAX];
00057 FILE *sysfile = NULL;
00058
00059 sprintf(path, "/sys/class/infiniband/%s/device/local_cpus",
00060 ibv_get_device_name(ibdev));
00061 sysfile = fopen(path, "r");
00062 if (!sysfile)
00063 return -1;
00064
00065 hwloc_linux_parse_cpumap_file(sysfile, set);
00066 if (hwloc_bitmap_iszero(set))
00067 hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
00068
00069 fclose(sysfile);
00070 #else
00071
00072 hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
00073 #endif
00074 return 0;
00075 }
00076
00080 #ifdef __cplusplus
00081 }
00082 #endif
00083
00084
00085 #endif