Open MPI logo

Portable Hardware Locality (hwloc) Documentation: v1.2.2

  |   Home   |   Support   |   FAQ   |  
myriexpress.h
Go to the documentation of this file.
00001 /*
00002  * Copyright © 2010 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 
00040 static inline int
00041 hwloc_mx_board_get_device_cpuset(hwloc_topology_t topology,
00042                                  unsigned id, hwloc_cpuset_t set)
00043 {
00044   uint32_t in, out;
00045 
00046   in = id;
00047   if (mx_get_info(NULL, MX_NUMA_NODE, &in, sizeof(in), &out, sizeof(out)) != MX_SUCCESS) {
00048     errno = EINVAL;
00049     return -1;
00050   }
00051 
00052   if (out != (uint32_t) -1) {
00053     hwloc_obj_t obj = NULL;
00054     while ((obj = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_NODE, obj)) != NULL)
00055       if (obj->os_index == out) {
00056         hwloc_bitmap_copy(set, obj->cpuset);
00057         goto out;
00058       }
00059   }
00060   /* fallback to the full topology cpuset */
00061   hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
00062 
00063  out:
00064   return 0;
00065 }
00066 
00073 static inline int
00074 hwloc_mx_endpoint_get_device_cpuset(hwloc_topology_t topology,
00075                                     mx_endpoint_t endpoint, hwloc_cpuset_t set)
00076 {
00077   uint64_t nid;
00078   uint32_t nindex, eid;
00079   mx_endpoint_addr_t eaddr;
00080 
00081   if (mx_get_endpoint_addr(endpoint, &eaddr) != MX_SUCCESS) {
00082     errno = EINVAL;
00083     return -1;
00084   }
00085 
00086   if (mx_decompose_endpoint_addr(eaddr, &nid, &eid) != MX_SUCCESS) {
00087     errno = EINVAL;
00088     return -1;
00089   }
00090 
00091   if (mx_nic_id_to_board_number(nid, &nindex) != MX_SUCCESS) {
00092     errno = EINVAL;
00093     return -1;
00094   }
00095 
00096   return hwloc_mx_board_get_device_cpuset(topology, nindex, set);
00097 }
00098 
00102 #ifdef __cplusplus
00103 } /* extern "C" */
00104 #endif
00105 
00106 
00107 #endif /* HWLOC_MYRIEXPRESS_H */