Actual source code: plogmpe.c

  1: #define PETSC_DLL
  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;

 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

 37: @*/
 38: PetscErrorCode  PetscLogMPEBegin(void)
 39: {
 41:   int        rank;
 42: 
 44:   /* Do MPE initialization */
 45:   if (!MPE_Initialized_logging()) { /* This function exists in mpich 1.1.2 and higher */
 46:     PetscInfo(0,"Initializing MPE.\n");
 47:     MPE_Init_log();
 48:     PetscBeganMPE = PETSC_TRUE;
 49:   } else {
 50:     PetscInfo(0,"MPE already initialized. Not attempting to reinitialize.\n");
 51:   }
 52:   MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
 53:   UseMPE = PETSC_TRUE;
 54:   return(0);
 55: }

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

 62:    Collective over PETSC_COMM_WORLD

 64:    Level: advanced

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

 74:   if (PetscBeganMPE) {
 75:     PetscInfo(0,"Finalizing MPE.\n");
 76:     if (sname) { PetscStrcpy(name,sname);}
 77:     else { PetscGetProgramName(name,PETSC_MAX_PATH_LEN);}
 78:     MPE_Finish_log(name);
 79:   } else {
 80:     PetscInfo(0,"Not finalizing MPE (not started by PETSc).\n");
 81:   }
 82:   return(0);
 83: }

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


 88: /* Color function used by MPE */


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

136: /*@C
138:   
139:   Not collective. Maybe it should be?

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

144:   Level: beginner

146: .keywords: log, mpe , color
148: @*/
149: PetscErrorCode  PetscLogGetRGBColor(const char *str[])
150: {
151:   static int idx = 0;

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