[comp.unix.questions] Counting FLOPS

rouben@math9.math.umbc.edu (Rouben Rostamian) (02/15/91)

How does one count the number of floating point operations (flops) during
the execution of a C program?  I guess it is possible to trace manually all
loops and function calls and iterations and recursions, etc., and add them
up, but that will easily gets out of hand for a half-way complicated program.
Are there automatic tools for doing this?

I am primarily interested in a solution which will work under RISC Ultrix,
if that matters.

Rouben Rostamian

--
Rouben Rostamian                          Telephone: (301) 455-2458
Department of Mathematics and Statistics  e-mail:
University of Maryland Baltimore County   bitnet: rostamian@umbc.bitnet
Baltimore, MD 21228,  U.S.A.              internet: rouben@math9.math.umbc.edu

gwyn@smoke.brl.mil (Doug Gwyn) (02/16/91)

In article <5025@umbc3.UMBC.EDU> rouben@math9.math.umbc.edu writes:
>How does one count the number of floating point operations (flops) during
>the execution of a C program?

I for one would have to know exactly what is meant by a "FLOP".
I'm not being facetious; there is considerable truth to the saying
that "there are lies, damned lies, and benchmarks".  (Originally
"statistics" was the third category, but it was adapted for modern
purposes.)  On all computing architectures known to me, different
floating-point operations take different amounts of time, sometimes
in fact dependent on the content of the data being operated on;
thus an measure such as "FLOPs per second" is not a very well-
defined quantity.  On the other hand, in some implementations that
I know of, the floating-point processor is involved in executing
some operations on what would probably be considered "integer" data;
is it intended that those operations be counted or excluded?

It may be that your best bet would be to rely on total time required
to perform some lengthy computation (perhaps numerous iterations of
some shorter computation), rather than number of operations as such.