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: #undef __FUNCT__  
 15: /*@C
 16:    PetscLogMPEBegin - Turns on MPE logging of events. This creates large log files 
 17:    and slows the program down.

 19:    Collective over PETSC_COMM_WORLD

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

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

 30:    Level: advanced

 32:    Concepts: logging^MPE
 33:    Concepts: logging^message passing

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

 56: #undef __FUNCT__  
 58: /*@C
 59:    PetscLogMPEDump - Dumps the MPE logging info to file for later use with Upshot.

 61:    Collective over PETSC_COMM_WORLD

 63:    Level: advanced

 65: .seealso: PetscLogDump(), PetscLogAllBegin(), PetscLogMPEBegin()
 66: @*/
 67: int PetscLogMPEDump(const char sname[])
 68: {
 69:   char name[PETSC_MAX_PATH_LEN];
 70:   int  ierr;

 73:   if (PetscBeganMPE) {
 74:     PetscLogInfo(0,"PetscLogMPEDump: Finalizing MPE.n");
 75:     if (sname) { PetscStrcpy(name,sname);}
 76:     else { PetscGetProgramName(name,PETSC_MAX_PATH_LEN);}
 77:     MPE_Finish_log(name);
 78:   } else {
 79:     PetscLogInfo(0,"PetscLogMPEDump: Not finalizing MPE.n");
 80:   }
 81:   return(0);
 82: }

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


 87: /* Color function used by MPE */


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

133: #undef __FUNCT__  
135: /*@C
136:   PetscLogGetRGBColor - This routine returns a rgb color useable with PetscLogEventRegister()
137:   
138:   Not collective. Maybe it should be?

140:   Output Parameter
141: . str - charecter string representing the color

143:   Level: beginner

145: .keywords: log, mpe , color
146: .seealso: PetscLogEventRegister
147: @*/
148: int PetscLogGetRGBColor(char **str)
149: {
150:   static int idx = 0;

153:   *str  = PetscRGBColor[idx];
154:   idx = (idx + 1)% PETSC_RGB_COLOR_MAX;
155:   return(0);
156: }