Skip to content

Commit

Permalink
ADI: add MPID_Allocate_vci and MPID_Deallocate_vci
Browse files Browse the repository at this point in the history
This ADI allows MPIR layer to request for explicit vcis.
  • Loading branch information
hzhou committed Apr 19, 2022
1 parent fdec17b commit 6252a53
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/mpi/errhan/errnames.txt
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,11 @@ is too big (> MPIU_SHMW_GHND_SZ)
**set_thread_affinity:Failed to set the async thread affinity
**set_thread_affinity %d:Failed to set the async thread affinity to the logical processor [%d]

## MPIX_Stream
**ch3nostream:Stream is not supported in ch3.
**ch4nostream:No streams available. Configure --enable-thread-cs=per-vci and --with-ch4-max-vcis=# to enable streams.
**outofstream:No streams available. Use MPIR_CVAR_CH4_RESERVE_VCIS to reserve the number of streams can be allocated.

# -----------------------------------------------------------------------------
# The following names are defined but not used (see the -careful option
# for extracterrmsgs) (still to do: move the undefined names here)
3 changes: 3 additions & 0 deletions src/mpid/ch3/include/mpidpre.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,9 @@ int MPID_Init(int required, int *provided);

int MPID_InitCompleted( void );

int MPID_Allocate_vci(int *vci);
int MPID_Deallocate_vci(int vci);

int MPID_Finalize(void);

int MPID_Abort( MPIR_Comm *comm, int mpi_errno, int exit_code, const char *error_msg );
Expand Down
13 changes: 13 additions & 0 deletions src/mpid/ch3/src/mpid_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,19 @@ int MPID_InitCompleted( void )
/* --END ERROR HANDLING-- */
}

int MPID_Allocate_vci(int *vci)
{
int mpi_errno = MPI_SUCCESS;
*vci = 0;
MPIR_ERR_SET(mpi_errno, MPI_ERR_OTHER, "**ch3nostream");
return mpi_errno;
}

int MPID_Deallocate_vci(int vci)
{
MPIR_Assert(0);
return MPI_SUCCESS;
}
/*
* Initialize the process group structure by using PMI calls.
* This routine initializes PMI and uses PMI calls to setup the
Expand Down
2 changes: 2 additions & 0 deletions src/mpid/ch4/include/mpidch4.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

int MPID_Init(int, int *);
int MPID_InitCompleted(void);
int MPID_Allocate_vci(int *vci);
int MPID_Deallocate_vci(int vci);
MPL_STATIC_INLINE_PREFIX int MPID_Cancel_recv(MPIR_Request *) MPL_STATIC_INLINE_SUFFIX;
MPL_STATIC_INLINE_PREFIX int MPID_Cancel_send(MPIR_Request *) MPL_STATIC_INLINE_SUFFIX;
int MPID_Comm_disconnect(MPIR_Comm *);
Expand Down
34 changes: 34 additions & 0 deletions src/mpid/ch4/src/ch4_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,40 @@ int MPID_InitCompleted(void)
goto fn_exit;
}

int MPID_Allocate_vci(int *vci)
{
int mpi_errno = MPI_SUCCESS;

*vci = 0;
#if MPIDI_CH4_MAX_VCIS == 1
MPIR_ERR_SET(mpi_errno, MPI_ERR_OTHER, "**ch4nostream");
#else

if (MPIDI_global.n_vcis + MPIDI_global.n_reserved_vcis >= MPIDI_global.n_total_vcis) {
MPIR_ERR_SET(mpi_errno, MPI_ERR_OTHER, "**outofstream");
} else {
MPIDI_global.n_reserved_vcis++;
for (int i = MPIDI_global.n_vcis; i < MPIDI_global.n_total_vcis; i++) {
if (!MPIDI_VCI(i).allocated) {
MPIDI_VCI(i).allocated = true;
*vci = i;
break;
}
}
}
#endif
return mpi_errno;
}

int MPID_Deallocate_vci(int vci)
{
MPIR_Assert(vci < MPIDI_global.n_total_vcis && vci >= MPIDI_global.n_vcis);
MPIR_Assert(MPIDI_VCI(vci).allocated);
MPIDI_VCI(vci).allocated = false;
MPIDI_global.n_reserved_vcis--;
return MPI_SUCCESS;
}

int MPID_Finalize(void)
{
int mpi_errno;
Expand Down
1 change: 1 addition & 0 deletions src/mpid/ch4/src/ch4_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ typedef struct MPIDI_per_vci {
MPL_atomic_uint64_t exp_seq_no;
MPL_atomic_uint64_t nxt_seq_no;

bool allocated;
char pad MPL_ATTR_ALIGNED(MPL_CACHELINE_SIZE);
} MPIDI_per_vci_t;

Expand Down

0 comments on commit 6252a53

Please sign in to comment.