Skip to content

Commit

Permalink
ch4: remove MPIDIU_comm_rank_to_pid
Browse files Browse the repository at this point in the history
This is fully replaced by MPIR_comm_rank_to_lpid.
  • Loading branch information
hzhou committed Dec 20, 2024
1 parent 6ab4be0 commit fda47b7
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 229 deletions.
2 changes: 0 additions & 2 deletions src/mpid/ch4/netmod/ofi/ofi_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ ATTRIBUTE((unused));
#define MPIDI_OFI_DT(dt) ((dt)->dev.netmod.ofi)
#define MPIDI_OFI_OP(op) ((op)->dev.netmod.ofi)
#define MPIDI_OFI_COMM(comm) ((comm)->dev.ch4.netmod.ofi)
#define MPIDI_OFI_COMM_TO_INDEX(comm,rank) \
MPIDIU_comm_rank_to_pid(comm, rank, NULL, NULL)
#define MPIDI_OFI_TO_PHYS(avtid, lpid, _nic) \
MPIDI_OFI_AV(&MPIDIU_get_av((avtid), (lpid))).dest[_nic][0]

Expand Down
1 change: 0 additions & 1 deletion src/mpid/ch4/netmod/ucx/ucx_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#define MPIDI_UCX_COMM(comm) ((comm)->dev.ch4.netmod.ucx)
#define MPIDI_UCX_REQ(req) ((req)->dev.ch4.netmod.ucx)
#define COMM_TO_INDEX(comm,rank) MPIDIU_comm_rank_to_pid(comm, rank, NULL, NULL)
#define MPIDI_UCX_COMM_TO_EP(comm,rank,vci_src,vci_dst) \
MPIDI_UCX_AV(MPIDIU_comm_rank_to_av(comm, rank)).dest[vci_src][vci_dst]
#define MPIDI_UCX_AV_TO_EP(av,vci_src,vci_dst) MPIDI_UCX_AV((av)).dest[vci_src][vci_dst]
Expand Down
89 changes: 0 additions & 89 deletions src/mpid/ch4/src/ch4_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,92 +377,3 @@ int MPIDIU_upids_to_lpids(int size, int *remote_upid_size, char *remote_upids,
fn_fail:
goto fn_exit;
}

int MPIDIU_alloc_lut(MPIDI_rank_map_lut_t ** lut, int size)
{
int mpi_errno = MPI_SUCCESS;
MPIDI_rank_map_lut_t *new_lut = NULL;

MPIR_FUNC_ENTER;

new_lut = (MPIDI_rank_map_lut_t *) MPL_malloc(sizeof(MPIDI_rank_map_lut_t)
+ size * sizeof(MPIDI_lpid_t), MPL_MEM_ADDRESS);
if (new_lut == NULL) {
*lut = NULL;
MPIR_ERR_SETANDJUMP(mpi_errno, MPI_ERR_OTHER, "**nomem");
}

MPIR_cc_set(&new_lut->ref_count, 1);
*lut = new_lut;

MPL_DBG_MSG_FMT(MPIDI_CH4_DBG_MEMORY, VERBOSE,
(MPL_DBG_FDEST, "alloc lut %p, size %lu, refcount=%d",
new_lut, size * sizeof(MPIDI_lpid_t), MPIR_cc_get(&new_lut->ref_count)));
fn_exit:
MPIR_FUNC_EXIT;
return mpi_errno;
fn_fail:
goto fn_exit;
}

int MPIDIU_release_lut(MPIDI_rank_map_lut_t * lut)
{
int mpi_errno = MPI_SUCCESS;
int in_use = 0;

MPIR_FUNC_ENTER;

MPIR_cc_decr(&lut->ref_count, &in_use);
MPL_DBG_MSG_FMT(MPIDI_CH4_DBG_MEMORY, VERBOSE, (MPL_DBG_FDEST, "dec ref to lut %p", lut));
if (!in_use) {
MPL_free(lut);
MPL_DBG_MSG_FMT(MPIDI_CH4_DBG_MEMORY, VERBOSE, (MPL_DBG_FDEST, "free lut %p", lut));
}
MPIR_FUNC_EXIT;
return mpi_errno;
}

