Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: [OMPI users] Application logging
From: Alberto Giannetti (albertogiannetti_at_[hidden])
Date: 2008-05-07 12:33:59


I need to log application-level messages on disk to trace my program
activity. For better performances, one solution is to dedicate one
processor to the actual I/O logging, while the other working
processors would trace their activity through non-blocking, string
message sends:

/* LOGGER PROCESSOR MAIN LOOP */
void logger(void)
{
   MPI_Status status;
   char buf[LOGMSG_MAXSIZE];

   printf("Logger: Started\n");

   while( 1 ) {
     MPI_Recv(&buf, LOGMSG_MAXSIZE, MPI_CHAR, MPI_ANY_SOURCE,
LOGMSG_TAG, MPI_COMM_WORLD, &status);
     buf[status.count] = '\0';
     /* ACTUAL I/O */
     printf("Processor %d ==> %s\n", status.MPI_SOURCE, buf);
   }
}

/* WORKER PROCESSOR LOGGING */
void mylog(char* msg)
{
   MPI_Request req;
   int msglen = strlen(msg);

   if( msglen > LOGMSG_MAXSIZE ) {
     /* Truncate */
     msg[LOGMSG_MAXSIZE-1] = '\0';
     msglen = LOGMSG_MAXSIZE;
   }

   /* Non-blocking send */
   MPI_Isend(msg, msglen, MPI_CHAR, LOGGER, LOGMSG_TAG,
MPI_COMM_WORLD, &req);
}

I figured this must be a common problem in MPI applications and was
wondering if there is any library available or related discussions.