Commit 181d99f2 authored by Philipp Samfaß's avatar Philipp Samfaß
Browse files

adapted rank mapping

parent 7b418034
...@@ -180,6 +180,21 @@ int mapTeamToWorldRank(int rank, int r) { ...@@ -180,6 +180,21 @@ int mapTeamToWorldRank(int rank, int r) {
return rank + r * getTeamSize(); return rank + r * getTeamSize();
} }
int translateRank(MPI_Comm srcComm, int srcRank, MPI_Comm destComm) {
MPI_Group srcCommGroup, destCommGroup;
int result;
MPI_Comm_group(srcComm, &srcCommGroup);
MPI_Comm_group(destComm, &destCommGroup);
MPI_Group_translate_ranks(srcCommGroup, 1, &srcRank, destCommGroup, &result);
return result;
}
int mapToWorldRank(int rank, MPI_Comm comm) {
return translateRank(rank, comm, MPI_COMM_WORLD);
}
void remapStatus(MPI_Status *status) { void remapStatus(MPI_Status *status) {
if ((status != MPI_STATUS_IGNORE ) && (status != MPI_STATUSES_IGNORE )) { if ((status != MPI_STATUS_IGNORE ) && (status != MPI_STATUSES_IGNORE )) {
status->MPI_SOURCE = mapWorldToTeamRank(status->MPI_SOURCE); status->MPI_SOURCE = mapWorldToTeamRank(status->MPI_SOURCE);
......
...@@ -84,6 +84,10 @@ int mapWorldToTeamRank(int rank); ...@@ -84,6 +84,10 @@ int mapWorldToTeamRank(int rank);
int mapTeamToWorldRank(int rank, int r); int mapTeamToWorldRank(int rank, int r);
int translateRank(int srcRank, MPI_Comm srcComm, MPI_Comm destComm);
int mapToWorldRank(int rank, MPI_Comm comm);
/* Alters the MPI_SOURCE member of MPI_Status to 0 <= r < team size */ /* Alters the MPI_SOURCE member of MPI_Status to 0 <= r < team size */
void remapStatus(MPI_Status *status); void remapStatus(MPI_Status *status);
......
...@@ -43,6 +43,16 @@ int MPI_Is_thread_main(int* flag) { ...@@ -43,6 +43,16 @@ int MPI_Is_thread_main(int* flag) {
return MPI_SUCCESS; return MPI_SUCCESS;
} }
int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *newcomm) {
if(comm==MPI_COMM_WORLD)
#ifdef USE_MPI_OFFLOADING
PMPI_Comm_split(_comm, color, key, newcomm);
#else
PMPI_Comm_split(comm, color, key, newcomm);
#endif
return MPI_SUCCESS;
}
int MPI_Comm_rank(MPI_Comm comm, int *rank) { int MPI_Comm_rank(MPI_Comm comm, int *rank) {
// todo: assert that a team comm is used // todo: assert that a team comm is used
//assert(comm == MPI_COMM_WORLD); //assert(comm == MPI_COMM_WORLD);
...@@ -221,17 +231,17 @@ int MPI_Iprobe_offload(int source, int tag, MPI_Comm comm, int *flag, MPI_Status ...@@ -221,17 +231,17 @@ int MPI_Iprobe_offload(int source, int tag, MPI_Comm comm, int *flag, MPI_Status
int MPI_Send_offload(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) { int MPI_Send_offload(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
#if COMMUNICATION_MODE==0 #if COMMUNICATION_MODE==0
return ompi_send_offload_p2p(buf, count, datatype, mapTeamToWorldRank(dest, getTeam()), tag, comm); return ompi_send_offload_p2p(buf, count, datatype, mapToWorldRank(dest, comm), tag, comm);
#elif COMMUNICATION_MODE==1 #elif COMMUNICATION_MODE==1
return ompi_send_offload_rma(buf, count, datatype, mapTeamToWorldRank(dest, getTeam()), tag, comm); return ompi_send_offload_rma(buf, count, datatype, mapToWorldRank(dest, comm), tag, comm);
#endif #endif
} }
int MPI_Recv_offload(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status_Offload *stat) { int MPI_Recv_offload(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status_Offload *stat) {
#if COMMUNICATION_MODE==0 #if COMMUNICATION_MODE==0
return ompi_recv_offload_p2p(buf, count, datatype, mapTeamToWorldRank(source, getTeam()), tag, comm, stat); return ompi_recv_offload_p2p(buf, count, datatype, mapToWorldRank(source, comm), tag, comm, stat);
#elif COMMUNICATION_MODE==1 #elif COMMUNICATION_MODE==1
return ompi_recv_offload_rma(buf, count, datatype, mapTeamToWorldRank(source, getTeam()), tag, comm, stat); return ompi_recv_offload_rma(buf, count, datatype, mapToWorldRank(source, comm), tag, comm, stat);
#endif #endif
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment