Commit 7390e792 authored by Shen Yu's avatar Shen Yu
Browse files

modified: openmpi-4.1.1/ompi/mpi/c/_MSGLOG_.h

	modified:   openmpi-4.1.1/ompi/mpi/c/allgather.c
	modified:   openmpi-4.1.1/ompi/mpi/c/allgatherv.c
	modified:   openmpi-4.1.1/ompi/mpi/c/allreduce.c
	modified:   openmpi-4.1.1/ompi/mpi/c/alltoall.c
	modified:   openmpi-4.1.1/ompi/mpi/c/alltoallv.c
	modified:   openmpi-4.1.1/ompi/mpi/c/alltoallw.c
	modified:   openmpi-4.1.1/ompi/mpi/c/barrier.c
	modified:   openmpi-4.1.1/ompi/mpi/c/bcast.c
	modified:   openmpi-4.1.1/ompi/mpi/c/comm_create.c
	modified:   openmpi-4.1.1/ompi/mpi/c/comm_create_group.c
	modified:   openmpi-4.1.1/ompi/mpi/c/comm_dup.c
	modified:   openmpi-4.1.1/ompi/mpi/c/comm_join.c
	modified:   openmpi-4.1.1/ompi/mpi/c/comm_split.c
	modified:   openmpi-4.1.1/ompi/mpi/c/finalize.c
	modified:   openmpi-4.1.1/ompi/mpi/c/gather.c
	modified:   openmpi-4.1.1/ompi/mpi/c/gatherv.c
	modified:   openmpi-4.1.1/ompi/mpi/c/init.c
	modified:   openmpi-4.1.1/ompi/mpi/c/irecv.c
	modified:   openmpi-4.1.1/ompi/mpi/c/isend.c
	modified:   openmpi-4.1.1/ompi/mpi/c/recv.c
	modified:   openmpi-4.1.1/ompi/mpi/c/reduce.c
	modified:   openmpi-4.1.1/ompi/mpi/c/rsend.c
	modified:   openmpi-4.1.1/ompi/mpi/c/scatter.c
	modified:   openmpi-4.1.1/ompi/mpi/c/send.c
	modified:   openmpi-4.1.1/ompi/mpi/c/ssend.c
	new file:   replayer/GlobalComm.cpp
	new file:   replayer/GlobalComm.h
	new file:   replayer/commset.h

