Actual source code: plogmpe.c

  1: /*$Id: plogmpe.c,v 1.58 2001/05/29 16:34:36 bsmith Exp $*/
  2: /*
  3:       PETSc code to log PETSc events using MPE
  4: */
 5:  #include petsc.h
  6: #if defined(PETSC_USE_LOG) && defined (PETSC_HAVE_MPE)
 7:  #include petscsys.h
  8: #include "mpe.h"

 10: PetscTruth UseMPE = PETSC_FALSE;
 11: PetscTruth PetscBeganMPE = PETSC_FALSE;

 13: /*@C
 14:    PetscLogMPEBegin - Turns on MPE logging of events. This creates large log files 
 15:    and slows the program down.

 17:    Collective over PETSC_COMM_WORLD

 19:    Options Database Keys:
 20: . -log_mpe - Prints extensive log information (for code compiled
 21:              with PETSC_USE_LOG)

 23:    Notes:
 24:    A related routine is PetscLogBegin (with the options key -log), which is 
 25:    intended for production runs since it logs only flop rates and object
 26:    creation (and should not significantly slow the programs).

 28:    Level: advanced

 30:    Concepts: logging^MPE
 31:    Concepts: logging^message passing

 33: .seealso: PetscLogDump(), PetscLogBegin(), PetscLogAllBegin(), PetscLogEventActivate(),
 34:           PetscLogEventDeactivate()
 35: @*/
 36: int PetscLogMPEBegin(void)
 37: {
 38:   int        rank,ierr;
 39: 
 41:   /* Do MPE initialization */
 42:   if (!MPE_Initialized_logging()) { /* This function exists in mpich 1.1.2 and higher */
 43:     PetscLogInfo(0,"PetscLogMPEBegin: Initializing MPE.n");
 44:     MPE_Init_log();
 45:     PetscBeganMPE = PETSC_TRUE;
 46:   } else {
 47:     PetscLogInfo(0,"PetscLogMPEBegin: MPE already initialized. Not attempting to reinitialize.n");
 48:   }
 49:   MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
 50:   UseMPE = PETSC_TRUE;
 51:   return(0);
 52: }

 54: /*@C
 55:    PetscLogMPEDump - Dumps the MPE logging info to file for later use with Upshot.

 57:    Collective over PETSC_COMM_WORLD

 59:    Level: advanced

 61: .seealso: PetscLogDump(), PetscLogAllBegin(), PetscLogMPEBegin()
 62: @*/
 63: int PetscLogMPEDump(const char sname[])
 64: {
 65:   char name[256];
 66:   int  ierr;

 69:   if (PetscBeganMPE) {
 70:     PetscLogInfo(0,"PetscLogMPEDump: Finalizing MPE.n");
 71:     if (sname) { PetscStrcpy(name,sname);}
 72:     else { PetscGetProgramName(name,256);}
 73:     MPE_Finish_log(name);
 74:   } else {
 75:     PetscLogInfo(0,"PetscLogMPEDump: Not finalizing MPE.n");
 76:   }
 77:   return(0);
 78: }

 80: #endif /* PETSC_USE_LOG && PETSC_HAVE_MPE */


 83: /* Color function used by MPE */


 86: #define PETSC_RGB_COLOR_MAX 39
 87: char *(PetscRGBColor[PETSC_RGB_COLOR_MAX]) = {
 88:   "OliveDrab:      ",
 89:   "BlueViolet:     ",
 90:   "CadetBlue:      ",
 91:   "CornflowerBlue: ",
 92:   "DarkGoldenrod:  ",
 93:   "DarkGreen:      ",
 94:   "DarkKhaki:      ",
 95:   "DarkOliveGreen: ",
 96:   "DarkOrange:     ",
 97:   "DarkOrchid:     ",
 98:   "DarkSeaGreen:   ",
 99:   "DarkSlateGray:  ",
100:   "DarkTurquoise:  ",
101:   "DeepPink:       ",
102:   "DarkKhaki:      ",
103:   "DimGray:        ",
104:   "DodgerBlue:     ",
105:   "GreenYellow:    ",
106:   "HotPink:        ",
107:   "IndianRed:      ",
108:   "LavenderBlush:  ",
109:   "LawnGreen:      ",
110:   "LemonChiffon:   ",
111:   "LightCoral:     ",
112:   "LightCyan:      ",
113:   "LightPink:      ",
114:   "LightSalmon:    ",
115:   "LightSlateGray: ",
116:   "LightYellow:    ",
117:   "LimeGreen:      ",
118:   "MediumPurple:   ",
119:   "MediumSeaGreen: ",
120:   "MediumSlateBlue:",
121:   "MidnightBlue:   ",
122:   "MintCream:      ",
123:   "MistyRose:      ",
124:   "NavajoWhite:    ",
125:   "NavyBlue:       ",
126:   "OliveDrab:      "
127: };

129: /*@C
130:   PetscLogGetRGBColor - This routine returns a rgb color useable with PetscLogEventRegister()
131:   
132:   Not collective. Maybe it should be?

134:   Output Parameter
135: . str - charecter string representing the color

137:   Level: beginner

139: .keywords: log, mpe , color
140: .seealso: PetscLogEventRegister
141: @*/
142: int PetscLogGetRGBColor(char **str)
143: {
144:   static int index = 0;

147:   *str  = PetscRGBColor[index];
148:   index = (index + 1)% PETSC_RGB_COLOR_MAX;
149:   return(0);
150: }