ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
sltimer.f
Go to the documentation of this file.
1  SUBROUTINE slboot()
2 *
3 * -- ScaLAPACK tools routine (version 1.7) --
4 * University of Tennessee, Knoxville, Oak Ridge National Laboratory,
5 * and University of California, Berkeley.
6 * May 1, 1997
7 *
8 * Purpose
9 * =======
10 *
11 * SLBOOT (re)sets all timers to 0, and enables SLtimer.
12 *
13 * =====================================================================
14 *
15 * .. Parameters ..
16  INTEGER NTIMER
17  parameter( ntimer = 64 )
18  DOUBLE PRECISION STARTFLAG, ZERO
19  parameter( startflag = -5.0d+0, zero = 0.0d+0 )
20 * ..
21 * .. Local Scalars ..
22  INTEGER I
23 * ..
24 * .. Common Blocks ..
25  LOGICAL DISABLED
26  DOUBLE PRECISION CPUSEC( NTIMER ), CPUSTART( NTIMER ),
27  $ WALLSEC( NTIMER ), WALLSTART( NTIMER )
28  COMMON /sltimer00/ cpusec, wallsec, cpustart, wallstart, disabled
29 * ..
30 * .. Executable Statements ..
31 *
32  disabled = .false.
33  DO 10 i = 1, ntimer
34  cpusec( i ) = zero
35  wallsec( i ) = zero
36  cpustart( i ) = startflag
37  wallstart( i ) = startflag
38  10 CONTINUE
39 *
40  RETURN
41 *
42 * End of SLBOOT
43 *
44  END
45 *
46  SUBROUTINE sltimer( I )
47 *
48 * -- ScaLAPACK tools routine (version 1.7) --
49 * University of Tennessee, Knoxville, Oak Ridge National Laboratory,
50 * and University of California, Berkeley.
51 * May 1, 1997
52 *
53 * .. Scalar Arguments ..
54  INTEGER I
55 * ..
56 *
57 * Purpose
58 * =======
59 *
60 * SLtimer provides a "stopwatch" functionality cpu/wall timer
61 * (in seconds). Up to 64 separate timers can be functioning at once.
62 * The first call starts the timer, and the second stops it. This
63 * routine can be disenabled, so that calls to the timer are ignored.
64 * This feature can be used to make sure certain sections of code do
65 * not affect timings, even if they call routines which have SLtimer
66 * calls in them.
67 *
68 * Arguments
69 * =========
70 *
71 * I (global input) INTEGER
72 * The timer to stop/start.
73 *
74 * =====================================================================
75 *
76 * .. Parameters ..
77  INTEGER NTIMER
78  parameter( ntimer = 64 )
79  DOUBLE PRECISION STARTFLAG
80  parameter( startflag = -5.0d+0 )
81 * ..
82 * .. External Functions ..
83  DOUBLE PRECISION DCPUTIME00, DWALLTIME00
84  EXTERNAL dcputime00, dwalltime00
85 * ..
86 * .. Common Blocks ..
87  LOGICAL DISABLED
88  DOUBLE PRECISION CPUSEC( NTIMER ), CPUSTART( NTIMER ),
89  $ WALLSEC( NTIMER ), WALLSTART( NTIMER )
90  COMMON /sltimer00/ cpusec, wallsec, cpustart, wallstart, disabled
91 * ..
92 * .. Executable Statements ..
93 *
94 * If timing disabled, return
95 *
96  IF( disabled )
97  $ RETURN
98 *
99  IF( wallstart( i ).EQ.startflag ) THEN
100 *
101 * If timer has not been started, start it
102 *
103  wallstart( i ) = dwalltime00()
104  cpustart( i ) = dcputime00()
105 *
106  ELSE
107 *
108 * Stop timer and add interval to count
109 *
110  cpusec( i ) = cpusec( i ) + dcputime00() - cpustart( i )
111  wallsec( i ) = wallsec( i ) + dwalltime00() - wallstart( i )
112  wallstart( i ) = startflag
113 *
114  END IF
115 *
116  RETURN
117 *
118 * End of SLTIMER
119 *
120  END
121 *
122  SUBROUTINE slenable()
123 *
124 * -- ScaLAPACK tools routine (version 1.7) --
125 * University of Tennessee, Knoxville, Oak Ridge National Laboratory,
126 * and University of California, Berkeley.
127 * May 1, 1997
128 *
129 * Purpose
130 * =======
131 *
132 * SLENABLE sets it so calls to SLtimer are not ignored.
133 *
134 * =====================================================================
135 *
136 * .. Parameters ..
137  INTEGER NTIMER
138  parameter( ntimer = 64 )
139 * ..
140 * .. Common Blocks ..
141  LOGICAL DISABLED
142  DOUBLE PRECISION CPUSEC( NTIMER ), CPUSTART( NTIMER ),
143  $ WALLSEC( NTIMER ), WALLSTART( NTIMER )
144  COMMON /sltimer00/ cpusec, wallsec, cpustart, wallstart, disabled
145 * ..
146 * .. Executable Statements ..
147 *
148  disabled = .false.
149 *
150  RETURN
151 *
152  END
153 *
154  SUBROUTINE sldisable()
155 *
156 * -- ScaLAPACK tools routine (version 1.7) --
157 * University of Tennessee, Knoxville, Oak Ridge National Laboratory,
158 * and University of California, Berkeley.
159 * May 1, 1997
160 *
161 * Purpose
162 * =======
163 *
164 * SLDISABLE sets it so calls to SLTIMER are ignored.
165 *
166 * =====================================================================
167 *
168 * .. Parameters ..
169  INTEGER NTIMER
170  parameter( ntimer = 64 )
171 * ..
172 * .. Common Blocks ..
173  LOGICAL DISABLED
174  DOUBLE PRECISION CPUSEC( NTIMER ), CPUSTART( NTIMER ),
175  $ WALLSEC( NTIMER ), WALLSTART( NTIMER )
176  COMMON /sltimer00/ cpusec, wallsec, cpustart, wallstart, disabled
177 * ..
178 * .. Executable Statements ..
179 *
180  disabled = .true.
181 *
182  RETURN
183 *
184 * End of SLDISABLE
185 *
186  END
187 *
188  DOUBLE PRECISION FUNCTION slinquire( TIMETYPE, I )
189 *
190 * -- ScaLAPACK tools routine (version 1.7) --
191 * University of Tennessee, Knoxville, Oak Ridge National Laboratory,
192 * and University of California, Berkeley.
193 * May 1, 1997
194 *
195 * .. Scalar Arguments ..
196  CHARACTER*1 timetype
197  INTEGER i
198 * ..
199 *
200 * Purpose
201 * =======
202 *
203 * SLINQUIRE returns wall or cpu time that has accumulated in timer I.
204 *
205 * Arguments
206 * =========
207 *
208 * TIMETYPE (global input) CHARACTER
209 * Controls what time will be returned:
210 * = 'W': wall clock time is returned,
211 * = 'C': CPU time is returned (default).
212 *
213 * I (global input) INTEGER
214 * The timer to return.
215 *
216 * =====================================================================
217 *
218 * .. Parameters ..
219  INTEGER ntimer
220  parameter( ntimer = 64 )
221  DOUBLE PRECISION errflag
222  parameter( errflag = -1.0d+0 )
223 * ..
224 * .. Local Scalars ..
225  DOUBLE PRECISION time
226 * ..
227 * .. External Functions ..
228  LOGICAL lsame
229  DOUBLE PRECISION dcputime00, dwalltime00
230  EXTERNAL dcputime00, dwalltime00, lsame
231 * ..
232 * .. Common Blocks ..
233  LOGICAL disabled
234  DOUBLE PRECISION cpusec( ntimer ), cpustart( ntimer ),
235  $ wallsec( ntimer ), wallstart( ntimer )
236  COMMON /sltimer00/ cpusec, wallsec, cpustart, wallstart, disabled
237 * ..
238 * .. Executable Statements ..
239 *
240  IF( lsame( timetype, 'W' ) ) THEN
241 *
242 * If walltime not available on this machine, return -1 flag
243 *
244  IF( dwalltime00().EQ.errflag ) THEN
245  time = errflag
246  ELSE
247  time = wallsec( i )
248  END IF
249  ELSE
250  IF( dcputime00().EQ.errflag ) THEN
251  time = errflag
252  ELSE
253  time = cpusec( i )
254  END IF
255  END IF
256 *
257  slinquire = time
258 *
259  RETURN
260 *
261 * End of SLINQUIRE
262 *
263  END
264 *
265  SUBROUTINE slcombine( ICTXT, SCOPE, OP, TIMETYPE, N, IBEG,
266  $ TIMES )
267 *
268 * -- ScaLAPACK tools routine (version 1.7) --
269 * University of Tennessee, Knoxville, Oak Ridge National Laboratory,
270 * and University of California, Berkeley.
271 * May 1, 1997
272 *
273 * .. Scalar Arguments ..
274  CHARACTER OP, SCOPE, TIMETYPE
275  INTEGER IBEG, ICTXT, N
276 * ..
277 * .. Array Arguments ..
278  DOUBLE PRECISION TIMES( N )
279 * ..
280 *
281 * Purpose
282 * =======
283 *
284 * SLCOMBINE takes the timing information stored on a scope of processes
285 * and combines them into the user's TIMES array.
286 *
287 * Arguments
288 * =========
289 *
290 * ICTXT (local input) INTEGER
291 * The BLACS context handle.
292 *
293 * SCOPE (global input) CHARACTER
294 * Controls what processes in grid participate in combine.
295 * Options are 'Rowwise', 'Columnwise', or 'All'.
296 *
297 * OP (global input) CHARACTER
298 * Controls what combine should be done:
299 * = '>': get maximal time on any process (default),
300 * = '<': get minimal time on any process,
301 * = '+': get sum of times across processes.
302 *
303 * TIMETYPE (global input) CHARACTER
304 * Controls what time will be returned in TIMES:
305 * = 'W': wall clock time,
306 * = 'C': CPU time (default).
307 *
308 * N (global input) INTEGER
309 * The number of timers to combine.
310 *
311 * IBEG (global input) INTEGER
312 * The first timer to be combined.
313 *
314 * TIMES (global output) DOUBLE PRECISION array, dimension (N)
315 * The requested timing information is returned in this array.
316 *
317 * =====================================================================
318 *
319 * .. Parameters ..
320  INTEGER NTIMER
321  parameter( ntimer = 64 )
322  DOUBLE PRECISION ERRFLAG
323  parameter( errflag = -1.0d+0 )
324 * ..
325 * .. Local Scalars ..
326  LOGICAL TMPDIS
327  INTEGER I
328 * ..
329 * .. External Subroutines ..
330  EXTERNAL dgamx2d, dgamn2d, dgsum2d
331 * ..
332 * .. External Functions ..
333  LOGICAL LSAME
334  DOUBLE PRECISION DCPUTIME00, DWALLTIME00
335  EXTERNAL dcputime00, dwalltime00, lsame
336 * ..
337 * .. Common Blocks ..
338  LOGICAL DISABLED
339  DOUBLE PRECISION CPUSEC( NTIMER ), CPUSTART( NTIMER ),
340  $ wallsec( ntimer ), wallstart( ntimer )
341  COMMON /sltimer00/ cpusec, wallsec, cpustart, wallstart, disabled
342 * ..
343 * .. Executable Statements ..
344 *
345 * Disable timer for combine operation
346 *
347  tmpdis = disabled
348  disabled = .true.
349 *
350 * Copy timer information into user's times array
351 *
352  IF( lsame( timetype, 'W' ) ) THEN
353 *
354 * If walltime not available on this machine, fill in times
355 * with -1 flag, and return
356 *
357  IF( dwalltime00().EQ.errflag ) THEN
358  DO 10 i = 1, n
359  times( i ) = errflag
360  10 CONTINUE
361  RETURN
362  ELSE
363  DO 20 i = 1, n
364  times( i ) = wallsec( ibeg + i - 1 )
365  20 CONTINUE
366  END IF
367  ELSE
368  IF( dcputime00().EQ.errflag ) THEN
369  DO 30 i = 1, n
370  times( i ) = errflag
371  30 CONTINUE
372  RETURN
373  ELSE
374  DO 40 i = 1, n
375  times( i ) = cpusec( ibeg + i - 1 )
376  40 CONTINUE
377  END IF
378  ENDIF
379 *
380 * Combine all nodes' information, restore disabled, and return
381 *
382  IF( op.EQ.'>' ) THEN
383  CALL dgamx2d( ictxt, scope, ' ', n, 1, times, n, -1, -1,
384  $ -1, -1, 0 )
385  ELSE IF( op.EQ.'<' ) THEN
386  CALL dgamn2d( ictxt, scope, ' ', n, 1, times, n, -1, -1,
387  $ -1, -1, 0 )
388  ELSE IF( op.EQ.'+' ) THEN
389  CALL dgsum2d( ictxt, scope, ' ', n, 1, times, n, -1, 0 )
390  ELSE
391  CALL dgamx2d( ictxt, scope, ' ', n, 1, times, n, -1, -1,
392  $ -1, -1, 0 )
393  END IF
394 *
395  disabled = tmpdis
396 *
397  RETURN
398 *
399 * End of SLCOMBINE
400 *
401  END
sltimer
subroutine sltimer(I)
Definition: sltimer.f:47
sldisable
subroutine sldisable()
Definition: sltimer.f:155
lsame
logical function lsame(CA, CB)
Definition: tools.f:1724
slboot
subroutine slboot()
Definition: sltimer.f:2
slenable
subroutine slenable()
Definition: sltimer.f:123
slcombine
subroutine slcombine(ICTXT, SCOPE, OP, TIMETYPE, N, IBEG, TIMES)
Definition: sltimer.f:267
slinquire
double precision function slinquire(TIMETYPE, I)
Definition: sltimer.f:189