Hardware Locality (hwloc) 1.4.2

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List

openfabrics-verbs.h

    00001 /*
    00002  * Copyright © 2009 CNRS
    00003  * Copyright © 2009-2012 inria.  All rights reserved.
    00004  * Copyright © 2009-2010 Université Bordeaux 1
    00005  * Copyright © 2009-2011 Cisco Systems, Inc.  All rights reserved.
    00006  * See COPYING in top-level directory.
    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 inline int
    00049 hwloc_ibv_get_device_cpuset(hwloc_topology_t topology ,
    00050                             struct ibv_device *ibdev, hwloc_cpuset_t set)
    00051 {
    00052 #ifdef HWLOC_LINUX_SYS
    00053   /* If we're on Linux, use the verbs-provided sysfs mechanism to
    00054      get the local cpus */
    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   /* Non-Linux systems simply get a full cpuset */
    00072   hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
    00073 #endif
    00074   return 0;
    00075 }
    00076
    00080 #ifdef __cplusplus
    00081 } /* extern "C" */
    00082 #endif
    00083
    00084
    00085 #endif /* HWLOC_OPENFABRICS_VERBS_H */