File: clog_util.c

package info (click to toggle)
mpich 1.1.0-3
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 22,116 kB
  • ctags: 27,349
  • sloc: ansic: 193,435; sh: 11,172; fortran: 6,545; makefile: 5,801; cpp: 5,020; tcl: 3,548; asm: 3,536; csh: 1,079; java: 614; perl: 183; awk: 168; sed: 70; f90: 62
file content (209 lines) | stat: -rw-r--r-- 6,054 bytes parent folder | download | duplicates (2)
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
199
200
201
202
203
204
205
206
207
208
209
#include "clogimpl.h"

void CLOG_dumplog()
{
    CLOG_BLOCK *block;

    block = CLOG_first;
    while (block) {
	printf("block at 0x%x: \n", (char *) block);
	CLOG_dumpblock(block->data);
	block = block->next;
    }
}

void CLOG_outblock( p )
double *p;
{
    CLOG_dumpblock(p);		/* for the time being */
}

void CLOG_dumpblock( p )
double *p;
{
    int         rtype;
    CLOG_HEADER *h;

    rtype = CLOG_UNDEF;
    while (rtype != CLOG_ENDBLOCK && rtype != CLOG_ENDLOG) {
	h = (CLOG_HEADER *) p;
	rtype = h->rectype;
	
	printf("ts=%f type=", h->timestamp);
	CLOG_rectype(h->rectype); /* print record type */
	printf(" len=%d, pid=%d ", h->length, h->procid);
	p = (double *) (h->rest);	/* skip to end of header */
	switch (rtype) {
	case CLOG_MSGEVENT:
	    printf("et="); CLOG_msgtype(((CLOG_MSG *) p)->etype);
	    printf(" tg=%d ",      ((CLOG_MSG *) p)->tag);
	    printf("prt=%d ",      ((CLOG_MSG *) p)->partner);
	    printf("cm=%d ",       ((CLOG_MSG *) p)->comm);
	    printf("sz=%d ",       ((CLOG_MSG *) p)->size);
	    printf("loc=%d\n",     ((CLOG_MSG *) p)->srcloc);
	    p = (double *)        (((CLOG_MSG *) p)->end);
	    break;
	case CLOG_COLLEVENT:
	    printf("et="); CLOG_colltype(((CLOG_COLL *) p)->etype);
	    printf(" root=%d ",   ((CLOG_COLL *) p)->root);
	    printf("cm=%d ",      ((CLOG_COLL *) p)->comm);
	    printf("sz=%d\n",     ((CLOG_COLL *) p)->size);
	    p = (double *)       (((CLOG_COLL *) p)->end);
	    break;
	case CLOG_SRCLOC:
	    printf("srcid=%d ",    ((CLOG_SRC *) p)->srcloc);
	    printf("line=%d ",     ((CLOG_SRC *) p)->lineno);
	    printf("file=%s\n",    ((CLOG_SRC *) p)->filename);
	    p = (double *)        (((CLOG_SRC *) p)->end);
	    break;
	case CLOG_COMMEVENT:
	    printf("et="); CLOG_commtype(((CLOG_MSG *) p)->etype);
	    printf(" pt=%d ",     ((CLOG_COMM *) p)->parent);
	    printf("ncomm=%d ",   ((CLOG_COMM *) p)->newcomm);
	    printf("srcid=%d\n",  ((CLOG_COMM *) p)->srcloc);
	    p = (double *)       (((CLOG_COMM *) p)->end);
	    break;
	case CLOG_STATEDEF:
	    printf("id=%d ",     ((CLOG_STATE *) p)->stateid);
	    printf("start=%d ",  ((CLOG_STATE *) p)->startetype);
	    printf("end=%d ",    ((CLOG_STATE *) p)->endetype);
	    printf("color=%s ",  ((CLOG_STATE *) p)->color);
	    printf("desc=%s\n",  ((CLOG_STATE *) p)->description);
	    p = (double *)      (((CLOG_STATE *) p)->end);
	    break;
	case CLOG_EVENTDEF:
	    printf("id=%d ",     ((CLOG_EVENT *) p)->etype);
	    printf("desc=%s\n",  ((CLOG_EVENT *) p)->description);
	    p = (double *)      (((CLOG_EVENT *) p)->end);
	    break;
	case CLOG_SHIFT:
	    printf("shift=%f\n",((CLOG_TSHIFT *) p)->timeshift);
	    p = (double *)     (((CLOG_TSHIFT *) p)->end);
	    break;
	case CLOG_RAWEVENT:
	    printf("id=%d ",       ((CLOG_RAW *) p)->etype);
	    printf("data=%d ",     ((CLOG_RAW *) p)->data);
	    printf("srcid=%d ",    ((CLOG_RAW *) p)->srcloc);
	    printf("desc=%s\n",    ((CLOG_RAW *) p)->string);
	    p = (double *)        (((CLOG_RAW *) p)->end);
	    break;
	case CLOG_ENDBLOCK:
	    printf("end of block\n");
	    break;
	case CLOG_ENDLOG:
	    printf("end of log\n");
	    break;
	default:
	    printf("unrecognized record type\n");
	}
    }
}