Add local communicator id to global communicator id map to fix the bug
when the communication does not happen on MPI_COMM_WORLD
parent c056ac20
......@@ -4,6 +4,15 @@
#include <stdio.h>
#include <sys/time.h>
struct CommSet
{
int n; // number of comms in the set
int maxsize; // set maxsize
MPI_Comm* comms; // the array containing the comms
};
extern struct CommSet localComm;
extern FILE* MSGLOGFILE;
extern struct timeval START_TIME;
extern int LOGMSGMYID;
......@@ -130,5 +139,67 @@ inline void free_REQ_POOL()
REQ_POOL_SIZE=0;
}
inline int initCommSet(struct CommSet *CS)
{
CS->n=0;
CS->maxsize=16;
CS->comms=(MPI_Comm*)malloc(sizeof(MPI_Comm)*CS->maxsize);
if(CS->comms == NULL)
return -1;
else
return 0;
}
inline bool inCommSet(MPI_Comm comm, struct CommSet *CS)
{
bool r=false;
for(int i=0; i<CS->n; ++i)
{
if(CS->comms[i] == comm)
{
r=true;
break;
}
}
return r;
}
inline int addComm(MPI_Comm comm, struct CommSet *CS)
{
if(inCommSet(comm, CS))
return 0;
if(CS->n < CS->maxsize)
{
CS->comms[CS->n]=comm;
++(CS->n);
}
else
{
int oldmaxsize=CS->maxsize;
MPI_Comm* oldSet=CS->comms;
CS->maxsize *= 2;
CS->comms=(MPI_Comm*)malloc(sizeof(MPI_Comm)*CS->maxsize);
if(CS->comms == NULL)
{
CS->comms=oldSet;
return -1;
}
else
{
for(int i=0; i<oldmaxsize; ++i)
CS->comms[i]=oldSet[i];
free(oldSet);
CS->comms[CS->n]=comm;
++(CS->n);
}
}
return 0;
}
inline void freeCommSet(struct CommSet *CS)
{
free(CS->comms);
CS->comms=NULL;
}
#endif
// end
......@@ -143,6 +143,7 @@ int MPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
const int LOG_ARGC=4;
int LOG_ARGV[4]={sendcount, sendelemsize, recvcount, recvelemsize};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
addComm(comm, localComm);
// end
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
......
......@@ -166,6 +166,7 @@ int MPI_Allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
const int LOG_ARGC=2;
int LOG_ARGV[2]={sendcount, sendelemsize};
LOGMSG2(FUNC_ID, call_time, comm, LOG_ARGC, size, LOG_ARGV, recvsizelist);
addComm(comm, localComm);
// end
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
......
......@@ -129,6 +129,7 @@ int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count,
const int LOG_ARGC=3;
int LOG_ARGV[3]={count, MPI_Type_c2f(datatype), MPI_Op_c2f(op)};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
addComm(comm, localComm);
// end
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
......
......@@ -128,6 +128,7 @@ int MPI_Alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
const int LOG_ARGC=4;
int LOG_ARGV[4]={sendcount, sendelemsize, recvcount, recvelemsize};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
addComm(comm, localComm);
// end
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
......
......@@ -146,6 +146,7 @@ int MPI_Alltoallv(const void *sendbuf, const int sendcounts[],
int LOGMSG_SENDSIZE=LOGMSG_SIZE_V(size, sendtype, sendcounts, sendsizelist);
int LOGMSG_RECVSIZE=LOGMSG_SIZE_V(size, recvtype, recvcounts, recvsizelist);
LOGMSG2(FUNC_ID, call_time, comm, size, size, sendsizelist, recvsizelist);
addComm(comm, localComm);
// end
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
......
......@@ -141,6 +141,7 @@ int MPI_Alltoallw(const void *sendbuf, const int sendcounts[],
int LOGMSG_SENDSIZE=LOGMSG_SIZE_W(size, sendtypes, sendcounts, sendsizelist);
int LOGMSG_RECVSIZE=LOGMSG_SIZE_W(size, recvtypes, recvcounts, recvsizelist);
LOGMSG2(FUNC_ID, call_time, comm, size, size, sendsizelist, recvsizelist);
addComm(comm, localComm);
// end
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
......
......@@ -87,7 +87,8 @@ int MPI_Barrier(MPI_Comm comm)
// for log messages
const int FUNC_ID=26;
LOGMSG0(FUNC_ID, call_time, MPI_COMM_WORLD);
LOGMSG0(FUNC_ID, call_time, comm);
addComm(comm, localComm);
// end
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
......
......@@ -132,6 +132,7 @@ int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype,
// LOGTHIS is used to avoid logging the communication caused by the log itself
// in init.c
if(LOGTHIS) LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
addComm(comm, localComm);
// end
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
......
......@@ -82,6 +82,8 @@ int MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm *newcomm) {
const int newcommidx=MPI_Comm_c2f(*newcomm);
int LOG_ARGV[2]={groupidx, newcommidx};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
addComm(comm, localComm);
addComm(*newcomm, localComm);
// end
OMPI_ERRHANDLER_RETURN ( rc, comm, rc, FUNC_NAME);
......
......@@ -93,6 +93,8 @@ int MPI_Comm_create_group (MPI_Comm comm, MPI_Group group, int tag, MPI_Comm *ne
const int newcommidx=MPI_Comm_c2f(*newcomm);
int LOG_ARGV[3]={groupidx, tag, newcommidx};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
addComm(comm, localComm);
addComm(*newcomm, localComm);
// end
OMPI_ERRHANDLER_RETURN (rc, comm, rc, FUNC_NAME);
......
......@@ -78,6 +78,8 @@ int MPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm)
const int newcommidx=MPI_Comm_c2f(*newcomm);
int LOG_ARGV[1]={newcommidx};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
addComm(comm, localComm);
addComm(*newcomm, localComm);
// end
OMPI_ERRHANDLER_RETURN ( rc, comm, rc, FUNC_NAME);
......
......@@ -169,6 +169,8 @@ int MPI_Comm_join(int fd, MPI_Comm *intercomm)
const int intercommidx=MPI_Comm_c2f(*intercomm);
int LOG_ARGV[2]={fd, intercommidx};
LOGMSG1(FUNC_ID, call_time, MPI_COMM_SELF, LOG_ARGC, LOG_ARGV);
addComm(comm, localComm);
addComm(*intercomm, localComm);
// end
OMPI_ERRHANDLER_RETURN (rc, MPI_COMM_SELF, rc, FUNC_NAME);
......
......@@ -84,6 +84,8 @@ int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *newcomm) {
const int newcommidx=MPI_Comm_c2f(*newcomm);
int LOG_ARGV[3]={color, key, newcommidx};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
addComm(comm, localComm);
addComm(*newcomm, localComm);
// end
OMPI_ERRHANDLER_RETURN ( rc, comm, rc, FUNC_NAME);
......
......@@ -27,6 +27,7 @@
// for log messages
#include "ompi/mpi/c/_MSGLOG_.h"
#include "GlobalComm.h"
// end
#if OMPI_BUILD_MPI_PROFILING
......@@ -65,6 +66,7 @@ int MPI_Finalize(void)
LOGMSG0(FUNC_ID, call_time, MPI_COMM_WORLD);
fclose(MSGLOGFILE);
free(INT_POOL);
saveGlobalCommMap(localComm, COMMFILE);
// end
return ompi_mpi_finalize();
......
......@@ -200,7 +200,8 @@ int MPI_Gather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
int LOGMSG_RECVSIZE=LOGMSG_SIZE(recvtype, recvcount, &recvelemsize);
const int LOG_ARGC=5;
int LOG_ARGV[5]={root, sendcount, recvcount, sendelemsize, recvelemsize};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
if(LOGTHIS) LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
addComm(comm, localComm);
// end
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
......
......@@ -215,7 +215,8 @@ int MPI_Gatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
int LOGMSG_RECVSIZE=LOGMSG_SIZE_V(size, recvtype, recvcounts, recvelemsizelist);
const int LOG_ARGC=3;
int LOG_ARGV[3]={root, sendcount, sendelemsize};
LOGMSG2(FUNC_ID, call_time, comm, LOG_ARGC, size, LOG_ARGV, recvelemsizelist);
if(LOGTHIS) LOGMSG2(FUNC_ID, call_time, comm, LOG_ARGC, size, LOG_ARGV, recvelemsizelist);
addComm(comm, localComm);
// end
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
......
......@@ -37,8 +37,10 @@
#include <unistd.h>
#include <string.h>
#include "ompi/mpi/c/_MSGLOG_.h"
struct CommSet localComm;
struct timeval START_TIME;
FILE* MSGLOGFILE;
char COMMFILE[4096];
int LOGMSGMYID;
int* INT_POOL;
int REQ_POOL_SIZE;
......@@ -128,6 +130,7 @@ int MPI_Init(int *argc, char ***argv)
sprintf(logfilepath, "%s/%s", inputlogpath, datetime);
printf("logfilepath=%s\n",logfilepath);
sprintf(COMMFILE, "%s/COMM.txt", logfilepath);
}
LOGTHIS=false;
MPI_Bcast(logfilepath, 4000, MPI_CHAR, 0, MPI_COMM_WORLD);
......@@ -151,6 +154,8 @@ int MPI_Init(int *argc, char ***argv)
INT_POOL=malloc(total_nproc*2*sizeof(int));
REQ_POOL_SIZE=1024;
REQ_POOL=malloc(1024*sizeof(int));
initCommSet(localComm);
addComm(MPI_COMM_WORLD, localComm);
// end
return MPI_SUCCESS;
......
......@@ -99,6 +99,7 @@ int MPI_Irecv(void *buf, int count, MPI_Datatype type, int source,
const int LOG_ARGC=5;
int LOG_ARGV[5]={source, count, elemsize, tag, request_idx};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
addComm(comm, localComm);
// end
OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME);
......
......@@ -112,6 +112,7 @@ int MPI_Isend(const void *buf, int count, MPI_Datatype type, int dest,
const int LOG_ARGC=5;
int LOG_ARGV[5]={dest, count, elemsize, tag, request_idx};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
addComm(comm, localComm);
// end
OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME);
......
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