int MPIDIU_alloc_mlut(MPIDI_rank_map_mlut_t ** mlut, int size)
{
int mpi_errno = MPI_SUCCESS;
MPIDI_rank_map_mlut_t *new_mlut = NULL;

MPIR_FUNC_ENTER;

new_mlut = (MPIDI_rank_map_mlut_t *) MPL_malloc(sizeof(MPIDI_rank_map_mlut_t)
+ size * sizeof(MPIDI_gpid_t), MPL_MEM_ADDRESS);
if (new_mlut == NULL) {
*mlut = NULL;
MPIR_ERR_SETANDJUMP(mpi_errno, MPI_ERR_OTHER, "**nomem");
}

MPIR_cc_set(&new_mlut->ref_count, 1);
*mlut = new_mlut;

MPL_DBG_MSG_FMT(MPIDI_CH4_DBG_MEMORY, VERBOSE,
(MPL_DBG_FDEST, "alloc mlut %p, size %lu, refcount=%d",
new_mlut, size * sizeof(MPIDI_gpid_t), MPIR_cc_get(&new_mlut->ref_count)));
fn_exit:
MPIR_FUNC_EXIT;
return mpi_errno;
fn_fail:
goto fn_exit;
}

int MPIDIU_release_mlut(MPIDI_rank_map_mlut_t * mlut)
{
int mpi_errno = MPI_SUCCESS;
int in_use = 0;

MPIR_FUNC_ENTER;

MPIR_cc_decr(&mlut->ref_count, &in_use);
MPL_DBG_MSG_FMT(MPIDI_CH4_DBG_MEMORY, VERBOSE, (MPL_DBG_FDEST, "dec ref to mlut %p", mlut));
if (!in_use) {
MPL_free(mlut);
MPL_DBG_MSG_FMT(MPIDI_CH4_DBG_MEMORY, VERBOSE, (MPL_DBG_FDEST, "free mlut %p", mlut));
}

MPIR_FUNC_EXIT;
return mpi_errno;
}
124 changes: 0 additions & 124 deletions src/mpid/ch4/src/ch4_proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,85 +35,6 @@ void MPIDIU_upidhash_free(void);
#endif
int MPIDIU_upids_to_lpids(int size, int *remote_upid_size, char *remote_upids,
MPIR_Lpid * remote_lpids);
int MPIDIU_alloc_lut(MPIDI_rank_map_lut_t ** lut, int size);
int MPIDIU_release_lut(MPIDI_rank_map_lut_t * lut);
int MPIDIU_alloc_mlut(MPIDI_rank_map_mlut_t ** mlut, int size);
int MPIDIU_release_mlut(MPIDI_rank_map_mlut_t * mlut);
#define MPIDIU_lut_add_ref(lut) \
do { \
MPL_DBG_MSG_FMT(MPIDI_CH4_DBG_MEMORY, VERBOSE, (MPL_DBG_FDEST, "inc ref to lut %p", lut)); \
MPIR_cc_inc(&(lut)->ref_count); \
} while (0)

#define MPIDIU_mlut_add_ref(mlut) \
do { \
MPL_DBG_MSG_FMT(MPIDI_CH4_DBG_MEMORY, VERBOSE, (MPL_DBG_FDEST, "inc ref to mlut %p", mlut)); \
MPIR_cc_inc(&(mlut)->ref_count); \
} while (0)

