From tom@@@k@||ber@ @end|ng |rom gm@||@com  Wed Nov  1 19:47:23 2023
From: tom@@@k@||ber@ @end|ng |rom gm@||@com (Tomas Kalibera)
Date: Wed, 1 Nov 2023 19:47:23 +0100
Subject: [Rd] 
 configure output with flexiblas [was Re: About FlexiBLAS in
 the R-admin docs]
In-Reply-To: <CALEXWq0fy-CGgDeraUhVh4gO3z1+BaZcmO9ioaXsj0D=a-CZ8g@mail.gmail.com>
References: <mailman.53774.3.1695895202.51578.r-devel@r-project.org>
 <E698DC79-C258-4A95-A8C6-933A512CA108@gmail.com>
 <5bcf6c56-bcfb-4f8b-8ba0-91375a5a540e@gmail.com>
 <CALEXWq0BFQ62UbJt9yNmG6EWSgEJkyoQ2wT3XV7T2XxNERySEw@mail.gmail.com>
 <9cab2be0-618f-4f78-a353-9563670c795f@gmail.com>
 <CALEXWq0fy-CGgDeraUhVh4gO3z1+BaZcmO9ioaXsj0D=a-CZ8g@mail.gmail.com>
Message-ID: <22cf8a28-7c7e-4396-83e1-5e1d22cd4a44@gmail.com>


On 11/1/23 13:29, I?aki Ucar wrote:
> On Wed, 1 Nov 2023 at 12:57, Tomas Kalibera <tomas.kalibera at gmail.com> wrote:
>>
>> On 10/31/23 10:45, I?aki Ucar wrote:
>>> On Tue, 24 Oct 2023 at 12:53, Tomas Kalibera <tomas.kalibera at gmail.com> wrote:
>>>> The output of session info is based on that flexiblas is used and on
>>>> what flexiblas tells R is the backend it uses. R does not attempt to
>>>> check that optimized LAPACK functions from the backend really end up
>>>> called via flexiblas, and I don't think it could be realistically checked.
>>>>
>>>> But I've checked one case manually in Fedora 38 using Linux perf tool.
>>>> The following code:
>>>>
>>>> S <- toeplitz((10:1)/10)
>>>> repeat { R <- rWishart(10, 20, S) }
>>>>
>>>> uses dpotrf from LAPACK, which is optimized in OpenBLAS and ATLAS and
>>>> the corresponding optimized implementations really appeared on the
>>>> sampling profile for me from the backend libraries.
>>>>
>>>> The comment from R Admin has been removed now and if anyone runs into
>>>> the problem (that an optimized LAPACK function is not called from a
>>>> backend that provides it), it would be best to report it with sufficient
>>>> detail to flexiblas.
>>> Thanks, Tomas. Yes, if an expected redirection to an optimized
>>> function does not happen, that would be a bug in FlexiBLAS and should
>>> be reported upstream.
>>>
>>> Related to this, a small detail... I noticed that the R configure
>>> script reports "BLAS(FlexiBlas)" correctly as an external library, but
>>> then "LAPACK(generic)". This should be FlexiBLAS too instead of
>>> "generic". It doesn't make any difference, since the LAPACK symbols in
>>> FlexiBLAS are called anyway, but it's misleading.
>> This depends on how you configure R. On Fedora 38,
>>
>> ../trunk/configure --with-blas=flexiblas --with-lapack
>>
>> reports "BLAS(FlexiBlas), LAPACK(in blas)" and from my reading of
>> R-admin, this is the recommended way of configuring with flexiblas.
>>
>> Configuring via (is this what you had in mind?):
>>
>> ../trunk/configure --with-blas=flexiblas --with-lapack=flexiblas
>>
>> reports "BLAS(FlexiBlas), LAPACK(generic)". The build would actually do
>> "-lflexiblas -lflexiblas", the former for LAPACK (from --with-lapack
>> value) and the latter for BLAS (from --with-blas value). The "generic"
>> here means not from BLAS, but from an extra standalone library. Compare
>> with the first (recommended) use when the build would only link
>> "-lflexiblas" once.
> I see. I didn't understand that part then. I thought that a library
> should be specified.

I read this from R-Admin re --with-lapack:

"In practice its main uses are without a value,

- with an `enhanced' BLAS such as ATLAS, FlexiBLAS, MKL or OpenBLAS which
contains a full LAPACK (to avoid possible conflicts), or

- on Debian/Ubuntu systems to select the system liblapack which can
be switched by the `alternatives' mechanism.
"

I've updated configure in R-devel to detect when the same library is 
specified explicitly for blas and lapack, so that now even that is 
handled and reported as LAPACK in Blas libs.

Best
Tomas

>



[Rd] configure output with flexiblas [was Re: About FlexiBLAS in the R-admin docs]
Tomas Kalibera