• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List

openfabrics-verbs.h

00001 /*
00002  * Copyright © 2009 CNRS, INRIA, Université Bordeaux 1
00003  * Copyright © 2009 Cisco Systems, Inc.  All rights reserved.
00004  * See COPYING in top-level directory.
00005  */
00006 
00017 #ifndef HWLOC_OPENFABRICS_VERBS_H
00018 #define HWLOC_OPENFABRICS_VERBS_H
00019 
00020 #include <hwloc.h>
00021 #include <hwloc/config.h>
00022 #include <hwloc/linux.h>
00023 
00024 #include <infiniband/verbs.h>
00025 
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030 
00031 
00044 static __hwloc_inline int
00045 hwloc_ibv_get_device_cpuset(hwloc_topology_t topology __hwloc_attribute_unused,
00046                             struct ibv_device *ibdev, hwloc_cpuset_t set)
00047 {
00048 #ifdef HWLOC_LINUX_SYS
00049   /* If we're on Linux, use the verbs-provided sysfs mechanism to
00050      get the local cpus */
00051 #define HWLOC_OPENFABRICS_VERBS_SYSFS_PATH_MAX 128
00052   char path[HWLOC_OPENFABRICS_VERBS_SYSFS_PATH_MAX];
00053   FILE *sysfile = NULL;
00054 
00055   sprintf(path, "/sys/class/infiniband/%s/device/local_cpus",
00056           ibv_get_device_name(ibdev));
00057   sysfile = fopen(path, "r");
00058   if (!sysfile)
00059     return -1;
00060 
00061   hwloc_linux_parse_cpumap_file(sysfile, set);
00062 
00063   fclose(sysfile);
00064 #else
00065   /* Non-Linux systems simply get a full cpuset */
00066   hwloc_cpuset_copy(set, hwloc_topology_get_complete_cpuset(topology));
00067 #endif
00068   return 0;
00069 }
00070 
00074 #ifdef __cplusplus
00075 } /* extern "C" */
00076 #endif
00077 
00078 
00079 #endif /* HWLOC_OPENFABRICS_VERBS_H */

Generated on Thu Dec 16 2010 06:44:16 for Hardware Locality (hwloc) by  doxygen 1.7.1