Skip to content

Commit

Permalink
Cleanup group code.
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel K. Gutierrez <samuel@lanl.gov>
  • Loading branch information
samuelkgutierrez committed Mar 18, 2024
1 parent c924ef2 commit 3177f8e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
8 changes: 2 additions & 6 deletions src/qvi-group.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "qvi-common.h" // IWYU pragma: keep
#include "qvi-group.h"
#include "qvi-utils.h"
#include "qvi-log.h"

/**
Expand All @@ -37,12 +38,7 @@ void
qvi_group_free(
qvi_group_t **group
) {
if (!group) return;
qvi_group_t *igroup = *group;
if (!igroup) goto out;
delete igroup;
out:
*group = nullptr;
qvi_delete(group);
}

/*
Expand Down
33 changes: 18 additions & 15 deletions src/qvi-mpi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ using qvi_mpi_group_tab_t = std::unordered_map<
>;

struct qvi_mpi_group_s {
int qvim_rc = QV_SUCCESS;
/** ID used for table lookups */
qvi_mpi_group_id_t tabid = 0;
/** ID (rank) in group */
Expand All @@ -34,6 +35,20 @@ struct qvi_mpi_group_s {
int size = 0;
/** MPI communicator */
MPI_Comm mpi_comm = MPI_COMM_NULL;
/** Constructor */
qvi_mpi_group_s(void) = default;
/** Destructor */
~qvi_mpi_group_s(void) = default;
/** Assignment operator. */
void operator=
(const qvi_mpi_group_s &src)
{
qvim_rc = src.qvim_rc;
tabid = src.tabid;
id = src.id;
size = src.size;
mpi_comm = src.mpi_comm;
}
};

struct qvi_mpi_s {
Expand Down Expand Up @@ -81,8 +96,7 @@ cp_mpi_group(
const qvi_mpi_group_t *src,
qvi_mpi_group_t *dst
) {
static_assert(std::is_trivially_copyable<qvi_mpi_group_t>::value, "");
memmove(dst, src, sizeof(*src));
*dst = *src;
}

/**
Expand Down Expand Up @@ -422,25 +436,14 @@ int
qvi_mpi_group_new(
qvi_mpi_group_t **group
) {
int rc = QV_SUCCESS;

qvi_mpi_group_t *igroup = qvi_new qvi_mpi_group_t();
if (!igroup) rc = QV_ERR_OOR;

*group = igroup;
return rc;
return qvi_new_rc(group);
}

void
qvi_mpi_group_free(
qvi_mpi_group_t **group
) {
if (!group) return;
qvi_mpi_group_t *igroup = *group;
if (!igroup) goto out;
delete igroup;
out:
*group = nullptr;
qvi_delete(group);
}

int
Expand Down

0 comments on commit 3177f8e

Please sign in to comment.