MPL_STATIC_INLINE_PREFIX int MPIDIU_comm_rank_to_pid(MPIR_Comm * comm, int rank, int *idx,
int *avtid)
{
MPIR_FUNC_ENTER;

*avtid = 0;
*idx = 0;

switch (MPIDI_COMM(comm, map).mode) {
case MPIDI_RANK_MAP_DIRECT:
*avtid = MPIDI_COMM(comm, map).avtid;
*idx = rank;
break;
case MPIDI_RANK_MAP_DIRECT_INTRA:
*idx = rank;
break;
case MPIDI_RANK_MAP_OFFSET:
*avtid = MPIDI_COMM(comm, map).avtid;
*idx = rank + MPIDI_COMM(comm, map).reg.offset;
break;
case MPIDI_RANK_MAP_OFFSET_INTRA:
*idx = rank + MPIDI_COMM(comm, map).reg.offset;
break;
case MPIDI_RANK_MAP_STRIDE:
*avtid = MPIDI_COMM(comm, map).avtid;
*idx = MPIDI_CALC_STRIDE_SIMPLE(rank, MPIDI_COMM(comm, map).reg.stride.stride,
MPIDI_COMM(comm, map).reg.stride.offset);
break;
case MPIDI_RANK_MAP_STRIDE_INTRA:
*idx = MPIDI_CALC_STRIDE_SIMPLE(rank, MPIDI_COMM(comm, map).reg.stride.stride,
MPIDI_COMM(comm, map).reg.stride.offset);
break;
case MPIDI_RANK_MAP_STRIDE_BLOCK:
*avtid = MPIDI_COMM(comm, map).avtid;
*idx = MPIDI_CALC_STRIDE(rank, MPIDI_COMM(comm, map).reg.stride.stride,
MPIDI_COMM(comm, map).reg.stride.blocksize,
MPIDI_COMM(comm, map).reg.stride.offset);
break;
case MPIDI_RANK_MAP_STRIDE_BLOCK_INTRA:
*idx = MPIDI_CALC_STRIDE(rank, MPIDI_COMM(comm, map).reg.stride.stride,
MPIDI_COMM(comm, map).reg.stride.blocksize,
MPIDI_COMM(comm, map).reg.stride.offset);
break;
case MPIDI_RANK_MAP_LUT:
*avtid = MPIDI_COMM(comm, map).avtid;
*idx = MPIDI_COMM(comm, map).irreg.lut.lpid[rank];
break;
case MPIDI_RANK_MAP_LUT_INTRA:
*idx = MPIDI_COMM(comm, map).irreg.lut.lpid[rank];
break;
case MPIDI_RANK_MAP_MLUT:
*idx = MPIDI_COMM(comm, map).irreg.mlut.gpid[rank].lpid;
*avtid = MPIDI_COMM(comm, map).irreg.mlut.gpid[rank].avtid;
break;
case MPIDI_RANK_MAP_NONE:
MPIR_Assert(0);
break;
}
MPL_DBG_MSG_FMT(MPIDI_CH4_DBG_MAP, VERBOSE,
(MPL_DBG_FDEST, " comm_to_pid: rank=%d, avtid=%d idx=%d", rank, *avtid, *idx));
MPIR_FUNC_EXIT;
return *idx;
}

