Open MPI logo

Portable Hardware Locality (hwloc) Documentation: v1.7.2

  |   Home   |   Support   |   FAQ   |  
myriexpress.h
1 /*
2  * Copyright © 2010-2013 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 
45 static __hwloc_inline int
47  unsigned id, hwloc_cpuset_t set)
48 {
49  uint32_t in, out;
50 
51  if (!hwloc_topology_is_thissystem(topology)) {
52  errno = EINVAL;
53  return -1;
54  }
55 
56  in = id;
57  if (mx_get_info(NULL, MX_NUMA_NODE, &in, sizeof(in), &out, sizeof(out)) != MX_SUCCESS) {
58  errno = EINVAL;
59  return -1;
60  }
61 
62  if (out != (uint32_t) -1) {
63  hwloc_obj_t obj = NULL;
64  while ((obj = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_NODE, obj)) != NULL)
65  if (obj->os_index == out) {
66  hwloc_bitmap_copy(set, obj->cpuset);
67  goto out;
68  }
69  }
70  /* fallback to the full topology cpuset */
72 
73  out:
74  return 0;
75 }
76 
89 static __hwloc_inline int
91  mx_endpoint_t endpoint, hwloc_cpuset_t set)
92 {
93  uint64_t nid;
94  uint32_t nindex, eid;
95  mx_endpoint_addr_t eaddr;
96 
97  if (mx_get_endpoint_addr(endpoint, &eaddr) != MX_SUCCESS) {
98  errno = EINVAL;
99  return -1;
100  }
101 
102  if (mx_decompose_endpoint_addr(eaddr, &nid, &eid) != MX_SUCCESS) {
103  errno = EINVAL;
104  return -1;
105  }
106 
107  if (mx_nic_id_to_board_number(nid, &nindex) != MX_SUCCESS) {
108  errno = EINVAL;
109  return -1;
110  }
111 
112  return hwloc_mx_board_get_device_cpuset(topology, nindex, set);
113 }
114 
118 #ifdef __cplusplus
119 } /* extern "C" */
120 #endif
121 
122 
123 #endif /* HWLOC_MYRIEXPRESS_H */