/*@
     CLOG_reclen - get length (in doubles) of log record by type
@*/
int CLOG_reclen( type )
int type;
{
    int restlen;

    switch (type) {
    case CLOG_ENDLOG:
	restlen = 1; break;
    case CLOG_ENDBLOCK:
	restlen = 1; break;
    case CLOG_MSGEVENT:
	restlen = sizeof(CLOG_MSG) / sizeof(double);	break;
    case CLOG_COLLEVENT:
	restlen = sizeof(CLOG_COLL) / sizeof(double);   break;
    case CLOG_COMMEVENT:
	restlen = sizeof(CLOG_COMM) / sizeof(double);	break;
    case CLOG_EVENTDEF:
	restlen = sizeof(CLOG_EVENT) / sizeof(double);	break;
    case CLOG_STATEDEF:
	restlen = sizeof(CLOG_STATE) / sizeof(double);	break;
    case CLOG_SHIFT:
	restlen = sizeof(CLOG_TSHIFT) / sizeof(double);	break;
    case CLOG_RAWEVENT:
	restlen = sizeof(CLOG_RAW) / sizeof(double);	break;
    case CLOG_SRCLOC:
	restlen = sizeof(CLOG_SRC) / sizeof(double);	break;
    default:
	printf("CLOG: Can't get length of unknown record type %d\n", type);
    }
    /* The above caculation is off by 2 because of the "rest" and "end"
       markers which are overwritten, so we subtract 2 in the next line.
       (For ENDLOG and ENDBLOCK restlen is set to 1 to make this work.) */

    return ( (sizeof(CLOG_HEADER) / sizeof(double)) + restlen - 2 );
}

/*@
     CLOG_msgtype - print communication event type

. etype - event type for pt2pt communication event

@*/
void CLOG_msgtype( etype )
int etype;
{
    switch (etype) {
	/* none predefined */
    default:    printf("unk(%d)", etype);
    }
}

/*@
     CLOG_commtype - print communicator creation event type

. etype - event type for communicator creation event

@*/
void CLOG_commtype( etype )
int etype;
{
    switch (etype) {
    case INIT:   printf("init"); break;
    case DUP:    printf("dup "); break;
    case SPLIT:  printf("splt"); break;
    case CARTCR: printf("crtc"); break;
    case COMMCR: printf("cmmc"); break;
    case CFREE:  printf("free"); break;
    default:     printf("unknown(%d)", etype);
    }
}

void CLOG_colltype( etype )
int etype;
{
    switch (etype) {
        /* none predefined */
    default:      printf("unk(%d)", etype);
    }
}

/*@
     CLOG_rectype - print log record type

. rtype - record type

@*/
void CLOG_rectype( type )
int type;
{
    switch (type) {
    case CLOG_ENDLOG:    printf("elog"); break;
    case CLOG_ENDBLOCK:  printf("eblk"); break;
    case CLOG_UNDEF:     printf("udef"); break;
    case CLOG_MSGEVENT:  printf("msg "); break;
    case CLOG_COLLEVENT: printf("coll"); break;
    case CLOG_COMMEVENT: printf("comm"); break;
    case CLOG_EVENTDEF:  printf("edef"); break;
    case CLOG_STATEDEF:  printf("sdef"); break;
    case CLOG_SRCLOC:    printf("loc "); break;
    case CLOG_SHIFT:     printf("shft"); break;
    case CLOG_RAWEVENT:  printf("raw "); break;
    default:             printf("unknown(%d)", type);
    }
}