forked from johannesgerer/jburkardt-f77
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.html
More file actions
247 lines (212 loc) · 6.97 KB
/
timer.html
File metadata and controls
247 lines (212 loc) · 6.97 KB
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<html>
<head>
<title>
TIMER - Compute Elapsed Time
</title>
</head>
<body bgcolor="#EEEEEE" link="#CC0000" alink="#FF3300" vlink="#000055">
<h1 align = "center">
TIMER <br> Compute Elapsed Time
</h1>
<hr>
<p>
<b>TIMER</b>
is a directory of FORTRAN77 programs which
compute the elapsed CPU time or wallclock time
of a part of a calculation.
</p>
<p>
The idea is that you want to
determine the amount of CPU time taken by a piece of your code, so
you write lines like this:
<pre><tt>
call timer ( t_start)
do i = 1, n
...some big calculation...
end do
call timer ( t_stop )
write ( *, * ) 'Elapsed CPU time = ', t_stop - t_start
</pre></tt>
</p>
<p>
Up until FORTRAN90, the FORTRAN language did not specify a standard
way to access a system timer. Users of FORTRAN on UNIX systems
could access a system library routine called ETIME for this purpose,
but ETIME was not part of the language, and was not to be found on
other operating systems.
</p>
<p>
On various
computers, there are often vendor-supplied routines to do this chore.
You will often find that the timer is inaccurate; some operations will
be reported as taking zero time; other operations will be reported
with times that differ by 5 or 10 percent. Moreover, two timers that
profess to measure the same thing may produce results that are
consistently different by a factor of 40 percent.
</p>
<p>
Another problem is "wrap around". Many timers reach a maximum value,
and then reset themselves to zero. If this happens to you, (it's
happened to me many times!) you may find that a certain procedure
seems to take negative time!
</p>
<p>
Some timers return CPU time, that is, the amount of elapsed computer
time that was used by your program; other routines return "real" time
or "wall clock" time, which will not account for situations in which
your program started, and then was paused for some reason (swapped out,
waiting for I/O, or other system functions), and then finished.
</p>
<p>
For parallel programming, the important thing to measure is the elapsed
wallclock time. This can be found by subtracting an initial reading of
the wallclock time from a final one.
</p>
<p>
The OpenMP system provides a function used as follows:
<pre>
seconds = omp_get_wtime ( )
operations to time;
seconds = omp_get_wtime ( ) - seconds;
</pre>
while the MPI system provides a similar function used as:
<pre>
seconds = MPI_Wtime ( );
operations;
seconds = MPI_Wtime ( ) - seconds;
</pre>
and in MATLAB, wallclock time can be taken with "tic" and "toc":
<pre>
tic;
operation;
seconds = toc;
</pre>
</p>
<h3 align = "center">
Licensing:
</h3>
<p>
The computer code and data files described and made available on this web page
are distributed under
<a href = "../../txt/gnu_lgpl.txt">the GNU LGPL license.</a>
</p>
<h3 align = "center">
Languages:
</h3>
<p>
<b>TIMER</b> is available in
<a href = "../../c_src/timer/timer.html">a C version</a> and
<a href = "../../cpp_src/timer/timer.html">a C++ version</a> and
<a href = "../../f77_src/timer/timer.html">a FORTRAN77 version</a> and
<a href = "../../f_src/timer/timer.html">a FORTRAN90 version</a> and
<a href = "../../m_src/timer/timer.html">a MATLAB version</a>.
</p>
<h3 align = "center">
Related Data and Programs:
</h3>
<p>
<a href = "../../f77_src/linpack_bench/linpack_bench.html">
LINPACK_BENCH</a>,
a FORTRAN77 program which
measures the time taken by <b>LINPACK</b> to solve a particular linear system.
</p>
<p>
<a href = "../../f77_src/matmul/matmul.html">
MATMUL</a>,
a FORTRAN77 program which
is an interactive matrix multiplication benchmark program.
</p>
<p>
<a href = "../../f77_src/mdbnch/mdbnch.html">
MDBNCH</a>,
a FORTRAN77 program which
is a benchmark code for a molecular dynamics calculation.
</p>
<p>
<a href = "../../f_src/memory_test/memory_test.html">
MEMORY_TEST</a>,
a FORTRAN90 program which
declares and uses a sequence of larger
and larger vectors, to see how big a vector can be used on a given
machine and compiler.
</p>
<p>
<a href = "../../f77_src/mpi/mpi.html">
MPI</a>,
FORTRAN77 programs which
illustrate the use of the MPI application program interface
for carrying out parallel computations in a distributed memory environment.
</p>
<p>
<a href = "../../f77_src/openmp/openmp.html">
OPENMP</a>,
FORTRAN77 programs which
illustrate the use of the OpenMP application program interface
for carrying out parallel computations in a shared memory environment.
</p>
<p>
<a href = "../../f77_src/sum_million/sum_million.html">
SUM_MILLION</a>,
a FORTRAN77 program which
sums the integers from 1 to 1,000,000, as a demonstration of how
to rate a computer's speed;
</p>
<p>
<a href = "../../f77_src/timestamp/timestamp.html">
TIMESTAMP</a>,
a FORTRAN77 library which
returns the YMDHMS date as a timestamp.
</p>
<p>
<a href = "../../f77_src/wtime/wtime.html">
WTIME</a>,
a FORTRAN77 library which
returns a reading of the wall clock time in seconds.
</p>
<h3 align = "center">
Examples and Tests:
</h3>
<p>
<b>TIMER_ETIME</b> uses the ETIME routine, which is only available
on UNIX systems:
<ul>
<li>
<a href = "timer_etime.f">timer_etime.f</a>, the test;
</li>
<li>
<a href = "timer_etime.sh">timer_etime.sh</a>,
commands to compile and run the test;
</li>
<li>
<a href = "timer_etime_output.txt">timer_etime_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>TIMER_OMP_GET_WTIME</b> uses the OpenMP wall clock function <b>omp_get_wtime()</b>:
<ul>
<li>
<a href = "timer_omp_get_wtime.f">timer_omp_get_wtime.f</a>, the test;
</li>
<li>
<a href = "timer_omp_get_wtime.sh">timer_omp_get_wtime.sh</a>,
commands to compile and run the test;
</li>
<li>
<a href = "timer_omp_get_wtime_output.txt">timer_omp_get_wtime_output.txt</a>,
the output file.
</li>
</ul>
</p>
<p>
You can go up one level to <a href = "../f77_src.html">
the FORTRAN77 source codes</a>.
</p>
<hr>
<i>
Last revised on 06 March 2008.
</i>
<!-- John Burkardt -->
</body>
</html>