• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List

myriexpress.h

00001 /*
00002  * Copyright © 2010 INRIA
00003  * See COPYING in top-level directory.
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 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   /* fallback to the full topology cpuset */
00060   hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
00061 
00062  out:
00063   return 0;
00064 }
00065 
00072 static 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 } /* extern "C" */
00103 #endif
00104 
00105 
00106 #endif /* HWLOC_MYRIEXPRESS_H */

Generated on Mon Jan 24 2011 17:12:07 for Hardware Locality (hwloc) by  doxygen 1.7.2