Commit 67979ad7 authored by Shen Yu's avatar Shen Yu
Browse files

openmpi with log, compiling passed

parent 57c6540a
......@@ -71,13 +71,13 @@ inline void LOGMSG2(const int FUNC_ID, const struct timeval call_time, const MPI
fprintf(MSGLOGFILE, "\n");
}
inline int LOGMSG_SIZE(const MPI_Datatype t, const int c, int& log_elem_size)
inline int LOGMSG_SIZE(const MPI_Datatype t, const int c, int* log_elem_size)
{
MPI_Type_size(t, &log_elem_size);
return c*log_elem_size;
MPI_Type_size(t, log_elem_size);
return c * (*log_elem_size);
}
inline int LOGMSG_SIZE_V(const int NPROC, const MPI_Datatype t, const int c[], int& log_elem_size[])
inline int LOGMSG_SIZE_V(const int NPROC, const MPI_Datatype t, const int c[], int log_elem_size[])
{
int TYPESIZE;
MPI_Type_size(t, &TYPESIZE);
......@@ -91,7 +91,7 @@ inline int LOGMSG_SIZE_V(const int NPROC, const MPI_Datatype t, const int c[], i
return MSGSIZE;
}
inline int LOGMSG_SIZE_W(const int NPROC, const MPI_Datatype t[], const int c[], int& log_elem_size[])
inline int LOGMSG_SIZE_W(const int NPROC, const MPI_Datatype t[], const int c[], int log_elem_size[])
{
int MSGSIZE=0;
int TYPESIZE;
......@@ -108,16 +108,16 @@ inline int init_REQ_POOL(int size)
{
if(size > REQ_POOL_SIZE)
{
int* old_pool=REQ_POOL;
int* new_pool=malloc(size*sizeof(int));
int* new_pool=realloc(REQ_POOL, size*sizeof(int));
if(new_pool)
{
REQ_POOL=new_pool;
delete[] old_pool;
REQ_POOL_SIZE = size;
return 0;
}
else
{
free(REQ_POOL);
return 1;
}
}
......
......@@ -138,10 +138,10 @@ int MPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
// for log messages
const int FUNC_ID=1;
int sendelemsize, recvelemsize;
int LOGMSG_SENDSIZE=LOGMSG_SIZE(sendtype, sendcount, sendelemsize);
int LOGMSG_RECVSIZE=LOGMSG_SIZE(recvtype, recvcount, recvelemsize);
int LOGMSG_SENDSIZE=LOGMSG_SIZE(sendtype, sendcount, &sendelemsize);
int LOGMSG_RECVSIZE=LOGMSG_SIZE(recvtype, recvcount, &recvelemsize);
const int LOG_ARGC=4;
int LOG_ARGV[LOG_ARGC]={sendcount, sendelemsize, recvcount, recvelemsize};
int LOG_ARGV[4]={sendcount, sendelemsize, recvcount, recvelemsize};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
// end
......
......@@ -160,12 +160,12 @@ int MPI_Allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
// for log messages
const int FUNC_ID=2;
int sendelemsize;
int* recvelemsizelist=INT_POOL;
int LOGMSG_SENDSIZE=LOGMSG_SIZE(sendtype, sendcount, sendelemsize);
int LOGMSG_RECVSIZE=LOGMSG_SIZE_V(size, recvtype, recvcount, recvelemsizelist);
int* recvsizelist=INT_POOL;
int LOGMSG_SENDSIZE=LOGMSG_SIZE(sendtype, sendcount, &sendelemsize);
int LOGMSG_RECVSIZE=LOGMSG_SIZE_V(size, recvtype, recvcounts, recvsizelist);
const int LOG_ARGC=2;
int LOG_ARGV[LOG_ARGC]={sendcount, sendelemsize};
LOGMSG2(FUNC_ID, call_time, comm, LOG_ARGC, size, LOG_ARGV, recvelemsizelist);
int LOG_ARGV[2]={sendcount, sendelemsize};
LOGMSG2(FUNC_ID, call_time, comm, LOG_ARGC, size, LOG_ARGV, recvsizelist);
// end
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
......
......@@ -126,11 +126,8 @@ int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count,
// for log messages
const int FUNC_ID=3;
int sendelemsize, recvelemsize;
int LOGMSG_SENDSIZE=LOGMSG_SIZE(sendtype, count, sendelemsize);
int LOGMSG_RECVSIZE=LOGMSG_SIZE(recvtype, count, recvelemsize);
const int LOG_ARGC=4;
int LOG_ARGV[LOG_ARGC]={count, sendelemsize, recvelemsize, MPI_Op_c2f(op)};
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);
// end
......
......@@ -123,10 +123,10 @@ int MPI_Alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
// for log messages
const int FUNC_ID=4;
int sendelemsize, recvelemsize;
int LOGMSG_SENDSIZE=LOGMSG_SIZE(sendtype, sendcount, sendelemsize);
int LOGMSG_RECVSIZE=LOGMSG_SIZE(recvtype, recvcount, recvelemsize);
int LOGMSG_SENDSIZE=LOGMSG_SIZE(sendtype, sendcount, &sendelemsize);
int LOGMSG_RECVSIZE=LOGMSG_SIZE(recvtype, recvcount, &recvelemsize);
const int LOG_ARGC=4;
int LOG_ARGV[LOG_ARGC]={sendcount, sendelemsize, recvcount, recvelemsize};
int LOG_ARGV[4]={sendcount, sendelemsize, recvcount, recvelemsize};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
// end
......
......@@ -141,11 +141,11 @@ int MPI_Alltoallv(const void *sendbuf, const int sendcounts[],
// for log messages
const int FUNC_ID=5;
int* sendelemsizelist=&INT_POOL[0];
int* recvelemsizelist=&INT_POOL[size];
int LOGMSG_SENDSIZE=LOGMSG_SIZE_V(size, sendtype, sendcounts, sendelemsizelist);
int LOGMSG_RECVSIZE=LOGMSG_SIZE_V(size, recvtype, recvcounts, recvelemsizelist);
LOGMSG2(FUNC_ID, call_time, comm, size, size, sendelemsizelist, recvelemsizelist);
int* sendsizelist=&INT_POOL[0];
int* recvsizelist=&INT_POOL[size];
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);
// end
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
......
......@@ -136,11 +136,11 @@ int MPI_Alltoallw(const void *sendbuf, const int sendcounts[],
// for log messages
const int FUNC_ID=6;
int* sendelemsizelist=&INT_POOL[0];
int* recvelemsizelist=&INT_POOL[size];
int LOGMSG_SENDSIZE=LOGMSG_SIZE_W(size, sendtypes, sendcounts, sendelemsizelist);
int LOGMSG_RECVSIZE=LOGMSG_SIZE_W(size, recvtypes, recvcounts, recvelemsizelist);
LOGMSG2(FUNC_ID, call_time, comm, size, size, sendelemsizelist, recvelemsizelist);
int* sendsizelist=&INT_POOL[0];
int* recvsizelist=&INT_POOL[size];
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);
// end
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
......
......@@ -126,9 +126,9 @@ int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype,
// for log messages
const int FUNC_ID=7;
int elemsize;
int datasize=LOGMSG_SIZE(datatype, count, elemsize);
const int LOG_ARGC=2;
int LOG_ARGV[LOG_ARGC]={root, datasize};
int datasize=LOGMSG_SIZE(datatype, count, &elemsize);
const int LOG_ARGC=3;
int LOG_ARGV[3]={root, count, elemsize};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
// end
......
......@@ -68,7 +68,7 @@ int MPI_Finalize(void)
const int FUNC_ID=255;
LOGMSG0(FUNC_ID, call_time, MPI_COMM_WORLD);
fclose(MSGLOGFILE);
delete[] INT_POOL;
free(INT_POOL);
// end
return ompi_mpi_finalize();
......
......@@ -196,10 +196,10 @@ int MPI_Gather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
// for log messages
const int FUNC_ID=1;
int sendelemsize, recvelemsize;
int LOGMSG_SENDSIZE=LOGMSG_SIZE(sendtype, sendcount, sendelemsize);
int LOGMSG_RECVSIZE=LOGMSG_SIZE(recvtype, recvcount, recvelemsize);
int LOGMSG_SENDSIZE=LOGMSG_SIZE(sendtype, sendcount, &sendelemsize);
int LOGMSG_RECVSIZE=LOGMSG_SIZE(recvtype, recvcount, &recvelemsize);
const int LOG_ARGC=5;
int LOG_ARGV[LOG_ARGC]={root, sendcount, recvcount, sendelemsize, recvelemsize};
int LOG_ARGV[5]={root, sendcount, recvcount, sendelemsize, recvelemsize};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
// end
......
......@@ -211,10 +211,10 @@ int MPI_Gatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
const int FUNC_ID=9;
int sendelemsize;
int* recvelemsizelist=&INT_POOL[0];
int LOGMSG_SENDSIZE=LOGMSG_SIZE(sendtype, sendcount, sendelemsize);
int LOGMSG_RECVSIZE=LOGMSG_SIZE_V(recvtype, recvcounts, recvelemsizelist);
const int LOG_ARGC=4;
int LOG_ARGV[LOG_ARGC]={root, sendcount, sendelemsize};
int LOGMSG_SENDSIZE=LOGMSG_SIZE(sendtype, sendcount, &sendelemsize);
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, LOG_ARGV, size, recvelemsizelist);
// end
......
......@@ -105,36 +105,47 @@ int MPI_Init(int *argc, char ***argv)
int namelen;
char HOSTNAME[MPI_MAX_PROCESSOR_NAME];
MPI_Get_processor_name(HOSTNAME, &namelen);
// debug
printf("HOSTNAME=%s\n",HOSTNAME);
// end debug
char *logfilepath;
logfilepath=getenv("MSGLOGPATH");
if(logfilepath == NULL)
logfilepath="/tmp";
if(strlen(logfilepath) > 4000)
logfilepath="/tmp"
logfilepath="/tmp";
// debug
printf("logfilepath=%s\n",logfilepath);
// end debug
char logfilename[4096];
if (NULL != (env = getenv("OMPI_COMM_WORLD_RANK"))) {
LOGMSGMYID = atoi(env);
sprintf(logfilename, "%s/%d/MSGLOG.%s.%d.csv", logfilepath, int(START_TIME.tv_sec/100)*100, HOSTNAME, LOGMSGMYID);
sprintf(&logfilename[0], "%s/%d/MSGLOG.%s.%d.csv", logfilepath, (int)(START_TIME.tv_sec/100), HOSTNAME, LOGMSGMYID);
}
else if (NULL != (env = getenv("PMIX_RANK")))
{
LOGMSGMYID = atoi(env);
sprintf(logfilename, "%s/%d/MSGLOG.%s.%d.csv", logfilepath, int(START_TIME.tv_sec/100)*100, HOSTNAME, LOGMSGMYID);
sprintf(&logfilename[0], "%s/%d/MSGLOG.%s.%d.csv", logfilepath, (int)(START_TIME.tv_sec/100), HOSTNAME, LOGMSGMYID);
}
else
{
sprintf(logfilename, "%s/%d/MSGLOG.%s.csv", logfilepath, int(START_TIME.tv_sec/100)*100, HOSTNAME);
sprintf(&logfilename[0], "%s/%d/MSGLOG.%s.csv", logfilepath, (int)(START_TIME.tv_sec/100), HOSTNAME);
}
// debug
printf("logfilename=%s\n",logfilename);
// end debug
MSGLOGFILE=fopen(logfilename, "w+");
const int FUNC_ID=0;
LOGMSG0(FUNC_ID, START_TIME, MPI_COMM_WORLD);
const int total_nproc=ompi_comm_size(MPI_COMM_WORLD);
INT_POOL=new int[total_nproc*2];
REQ_POOL_SIZE=0;
init_REQ_POOL(1024);
INT_POOL=malloc(total_nproc*2*sizeof(int));
printf("INT_POOL inited\n");
REQ_POOL_SIZE=1024;
REQ_POOL=malloc(1024*sizeof(int));
// debug
printf("REQ_POOL inited\n");
// end debug
// end
return MPI_SUCCESS;
......
......@@ -47,7 +47,6 @@ int MPI_Irecv(void *buf, int count, MPI_Datatype type, int source,
int tag, MPI_Comm comm, MPI_Request *request)
{
// for log messages
const int old_request=MPI_Request_c2f(request);
struct timeval call_time;
gettimeofday(&call_time, NULL);
// end
......@@ -95,10 +94,10 @@ int MPI_Irecv(void *buf, int count, MPI_Datatype type, int source,
// for log messages
const int FUNC_ID=14;
int elemsize;
int MSG_SIZE=LOGMSG_SIZE(type, count, elemsize);
const int new_request=MPI_Request_c2f(request);
const int LOG_ARGC=6;
int LOG_ARGV[LOG_ARGC]={source, count, elemsize, tag, old_request, new_request};
int MSG_SIZE=LOGMSG_SIZE(type, count, &elemsize);
const int request_idx=MPI_Request_c2f(request);
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);
// end
......
......@@ -51,7 +51,6 @@ int MPI_Isend(const void *buf, int count, MPI_Datatype type, int dest,
int tag, MPI_Comm comm, MPI_Request *request)
{
// for log messages
const int old_request=MPI_Request_c2f(request);
struct timeval call_time;
gettimeofday(&call_time, NULL);
// end
......@@ -108,10 +107,10 @@ int MPI_Isend(const void *buf, int count, MPI_Datatype type, int dest,
// for log messages
const int FUNC_ID=15;
int elemsize;
int MSG_SIZE=LOGMSG_SIZE(type, count, elemsize);
const int new_request=MPI_Request_c2f(request);
const int LOG_ARGC=6;
int LOG_ARGV[LOG_ARGC]={dest, count, elemsize, tag, old_request, new_request};
int MSG_SIZE=LOGMSG_SIZE(type, count, &elemsize);
const int request_idx=MPI_Request_c2f(request);
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);
// end
......
......@@ -93,9 +93,9 @@ int MPI_Recv(void *buf, int count, MPI_Datatype type, int source,
// for log messages
const int FUNC_ID=10;
int elemsize;
int MSG_SIZE=LOGMSG_SIZE(type, count, elemsize);
int MSG_SIZE=LOGMSG_SIZE(type, count, &elemsize);
const int LOG_ARGC=4;
int LOG_ARGV[LOG_ARGC]={source, count, elemsize, tag};
int LOG_ARGV[4]={source, count, elemsize, tag};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
// end
......
......@@ -153,11 +153,10 @@ int MPI_Reduce(const void *sendbuf, void *recvbuf, int count,
// for log messages
const int FUNC_ID=11;
const int size = OMPI_COMM_IS_INTER(comm)?ompi_comm_remote_size(comm):ompi_comm_size(comm);
int sendelemsize, recvelemsize;
int LOGMSG_SENDSIZE=LOGMSG_SIZE(sendtype, count, sendelemsize);
int LOGMSG_RECVSIZE=LOGMSG_SIZE(recvtype, count, recvelemsize);
const int LOG_ARGC=5;
int LOG_ARGV[LOG_ARGC]={root, count, sendelemsize, size, MPI_Op_c2f(op)};
int elemsize;
int DATASIZE=LOGMSG_SIZE(datatype, count, &elemsize);
const int LOG_ARGC=4;
int LOG_ARGV[4]={root, count, MPI_Type_c2f(datatype), MPI_Op_c2f(op)};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
// end
......
......@@ -94,9 +94,9 @@ int MPI_Rsend(const void *buf, int count, MPI_Datatype type, int dest, int tag,
// for log messages
const int FUNC_ID=24;
int elemsize;
int MSG_SIZE=LOGMSG_SIZE(type, count, elemsize);
int MSG_SIZE=LOGMSG_SIZE(type, count, &elemsize);
const int LOG_ARGC=4;
int LOG_ARGV[LOG_ARGC]={dest, count, elemsize, tag};
int LOG_ARGV[4]={dest, count, elemsize, tag};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
// end
......
......@@ -181,10 +181,10 @@ int MPI_Scatter(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
const int FUNC_ID=12;
const int size = OMPI_COMM_IS_INTER(comm)?ompi_comm_remote_size(comm):ompi_comm_size(comm);
int sendelemsize, recvelemsize;
int LOGMSG_SENDSIZE=LOGMSG_SIZE(sendtype, sendcount, sendelemsize);
int LOGMSG_RECVSIZE=LOGMSG_SIZE(recvtype, recvcount, recvelemsize);
int LOGMSG_SENDSIZE=LOGMSG_SIZE(sendtype, sendcount, &sendelemsize);
int LOGMSG_RECVSIZE=LOGMSG_SIZE(recvtype, recvcount, &recvelemsize);
const int LOG_ARGC=6;
int LOG_ARGV[LOG_ARGC]={root, sendcount, sendelemsize, recvcount, recvelemsize, size};
int LOG_ARGV[6]={root, sendcount, sendelemsize, recvcount, recvelemsize, size};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
// end
......
......@@ -197,15 +197,5 @@ int MPI_Scatterv(const void *sendbuf, const int sendcounts[], const int displs[]
sendtype, recvbuf, recvcount, recvtype, root, comm,
comm->c_coll->coll_scatterv_module);
// for log messages
const int FUNC_ID=13;
int sendelemsize, recvelemsize;
int LOGMSG_SENDSIZE=LOGMSG_SIZE(sendtype, sendcount, sendelemsize);
int LOGMSG_RECVSIZE=LOGMSG_SIZE(recvtype, recvcount, recvelemsize);
const int LOG_ARGC=6;
int LOG_ARGV[LOG_ARGC]={root, sendcount, sendelemsize, recvcount, recvelemsize, size};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
// end
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
}
......@@ -92,9 +92,9 @@ int MPI_Send(const void *buf, int count, MPI_Datatype type, int dest,
// for log messages
const int FUNC_ID=13;
int elemsize;
int MSG_SIZE=LOGMSG_SIZE(type, count, elemsize);
int MSG_SIZE=LOGMSG_SIZE(type, count, &elemsize);
const int LOG_ARGC=4;
int LOG_ARGV[LOG_ARGC]={dest, count, elemsize, tag};
int LOG_ARGV[4]={dest, count, elemsize, tag};
LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
// end
......
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