Пример #1
0
/*******************  FUNCTION  *********************/
int TopoHwloc::getCurrentId ( int level, int depth ) const
{
	//vars
	int res = -1;

	//get absolute depth
	int absDepth = getAbsDepth(level,depth);
	
	//search current thread binding
	hwloc_cpuset_t cpuset = hwloc_bitmap_alloc();
	int status = hwloc_get_cpubind (topology, cpuset, 0);
	allocAssume(status >= 0,"Failed to get the current thread CPU binding with hwloc.");
	
	//count overlap over current level
	int cnt = hwloc_get_nbobjs_inside_cpuset_by_depth(topology,cpuset,absDepth);
	
	//if get only one return its ID
	if (cnt == 1)
	{
		hwloc_obj_t obj = hwloc_get_obj_inside_cpuset_by_depth(topology,cpuset,absDepth,0);
		//TODO maybe their is an accessor for this
		res = obj->logical_index;
	}
	
	//clean memory
	hwloc_bitmap_free(cpuset);
	
	return res;
}
Пример #2
0
static inline
hwloc_obj_t getNumaObj(c_sublocid_t subloc) {
  // could easily imagine this being a bit slow, but it's okay for now
  return
    hwloc_get_obj_inside_cpuset_by_depth(topology,
                                         hwloc_get_root_obj(topology)->cpuset,
                                         numaLevel,
                                         subloc);
}
int hmonitor_eventset_add_named_event(void * monitor_eventset, const char * event)
{
  struct accumulate_eventset * set = (struct accumulate_eventset *) monitor_eventset;
  harray child_events = NULL;
  hwloc_obj_t obj;
  unsigned depth,index,i, n_events = 0;
  hmon m;
  
  if(event==NULL || monitor_eventset == NULL)
    return -1;

  /* Decend depth by depth to look if event exists */
  int topo_depth = hwloc_topology_get_depth(hmon_topology);
  for(depth=set->location->depth; depth<topo_depth; depth++){
    /* Traverse depth to find matching event */
    for(index=0; index<hwloc_get_nbobjs_inside_cpuset_by_depth(hmon_topology, set->location->cpuset, depth); index++){
      obj = hwloc_get_obj_inside_cpuset_by_depth(hmon_topology, set->location->cpuset, depth, index);
      child_events = obj->userdata;
      if(child_events != NULL){
	/* Walk monitor list at this location to find matching event */
	for(i=0; i<harray_length(child_events); i++){
	  m  = harray_get(child_events,i);
	  if(!strcmp(m->id, event)){
	    harray_push(set->child_events, m);
	    n_events=m->n_samples;
	  }
	}
      }
    }
  }
  
  if(n_events  == 0){
    /* Exit failure */
    fprintf(stderr, "Unrecognized event name %s, expected defined monitor name, deeper than %s.\n", event, hwloc_type_name(set->location->type));
    return -1;
  }

  return n_events;
}