[Haskell-cafe] [Somewhat OT] Speed

Henning Thielemann lemming at henning-thielemann.de
Tue Oct 28 15:55:59 EDT 2008


On Tue, 28 Oct 2008, Andrew Coppin wrote:

> Hi guys.
>
> This isn't specifically to do with Haskell, but... does anybody have any idea 
> roughly how fast various CPU operations are?

Unfortunately, the knowledge I acquired for Z80 and MC68000 is no longer 
of that importance today.

It's still true that simpler operations require less resources, but modern 
processors often hide complexity, making many operations equally fast (or 
equally slow) by using more space on the chip for the more complex 
operations.

> For example, is integer arithmetic faster or slower than floating-point?

In principle integer arithmetic is simpler and faster. But your processor 
may do it in the same time.

> Is addition faster or slower than multiplication?

Multiplication can be done almost as fast as addition. This is so, because 
a sum of n numbers can be computed much faster than n individual 
additions.

> How much slower are the trigonometric functions?

division, square root are similar in complexity. exp, log, arctan can be 
implemented with a school division like algorithm (CORDIC) and are similar 
in performance.

> Does using 8-bit integers make arithmetic any faster than using wider 
> values?

On an n-bit processor all integer operations up to n bit are equally fast. 
However, it may be that a vector unit can process several 8 bit values in 
parallel. If you can make use of it, then more 8 bit operations may be 
performed in parallel than 16 bit operations.

> Does anybody have a good resource for this kind of information?

The definite information for your processor can be found in its manual. 
You can download those manuals from the site of the manufacturer. They 
tell you how much cycles an operation eats, which ones can be done in 
parallel, how pipelining reduces the average amount of cycles per 
operation and so on.


More information about the Haskell-Cafe mailing list