Rev 31272 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
Notes on using Atlas libs with GNU Octave and GNU RI. OverviewAs of the Debian releases 2.1.34-6 (for GNU Octave) and 1.3.0-3 (for GNU R),both Octave and R can be used with Atlas, the Automatically Tuned LinearAlgebra Software, in order to obtain much faster linear algebra operations.To make use of Atlas, Debian users need to install the Atlas libraries fortheir given cpu architecture. Concretely, one ofatlas2-base - Automatically Tuned Linear Algebra Softwareatlas2-p3 - Automatically Tuned Linear Algebra Softwareatlas2-p4 - Automatically Tuned Linear Algebra Softwareatlas2-athlon - Automatically Tuned Linear Algebra Softwaremust be installed. Here, 'base' provides generic libraries which run on allplatforms whereas 'p3', 'p4' and 'athlon' stand for the Pentium III and IV aswell as the AMD Athlon, respectively. The actual libraries are installed in/usr/lib/atlas (in the case of 'base') and in /usr/lib/$arch/atlas for thecpu-specific versions. Here $arch stands for the cpu code used by the kerneland shown in /proc/cpuinfo.The Atlas libraries can be loaded dynamically instead of the (non-optimised)blas libraries against which both Octave and R are compiled.Section III below briefly describes how Atlas libraries can be compiled foryour specific machine to further optimise performance.II. Using the Atlas librariesII.A New default behaviour with automatic loading of the Atlas librariesIn order to have the libraries loaded at run-time, the location needs to becommunicated to the dynamic linker/loader. As of the Debian releaselibc6_2.2.4-5 of the glibc library, a patch to ldconfig automates the use ofthe Atlas library. If an Atlas package is installed, and correctly registeredin /etc/ld.so.conf as done by its postinst script, ldconfig willautomatically load the Atlas' version of the Blas instead of the (slower)default Blas.The following text is hence only relevant for systems which have not yetupgraded to libc6_2.2.4-5 or later.II.B Old behaviour requiring LD_LIBRARY_PATH for OctaveFor Octave, use the variable LD_LIBRARY_PATH. On a computer with theatlas2-base package:$ LD_LIBRARY_PATH=/usr/lib/atlas octave2.1 -qoctave2.1:1> X=randn(1000,1000);t=cputime();Y=X'*X;cputime-tans = 7.9600$ edd@homebud:~> octave2.1 -qoctave2.1:1> X=randn(1000,1000);t=cputime();Y=X'*X;cputime-tans = 61.520For R version 1.3.0-4, the R_LD_LIBRARY_PATH variable has to be used, and itsvalue needs to be copied out of /usr/bin/R (or edited therein). For R version1.3.1 or later this is done automatically in the R startup shell script. Foran Athlon machine, and with the explicit definition which is no longer neededas of R 1.3.1, the example becomes$ R_LD_LIBRARY_PATH=/usr/lib/R/bin:/usr/local/lib:/usr/X11R6/lib:/usr/lib/3dnow/atlas:/usr/lib:/usr/X11R6/lib:/usr/lib/gcc-lib/i386-linux/2.95.4:. R --vanilla -q> mm <- matrix(rnorm(10^6), ncol = 10^3)> system.time(crossprod(mm))[1] 2.38 0.04 2.84 0.00 0.00$ R --vanilla -q> mm <- matrix(rnorm(10^6), ncol = 10^3)> system.time(crossprod(mm))[1] 28.28 0.08 33.54 0.00 0.00>Running such a small example is highly recommded to ascertain that thelibraries are indeed found, and to "prove" that the speed gain is real (andsignificant) for problems of at least a medium size as the 1000x1000 examplesabove.Note that the example use "/usr/lib/atlas" for the atlas2-base package;Athlon users should employ "/usr/lib/3dnow/atlas", Pentium III users shouldemploy "/usr/lib/xmm/atlas" and Pentium IV users should employ"/usr/lib/26/atlas".Lastly, it should be pointed out that it is probably worthwhile to locallycompile, and thereby optimise, the Atlas libraries if at least a moderatelyintensive load is expected. This is described in the next section.III. Locally compiling the Atlas librariesThe Debian Atlas packages have been setup to allow for local recompilation ofthe Atlas libraries. This way the behaviour will be tuned exactly to thespecific CPU rather than the broader class of CPUs. It has been reported thatthis can increase performance by a further 12% on the examples above.Detailed instructions are in /usr/share/doc/atlas2-base/README.debian.gz butthe process is essentially the following [ courtesy of Doug Bates ]apt-get source atlas2-basecd atlas2-$VERSIONfakeroot debian/rules/custom# wait for a *very* long timedpkg -i ../atlas2-base*.debIV. See alsoThe Atlas packages have a very detailed README.Debian file which should beconsulted; it also details local recompilation. Sources and documentation forAtlas are at http://www.netlib.org/atlas.V. AcknowledgementsCamm Maguire developed the scheme of overloading Atlas over the default blaslibraries and deserves all the credit. Many thanks to John Eaton for helpingdebug some errors in the initial setup, and to Doug Bates for work on the Rpackage. Special thanks to Ben Collins for providing a patched ldconfig aspart of the libc6 package.Initial version-- Dirk Eddelbuettel <edd@debian.org> Tue, 21 Aug 2001 21:37:15 -0500First updated-- Dirk Eddelbuettel <edd@debian.org> Sun, 11 Nov 2001 11:03:19 -0600