From maechler at stat.math.ethz.ch  Fri Feb 27 16:54:44 2004
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Fri Feb 27 16:56:12 2004
Subject: [Rd] ATLAS threaded 64 bit Opteron build for R: need -fPIC
In-Reply-To: <x2u11dew8v.fsf@biostat.ku.dk>
References: <16445.47460.107721.166477@gargle.gargle.HOWL>
	<x27jyaf747.fsf@biostat.ku.dk>
	<6r7jyax7nh.fsf@bates4.stat.wisc.edu>
	<x2u11dew8v.fsf@biostat.ku.dk>
Message-ID: <16447.26692.713028.344957@gargle.gargle.HOWL>

>>>>> "PD" == Peter Dalgaard <p.dalgaard@biostat.ku.dk>
>>>>>     on 26 Feb 2004 15:44:16 +0100 writes:

    PD> Douglas Bates <bates@stat.wisc.edu> writes:
    >> Have you tried configuring R with Goto's BLAS
    >> http://www.cs.utexas.edu/users/kgoto/
    >> 
    >> I haven't worked with Opteron or Athlon64 computers but I understand
    >> that Goto's BLAS are very effective on those machines.  Furthermore
    >> Goto's BLAS are (only) available as .so libraries so you don't need to
    >> mess with creating the .so version.

    PD> I tried it, yes. Somewhat to my surprise, it seemed to be not quite as
    PD> fast as the threaded ATLAS, but I wasn't very systematic about the
    PD> benchmarking.

    PD> (and the Goto items have license issues, which get in the way for
    PD> binary distributions.)

Thanks a lot, Peter, Brian, Doug, for your feedbacks!
In the mean time, I have three running versions of R(-devel) on
the 64-Opteron
- "plain"
- linked against threaded GOTO
- linked against threaded (static) ATLAS  (using -fPIC for compilation;
					   "large" Rlapack)
and I find that GOTO is faster than ATLAS
consistently (between ~ 5-20%) for several tests
(square matrices; %*% and solve).
ATLAS is still an order of magnitude faster than "plain" for
3000x3000 matrices.

Here are somewhat repeatable "ATLAS for R" build instructions:

 1. get ATLAS source; unpack
 2. make : use defaults and "express" installation
 3. Before "make install ...", edit the  Make.<ARCHITECTURE> file:
    add "-fPIC" to three places, namely  F77FLAGS, CCFLAG0, and MMFLAGS:
    which in case of the "threaded Opteron" architecture, leads to
    the three new lines
       F77FLAGS = -fPIC -fomit-frame-pointer -O -m64

	CCFLAG0 = -fPIC -fomit-frame-pointer -O -mfpmath=387 -m64

	MMFLAGS = -fPIC -fomit-frame-pointer -O -mfpmath=387 -m64
    in the file   Make.Linux_HAMMER64SSE2_2

 4. make install arch=Linux_HAMMER64SSE2_2

 5. Sym.link the ATLAS libraries into /usr/local/lib:

    cd /usr/local/lib
    ln -s <ATLAS_build_dir>/lib/Linux_HAMMER64SSE2_2/lib* .

 6. (needed for runtime!):
    Use environment variable LD_LIBRARY_PATH=/usr/local/lib


Note that I haven't built *.so (shared) libraries yet.

Martin Maechler <maechler@stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO C16	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><


[Rd] ATLAS threaded 64 bit Opteron build for R: need -fPIC
Martin Maechler