Open MPI logo

Portable Hardware Locality (hwloc) Documentation: v1.3.3

  |   Home   |   Support   |   FAQ   |  
myriexpress.h
1 /*
2  * Copyright © 2010 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 
40 static inline int
42  unsigned id, hwloc_cpuset_t set)
43 {
44  uint32_t in, out;
45 
46  in = id;
47  if (mx_get_info(NULL, MX_NUMA_NODE, &in, sizeof(in), &out, sizeof(out)) != MX_SUCCESS) {
48  errno = EINVAL;
49  return -1;
50  }
51 
52  if (out != (uint32_t) -1) {
53  hwloc_obj_t obj = NULL;
54  while ((obj = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_NODE, obj)) != NULL)
55  if (obj->os_index == out) {
56  hwloc_bitmap_copy(set, obj->cpuset);
57  goto out;
58  }
59  }
60  /* fallback to the full topology cpuset */
62 
63  out:
64  return 0;
65 }
66 
73 static inline int
75  mx_endpoint_t endpoint, hwloc_cpuset_t set)
76 {
77  uint64_t nid;
78  uint32_t nindex, eid;
79  mx_endpoint_addr_t eaddr;
80 
81  if (mx_get_endpoint_addr(endpoint, &eaddr) != MX_SUCCESS) {
82  errno = EINVAL;
83  return -1;
84  }
85 
86  if (mx_decompose_endpoint_addr(eaddr, &nid, &eid) != MX_SUCCESS) {
87  errno = EINVAL;
88  return -1;
89  }
90 
91  if (mx_nic_id_to_board_number(nid, &nindex) != MX_SUCCESS) {
92  errno = EINVAL;
93  return -1;
94  }
95 
96  return hwloc_mx_board_get_device_cpuset(topology, nindex, set);
97 }
98 
102 #ifdef __cplusplus
103 } /* extern "C" */
104 #endif
105 
106 
107 #endif /* HWLOC_MYRIEXPRESS_H */