Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify more code. #202

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/qvi-group-mpi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ qvi_group_mpi_s::make_intrinsic(
qv_scope_intrinsic_t scope
) {
int rc = QV_SUCCESS;
qvi_mpi_group_id_t mpi_group_type;
qvi_group_id_t mpi_group_type;
// TODO(skg) Finish implementation.
switch (scope) {
case QV_SCOPE_SYSTEM:
Expand Down
4 changes: 2 additions & 2 deletions src/qvi-group.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ struct qvi_group_s {
qvi_group_id_t *gid
) {
// Global group ID. Note that we pad its initial value so that other
// infrastructure (e.g., QVI_MPI_GROUP_INTRINSIC_END) will never
// equal or exceed this value.
// infrastructure (e.g., QVI_MPI_GROUP_WORLD) will never equal or exceed
// this value.
static std::atomic<qvi_group_id_t> group_id(64);
if (group_id == UINT64_MAX) {
qvi_log_error("Group ID space exhausted");
Expand Down
20 changes: 8 additions & 12 deletions src/qvi-mpi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "qvi-utils.h"

using qvi_mpi_group_tab_t = std::unordered_map<
qvi_mpi_group_id_t, qvi_mpi_group_t
qvi_group_id_t, qvi_mpi_group_t
>;

struct qvi_mpi_comm_s {
Expand Down Expand Up @@ -65,8 +65,6 @@ struct qvi_mpi_comm_s {
};

struct qvi_mpi_group_s {
/** ID used for table lookups. */
qvi_mpi_group_id_t tabid = 0;
/** The group's communicator info. */
qvi_mpi_comm_s qvcomm;
};
Expand All @@ -93,17 +91,15 @@ struct qvi_mpi_s {
int
add_group(
qvi_mpi_group_s &group,
qvi_mpi_group_id_t given_id = QVI_MPI_GROUP_NULL
qvi_group_id_t given_id = QVI_MPI_GROUP_NULL
) {
qvi_group_id_t gid = given_id;
// Marker used to differentiate between intrinsic and automatic IDs.
if (given_id != QVI_MPI_GROUP_NULL) {
group.tabid = given_id;
}
else {
const int rc = qvi_group_t::next_id(&group.tabid);
if (given_id == QVI_MPI_GROUP_NULL) {
const int rc = qvi_group_t::next_id(&gid);
if (rc != QV_SUCCESS) return rc;
}
group_tab.insert({group.tabid, group});
group_tab.insert({gid, group});
return QV_SUCCESS;
}
};
Expand Down Expand Up @@ -255,7 +251,7 @@ qvi_mpi_group_id(
int
qvi_mpi_group_lookup_by_id(
qvi_mpi_t *mpi,
qvi_mpi_group_id_t id,
qvi_group_id_t id,
qvi_mpi_group_t &group
) {
auto got = mpi->group_tab.find(id);
Expand All @@ -269,7 +265,7 @@ qvi_mpi_group_lookup_by_id(
int
qvi_mpi_group_create_from_group_id(
qvi_mpi_t *mpi,
qvi_mpi_group_id_t id,
qvi_group_id_t id,
qvi_mpi_group_t **group
) {
qvi_mpi_group_s tmp_group;
Expand Down
19 changes: 6 additions & 13 deletions src/qvi-mpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
#include "qvi-group.h"
#include "quo-vadis-mpi.h" // IWYU pragma: keep

// Type definitions.
typedef qvi_group_id_t qvi_mpi_group_id_t;

// Forward declarations.
struct qvi_mpi_s;
typedef struct qvi_mpi_s qvi_mpi_t;
Expand All @@ -34,14 +31,10 @@ typedef struct qvi_mpi_group_s qvi_mpi_group_t;
/**
* Intrinsic group IDs.
*/
static const qvi_mpi_group_id_t QVI_MPI_GROUP_NULL = 0;
static const qvi_mpi_group_id_t QVI_MPI_GROUP_SELF = 1;
static const qvi_mpi_group_id_t QVI_MPI_GROUP_NODE = 2;
static const qvi_mpi_group_id_t QVI_MPI_GROUP_WORLD = 3;
// Sentinel value marking first available group ID. This is expected to be the
// very last item, so don't change its relative position without carefully
// modifying at the code that uses this value.
static const qvi_mpi_group_id_t QVI_MPI_GROUP_INTRINSIC_END = 4;
static constexpr qvi_group_id_t QVI_MPI_GROUP_NULL = 0;
static constexpr qvi_group_id_t QVI_MPI_GROUP_SELF = 1;
static constexpr qvi_group_id_t QVI_MPI_GROUP_NODE = 2;
static constexpr qvi_group_id_t QVI_MPI_GROUP_WORLD = 3;

/**
*
Expand Down Expand Up @@ -106,7 +99,7 @@ qvi_mpi_group_id(
int
qvi_mpi_group_lookup_by_id(
qvi_mpi_t *mpi,
qvi_mpi_group_id_t id,
qvi_group_id_t id,
qvi_mpi_group_t &group
);

Expand All @@ -116,7 +109,7 @@ qvi_mpi_group_lookup_by_id(
int
qvi_mpi_group_create_from_group_id(
qvi_mpi_t *mpi,
qvi_mpi_group_id_t id,
qvi_group_id_t id,
qvi_mpi_group_t **group
);

Expand Down
Loading