[comp.lang.c] Dhrystones

tim@amdcad.AMD.COM (Tim Olson) (01/01/70)

In article <2617@watcgl.waterloo.edu> smvorkoetter@watmum.waterloo.edu (Stefan M. Vorkoetter) writes:
| In article <19440@amdcad.AMD.COM> tim@amdcad.UUCP (Tim Olson) writes:
| )		IntLoc2 = IntLoc3 / IntLoc1;
| )		IntLoc2 = 7 * (IntLoc3 - IntLoc2) - IntLoc1;
| )
| )The first assignment into IntLoc2 is replaced in the next expression --
| )no need to calculate it (and we take a divide out of the loop -- big win ;-)
| )
| The first IntLoc2 assignment and the division must be done since the result is
| used to calculate the value for the second assignment.

Sorry.  I noticed that neither expression generated code, and didn't
notice the use of IntLoc2 in the second expression.  What *really*
happened is that the compiler determined that the second expression was
dead code, which *then* made the first expression dead.

Thanks for catching that.

	-- Tim Olson
	Advanced Micro Devices
	(tim@amdcad.amd.com)

richw@rosevax.Rosemount.COM (Rich Wagenknecht) (12/03/87)

Could somemone tell me what a 'Dhrystone' (<-sp.?) is?
Why is it used so often to evaluate compiler performance?
Is it a good overall indicator of compiler peformance?

Thanks in advance,
Rich W.

kgregory@bbn.COM (Keith D. Gregory) (12/03/87)

In article <3368@rosevax.Rosemount.COM> richw@rosevax.Rosemount.COM (Rich Wagenknecht) writes:
>Could somemone tell me what a 'Dhrystone' (<-sp.?) is?
>Why is it used so often to evaluate compiler performance?
>Is it a good overall indicator of compiler peformance?


Well, we all know that benchmarks are invalid :-)

The dhrystone benchmark produces a number which lets you know how efficiently
your compiler/computer can perform integer operations (as opposed to Whetstone,
which is FP, and yes, I know that the compiler doesn't perform anything except
a compilation :-)

As I see things, there are two uses for Dhrystone:

1 - Compare different compilers for a given machine.  I find this to be very
    useful - although there are certainly many factors contributing to the
    efficiency of compiled code, I've found that Dhrystone figures give a
    fairly accurate comparison of two compilers (as I see it, if a compiler
    writer makes efficient integer procesing code, the system calls will
    probably be efficient too).

2 - Having a number to hang your hat on.
    Let's face it, when I say that my 20MHz 386, running Xenix-386 can turn
    4800 dhrystones/second (and it can :-), that's bound to impress the hexk
    out of someone using a Mac which turns 1000. . .never mind that there
    are vast differences between the two machines/compilers ;-)

-kdg

tim@amdcad.AMD.COM (Tim Olson) (12/04/87)

In article <5096@ccv.bbn.COM> kgregory@ccv.bbn.com.BBN.COM (Keith D. Gregory) writes:
| In article <3368@rosevax.Rosemount.COM> richw@rosevax.Rosemount.COM (Rich Wagenknecht) writes:
| >Could somemone tell me what a 'Dhrystone' (<-sp.?) is?
| >Why is it used so often to evaluate compiler performance?
| >Is it a good overall indicator of compiler peformance?
|
| 1 - Compare different compilers for a given machine.  I find this to be very
|     useful - although there are certainly many factors contributing to the
|     efficiency of compiled code, I've found that Dhrystone figures give a
|     fairly accurate comparison of two compilers (as I see it, if a compiler
|     writer makes efficient integer procesing code, the system calls will
|     probably be efficient too).

I just wanted to add the caveat that Dhrystone has some major problems
as a benchmark when you are talking about very good optimizing
compilers.  There exists quite a lot of "dead code" in Dhrystone
(expressions which aren't ever used) which good compilers can optimize
totally away.  This isn't the case with real-world code.  At the
high-end, all you are comparing with Dhrystone is how much code your
compiler threw away vs another compiler ;-)

Dhrystone is also heavily weighted towards string operations (strcpy &
strcmp can total 35% - 40% of the runtime).

	-- Tim Olson
	Advanced Micro Devices
	(tim@amdcad.amd.com)

chris@mimsy.UUCP (12/04/87)

