Open MPI logo

Portable Hardware Locality (hwloc) Documentation: v1.4.3

  |   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  in = id;
49  if (mx_get_info(NULL, MX_NUMA_NODE, &in, sizeof(in), &out, sizeof(out)) != MX_SUCCESS) {
50  errno = EINVAL;
51  return -1;
52  }
53 
54  if (out != (uint32_t) -1) {
55  hwloc_obj_t obj = NULL;
56  while ((obj = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_NODE, obj)) != NULL)
57  if (obj->os_index == out) {
58  hwloc_bitmap_copy(set, obj->cpuset);
59  goto out;
60  }
61  }
62  /* fallback to the full topology cpuset */
64 
65  out:
66  return 0;
67 }
68 
77 static inline int
79  mx_endpoint_t endpoint, hwloc_cpuset_t set)
80 {
81  uint64_t nid;
82  uint32_t nindex, eid;
83  mx_endpoint_addr_t eaddr;
84 
85  if (mx_get_endpoint_addr(endpoint, &eaddr) != MX_SUCCESS) {
86  errno = EINVAL;
87  return -1;
88  }
89 
90  if (mx_decompose_endpoint_addr(eaddr, &nid, &eid) != MX_SUCCESS) {
91  errno = EINVAL;
92  return -1;
93  }
94 
95  if (mx_nic_id_to_board_number(nid, &nindex) != MX_SUCCESS) {
96  errno = EINVAL;
97  return -1;
98  }
99 
100  return hwloc_mx_board_get_device_cpuset(topology, nindex, set);
101 }
102 
106 #ifdef __cplusplus
107 } /* extern "C" */
108 #endif
109 
110 
111 #endif /* HWLOC_MYRIEXPRESS_H */