MPL_STATIC_INLINE_PREFIX MPIDI_av_entry_t *MPIDIU_comm_rank_to_av(MPIR_Comm * comm, int rank)
{
Expand All @@ -130,51 +51,6 @@ MPL_STATIC_INLINE_PREFIX MPIDI_av_entry_t *MPIDIU_comm_rank_to_av(MPIR_Comm * co
return ret;
}

MPL_STATIC_INLINE_PREFIX int MPIDIU_comm_rank_to_pid_local(MPIR_Comm * comm, int rank, int *idx,
int *avtid)
{
MPIR_FUNC_ENTER;

*avtid = MPIDI_COMM(comm, local_map).avtid;
switch (MPIDI_COMM(comm, local_map).mode) {
case MPIDI_RANK_MAP_DIRECT:
case MPIDI_RANK_MAP_DIRECT_INTRA:
*idx = rank;
break;
case MPIDI_RANK_MAP_OFFSET:
case MPIDI_RANK_MAP_OFFSET_INTRA:
*idx = rank + MPIDI_COMM(comm, local_map).reg.offset;
break;
case MPIDI_RANK_MAP_STRIDE:
case MPIDI_RANK_MAP_STRIDE_INTRA:
*idx = MPIDI_CALC_STRIDE_SIMPLE(rank, MPIDI_COMM(comm, local_map).reg.stride.stride,
MPIDI_COMM(comm, local_map).reg.stride.offset);
break;
case MPIDI_RANK_MAP_STRIDE_BLOCK:
case MPIDI_RANK_MAP_STRIDE_BLOCK_INTRA:
*idx = MPIDI_CALC_STRIDE(rank, MPIDI_COMM(comm, local_map).reg.stride.stride,
MPIDI_COMM(comm, local_map).reg.stride.blocksize,
MPIDI_COMM(comm, local_map).reg.stride.offset);
break;
case MPIDI_RANK_MAP_LUT:
case MPIDI_RANK_MAP_LUT_INTRA:
*idx = MPIDI_COMM(comm, local_map).irreg.lut.lpid[rank];
break;
case MPIDI_RANK_MAP_MLUT:
*idx = MPIDI_COMM(comm, local_map).irreg.mlut.gpid[rank].lpid;
*avtid = MPIDI_COMM(comm, local_map).irreg.mlut.gpid[rank].avtid;
break;
case MPIDI_RANK_MAP_NONE:
MPIR_Assert(0);
break;
}
MPL_DBG_MSG_FMT(MPIDI_CH4_DBG_MAP, VERBOSE,
(MPL_DBG_FDEST, " comm_to_pid_local: rank=%d, avtid=%d idx=%d",
rank, *avtid, *idx));
MPIR_FUNC_EXIT;
return *idx;
}

MPL_STATIC_INLINE_PREFIX int MPIDIU_av_is_local(MPIDI_av_entry_t * av)
{
int ret = 0;
Expand Down
2 changes: 0 additions & 2 deletions src/mpid/ch4/src/init_comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ int MPIDI_create_init_comm(MPIR_Comm ** comm)
int node_roots_comm_size = MPIR_Process.num_nodes;
int node_roots_comm_rank = MPIR_Process.node_map[world_rank];
MPIR_Comm *init_comm = NULL;
MPIDI_rank_map_lut_t *lut = NULL;

mpi_errno = MPIR_Comm_create(&init_comm);
MPIR_ERR_CHECK(mpi_errno);
Expand Down Expand Up @@ -66,7 +65,6 @@ void MPIDI_destroy_init_comm(MPIR_Comm ** comm_ptr)
MPIR_Comm *comm = NULL;
if (*comm_ptr != NULL) {
comm = *comm_ptr;
MPIDIU_release_lut(MPIDI_COMM(comm, map).irreg.lut.t);
MPIDIG_destroy_comm(comm);
MPIR_Object_release_ref(comm, &in_use);
MPIR_Assertp(in_use == 0);
Expand Down
13 changes: 2 additions & 11 deletions src/mpid/ch4/src/mpidig_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -562,18 +562,9 @@ MPL_STATIC_INLINE_PREFIX int MPIDIG_win_shared_query_part(MPIR_Win * win, int ra
*disp_unit = 0;
*((void **) baseptr) = NULL;
} else {
int shm_rank = -1;
/* find shm_rank in node_comm. Q: can we rely on comm_ptr->intranode_table? */
int avtid, idx;
MPIDIU_comm_rank_to_pid(win->comm_ptr, rank, &idx, &avtid);
for (int i = 0; i < win->comm_ptr->node_comm->local_size; i++) {
int tmp_avtid, tmp_idx;
MPIDIU_comm_rank_to_pid(win->comm_ptr->node_comm, i, &tmp_idx, &tmp_avtid);
if (tmp_avtid == avtid && tmp_idx == idx) {
shm_rank = i;
break;
}
}
MPIR_Lpid lpid = MPIR_comm_rank_to_lpid(win->comm_ptr, rank);
int shm_rank = MPIR_Group_lpid_to_rank(win->comm_ptr->node_comm->local_group, lpid);
MPIR_Assert(shm_rank >= 0);

MPIDIG_win_shared_info_t *shared_table = MPIDIG_WIN(win, shared_table);
Expand Down

0 comments on commit fda47b7

Please sign in to comment.