Skip to content

Commit

Permalink
ch3: add ch3_vcrt to MPIR_Group
Browse files Browse the repository at this point in the history
Group are a natural place to host vcrt (virtual connection reference
table). When communicators are duplicated, groups are simply inherited
and reference counted. Thus we won't end up with duplication of vcrt.
  • Loading branch information
hzhou committed Dec 20, 2024
1 parent 1e1d200 commit 3e9ad9d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/mpi/group/grouputil.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ int MPIR_Group_init(void)
pmap->u.stride.stride = 1;
pmap->u.stride.blocksize = 1;

#ifdef MPID_DEV_GROUP_DECL
for (int i = 0; i < MPIR_GROUP_N_BUILTIN; i++) {
MPID_Group_init_hook(MPIR_Group_builtin + i);
}
#endif
return mpi_errno;
}

Expand All @@ -107,6 +112,9 @@ int MPIR_Group_release(MPIR_Group * group_ptr)
/* Release session */
MPIR_Session_release(group_ptr->session_ptr);
}
#ifdef MPID_DEV_GROUP_DECL
mpi_errno = MPID_Group_free_hook(group_ptr);
#endif
MPIR_Handle_obj_free(&MPIR_Group_mem, group_ptr);
}
return mpi_errno;
Expand Down Expand Up @@ -138,6 +146,9 @@ int MPIR_Group_create(int nproc, MPIR_Group ** new_group_ptr)
(*new_group_ptr)->session_ptr = NULL;
memset(&(*new_group_ptr)->pmap, 0, sizeof(struct MPIR_Pmap));
(*new_group_ptr)->pmap.size = nproc;
#ifdef MPID_DEV_GROUP_DECL
mpi_errno = MPID_Group_init_hook(*new_group_ptr);
#endif

return mpi_errno;
}
Expand Down
5 changes: 5 additions & 0 deletions src/mpid/ch3/include/mpidpre.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ typedef struct MPIDI_CH3I_comm
}
MPIDI_CH3I_comm_t;

/* add vcrt to MPIR_Group so we can inherit it whenever possible */
#define MPID_DEV_GROUP_DECL struct MPIDI_VCRT *ch3_vcrt;
int MPID_Group_init_hook(MPIR_Group * group_ptr);
int MPID_Group_free_hook(MPIR_Group * group_ptr);

#define MPID_DEV_COMM_DECL MPIDI_CH3I_comm_t dev;

#ifndef DEFINED_REQ
Expand Down
19 changes: 19 additions & 0 deletions src/mpid/ch3/src/ch3u_comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,3 +581,22 @@ void MPIDI_CH3I_Comm_find(int context_id, MPIR_Comm **comm)

MPIR_FUNC_EXIT;
}

int MPID_Group_init_hook(MPIR_Group * group_ptr)
{
group_ptr->ch3_vcrt = NULL;
return MPI_SUCCESS;
}

int MPID_Group_free_hook(MPIR_Group * group_ptr)
{
int mpi_errno = MPI_SUCCESS;

if (group_ptr->ch3_vcrt) {
/* FIXME: setting TRUE so vc entries may get released.
* Is there a case we don't want that?
*/
mpi_errno = MPIDI_VCRT_Release(group_ptr->ch3_vcrt, TRUE);
}
return mpi_errno;
}

0 comments on commit 3e9ad9d

Please sign in to comment.