Open MPI logo

Portable Hardware Locality (hwloc) Documentation: v1.2.2

  |   Home   |   Support   |   FAQ   |  
openfabrics-verbs.h
Go to the documentation of this file.
00001 /*
00002  * Copyright © 2009 CNRS
00003  * Copyright © 2009-2010 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 
00046 static inline int
00047 hwloc_ibv_get_device_cpuset(hwloc_topology_t topology ,
00048                             struct ibv_device *ibdev, hwloc_cpuset_t set)
00049 {
00050 #ifdef HWLOC_LINUX_SYS
00051   /* If we're on Linux, use the verbs-provided sysfs mechanism to
00052      get the local cpus */
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 
00065   fclose(sysfile);
00066 #else
00067   /* Non-Linux systems simply get a full cpuset */
00068   hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
00069 #endif
00070   return 0;
00071 }
00072 
00076 #ifdef __cplusplus
00077 } /* extern "C" */
00078 #endif
00079 
00080 
00081 #endif /* HWLOC_OPENFABRICS_VERBS_H */