00001
00002
00003
00004
00005
00014 #ifndef HWLOC_MYRIEXPRESS_H
00015 #define HWLOC_MYRIEXPRESS_H
00016
00017 #include <hwloc.h>
00018 #include <hwloc/config.h>
00019 #include <hwloc/linux.h>
00020
00021 #include <myriexpress.h>
00022
00023
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027
00028
00039 static __hwloc_inline int
00040 hwloc_mx_board_get_device_cpuset(hwloc_topology_t topology,
00041 unsigned id, hwloc_cpuset_t set)
00042 {
00043 uint32_t in, out;
00044
00045 in = id;
00046 if (mx_get_info(NULL, MX_NUMA_NODE, &in, sizeof(in), &out, sizeof(out)) != MX_SUCCESS) {
00047 errno = EINVAL;
00048 return -1;
00049 }
00050
00051 if (out != (uint32_t) -1) {
00052 hwloc_obj_t obj = NULL;
00053 while ((obj = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_NODE, obj)) != NULL)
00054 if (obj->os_index == out) {
00055 hwloc_bitmap_copy(set, obj->cpuset);
00056 goto out;
00057 }
00058 }
00059
00060 hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
00061
00062 out:
00063 return 0;
00064 }
00065
00072 static __hwloc_inline int
00073 hwloc_mx_endpoint_get_device_cpuset(hwloc_topology_t topology,
00074 mx_endpoint_t endpoint, hwloc_cpuset_t set)
00075 {
00076 uint64_t nid;
00077 uint32_t nindex, eid;
00078 mx_endpoint_addr_t eaddr;
00079
00080 if (mx_get_endpoint_addr(endpoint, &eaddr) != MX_SUCCESS) {
00081 errno = EINVAL;
00082 return -1;
00083 }
00084
00085 if (mx_decompose_endpoint_addr(eaddr, &nid, &eid) != MX_SUCCESS) {
00086 errno = EINVAL;
00087 return -1;
00088 }
00089
00090 if (mx_nic_id_to_board_number(nid, &nindex) != MX_SUCCESS) {
00091 errno = EINVAL;
00092 return -1;
00093 }
00094
00095 return hwloc_mx_board_get_device_cpuset(topology, nindex, set);
00096 }
00097
00101 #ifdef __cplusplus
00102 }
00103 #endif
00104
00105
00106 #endif