Open MPI logo

Portable Hardware Locality (hwloc) Documentation: v1.4.3

  |   Home   |   Support   |   FAQ   |  
openfabrics-verbs.h
1 /*
2  * Copyright © 2009 CNRS
3  * Copyright © 2009-2012 inria. All rights reserved.
4  * Copyright © 2009-2010 Université Bordeaux 1
5  * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
6  * See COPYING in top-level directory.
7  */
8 
19 #ifndef HWLOC_OPENFABRICS_VERBS_H
20 #define HWLOC_OPENFABRICS_VERBS_H
21 
22 #include <hwloc.h>
23 #include <hwloc/autogen/config.h>
24 #include <hwloc/linux.h>
25 
26 #include <infiniband/verbs.h>
27 
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 
48 static inline int
50  struct ibv_device *ibdev, hwloc_cpuset_t set)
51 {
52 #ifdef HWLOC_LINUX_SYS
53  /* If we're on Linux, use the verbs-provided sysfs mechanism to
54  get the local cpus */
55 #define HWLOC_OPENFABRICS_VERBS_SYSFS_PATH_MAX 128
56  char path[HWLOC_OPENFABRICS_VERBS_SYSFS_PATH_MAX];
57  FILE *sysfile = NULL;
58 
59  sprintf(path, "/sys/class/infiniband/%s/device/local_cpus",
60  ibv_get_device_name(ibdev));
61  sysfile = fopen(path, "r");
62  if (!sysfile)
63  return -1;
64 
65  hwloc_linux_parse_cpumap_file(sysfile, set);
66  if (hwloc_bitmap_iszero(set))
68 
69  fclose(sysfile);
70 #else
71  /* Non-Linux systems simply get a full cpuset */
73 #endif
74  return 0;
75 }
76 
80 #ifdef __cplusplus
81 } /* extern "C" */
82 #endif
83 
84 
85 #endif /* HWLOC_OPENFABRICS_VERBS_H */