From: Hartmut Schirmer Newsgroups: comp.os.msdos.djgpp Subject: Re: Fixed Point (Optimization) Date: Mon, 06 Jan 1997 15:39:49 +0100 Organization: Technische Fakultaet, University of Kiel, Germany Lines: 43 Message-ID: <32D10EB5.14D7@techfak.uni-kiel.de> References: <32d0610c DOT 1680703 AT ursa DOT smsu DOT edu> <32D09DEC DOT 69DB AT gbrmpa DOT gov DOT au> NNTP-Posting-Host: zora.techfak.uni-kiel.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit CC: leathm AT gbrmpa DOT gov DOT au, aho450s AT nic DOT smsu DOT edu To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp 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