Hardware Locality (hwloc)  1.11.12
myriexpress.h
1 /*
2  * Copyright © 2010-2014 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 
21 #include <myriexpress.h>
22 
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 
49 static __hwloc_inline int
51  unsigned id, hwloc_cpuset_t set)
52 {
53  uint32_t in, out;
54 
55  if (!hwloc_topology_is_thissystem(topology)) {
56  errno = EINVAL;
57  return -1;
58  }
59 
60  in = id;
61  if (mx_get_info(NULL, MX_NUMA_NODE, &in, sizeof(in), &out, sizeof(out)) != MX_SUCCESS) {
62  errno = EINVAL;
63  return -1;
64  }
65 
66  if (out != (uint32_t) -1) {
67  hwloc_obj_t obj = NULL;
68  while ((obj = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_NUMANODE, obj)) != NULL)
69  if (obj->os_index == out) {
70  hwloc_bitmap_copy(set, obj->cpuset);
71  goto out;
72  }
73  }
74  /* fallback to the full topology cpuset */
76 
77  out:
78  return 0;
79 }
80 
93 static __hwloc_inline int
95  mx_endpoint_t endpoint, hwloc_cpuset_t set)
96 {
97  uint64_t nid;
98  uint32_t nindex, eid;
99  mx_endpoint_addr_t eaddr;
100 
101  if (mx_get_endpoint_addr(endpoint, &eaddr) != MX_SUCCESS) {
102  errno = EINVAL;
103  return -1;
104  }
105 
106  if (mx_decompose_endpoint_addr(eaddr, &nid, &eid) != MX_SUCCESS) {
107  errno = EINVAL;
108  return -1;
109  }
110 
111  if (mx_nic_id_to_board_number(nid, &nindex) != MX_SUCCESS) {
112  errno = EINVAL;
113  return -1;
114  }
115 
116  return hwloc_mx_board_get_device_cpuset(topology, nindex, set);
117 }
118 
122 #ifdef __cplusplus
123 } /* extern "C" */
124 #endif
125 
126 
127 #endif /* HWLOC_MYRIEXPRESS_H */