Mail Archives: djgpp/1997/01/06/10:59:00
Leath Muller wrote:
>
> > My computer betrays me once again. I rewrote a simple timing program
> > that merely calculates elapsed time using clock() and divides by
> > CLK_TCK. _THIS TIME_ I ran it through 500,000 loops just adding 100.0
> > to a type double accumulator. Once the floating point loop finished,
> > I repeated the loop using a type long as my accumulator. On my
> > Pentium 120, the floating point addition loop was roughly half as fast
> > as the addition loop. The elapsed time was miniscule, not nearly the
> > same results I had gotten previously.
>
> It should be about half the speed. An FP add takes 3 cycles, and it
> takes 1 cycle for an int add. Assuming normal simple loop overhead,
> I would think it would take 4 cycles for an FP add loop, and 2 cycles
> for an INT one...
FP usage may speed up your program. Most times one will calculate
pointers
to get the data, do the calculation and check the loop conditions. Look
at
a scalar product:
double sp(double *a, double *b, int n) {
double res = 0.0;
while (n-->0)
res += *(a++) * *(b++);
return res;
}
The fpu and the integer unit will work truely parallel -> improved speed
!
I don't have a pentium around, but few month ago I achived factor 1.8
speed improvement using mixed integer/floating point calculations over
pure integer implementation.
Hartmut
--
Hartmut Schirmer | Phone: +49-431-77572-709 FAX:-703
Automatisierungs- & Regelungstech. | hsc AT techfak DOT uni-kiel DOT de
Technische Fakult"at, | http://www.techfak.uni-kiel.de/~hsc
Kaiserstr. 2, 24143 Kiel, Germany | PGP key via WWW, Key ID:6D84AEC1
- Raw text -