Actual source code: plogmpe.c

petsc-3.3-p7 2013-05-11
  2: /*
  3:       PETSc code to log PETSc events using MPE
  4: */
  5: #include <petscsys.h>        /*I    "petscsys.h"   I*/
  6: #if defined(PETSC_USE_LOG) && defined (PETSC_HAVE_MPE)
  7: #include <mpe.h>

  9: PetscBool  UseMPE = PETSC_FALSE;
 10: PetscBool  PetscBeganMPE = PETSC_FALSE;

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

 18:    Collective over PETSC_COMM_WORLD

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

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

 29:    Level: advanced

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

 34: .seealso: PetscLogDump(), PetscLogBegin(), PetscLogAllBegin(), PetscLogEventActivate(),
 35:           PetscLogEventDeactivate()
 36: @*/
 37: PetscErrorCode  PetscLogMPEBegin(void)
 38: {
 40:   PetscMPIInt    rank;
 41: 
 43:   /* Do MPE initialization */
 44:   if (!MPE_Initialized_logging()) { /* This function exists in mpich 1.1.2 and higher */
 45:     PetscInfo(0,"Initializing MPE.\n");
 46:     MPE_Init_log();
 47:     PetscBeganMPE = PETSC_TRUE;
 48:   } else {
 49:     PetscInfo(0,"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: }

 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: PetscErrorCode  PetscLogMPEDump(const char sname[])
 68: {
 69:   char           name[PETSC_MAX_PATH_LEN];

 73:   if (PetscBeganMPE) {
 74:     PetscInfo(0,"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:     PetscInfo(0,"Not finalizing MPE (not started by PETSc).\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: const 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: };

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: PetscErrorCode  PetscLogGetRGBColor(const char *str[])
149: {
150:   static int idx = 0;

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