The BLAS is library of simple linear algebra routines that are used in more advanced libraries such as LAPACK. Using optimized BLAS library such as Atlas is very important since linear algebra operations can very slow. For example matrix multiplication using ATLAS is about 50 times faster than vanilla C# code.
Installation of Atlas on Linux is very straightforward, while installing it on Windows can be quite
challenging. Hopefully reading this will save you some time and make installation of Atlas easier.
Prerarations
First download and install Linux-like command line environment for Windows called Cygwin. In Cygwin command line enter the following commands (you current directory should contain Atlas tar archive):
gunzip -c atlas3.8.0.tar | tar xfm -
mv ATLAS ATLAS3.8.0
cd ATLAS3.8.0
mkdir WinNT
cd WinNT
Configuration
Before running configuration script, make sure that “IRunArchInfo_winnt” is defined in
ATLAS\CONFIG\src\Makefile
If it is not defined, then copy definition for “IRunArchInfo_linux” and rename linux to winnt
So it should look like this in ATLAS\CONFIG\src\Makefile:
IRunArchInfo_winnt: xarchinfo_winnt
- rm -f config0.out
$(MAKE) $(atlrun) atldir=$(mydir) exe=xarchinfo_winnt args="$(args)" \
redir=config0.out
Now you can run atlas configuration script by entering the following in cygwin command promt
../configure -b 32 -D c - -DPentiumCPS=2800 -Fa alg -fPIC --with-netlib-lapack={your LAPACK path}/lapack_LINUX.a
If you have 64bit CPU then instead of “-b 32” use “-b 64”. Specify your CPU frequency in Mhz for example if you have 2.8Ghz CPU then use “-DPentiumCPS=2800” . If you want to use LAPACK library with your atlas you should specify where your lapack library is located. For example in order to use lapack from "C:\Numlib\LAPACK_3.1.1\lapack_LINUX.a" you should use to following command line argument in atlas configuration script
“--with-netlib-lapack= /cygdrive/c/Numlib/LAPACK_3.1.1/lapack_LINUX.a”
Run configuration script.
Build
If configuration script completes without errors, try to make atlas library by entering:
make build
The build takes about 20-30 minutes. Since atlas will be running benchmarks on your computer as a part of installation process, close all applications (except cygwin) and do not use your computer while installation is running (this is important if you want to have a good Atlas library).
Check
After installation is complete you can check atlas library.
make time
If check did not find any errors with your atlas library and you are happy with timings you can proceed to the next step of generating dynamic library.
Dynamic Library
Atlas static libraries are located in WinNT\lib folder, you will need them to build dynamic library.
Atlas provides a script that generates dynamic library (make shared) but this script does not work in cygwin environment (it did not work for me). So i wrote a script to create Atlas dynamic library that worked on my computer. You are welcome to use it and modify it in any way you want.
#! /bin/bash
# base name of the DLL
AtlasName=my_atlas_library
# set names for specific output files
defname=exports.def
dllname=${AtlasName}.dll
CLIBPATH=/cygdrive/c/cygwin/lib/mingw
CLIBPATH1=/cygdrive/c/cygwin/lib/gcc/i686-pc-mingw32/3.4.4
mingwclib="$CLIBPATH1/libg2c.a $CLIBPATH/libmoldname.a $CLIBPATH/libmsvcrt.a"
# Link Atlas DLL
echo 'Linking DLL and creating gcc import library...'
gcc -mno-cygwin -shared -o ${dllname} ${defname} \
liblapack.a libcblas.a libf77blas.a libatlas.a \
-Wl,--out-implib=${gcclibname} \
-Wl,--enable-auto-import \
-Wl,--no-whole-archive ${mingwclib}
###########EOF###########
Run this script by entering "./link.bash" in cygwin command window. ("./" before file name indicates that script is located in current folder)
exports.def – is the list of functions that you what to export. You can download it from http://www.dnanalytics.net/files/exports.def.
No comments:
Post a Comment