Open MPI logo

Portable Hardware Locality (hwloc) Documentation: v1.4.2

  |   Home   |   Support   |   FAQ   |  
myriexpress.h
00001 /*
00002  * Copyright © 2010-2012 inria.  All rights reserved.
00003  * Copyright © 2011 Cisco Systems, Inc.  All rights reserved.
00004  * See COPYING in top-level directory.
00005  */
00006 
00015 #ifndef HWLOC_MYRIEXPRESS_H
00016 #define HWLOC_MYRIEXPRESS_H
00017 
00018 #include <hwloc.h>
00019 #include <hwloc/autogen/config.h>
00020 #include <hwloc/linux.h>
00021 
00022 #include <myriexpress.h>
00023 
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 
00042 static inline int
00043 hwloc_mx_board_get_device_cpuset(hwloc_topology_t topology,
00044                                  unsigned id, hwloc_cpuset_t set)
00045 {
00046   uint32_t in, out;
00047 
00048   in = id;
00049   if (mx_get_info(NULL, MX_NUMA_NODE, &in, sizeof(in), &out, sizeof(out)) != MX_SUCCESS) {
00050     errno = EINVAL;
00051     return -1;
00052   }
00053 
00054   if (out != (uint32_t) -1) {
00055     hwloc_obj_t obj = NULL;
00056     while ((obj = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_NODE, obj)) != NULL)
00057       if (obj->os_index == out) {
00058         hwloc_bitmap_copy(set, obj->cpuset);
00059         goto out;
00060       }
00061   }
00062   /* fallback to the full topology cpuset */
00063   hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
00064 
00065  out:
00066   return 0;
00067 }
00068 
00077 static inline int
00078 hwloc_mx_endpoint_get_device_cpuset(hwloc_topology_t topology,
00079                                     mx_endpoint_t endpoint, hwloc_cpuset_t set)
00080 {
00081   uint64_t nid;
00082   uint32_t nindex, eid;
00083   mx_endpoint_addr_t eaddr;
00084 
00085   if (mx_get_endpoint_addr(endpoint, &eaddr) != MX_SUCCESS) {
00086     errno = EINVAL;
00087     return -1;
00088   }
00089 
00090   if (mx_decompose_endpoint_addr(eaddr, &nid, &eid) != MX_SUCCESS) {
00091     errno = EINVAL;
00092     return -1;
00093   }
00094 
00095   if (mx_nic_id_to_board_number(nid, &nindex) != MX_SUCCESS) {
00096     errno = EINVAL;
00097     return -1;
00098   }
00099 
00100   return hwloc_mx_board_get_device_cpuset(topology, nindex, set);
00101 }
00102 
00106 #ifdef __cplusplus
00107 } /* extern "C" */
00108 #endif
00109 
00110 
00111 #endif /* HWLOC_MYRIEXPRESS_H */