[Haskell-cafe] Data.Complex.magnitude slow?

Richard A. O'Keefe ok at cs.otago.ac.nz
Sun Jul 20 20:11:28 EDT 2008


>> On Fri, 18 Jul 2008, stefan kersten wrote:
>>
>>> On 17.07.2008, at 21:46, Lennart Augustsson wrote:
>>>> If scaleFloat and exponent are implemented with bit twiddling  
>>>> they can
>>>> be quite fast.
>>>
>>> is there a way in ghc to 'cast' between float/int32 and double/ 
>>> int64 (without going through memory)?

I read this as

	"Is there any way to take a 32-bit float in a register and end up  
with a 32-bit int
          in a register, without going through memory, in GHC?
	 How about the other way around?
	 How about 64-bit floats and integers?"

It is rather hard to do portably in GHC what some hardware does not do.
A long time ago hardware architects decided that separating the  
integer and
floating point register files was a Good Thing.
The machine I know best is SPARC, where there are no instructions to  
move
data directly between integer registers and floating point registers.

On the other hand, there are other pressures, notably graphics.
While integer and floating point registers may be kept separate, there  
are often
"vector" instructions that let you operate on integers in the floating- 
point
registers.  (Such as the VIS instructions on SPARCs, which are  
technically
optional.)  Exploiting such instructions tends to be rather non- 
portable.

All things considered, I wouldn't worry about it too much:  the memory  
in
question should be at the top of the stack, so should be in L1 cache,  
so should
be pretty fast to access, and other things may be more significant.



More information about the Haskell-Cafe mailing list