delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/07/23:12:03

Date: Tue, 7 Jan 1997 23:04:24 -0500 (EST)
From: Michael Phelps <morphine AT hops DOT cs DOT jhu DOT edu>
To: Philip S Galbiati <galbiati AT mdhost DOT cse DOT TEK DOT COM>
cc: djgpp AT delorie DOT com
Subject: Re: FP vs int timing
In-Reply-To: <Pine.SUN.3.95.970107112402.15288A-100000@mdjunior>
Message-ID: <Pine.GSO.3.95.970107230121.27833A-100000@hops.cs.jhu.edu>
MIME-Version: 1.0

On Tue, 7 Jan 1997, Philip S Galbiati wrote:

> 
> On Mon, 6 Jan 1997, Michael Phelps wrote:
> >
> > 	I have been unable to reproduce the claim that integer
> > instructions are "thousands" of times faster than floating-point in DJGPP:
> 
> <SNIP>
> 
> > 	start_time = uclock();
> > 	for (i = 0; i < ITERATIONS; i++)
> > 	{
> > 		b = (double)random();
> > 		c = (double)random();
> > 		a = b / c;
> > 	}
> > 	end_time = uclock();
> 
> <SNIP>
> 
> > results on my 5x86/100 under Win95:
> > 	doubles:  2.29s for 1000000 divides
> > 	ints:     2.12s for 1000000 divides
> 
> Those times are not just for a million divides, they are for a million
> divides plus two million function calls to random() plus two million
> long-to-double conversions plus a million integer compares plus a million
> integer increments plus a million jumps plus a single call to uclock()
> plus God knows howmany additional loads & stores, and since you are
> running under Windows, even He doesn't know what overhead is being added
> by the "OS". If you want to time the divides, you have to time the loop
> *without* the divides and subtract it from the loop *with* the divides.  I
> think that you will find that each divide takes significantly less than 2
> microseconds.
> 
> > conclusions:  on my machine, at least, there is not a significant
> > difference in speed between integer and floating-point math.  (The program
> > was compiled with -O2, by the way).
> 
> Since your times included such a large chunk of overhead (and non-constant
> non-predictable non-repeatable overhead at that), you are not really
> comparing the divide times, so your conclusion that there is no
> significant difference between dividing ints and dividing doubles is not
> valid.  When I subtracted the program overhead time, I found that on my
> p5-133, int divides appear to take roughly one-and-a-half times as long as
> double divides.

The hypothesis to be tested was that floating-point operations take
"thousands" of times longer than the corresponding integer operations.
Sure, there are many flaws in my method, but if the hypothesis had been
correct, then the calls to random() would have been negligible, and the
CPU load was approximately constant for both routines.  My results
disproved that assertion, and that was all I designed them to do.

 > 
> Furthermore, when I run the program in a full-screen dos box under win3.1,
> I get different speeds each time I run it, and ratios varying between
> about 1.2 and 1.9, so I'd say you can't conclude much (if anything) using
> this approach.  Run under pure dos, turn off all optimizations, and
> carefully account for all overhead, and you *might* get something 
> meaningful.
> 
> --Phil Galbiati
> =================================================
>      Any opinions expressed here reflect the
>      ignorance of the author, NOT Tektronix.
> =================================================
> 


						---Michael Phelps
						   morphine AT cs DOT jhu DOT edu


                               CH3
                               |
                               N
                             / |
                     ______/   |
                    /      \   CH2
             _____/         \__|__      
           //     \\        /  |  \\     
         //        \\______/___CH2 \\  
          \        /       \       /
           \______/         \_____/
          / ------ \       /      \
        OH           \   /         OH
                       O
 
                   Morphine


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019