Commit 055e7496 authored by Shen Yu's avatar Shen Yu
Browse files

modified: _MSGLOG_.h

	modified:   bcast.c
	modified:   gatherv.c
	modified:   init.c
change log directory to date and time
	modified:   ../../../../readme.md
	modified:   ../../../../replayer/mpi_player.cpp
finish programming, wait for test
parent 67979ad7
......@@ -10,6 +10,7 @@ extern int LOGMSGMYID;
extern int* INT_POOL;
extern int REQ_POOL_SIZE;
extern int* REQ_POOL;
extern bool LOGTHIS;
//inline void LOGMSG(const char FUNCNAME[], const struct timeval call_time, const MPI_Comm COMM,
// const int DSTPROC, const int SENDSIZE,
// const int SRCPROC, const int RECVSIZE);
......@@ -31,7 +32,7 @@ inline void LOGMSG0(const int FUNC_ID, const struct timeval call_time, const MPI
double ENDTIME = (end_time.tv_sec - START_TIME.tv_sec) +
(end_time.tv_usec - START_TIME.tv_usec)/1000000.0;
fprintf(MSGLOGFILE, "%lf, %lf, %d, %d",
fprintf(MSGLOGFILE, "%lf, %lf, %d, %d\n",
CALLTIME, ENDTIME, FUNC_ID, MPI_Comm_c2f(COMM));
}
......@@ -128,35 +129,6 @@ inline void free_REQ_POOL()
free(REQ_POOL);
REQ_POOL_SIZE=0;
}
/* replaced by MPI_Op_c2f
inline int MPI_Op_index(MPI_Op op)
{
int idx;
if(op == MPI_MAX)
idx=0;
else if(op == MPI_MIN)
idx=1;
else if(op == MPI_SUM)
idx=1;
else if(op == MPI_PROD)
idx=2;
else if(op == MPI_LAND)
idx=3;
else if(op == MPI_RAND)
idx=4;
else if(op == MPI_LOR)
idx=5;
else if(op == MPI_BOR)
idx=6;
else if(op == MPI_LXOR)
idx=7;
else if(op == MPI_BXOR)
idx=8;
else if(op == MPI_MAXLOC)
idx=9;
else if(op == MPI_MINLOC)
idx=10;
return idx;
}*/
#endif
// end
......@@ -129,7 +129,7 @@ int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype,
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);
if(LOGTHIS) LOGMSG1(FUNC_ID, call_time, comm, LOG_ARGC, LOG_ARGV);
// end
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
......
......@@ -215,7 +215,7 @@ 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, LOG_ARGV, size, recvelemsizelist);
LOGMSG2(FUNC_ID, call_time, comm, LOG_ARGC, size, LOG_ARGV, recvelemsizelist);
// end
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
......
......@@ -32,6 +32,10 @@
#include "ompi/constants.h"
// for log messages
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include "ompi/mpi/c/_MSGLOG_.h"
struct timeval START_TIME;
FILE* MSGLOGFILE;
......@@ -39,6 +43,7 @@ int LOGMSGMYID;
int* INT_POOL;
int REQ_POOL_SIZE;
int* REQ_POOL;
bool LOGTHIS;
// end
#if OMPI_BUILD_MPI_PROFILING
......@@ -102,40 +107,47 @@ int MPI_Init(int *argc, char ***argv)
// for log messages
// initialize
// set log position
char logfilepath[4000];
// process 0 set directory and bcast to others
MPI_Comm_rank(MPI_COMM_WORLD, &LOGMSGMYID);
if(LOGMSGMYID == 0)
{
char *inputlogpath;
inputlogpath=getenv("MSGLOGPATH");
if(inputlogpath == NULL)
inputlogpath="/tmp";
if(strlen(inputlogpath) > 3900)
inputlogpath="/tmp";
char datetime[40];
time_t t=START_TIME.tv_sec;
struct tm *info=localtime(&t);
strftime(datetime, sizeof datetime, "%Y%m%d%H%M%S", info);
sprintf(logfilepath, "%s/%s", inputlogpath, datetime);
printf("logfilepath=%s\n",logfilepath);
}
LOGTHIS=false;
MPI_Bcast(logfilepath, 4000, MPI_CHAR, 0, MPI_COMM_WORLD);
LOGTHIS=true;
// every process set its onw file name with hostname and pid
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";
// debug
printf("logfilepath=%s\n",logfilepath);
// end debug
char logfilename[4096];
if (NULL != (env = getenv("OMPI_COMM_WORLD_RANK"))) {
LOGMSGMYID = atoi(env);
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[0], "%s/%d/MSGLOG.%s.%d.csv", logfilepath, (int)(START_TIME.tv_sec/100), HOSTNAME, LOGMSGMYID);
}
else
{
sprintf(&logfilename[0], "%s/%d/MSGLOG.%s.csv", logfilepath, (int)(START_TIME.tv_sec/100), HOSTNAME);
sprintf(logfilename, "%s/MSGLOG.%s.%d.csv", logfilepath, HOSTNAME, LOGMSGMYID);
// if the directory is not existed, make it and open the file
struct stat st = {0};
if (stat(logfilepath, &st) == -1) {
mkdir(logfilepath, 0700);
}
// debug
printf("logfilename=%s\n",logfilename);
// end debug
MSGLOGFILE=fopen(logfilename, "w+");
// set start time
const int FUNC_ID=0;
LOGMSG0(FUNC_ID, START_TIME, MPI_COMM_WORLD);
const int total_nproc=ompi_comm_size(MPI_COMM_WORLD);
......@@ -143,9 +155,6 @@ int MPI_Init(int *argc, char ***argv)
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;
......
......@@ -31,16 +31,16 @@ MPI_COMM_WORLD.
2. `MPI_Allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, const int recvcounts[],
const int displs[], MPI_Datatype recvtype, MPI_Comm comm)`
- send data number
- send data count
- send data element size
- recv data size list
3. `MPI_Allreduce(const void *sendbuf, void *recvbuf, int count,
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)`
- send data count
- send data element size
- recv data element size
- data count
- data type
- reduce op
- *NOTICE: User definded datatypes or overloaded operations are not supported now*
4. `MPI_Alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype,
......@@ -101,10 +101,10 @@ MPI_COMM_WORLD.
11. `MPI_Reduce(const void *sendbuf, void *recvbuf, int count,
MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)`
- root rank
- send data count
- send data element size
- comm size
- data count
- data type
- reduce op
- *NOTICE: User definded datatypes or overloaded operations are not supported now*
12. `MPI_Scatter(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype,
......@@ -129,8 +129,7 @@ MPI_COMM_WORLD.
- data count
- element size
- tag
- old request
- new request
- request
15. `MPI_Isend(const void *buf, int count, MPI_Datatype type, int dest,
int tag, MPI_Comm comm, MPI_Request *request)`
......
This diff is collapsed.
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