File: mpil_trace.c

package info (click to toggle)
lam 7.1.4-8
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 56,404 kB
  • sloc: ansic: 156,541; sh: 9,991; cpp: 7,699; makefile: 5,621; perl: 488; fortran: 260; asm: 83
file content (211 lines) | stat: -rw-r--r-- 5,983 bytes parent folder | download | duplicates (11)
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
210
211
/*
 * Copyright (c) 2001-2002 The Trustees of Indiana University.  
 *                         All rights reserved.
 * Copyright (c) 1998-2001 University of Notre Dame. 
 *                         All rights reserved.
 * Copyright (c) 1994-1998 The Ohio State University.  
 *                         All rights reserved.
 * 
 * This file is part of the LAM/MPI software package.  For license
 * information, see the LICENSE file in the top level directory of the
 * LAM/MPI source distribution.
 * 
 * $HEADER$
 *
 * $Id: mpil_trace.c,v 6.5 2002/12/11 19:15:13 jsquyres Exp $
 *
 *	Function:	- toggles tracing status
 */

#include <blktype.h>
#include <mpi.h>
#include <mpisys.h>
#include <terror.h>

/*
 *	MPIL_Trace_on
 *
 *	Function:	- enables tracing; begins segment
 */
/*@

MPIL_Trace_on - LAM/MPI-specific function to enable run-time tracing

Notes:

These functions give the application the flexibility to generate
traces only during certain interesting phases of the application''s
execution.  This technique can considerably reduce the size of the
trace files and burden of displaying them.
 
Both functions are collective over the 'MPI_COMM_WORLD' communicator.
In typical usage, the '-toff' option of 'mpirun'(1) would be used to
enable tracing, but start with the runtime switch in the off position.
At the beginning of an interesting phase of program execution,
'MPIL_Trace_on' would be called.  'MPIL_Trace_off' would be called
after the interesting phase.  Tracing can be turned on and off many
times.  Each period of tracing eventually forms a trace segment in the
trace file extracted by 'lamtrace'(1).  If the on/off functions are
never used and tracing is enabled with the '-ton' option of
'mpirun'(1), a single trace segment is produced.
 
The on/off functions have no effect if tracing is not enabled by
'mpirun'(1) with either the '-ton' or '-toff' switches.  Thus, an
application can be littered with these functions but run without trace
collection and very little additional overhead due to the no-operation
function calls.
 
This is a LAM/MPI-specific function and is intended mainly for
debugging.  If this function is used, it should be used in conjunction
with the 'LAM_MPI' C preprocessor macro

.vb
  #if LAM_MPI
     MPIL_Trace_on();
  #endif
.ve

Limitations:

After the volume of generated traces exceeds a preset limit, the
oldest traces are discarded in favour of new traces.  Avoiding
discarded traces is further incentive to use 'MPIL_Trace_on' and
'MPIL_Trace_off'.

.N fortran

.N Errors
.N MPI_SUCCESS
.N MPI_ERR_OTHER

.seealso: MPI_Trace_off, mpirun
@*/
int MPIL_Trace_on(void)
{
	int		err;			/* error code */
	int		trmodesave;		/* save trace mode */
/*
 * This is a NOP if trace mode is off.
 */
	if ( ! (_kio.ki_rtf & RTF_TRACE)) return(MPI_SUCCESS);

	lam_initerr();
	lam_setfunc(BLKMPILTRACEON);
/*
 * Synchronize. We don't want to trace it though!
 */
	trmodesave = _kio.ki_rtf & RTF_TRSWITCH;
	_kio.ki_rtf &= ~RTF_TRSWITCH;
	
	err = MPI_Barrier(MPI_COMM_WORLD);

	_kio.ki_rtf |= trmodesave;
	
	if (err != MPI_SUCCESS) {
		return(lam_errfunc(MPI_COMM_WORLD, BLKMPILTRACEON, err));
	}
/*
 * Turn tracing on.
 */
	if (lam_tr_on() < 0) {
		return(lam_errfunc(MPI_COMM_WORLD, BLKMPILTRACEON,
				lam_mkerr(MPI_ERR_OTHER, errno)));
	}
	
	lam_resetfunc(BLKMPILTRACEON);
	return(MPI_SUCCESS);
}

/*
 *	MPIL_Trace_off
 *
 *	Function:	- disables tracing; ends segment
 */
/*@

MPIL_Trace_off - LAM/MPI-specific function to disable run-time tracing

Notes:

These functions give the application the flexibility to generate
traces only during certain interesting phases of the application''s
execution.  This technique can considerably reduce the size of the
trace files and burden of displaying them.
 
Both functions are collective over the 'MPI_COMM_WORLD' communicator.
In typical usage, the '-toff' option of 'mpirun'(1) would be used to
enable tracing, but start with the runtime switch in the off position.
At the beginning of an interesting phase of program execution,
'MPIL_Trace_on' would be called.  'MPIL_Trace_off' would be called
after the interesting phase.  Tracing can be turned on and off many
times.  Each period of tracing eventually forms a trace segment in the
trace file extracted by 'lamtrace'(1).  If the on/off functions are
never used and tracing is enabled with the '-ton' option of
'mpirun'(1), a single trace segment is produced.
 
The on/off functions have no effect if tracing is not enabled by
'mpirun'(1) with either the '-ton' or '-toff' switches.  Thus, an
application can be littered with these functions but run without trace
collection and very little additional overhead due to the no-operation
function calls.
 
This is a LAM/MPI-specific function and is intended mainly for
debugging.  If this function is used, it should be used in conjunction
with the 'LAM_MPI' C preprocessor macro

.vb
  #if LAM_MPI
     MPIL_Trace_off();
  #endif
.ve

Limitations:

After the volume of generated traces exceeds a preset limit, the
oldest traces are discarded in favour of new traces.  Avoiding
discarded traces is further incentive to use 'MPIL_Trace_on' and
'MPIL_Trace_off'.

.N fortran

.N Errors
.N MPI_SUCCESS
.N MPI_ERR_OTHER

.seealso: MPI_Trace_on, mpirun
@*/
int MPIL_Trace_off(void)
{
	int		err;			/* error code */
	int		trmodesave;		/* save trace mode */
/*
 * This is a NOP if trace mode is off.
 */
	if ( ! (_kio.ki_rtf & RTF_TRACE)) return(MPI_SUCCESS);
	
	lam_initerr();
	lam_setfunc(BLKMPILTRACEOFF);
/*
 * Synchronize. We don't want to trace it though!
 */
	trmodesave = _kio.ki_rtf & RTF_TRSWITCH;
	_kio.ki_rtf &= ~RTF_TRSWITCH;

	err = MPI_Barrier(MPI_COMM_WORLD);

	_kio.ki_rtf |= trmodesave;

	if (err != MPI_SUCCESS) {
		return(lam_errfunc(MPI_COMM_WORLD, BLKMPILTRACEOFF, err));
	}
/*
 * Turn tracing off.
 */
	if (lam_tr_off() < 0) {
		return(lam_errfunc(MPI_COMM_WORLD, BLKMPILTRACEOFF,
				lam_mkerr(MPI_ERR_OTHER, errno)));
	}
	
	lam_resetfunc(BLKMPILTRACEOFF);
	return(MPI_SUCCESS);
}