In article <19425@amdcad.AMD.COM> tim@amdcad.AMD.COM (Tim Olson) writes:
>... There exists quite a lot of "dead code" in Dhrystone
>(expressions which aren't ever used) which good compilers can optimize
>totally away.  This isn't the case with real-world code.

Are you sure?

(Change that to `good real-world code' and I will agree; change it to
`most real-world code' and I am still uncertain.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris

jep@oink.UUCP (12/04/87)

In article <3368@rosevax.Rosemount.COM> richw@rosevax.Rosemount.COM (Rich Wagenknecht) writes:
>Could somemone tell me what a 'Dhrystone' (<-sp.?) is?
>Why is it used so often to evaluate compiler performance?
>Is it a good overall indicator of compiler peformance?
>
>Thanks in advance,
>Rich W.

First there was the Whetstone benchmark.  It is rich in floating point
calculations, and as such is handy for comparing systems when you are
concerned about scientific calculations.

Most operating system programming doesn't use any floating point math.  Same 
goes for programs such as text editors, compilers, assemblers, linkers, 
and any other program primarily dealing with integers instead of of 
floating point data.  On machines without floating point hardware,
the Whetstone benchmark will report that the machine is very pokey,
even though it might scream when doing operating system stuff or any other
non-floating point calculations.

The Dhrystone benchmark program attempts to measure to speed of non-floating
point code.  As such, it is much better for comparing compilers that the
Whetstone benchmark.

Its name is a pun on "Whet", since it measures the opposite kind
of calculation.

In spite of the above, I am leery of benchmarks.  The is a saying:
"There are lies, damn lies, and benchmarks."

The correct way to compare systems, is to run the programs that *you*
are interested in, on them.  Make sure you are doing emprical bench-
marks, not just paper calculations of how much time it "should" take.
-- 
Jim Prior    jep@oink.UUCP    {ihnp4|cbosgd}!n8emr!oink!jep

tim@amdcad.AMD.COM (Tim Olson) (12/04/87)

In article <9613@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes:
| In article <19425@amdcad.AMD.COM> tim@amdcad.AMD.COM (Tim Olson) writes:
| >... There exists quite a lot of "dead code" in Dhrystone
| >(expressions which aren't ever used) which good compilers can optimize
| >totally away.  This isn't the case with real-world code.
| 
| Are you sure?
| 
| (Change that to `good real-world code' and I will agree; change it to
| `most real-world code' and I am still uncertain.)

I mean code like:

Proc4()
{
	REG boolean	BoolLoc;

	BoolLoc = Char1Glob == 'A';	<-- these 2 expressions are
	BoolLoc |= BoolGlob;		<-- totally useless
	Char2Glob = 'B';
}


That is a very obvious example, but there are many other places, such as
in proc0:

		IntLoc3 = IntLoc2 * IntLoc1;
		IntLoc2 = IntLoc3 / IntLoc1;
		IntLoc2 = 7 * (IntLoc3 - IntLoc2) - IntLoc1;

The first assignment into IntLoc2 is replaced in the next expression --
no need to calculate it (and we take a divide out of the loop -- big win ;-)
Actually, the second assignment into IntLoc2 doesn't need to be
performed, either, because it is to a register variable which isn't used
before it is assigned again.

This kind of code is not seen (I hope!) in real-world applications. 
Yes, there is still dead code there, but it falls more into the category
of previously live code that becomes dead, due to previous
optimizations.

	-- Tim Olson
	Advanced Micro Devices
	(tim@amdcad.amd.com)

smvorkoetter@watmum.UUCP (12/07/87)

In article <19440@amdcad.AMD.COM> tim@amdcad.UUCP (Tim Olson) writes:
)In article <9613@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes:
)| In article <19425@amdcad.AMD.COM> tim@amdcad.AMD.COM (Tim Olson) writes:
)| >... There exists quite a lot of "dead code" in Dhrystone
)| >(expressions which aren't ever used) which good compilers can optimize
)| >totally away.  This isn't the case with real-world code.
)
)		IntLoc3 = IntLoc2 * IntLoc1;
)		IntLoc2 = IntLoc3 / IntLoc1;
)		IntLoc2 = 7 * (IntLoc3 - IntLoc2) - IntLoc1;
)
)The first assignment into IntLoc2 is replaced in the next expression --
)no need to calculate it (and we take a divide out of the loop -- big win ;-)
)
)	-- Tim Olson
The first IntLoc2 assignment and the division must be done since the result is
used to calculate the value for the second assignment.