Skip to content

Commit

Permalink
Incorporate trivial cleanups. (#160)
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel K. Gutierrez <[email protected]>
  • Loading branch information
samuelkgutierrez authored May 23, 2024
1 parent 8828bba commit 5b0a374
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 27 deletions.
32 changes: 16 additions & 16 deletions src/qvi-map.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@
#include "qvi-common.h"
#include "qvi-hwloc.h"

/** Maintains a mapping between 'From IDs' to 'To IDs'. */
using qvi_map_t = std::map<uint_t, uint_t>;

/**
* Defines a function pointer to a desired mapping function.
*/
using qvi_map_fn_t = std::function<
int(qvi_map_t &map, uint_t nfids, const qvi_hwloc_cpusets_t &tres)
>;

/**
* Maintains a mapping between resource IDs to a set of
* consumer IDs that have shared affinity with a given resource.
*/
using qvi_map_shaffinity_t = std::map<uint_t, std::set<uint_t>>;

/**
* Returns the largest number that will fit in the space available.
*/
Expand All @@ -35,22 +51,6 @@ qvi_map_maxiperk(
uint_t k
);

/** Maintains a mapping between 'From IDs' to 'To IDs'. */
using qvi_map_t = std::map<uint_t, uint_t>;

/**
* Defines a function pointer to a desired mapping function.
*/
using qvi_map_fn_t = std::function<
int(qvi_map_t &map, uint_t nfids, const qvi_hwloc_cpusets_t &tres)
>;

/**
* Maintains a mapping between resource IDs to a set of
* consumer IDs that have shared affinity with a given resource.
*/
using qvi_map_shaffinity_t = std::map<uint_t, std::set<uint_t>>;

/**
* Prints debug output.
*/
Expand Down
20 changes: 9 additions & 11 deletions src/qvi-scope.cc
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ scope_split_coll_scatter(
int *colorp,
qvi_hwpool_s **result
) {
int rc = scatter_values(
const int rc = scatter_values(
splitcoll.parent_scope->group,
qvi_scope_split_coll_s::rootid,
splitcoll.gsplit.colors,
Expand All @@ -490,7 +490,7 @@ qvi_scope_split_agg_cpuset_dup(
hwloc_cpuset_t *result
) {
// This shouldn't happen.
assert(splitagg.hwpools.size() != 0);
if (splitagg.hwpools.size() == 0) qvi_abort();

return qvi_hwloc_bitmap_dup(
qvi_hwpool_cpuset_get(splitagg.hwpools[0]), result
Expand All @@ -517,7 +517,6 @@ qvi_scope_kfree(
uint_t k
) {
if (!kscopes) return;

qv_scope_t **ikscopes = *kscopes;
for (uint_t i = 0; i < k; ++i) {
qvi_scope_free(&ikscopes[i]);
Expand All @@ -533,8 +532,7 @@ scope_init(
qvi_group_t *group,
qvi_hwpool_s *hwpool
) {
assert(rmi && hwpool && scope);

if (!rmi || !hwpool || !scope) qvi_abort();
scope->rmi = rmi;
scope->group = group;
scope->hwpool = hwpool;
Expand All @@ -545,15 +543,15 @@ hwloc_const_cpuset_t
qvi_scope_cpuset_get(
qv_scope_t *scope
) {
assert(scope);
if (!scope) qvi_abort();
return qvi_hwpool_cpuset_get(scope->hwpool);
}

const qvi_hwpool_s *
qvi_scope_hwpool_get(
qv_scope_t *scope
) {
assert(scope);
if (!scope) qvi_abort();
return scope->hwpool;
}

Expand All @@ -562,7 +560,7 @@ qvi_scope_taskid(
qv_scope_t *scope,
int *taskid
) {
assert(scope);
if (!scope) qvi_abort();
*taskid = scope->group->id();
return QV_SUCCESS;
}
Expand All @@ -572,7 +570,7 @@ qvi_scope_ntasks(
qv_scope_t *scope,
int *ntasks
) {
assert(scope);
if (!scope) qvi_abort();
*ntasks = scope->group->size();
return QV_SUCCESS;
}
Expand All @@ -581,7 +579,7 @@ int
qvi_scope_barrier(
qv_scope_t *scope
) {
assert(scope);
if (!scope) qvi_abort();
return scope->group->barrier();
}

Expand Down Expand Up @@ -625,7 +623,7 @@ qvi_group_t *
qvi_scope_group_get(
qv_scope_t *scope
) {
assert(scope);
if (!scope) qvi_abort();
return scope->group;
}

Expand Down

0 comments on commit 5b0a374

Please sign in to comment.