Open MPI logo

Portable Hardware Locality (hwloc) Documentation: v1.5.1

  |   Home   |   Support   |   FAQ   |  
myriexpress.h
1 /*
2  * Copyright © 2010-2012 inria. All rights reserved.
3  * Copyright © 2011 Cisco Systems, Inc. All rights reserved.
4  * See COPYING in top-level directory.
5  */
6 
15 #ifndef HWLOC_MYRIEXPRESS_H
16 #define HWLOC_MYRIEXPRESS_H
17 
18 #include <hwloc.h>
19 #include <hwloc/autogen/config.h>
20 #include <hwloc/linux.h>
21 
22 #include <myriexpress.h>
23 
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
42 static inline int
44  unsigned id, hwloc_cpuset_t set)
45 {
46  uint32_t in, out;
47 
48  if (!hwloc_topology_is_thissystem(topology)) {
49  errno = EINVAL;
50  return -1;
51  }
52 
53  in = id;
54  if (mx_get_info(NULL, MX_NUMA_NODE, &in, sizeof(in), &out, sizeof(out)) != MX_SUCCESS) {
55  errno = EINVAL;
56  return -1;
57  }
58 
59  if (out != (uint32_t) -1) {
60  hwloc_obj_t obj = NULL;
61  while ((obj = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_NODE, obj)) != NULL)
62  if (obj->os_index == out) {
63  hwloc_bitmap_copy(set, obj->cpuset);
64  goto out;
65  }
66  }
67  /* fallback to the full topology cpuset */
69 
70  out:
71  return 0;
72 }
73 
82 static inline int
84  mx_endpoint_t endpoint, hwloc_cpuset_t set)
85 {
86  uint64_t nid;
87  uint32_t nindex, eid;
88  mx_endpoint_addr_t eaddr;
89 
90  if (mx_get_endpoint_addr(endpoint, &eaddr) != MX_SUCCESS) {
91  errno = EINVAL;
92  return -1;
93  }
94 
95  if (mx_decompose_endpoint_addr(eaddr, &nid, &eid) != MX_SUCCESS) {
96  errno = EINVAL;
97  return -1;
98  }
99 
100  if (mx_nic_id_to_board_number(nid, &nindex) != MX_SUCCESS) {
101  errno = EINVAL;
102  return -1;
103  }
104 
105  return hwloc_mx_board_get_device_cpuset(topology, nindex, set);
106 }
107 
111 #ifdef __cplusplus
112 } /* extern "C" */
113 #endif
114 
115 
116 #endif /* HWLOC_MYRIEXPRESS_H */