Skip to content

Commit

Permalink
Checkpoint new scope splitting work. (#108)
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel K. Gutierrez <[email protected]>
  • Loading branch information
samuelkgutierrez authored Apr 18, 2024
1 parent 7d9a296 commit a61a059
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/qvi-hwloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,15 @@ struct qvi_hwloc_bitmap_s {
{
qvi_hwloc_bitmap_free(&data);
}
/** Assignment operator. */
/**
* Assignment operator.
*
* Check qvim_rc on the LHS after assignment to verify status.
*/
void
operator=(const qvi_hwloc_bitmap_s &src)
{
qvim_rc = qvi_hwloc_bitmap_copy(src.data, data);
assert(qvim_rc == QV_SUCCESS);
}
};

Expand Down
25 changes: 25 additions & 0 deletions src/qvi-hwpool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,31 @@ qvi_hwpool_free(
qvi_delete(rpool);
}

int
qvi_hwpool_dup(
const qvi_hwpool_t *const rpool,
qvi_hwpool_t **dup
) {
qvi_hwpool_t *idup = nullptr;
int rc = qvi_hwpool_new(&idup);
if (rc != QV_SUCCESS) goto out;
// This performs a deep copy of the underlying CPUs.
idup->cpus = rpool->cpus;
// Assignment here sets qvim_rc, so check it.
if (idup->qvim_rc != QV_SUCCESS) {
rc = idup->qvim_rc;
goto out;
}
// This performs a deep copy of the underlying device infos.
idup->devinfos = rpool->devinfos;
out:
if (rc != QV_SUCCESS) {
qvi_hwpool_free(&idup);
}
*dup = idup;
return rc;
}

int
qvi_hwpool_new_from_line(
qvi_line_hwpool_t *line,
Expand Down
11 changes: 11 additions & 0 deletions src/qvi-hwpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ struct qvi_hwpool_devinfo_s {
std::string uuid;
/** The bitmap encoding CPU affinity. */
qvi_hwloc_bitmap_t affinity;
/** No default constructor. */
qvi_hwpool_devinfo_s(void) = delete;
/** Constructor */
qvi_hwpool_devinfo_s(
qv_hw_obj_type_t type,
Expand Down Expand Up @@ -153,6 +155,15 @@ qvi_hwpool_free(
qvi_hwpool_t **pool
);

/**
*
*/
int
qvi_hwpool_dup(
const qvi_hwpool_t *const rpool,
qvi_hwpool_t **dup
);

/**
*
*/
Expand Down
53 changes: 52 additions & 1 deletion src/qvi-scope.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ struct qvi_scope_split_agg_s {
qvi_hwloc_bitmap_free(&cpuset);
}
affinities.clear();

}
};

Expand Down Expand Up @@ -1144,6 +1143,58 @@ qvi_scope_split(
return rc;
}

#if 0
int
qvi_scope_ksplit(
qv_scope_t *parent,
int npieces,
int *colors,
uint_t k,
qv_hw_obj_type_t maybe_obj_type,
qv_scope_t **children
) {
int rc = QV_SUCCESS, colorp = 0;
qvi_hwpool_t *hwpool = nullptr;
qvi_group_t *group = nullptr;
qv_scope_t *ichild = nullptr;

qvi_scope_split_agg_s splitagg{};
splitagg.rmi = parent->rmi;
splitagg.base_hwpool = parent->hwpool;
splitagg.split_size = npieces;
splitagg.group_size = k;
splitagg.split_at_type = maybe_obj_type;
splitagg.colors = std::vector<int>(colors, colors + k);
for (uint_t i = 0; i < k; ++i) {
qvi_hwpool_t *hwp = nullptr;
rc = qvi_hwpool_dup(parent->hwpool, &hwp);
if (rc != QV_SUCCESS) goto out;
splitagg.hwpools.push_back(hwp);
}
// Split the hardware resources based on the provided split parameters.
rc = agg_split(splitagg);
if (rc != QV_SUCCESS) goto out;
// Split underlying group. Notice the use of colorp here.
rc = parent->group->split(
colorp, parent->group->id(), &group
);
if (rc != QV_SUCCESS) goto out;
// Create and initialize the new scope.
rc = qvi_scope_new(&ichild);
if (rc != QV_SUCCESS) goto out;

rc = scope_init(ichild, parent->rmi, group, hwpool);
out:
if (rc != QV_SUCCESS) {
qvi_scope_free(&ichild);
qvi_group_free(&group);
qvi_hwpool_free(&hwpool);
}
*children = ichild;
return rc;
}
#endif

int
qvi_scope_split_at(
qv_scope_t *parent,
Expand Down

0 comments on commit a61a059

Please sign in to comment.