Skip to content

Commit

Permalink
distances: hwloc_distances_get_by_type() isn't inline on top of by_de…
Browse files Browse the repository at this point in the history
…pth() anymore

Make it work even for Groups etc.

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed Jul 10, 2019
1 parent d5a0908 commit be595c6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
15 changes: 14 additions & 1 deletion hwloc/distances.c
Expand Up @@ -827,7 +827,7 @@ hwloc_distances_get_by_depth(hwloc_topology_t topology, int depth,
return -1;
}

/* switch back to types since we don't support groups for now */
/* FIXME: passing the depth of a group level may return group distances at a different depth */
type = hwloc_get_depth_type(topology, depth);
if (type == (hwloc_obj_type_t)-1) {
errno = EINVAL;
Expand All @@ -850,6 +850,19 @@ hwloc_distances_get_by_name(hwloc_topology_t topology, const char *name,
return hwloc__distances_get(topology, name, HWLOC_OBJ_TYPE_NONE, nrp, distancesp, HWLOC_DISTANCES_KIND_ALL, flags);
}

int
hwloc_distances_get_by_type(hwloc_topology_t topology, hwloc_obj_type_t type,
unsigned *nrp, struct hwloc_distances_s **distancesp,
unsigned long kind, unsigned long flags)
{
if (flags || !topology->is_loaded) {
errno = EINVAL;
return -1;
}

return hwloc__distances_get(topology, NULL, type, nrp, distancesp, kind, flags);
}

/******************************************************
* Grouping objects according to distances
*/
Expand Down
12 changes: 2 additions & 10 deletions include/hwloc/distances.h
Expand Up @@ -136,18 +136,10 @@ hwloc_distances_get_by_depth(hwloc_topology_t topology, int depth,
*
* Identical to hwloc_distances_get() with the additional \p type filter.
*/
static __hwloc_inline int
HWLOC_DECLSPEC int
hwloc_distances_get_by_type(hwloc_topology_t topology, hwloc_obj_type_t type,
unsigned *nr, struct hwloc_distances_s **distances,
unsigned long kind, unsigned long flags)
{
int depth = hwloc_get_type_depth(topology, type);
if (depth == HWLOC_TYPE_DEPTH_UNKNOWN || depth == HWLOC_TYPE_DEPTH_MULTIPLE) {
*nr = 0;
return 0;
}
return hwloc_distances_get_by_depth(topology, depth, nr, distances, kind, flags);
}
unsigned long kind, unsigned long flags);

/** \brief Retrieve a distance matrix with the given name.
*
Expand Down

0 comments on commit be595c6

Please sign in to comment.