00001
00002
00003
00004
00005
00006
00015 #ifndef HWLOC_MYRIEXPRESS_H
00016 #define HWLOC_MYRIEXPRESS_H
00017
00018 #include <hwloc.h>
00019 #include <hwloc/autogen/config.h>
00020
00021 #include <myriexpress.h>
00022
00023
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027
00028
00049 static __hwloc_inline int
00050 hwloc_mx_board_get_device_cpuset(hwloc_topology_t topology,
00051 unsigned id, hwloc_cpuset_t set)
00052 {
00053 uint32_t in, out;
00054
00055 if (!hwloc_topology_is_thissystem(topology)) {
00056 errno = EINVAL;
00057 return -1;
00058 }
00059
00060 in = id;
00061 if (mx_get_info(NULL, MX_NUMA_NODE, &in, sizeof(in), &out, sizeof(out)) != MX_SUCCESS) {
00062 errno = EINVAL;
00063 return -1;
00064 }
00065
00066 if (out != (uint32_t) -1) {
00067 hwloc_obj_t obj = NULL;
00068 while ((obj = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_NUMANODE, obj)) != NULL)
00069 if (obj->os_index == out) {
00070 hwloc_bitmap_copy(set, obj->cpuset);
00071 goto out;
00072 }
00073 }
00074
00075 hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
00076
00077 out:
00078 return 0;
00079 }
00080
00093 static __hwloc_inline int
00094 hwloc_mx_endpoint_get_device_cpuset(hwloc_topology_t topology,
00095 mx_endpoint_t endpoint, hwloc_cpuset_t set)
00096 {
00097 uint64_t nid;
00098 uint32_t nindex, eid;
00099 mx_endpoint_addr_t eaddr;
00100
00101 if (mx_get_endpoint_addr(endpoint, &eaddr) != MX_SUCCESS) {
00102 errno = EINVAL;
00103 return -1;
00104 }
00105
00106 if (mx_decompose_endpoint_addr(eaddr, &nid, &eid) != MX_SUCCESS) {
00107 errno = EINVAL;
00108 return -1;
00109 }
00110
00111 if (mx_nic_id_to_board_number(nid, &nindex) != MX_SUCCESS) {
00112 errno = EINVAL;
00113 return -1;
00114 }
00115
00116 return hwloc_mx_board_get_device_cpuset(topology, nindex, set);
00117 }
00118
00122 #ifdef __cplusplus
00123 }
00124 #endif
00125
00126
00127 #endif