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

feature: if more than 1 MPI process is detected, suffix hostname with… #30

Merged
merged 1 commit into from
Mar 29, 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
1 change: 1 addition & 0 deletions src/hp2p.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ typedef struct
int rank;
int local_rank;
int nproc;
int local_nproc;
MPI_Comm comm;
MPI_Comm local_comm;
char localhost[MPI_MAX_PROCESSOR_NAME];
Expand Down
18 changes: 10 additions & 8 deletions src/hp2p_mpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,27 @@ int hp2p_mpi_init(int *argc, char ***argv, hp2p_mpi_config *mpi_conf)
MPI_Comm_size(mpi_conf->comm, &mpi_conf->nproc);
MPI_Comm_rank(mpi_conf->comm, &mpi_conf->rank);

#ifdef _ENABLE_CUDA_
MPI_Comm_split_type(mpi_conf->comm, MPI_COMM_TYPE_SHARED, mpi_conf->rank,
MPI_INFO_NULL, &mpi_conf->local_comm);
MPI_Comm_rank(mpi_conf->local_comm, &mpi_conf->local_rank);
MPI_Comm_size(mpi_conf->local_comm, &mpi_conf->local_nproc);

#ifdef _ENABLE_CUDA_
cudaSetDevice(mpi_conf->local_rank);
#endif
#ifdef _ENABLE_ROCM_
MPI_Comm_split_type(mpi_conf->comm, MPI_COMM_TYPE_SHARED, mpi_conf->rank,
MPI_INFO_NULL, &mpi_conf->local_comm);
MPI_Comm_rank(mpi_conf->local_comm, &mpi_conf->local_rank);
hipSetDevice(mpi_conf->local_rank);
#endif

mpi_conf->root = 0;
MPI_Get_processor_name(mpi_conf->localhost, &namelen);
#if defined(_ENABLE_CUDA_) || defined(_ENABLE_ROCM_)
sprintf(mpi_conf->localhost, "%s:%d", mpi_conf->localhost,
mpi_conf->local_rank);
#endif
if (mpi_conf->local_nproc > 1)
{
char tmpstr[64] = "";
sprintf(tmpstr, ":%d", mpi_conf->local_rank);
strncat(mpi_conf->localhost, tmpstr, 64);
}

mpi_conf->hostlist =
malloc(mpi_conf->nproc * MPI_MAX_PROCESSOR_NAME * sizeof(char));
MPI_Allgather(mpi_conf->localhost, MPI_MAX_PROCESSOR_NAME, MPI_CHAR,
Expand Down