Re: using MFC VC++ - which is more efficient - float or double?
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Fri, 24 Jul 2009 22:59:40 -0400
Float has other nasty implications. The results of division certainly are different, and
the cumulative error on int may be massive but nonetheless is deterministic and expected,
whereas most people don't understand the effects of cumulative error on floating point,
and for them, it is effectively nondeterministic. Think of the rancorous debates by those
who keep insisting that binary floating point should behave exactly like decimal numbers.
Also, the tests did not show how ALU pipelining works, or note that the ALU on the
machines have three units: two integer units and one floating point unit, so in principle
each clock cycle can dispatch up to three instructions; since instruction ordering is
asynchronous (with the illusion of sequentiality always maintained), blends of
instructions can create different performance. This is why fixed tests of the sort I did
may be *indicative* of behavior, but are never *definitive*; only measurement of the
actual application, working on its actual application data, compiled in release mode, can
be used to guide optimization decisions.
For example, an L2 cache miss can cost 20-100 CPU cycles. Ultimately, data access can
dominate computation, so computation speeds are often irrelevant. A page fault, by the
way, costs 20,000,000-60,000,000 CPU clock cycles, so things like copies to compact data
to reduce page spread (representing lists as arrays, for example) can pay off completely
disproportionally to their naively-perceived "inefficiency". Algorithms that maximize
cache hits can buy a factor of 10-20 improvement in performance, while reordering
statements to improve instruction flow might gain 3% on a good day.
Ultimately, the best performance gains are from architecture redesign, not lines-of-code
tweaking.
joe
On Fri, 24 Jul 2009 18:53:25 -0700, "David Ching" <dc@xxxxxxxxxxxxxxxxxxxxxx> wrote:
So what is the takeaway from all this? Since Intel processors are widelyJoseph M. Newcomer [MVP]
used by people we are selling our software to, it looks like we should still
choose integers when floating point is not needed, and not use float for
everything.
-- David
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:96hj65l277dcedfa435ujub8ofab1ccvi2@xxxxxxxxxx
Which is why I gave detailed specifications of my CPU.
joe
On Thu, 23 Jul 2009 19:32:44 +0100, David Lowndes <DavidL@xxxxxxxxxxxxxxx>
wrote:
Joseph M. Newcomer [MVP]Now I'm very confused! My tests give quite different results. I'm
looking mostly at a debug build as I assume optimization will cloud the
results. I'm seeing on the order of 25x faster 32 bit int timing.
The results (int vs float speed) may depend on the type of processor.
Dave
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- using MFC VC++ - which is more efficient - float or double?
- From: Mechi
- RE: using MFC VC++ - which is more efficient - float or double?
- From: JRGlide
- Re: using MFC VC++ - which is more efficient - float or double?
- From: Joseph M . Newcomer
- Re: using MFC VC++ - which is more efficient - float or double?
- From: Joseph M . Newcomer
- Re: using MFC VC++ - which is more efficient - float or double?
- From: Stephen Myers
- Re: using MFC VC++ - which is more efficient - float or double?
- From: David Lowndes
- Re: using MFC VC++ - which is more efficient - float or double?
- From: Joseph M . Newcomer
- Re: using MFC VC++ - which is more efficient - float or double?
- From: David Ching
- using MFC VC++ - which is more efficient - float or double?
- Prev by Date: Re: using MFC VC++ - which is more efficient - float or double?
- Next by Date: Default size of icon with LoadImage
- Previous by thread: Re: using MFC VC++ - which is more efficient - float or double?
- Next by thread: Re: using MFC VC++ - which is more efficient - float or double?
- Index(es):
Relevant Pages
|
Loading