From gb at stat.umu.se  Tue Aug 24 09:13:02 2010
From: gb at stat.umu.se (=?ISO-8859-1?Q?G=F6ran_Brostr=F6m?=)
Date: Tue, 24 Aug 2010 09:13:02 +0200
Subject: [Rd] Speeding up matrix multiplies
In-Reply-To: <AANLkTiktNDSMj+Rae+9VuazCGiuU9Hb4F-a1DPxGUW=x@mail.gmail.com>
References: <20100823233927.GA21529@cs.toronto.edu>	<95C122CC-D17A-4007-ABDF-C77841E4000C@r-project.org>	<20100824023958.GA10777@cs.toronto.edu>
	<AANLkTiktNDSMj+Rae+9VuazCGiuU9Hb4F-a1DPxGUW=x@mail.gmail.com>
Message-ID: <4C7370FE.30602@stat.umu.se>



On 2010-08-24 05:37, Kasper Daniel Hansen wrote:
> On Mon, Aug 23, 2010 at 10:39 PM, Radford Neal<radford at cs.toronto.edu>  wrote:
>>> On Aug 23, 2010, at 7:39 PM, Radford Neal wrote:
>>
>>>> In particular, all matrix x vector and vector x matrix products will
>>>> in this version be done in the matprod routine, not the Fortran routine.
>>>> And this is the right thing to do, since the time for the ISNAN check
>>>> before calling the Fortan routine will be comparable to the time for
>>>> the matrix multiply.  So avoiding it will be desirable unless the Fortran
>>>> routine is really, really faster than the C code in matprod.
>>>
>>> It is, many times in fact, if you use threaded BLAS on a multi-core machine
>>> and large matrices.
>>
>> Well, it can't get any faster than taking zero time.  And even in that
>> case, using the C code in matprod will slow the program down (compared
>> to the existing version of R) by only about a factor of two.
>>
>>>> Of course, the real solution is to change the Fortran routine (which
>>>> seems to be in src/extra/blas/blas.f, and isn't all that complicated)
>>>
>>> Nope - it can be external and BLAS standard doesn't handle NAs.
>>
>> OK.  I see the problem if people can link in their own version of BLAS.
>> I wonder if there is any way of telling whether they did that?  Presumably
>> many people will use the BLAS routine supplied with R, which could be
>> made safe for NAs.
>
> Radford: this is highly platform dependent.  For example, all OS X
> users use a multithreaded BLAS supplied by Apple.  And I believe a
> multithreaded BLAS is used by Revolution R (all platforms).  Allowing
> a plugin BLAS is (in my opinion) an essential advantage of R and is
> used by many people who care about high performance.

How do I best achieve this on Ubuntu (10.04)?

G?ran

>
> Note that the BLAS version can be swapped after R has been compiled,
> so even if there is a way to tell what BLAS you are using (and I don't
> know if there is), it has to be a run-time check.
>
> Kasper
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Speeding up matrix multiplies
=?ISO-8859-1?Q?G=F6ran_Brostr=F6m?=