Skip to content

Commit

Permalink
Checkpoint more hwpool work.
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel K. Gutierrez <[email protected]>
  • Loading branch information
samuelkgutierrez committed Jun 14, 2024
1 parent eb404da commit 309a581
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 39 deletions.
11 changes: 2 additions & 9 deletions src/quo-vadis-mpi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,14 @@ qv_mpi_context_create(
qvi_catch_and_return();
}

static int
qvi_mpi_context_free(
qv_context_t *ctx
) {
qvi_delete(&ctx);
return QV_SUCCESS;
}

int
qv_mpi_context_free(
qv_context_t *ctx
) {
if (!ctx) return QV_ERR_INVLD_ARG;
try {
return qvi_mpi_context_free(ctx);
qvi_delete(&ctx);
return QV_SUCCESS;
}
qvi_catch_and_return();
}
Expand Down
2 changes: 1 addition & 1 deletion src/quo-vadis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ qv_bind_push(
try {
std::lock_guard<std::mutex> guard(ctx->mutex);
return qvi_bind_push(
ctx->bind_stack, qvi_scope_cpuset_get(scope)
ctx->bind_stack, qvi_scope_cpuset_get(scope).data
);
}
qvi_catch_and_return();
Expand Down
2 changes: 1 addition & 1 deletion src/qvi-hwpool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pool_release_cpus_by_cpuset(
#endif

int
qvi_hwpool_s::obtain_new_hwpool_by_cpuset(
qvi_hwpool_s::new_hwpool_by_cpuset(
qvi_hwloc_t *hwloc,
hwloc_const_cpuset_t cpuset,
qvi_hwpool_s **opool
Expand Down
40 changes: 27 additions & 13 deletions src/qvi-hwpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,36 @@ struct qvi_hwpool_s {
qvi_hwpool_cpu_s cpu;
/** The hardware pool's devices. */
qvi_hwpool_devs_t devs;
/** Initializes a hardware pool with the given cpuset. */
/**
* Initializes a hardware pool with the given cpuset.
*/
int
initialize(
hwloc_const_bitmap_t cpuset
) {
return cpu.cpuset.set(cpuset);
}
/**
* Obtains a new hardware pool based on the
* affinity encoded in the provided cpuset.
* Creates a new, initialized hardware pool based
* on the affinity encoded in the provided cpuset.
*/
int
obtain_new_hwpool_by_cpuset(
static int
new_hwpool_by_cpuset(
qvi_hwloc_t *hwloc,
hwloc_const_cpuset_t cpuset,
qvi_hwpool_s **opool
);
/** Returns a pointer to the hwpool's cpuset. */
hwloc_const_cpuset_t
/**
* Returns a pointer to the hwpool's cpuset.
*/
const qvi_hwloc_bitmap_s &
get_cpuset(void)
{
return cpu.cpuset.data;
return cpu.cpuset;
}
/** Adds a qvi_hwpool_dev_s device. */
/**
* Adds a qvi_hwpool_dev_s device.
*/
int
add_device(
const qvi_hwpool_dev_s &dev
Expand Down Expand Up @@ -148,25 +154,33 @@ struct qvi_hwpool_s {
}
return rc;
}
/** Releases all devices in the hwpool. */
/**
* Releases all devices in the hwpool.
*/
int
release_devices(void)
{
devs.clear();
return QV_SUCCESS;
}
/** Returns a const reference to the hardware pool's devices. */
/**
* Returns a const reference to the hardware pool's devices.
*/
const qvi_hwpool_devs_t &
get_devices(void)
{
return devs;
}
/** Packs the instance into a bbuff. */
/**
* Packs the instance into a bbuff.
*/
int
pack(
qvi_bbuff_t *buff
);
/** Unpacks the buffer and creates a new hardware pool instance. */
/**
* Unpacks the buffer and creates a new hardware pool instance.
*/
static int
unpack(
void *buff,
Expand Down
4 changes: 2 additions & 2 deletions src/qvi-rmi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ get_intrinsic_scope_user(
qvi_hwpool_s **hwpool
) {
// TODO(skg) Is the cpuset the best way to do this?
return server->hwpool->obtain_new_hwpool_by_cpuset(
return qvi_hwpool_s::new_hwpool_by_cpuset(
server->config.hwloc,
qvi_hwloc_topo_get_cpuset(server->config.hwloc),
hwpool
Expand All @@ -591,7 +591,7 @@ get_intrinsic_scope_proc(
);
if (rc != QV_SUCCESS) goto out;

rc = server->hwpool->obtain_new_hwpool_by_cpuset(
rc = qvi_hwpool_s::new_hwpool_by_cpuset(
server->config.hwloc, cpuset, hwpool
);
out:
Expand Down
20 changes: 9 additions & 11 deletions src/qvi-scope.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ get_nobjs_in_hwpool(
) {
if (qvi_hwloc_obj_type_is_host_resource(obj)) {
return qvi_rmi_get_nobjs_in_cpuset(
rmi, obj, hwpool->get_cpuset(), n
rmi, obj, hwpool->get_cpuset().data, n
);
}
// TODO(skg) This should go through the RMI.
Expand Down Expand Up @@ -487,14 +487,13 @@ scope_split_coll_scatter(
static int
qvi_scope_split_agg_cpuset_dup(
const qvi_scope_split_agg_s &splitagg,
hwloc_cpuset_t *result
qvi_hwloc_bitmap_s &result
) {
// This shouldn't happen.
if (splitagg.hwpools.size() == 0) qvi_abort();

return qvi_hwloc_bitmap_dup(
splitagg.hwpools[0]->get_cpuset(), result
);
result = splitagg.hwpools[0]->get_cpuset();
return QV_SUCCESS;
}

int
Expand Down Expand Up @@ -539,7 +538,7 @@ scope_init(
return QV_SUCCESS;
}

hwloc_const_cpuset_t
const qvi_hwloc_bitmap_s &
qvi_scope_cpuset_get(
qv_scope_t *scope
) {
Expand Down Expand Up @@ -807,8 +806,8 @@ agg_split_cpuset(
) {
int rc = QV_SUCCESS;
// The cpuset that we are going to split.
hwloc_cpuset_t base_cpuset = nullptr;
rc = qvi_scope_split_agg_cpuset_dup(splitagg, &base_cpuset);
qvi_hwloc_bitmap_s base_cpuset;
rc = qvi_scope_split_agg_cpuset_dup(splitagg, base_cpuset);
if (rc != QV_SUCCESS) return rc;
// Pointer to my hwloc instance.
qvi_hwloc_t *const hwloc = qvi_rmi_client_hwloc_get(splitagg.rmi);
Expand All @@ -819,12 +818,11 @@ agg_split_cpuset(
// algorithm.
for (uint_t chunkid = 0; chunkid < splitagg.split_size; ++chunkid) {
rc = qvi_hwloc_split_cpuset_by_chunk_id(
hwloc, base_cpuset, splitagg.split_size,
hwloc, base_cpuset.data, splitagg.split_size,
chunkid, result[chunkid].data
);
if (rc != QV_SUCCESS) break;
}
qvi_hwloc_bitmap_free(&base_cpuset);
return rc;
}

Expand Down Expand Up @@ -1260,7 +1258,7 @@ qvi_scope_create(
// TODO(skg) We need to acquire these resources.
int rc = qvi_rmi_get_cpuset_for_nobjs(
parent->rmi,
parent->hwpool->get_cpuset(),
parent->hwpool->get_cpuset().data,
type, nobjs, &cpuset
);
if (rc != QV_SUCCESS) goto out;
Expand Down
4 changes: 2 additions & 2 deletions src/qvi-scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ qvi_scope_group_get(
);

/**
*
* Returns a const reference to the provided scope's cpuset.
*/
hwloc_const_cpuset_t
const qvi_hwloc_bitmap_s &
qvi_scope_cpuset_get(
qv_scope_t *scope
);
Expand Down

0 comments on commit 309a581

Please sign in to comment.