From simon.urbanek at r-project.org  Thu Mar 24 17:54:16 2005
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Thu Mar 24 17:54:30 2005
Subject: float vs double on Macs [was Re: [Rd] NaN and linear algebra]
In-Reply-To: <9444a625058d32a3796a700d758668de@unsw.edu.au>
References: <200503241104.j2OB4U70024638@hypatia.math.ethz.ch>
	<9444a625058d32a3796a700d758668de@unsw.edu.au>
Message-ID: <4C39ADF6-C46A-47E8-93BF-887C698E64EE@r-project.org>

On Mar 24, 2005, at 6:59 AM, Bill Northcott wrote:

> PS  This discussion has given me another thought.  On MacOS X, it  
> would be much faster to use floats instead of doubles because they  
> can be directly processed by the Altivec section of the CPU.  I can  
> see no way to have R use floats.  Would that be possible as a  
> future enhancement or is it just too hard?

To have just a rough idea about how "much faster" this would be, here  
are some timings for 2000 runs of 1000x1000 matrix-vector  
multiplications using vecLib's BLAS:
G5 1.8GHz
sgemv: 2.9s
dgemv: 6.7s

G4 1.5GHz
sgemv: 10.1s
dgemv: 17.3s

The performance difference between double and float is actually less  
astonishing (although is proves that altiVec is used - still) than  
the G4 vs G5 comparison. vecLib for G5 seems to be fairly well  
optimized and the G5 architecture seems to have better throughput.

Anyway, I'm not quite sure switching from doubles to floats yields  
big enough speed up to justify the effort. Maybe some Lapack test  
would helpful, too, to have a bigger picture of this.

Cheers,
Simon

PS: I'd rather move this part to R-SIG-Mac as this is actually a Mac- 
only question.


float vs double on Macs [was Re: [Rd] NaN and linear algebra]
Simon Urbanek