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 #ifdef HWLOC_LINUX_SYS
00025 #include "hwloc/linux.h"
00026 #endif
00027
00028 #include <infiniband/verbs.h>
00029
00030
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif
00034
00035
00061 static __hwloc_inline int
00062 hwloc_ibv_get_device_cpuset(hwloc_topology_t topology __hwloc_attribute_unused,
00063 struct ibv_device *ibdev, hwloc_cpuset_t set)
00064 {
00065 #ifdef HWLOC_LINUX_SYS
00066
00067
00068 #define HWLOC_OPENFABRICS_VERBS_SYSFS_PATH_MAX 128
00069 char path[HWLOC_OPENFABRICS_VERBS_SYSFS_PATH_MAX];
00070
00071 if (!hwloc_topology_is_thissystem(topology)) {
00072 errno = EINVAL;
00073 return -1;
00074 }
00075
00076 sprintf(path, "/sys/class/infiniband/%s/device/local_cpus",
00077 ibv_get_device_name(ibdev));
00078 if (hwloc_linux_read_path_as_cpumask(path, set) < 0
00079 || hwloc_bitmap_iszero(set))
00080 hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
00081 #else
00082
00083 hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
00084 #endif
00085 return 0;
00086 }
00087
00104 static __hwloc_inline hwloc_obj_t
00105 hwloc_ibv_get_device_osdev_by_name(hwloc_topology_t topology,
00106 const char *ibname)
00107 {
00108 hwloc_obj_t osdev = NULL;
00109 while ((osdev = hwloc_get_next_osdev(topology, osdev)) != NULL) {
00110 if (HWLOC_OBJ_OSDEV_OPENFABRICS == osdev->attr->osdev.type
00111 && osdev->name && !strcmp(ibname, osdev->name))
00112 return osdev;
00113 }
00114 return NULL;
00115 }
00116
00131 static __hwloc_inline hwloc_obj_t
00132 hwloc_ibv_get_device_osdev(hwloc_topology_t topology,
00133 struct ibv_device *ibdev)
00134 {
00135 if (!hwloc_topology_is_thissystem(topology)) {
00136 errno = EINVAL;
00137 return NULL;
00138 }
00139 return hwloc_ibv_get_device_osdev_by_name(topology, ibv_get_device_name(ibdev));
00140 }
00141
00145 #ifdef __cplusplus
00146 }
00147 #endif
00148
00149
00150 #endif