1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
|
/* mpe_log.c - the externally callable functions in MPE_Log
New version to use CLOG - Bill Gropp and Rusty Lusk
*/
#include "clog.h"
#include "clog_merge.h"
#include "mpi.h" /* why? */
#include "mpe.h" /* why? */
#include "mpe_log.h"
/* why this? */
#ifdef USE_PMPI
#define MPI_BUILD_PROFILING
#include "mpiprof.h"
#endif
/* temporarily borrowed from mpe_log_genproc.h */ /* try to replace by CLOG */
int MPE_Log_hasBeenInit = 0;
int MPE_Log_hasBeenClosed = 0;
int MPE_Log_clockIsRunning = 0;
int MPE_Log_isLockedOut = 0;
int MPE_Log_AdjustedTimes = 0;
#define MPE_HAS_PROCID
static int MPE_Log_procid;
/* end of borrowing */
/*@
MPE_Init_log - Initialize for logging
Notes:
Initializes the MPE logging package. This must be called before any of
the other MPE logging routines.
.seealso: MPE_Finish_log
@*/
int MPE_Init_log()
{
if (!MPE_Log_hasBeenInit || MPE_Log_hasBeenClosed) {
MPI_Comm_rank( MPI_COMM_WORLD, &MPE_Log_procid ); /* get process ID */
CLOG_Init();
CLOG_LOGCOMM(INIT, -1, (int) MPI_COMM_WORLD);
MPE_Log_hasBeenInit = 1; /* set MPE_Log as being initialized */
MPE_Log_hasBeenClosed = 0;
MPE_Log_isLockedOut = 0;
}
return MPE_Log_OK;
}
/*@
MPE_Start_log - Begin logging of events
@*/
int MPE_Start_log()
{
if (!MPE_Log_hasBeenInit) return MPE_Log_NOT_INITIALIZED;
CLOG_status = 0;
MPE_Log_isLockedOut = 0;
return MPE_Log_OK;
}
/*@
MPE_Stop_log - Stop logging events
@*/
int MPE_Stop_log()
{
if (!MPE_Log_hasBeenInit) return MPE_Log_NOT_INITIALIZED;
MPE_Log_isLockedOut = 1;
CLOG_status = 1;
return MPE_Log_OK;
}
/*@
MPE_Describe_state - Create log record describing a state
Notes:
Adds string containing a state def to the logfile. The format of the
def is (LOG_STATE_DEF) 0 sevent eevent 0 0 "color" "name".
.seealso: MPE_Log_get_event_number
@*/
int MPE_Describe_state( start, end, name, color )
int start, end;
char *name, *color;
{
int stateid;
if (!MPE_Log_hasBeenInit) return MPE_Log_NOT_INITIALIZED;
stateid = CLOG_get_new_state();
CLOG_LOGSTATE( stateid, start, end, color, name);
return MPE_Log_OK;
}
/*@
MPE_Describe_event - Create log record describing an event type
Input Parameters:
. event - Event number
. name - String describing the event.
.seealso: MPE_Log_get_event_number
@*/
int MPE_Describe_event( event, name )
int event;
char *name;
{
if (!MPE_Log_hasBeenInit) return MPE_Log_NOT_INITIALIZED;
CLOG_LOGEVENT( event, name);
return MPE_Log_OK;
}
/*@
MPE_Log_get_event_number - Gets an unused event number
Returns:
A value that can be provided to MPE_Describe_event or MPE_Describe_state
which will define an event or state not used before.
Notes:
This routine is provided to allow packages to ensure that they are
using unique event numbers. It relies on all packages using this
routine.
@*/
int MPE_Log_get_event_number( )
{
return CLOG_get_new_event();
}
/*@
MPE_Log_send - Logs the sending of a message
@*/
int MPE_Log_send( otherParty, tag, size )
int otherParty, tag, size;
{
char comment[20];
sprintf(comment, "%d %d", tag, size);
CLOG_LOGRAW( LOG_MESG_SEND, otherParty, comment );
return MPE_Log_OK;
}
/*@
MPE_Log_receive - log the sending of a message
@*/
int MPE_Log_receive( otherParty, tag, size )
int otherParty, tag, size;
{
char comment[20];
sprintf(comment, "%d %d", tag, size);
CLOG_LOGRAW( LOG_MESG_RECV, otherParty, comment );
return MPE_Log_OK;
}
/*@
MPE_Log_event - Logs an event
Input Parameters:
. event - Event number
. data - Integer data value
. string - Optional string describing event
@*/
int MPE_Log_event(event,data,string)
int event, data;
char *string;
{
CLOG_LOGRAW( event, data, string );
return MPE_Log_OK;
}
/*@
MPE_Finish_log - Send log to master, who writes it out
Notes:
This routine dumps a logfile in clog format
@*/
int MPE_Finish_log( filename )
char *filename;
{
int shift;
int *is_globalp, flag;
CLOG_Finalize();
MPI_Attr_get( MPI_COMM_WORLD, MPI_WTIME_IS_GLOBAL, &is_globalp, &flag );
if (!flag || (is_globalp && !*is_globalp))
shift = CMERGE_SHIFT;
else
shift = CMERGE_NOSHIFT;
CLOG_mergelogs(shift, filename, ALOG_LOG ); /* for time being always alog*/
return MPE_Log_OK;
}
|