installation.html

来自「麻省理工的计算光子晶体的程序」· HTML 代码 · 共 541 行 · 第 1/2 页

HTML
541
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD><TITLE>Installation</TITLE><LINK rel="Contents" href="index.html"><LINK rel="Copyright" href="license.html"><LINK rel="Start" href="index.html"></HEAD><BODY TEXT="#000000" BGCOLOR="#FFFFFF">Go to the <a href="user-tutorial.html">next</a>, <a href="introduction.html">previous</a>, or <a href="index.html">main</a> section.<hr><h1>Installation</h1><p>In this section, we outline the procedure for installing the MITPhotonic-Bands package.  Mainly, this consists of downloading andinstalling various prerequisites.  As much as possible, we haveattempted to take advantage of existing packages such as BLAS, LAPACK,FFTW, and GNU Guile, in order to make our code smaller, more robust,faster, and more flexible.  Unfortunately, this may make theinstallation of MPB more complicated if you do not already have thesepackages.<p>You will also need an ANSI C compiler, of course (gcc is fine), andinstallation will be easiest on a UNIX-like system (Linux is fine).In the following list, some of the packages are dependent uponpackages listed earlier, so you should install them in more-or-lessthe order given.<p><b>Note:</b> Many of these libraries may be available inprecompiled binary form, especially for GNU/Linux systems.  Be aware,however, that library binary packages often come in two parts,<code>library</code> and <code>library-dev</code>, and <em>both</em>are required to compile programs using it.<p><b>Note:</b> It is important that you use the <em>same Fortrancompiler</em> to compile Fortran libraries (like LAPACK) and forconfiguring MPB.  Different Fortran compilers often have incompatiblelinking schemes.  (The Fortran compiler for MPB can be set via the<code>F77</code> environment variable.)<h2><a name="paths">Installation Paths</a></h2><p>First, let's review some important information about installingsoftware on Unix systems, especially in regards to installing softwarein non-standard locations.  (None of these issues are specific to MPB,but they've caused a lot of confusion among our beloved users.)<p>Most of the software below, including MPB, installs under<code>/usr/local</code> <a href="http://www.pathname.com/fhs/" title="Linux Filesystem Hierarchy Standard">by default</a>; that is, libraries go in<code>/usr/local/lib</code>, programs in <code>/usr/local/bin</code>,etc.  If you don't have <code>root</code> privileges on your machine,you may need to install somewhere else, e.g. under<code>$HOME/install</code> (the <code>install/</code> subdirectory ofyour home directory).  Most of the programs below use a GNU-style<code>configure</code> script, which means that all you would do toinstall there would be:<pre>./configure --prefix=$HOME/install</pre>when configuring the program; the directories<code>$HOME/install/lib</code> etc. are created automatically asneeded.<h3>Paths for Configuring</h3><p>There are two further complications.  First, if you install in anon-standard location (and <code>/usr/local</code> is considerednon-standard by some proprietary compilers), you will need to tell thecompilers where to find the libraries and header files that youdutifully installed.  You do this by setting two environment variables:<pre>setenv LDFLAGS "-L/usr/local/lib"setenv CPPFLAGS "-I/usr/local/include"</pre>Of course, substitute whatever installation directory you used.  Dothis <em>before</em> you run the <code>configure</code> scripts,etcetera.  You may need to include multiple <code>-L</code> and<code>-I</code> flags (separated by spaces) if your machine has stuffinstalled in several non-standard locations.  Bourne shell users(e.g. <code>bash</code> or <code>ksh</code>) should use the"<code>export FOO=bar</code>" syntax instead of <code>csh</code>'s"<code>setenv FOO bar</code>", of course.<p>You might also need to update your <code>PATH</code> so that youcan run the executables you installed (although<code>/usr/local/bin</code> is in the default <code>PATH</code> onmany systems).  e.g. if we installed in our home directory asdescribed above, we would do:<pre>setenv PATH "$HOME/install/bin:$PATH"</pre><h3>Paths for Running (Shared Libraries)</h3><p>Second, many of the packages installed below (e.g. Guile) areinstalled as shared libraries.  You need to make sure that yourruntime linker knows where to find these shared libraries.  The badnews is that every operating system does this in a slightly differentway.  The good news is that, when you run <code>make install</code>for the packages involving shared libraries, the output includes thenecessary instructions specific to your system, so pay closeattention!  It will say something like "<code>add LIBDIR to the<code><i>foobar</i></code> environment variable</code>," where<code>LIBDIR</code> will be your library installation directory(e.g. <code>/usr/local/lib</code>) and <i>foobar</i> is someenvironment variable specific to your system(e.g. <code>LD_LIBRARY_PATH</code> on some systems, including Linux).For example, you might do:<pre>setenv <i>foobar</i> "/usr/local/lib:$<i>foobar</i>"</pre>Note that we just add to the library path variable, and don't replaceit in case it contains stuff already.  If you use Linux and have<code>root</code> privileges, you can instead simply run<code>/sbin/ldconfig</code>, first making sure thata line "<code>/usr/local/lib</code>" (or whatever) is in<code>/etc/ld.so.conf</code>.<p>If you don't want to type these commands every time you log in, youcan put them in your <code>~/.cshrc</code> file (or<code>~/.profile</code>, or <code>~/.bash_profile</code>, depending onyour shell).  <h2><a name="fortran">Fun with Fortran</a></h2><p>MPB, and many of the libraries it calls, are written in C, but italso calls libraries such as BLAS and LAPACK (see below) that areusually compiled from Fortran.  This can cause some added difficultybecause of the various linking schemes used by Fortran compilers.MPB's <code>configure</code> script attempts to detect the Fortranlinking scheme automatically, but in order for this to work <em>youmust use the same Fortran compiler and options with MPB as were usedto compile BLAS/LAPACK</em>.<p>By default, MPB looks for a vendor Fortran compiler first(<code>f77</code>, <code>xlf</code>, etcetera) and then looks for GNU<code>g77</code>.  In order to manually specify a Fortran compiler<code>foobar</code> you would <a href="#mpb">configure MPB</a> with'<code>./configure F77=foobar ...</code>'.<p>If, when you compiled BLAS/LAPACK, you used compiler options thatalter the linking scheme (e.g. <code>g77</code>'s<code>-fcase-upper</code> or <code>-fno-underscoring</code>), you willneed to pass the same flags to MPB via '<code>./configureFFLAGS="...<i>flags</i>..." ...</code>'.<p>One final note: you may run into trouble if you use a C compiler bya different vendor than your Fortran compiler, due to incompatiblelibraries.  By default, MPB looks for a vendor C compiler(<code>cc</code>) first, but you can specify a different C compilerwith '<code>./configure CC=foobar ...</code>'.<h2><a name="blas">BLAS</a></h2><p>The first thing you must have on your system is a BLASimplementation.  "BLAS" stands for "Basic Linear Algebra Subroutines,"and is a standard interface for operations like matrix multiplication.It is designed as a building-block for other linear-algebraapplications, and is used both directly by our code and in LAPACK (seebelow).  By using it, we can take advantage of many highly-optimizedimplementations of these operations that have been written to the BLASinterface.  (Note that you will need implementations of BLAS levels 1-3.)<p>You can find more BLAS information, as well as a basicimplementation, on the <a href="http://www.netlib.org/blas/">BLASHomepage</a>.  Once you get things working with the basic BLASimplementation, it might be a good idea to try and find a moreoptimized BLAS code for your hardware.  Vendor-optimized BLASimplementations are available as part of the Compaq CXML, IBM ESSL,SGI sgimath, and other libraries.  Recently, there has also been workon self-optimizing BLAS implementations that can achieve performancecompetitive with vendor-tuned codes; see the <ahref="http://math-atlas.sourceforge.net/">ATLAS</a> homepage (and also <ahref="http://www.icsi.berkeley.edu/~bilmes/phipac/">PhiPACK</a>).Links to more BLAS implementations can be found on <ahref="http://SAL.KachinaTech.COM/B/0/BLAS.html" title="ScientificApplications on Linux (SAL) BLAS page">SAL</a>.  I recommend ATLAS,but it does take some time to compile.<p>Note that the generic BLAS does not come with a<code>Makefile</code>; compile it with something like:<pre>mkdir blas && cd blas # the BLAS archive does not create its own directory<i>get http://www.netlib.org/blas/blas.tgz</i>gunzip blas.tgztar xf blas.tarf77 -c -O3 *.f   # compile all of the .f files to produce .o filesar rv libblas.a *.o    #  combine the .o files into a librarysu -c "cp libblas.a /usr/local/lib"   # switch to root and install</pre><p>(Replace <code>-O3</code> with your favorite optimization options.On Linux, I use <code>g77 -O3 -fomit-frame-pointer-funroll-loops</code>, with <code>-malign-double -mcpu=i686</code> ona Pentium II.)  Note that MPB looks for the standard BLAS library with<code>-lblas</code>, so the library file should be called<code>libblas.a</code> and reside in a standard directory like<code>/usr/local/lib</code>.  (See also below for the<code>--with-blas=<i>lib</i></code> option to MPB's<code>configure</code> script, to manually specify a library location.)<h2><a name="lapack">LAPACK</a></h2><p>LAPACK, the Linear Algebra PACKage, is a standard collection ofroutines, built on BLAS, for more-complicated (dense) linear algebraoperations like matrix inversion and diagonalization.  You candownload LAPACK from the <ahref="http://www.netlib.org/lapack/">LAPACK Home Page</a>.  MoreLAPACK links can be found on <ahref="http://SAL.KachinaTech.COM/B/0/LAPACK.html" title="ScientificApplications on Linux (SAL) LAPACK page">SAL</a>.<p>Note that MPB looks for LAPACK by linking with<code>-llapack</code>.  This means that the library must be called<code>liblapack.a</code> and be installed in a standard directory like<code>/usr/local/lib</code> (alternatively, you can specify anotherdirectory via the <code>LDFLAGS</code> environment variable asdescribed earlier).  (See also below for the<code>--with-lapack=<i>lib</i></code> option to MPB's<code>configure</code> script, to manually specify a library location.)<h2><a name="mpi">MPI</a> <i>(optional)</i></h2><p>Optionally, MPB is able to run on a distributed-memory parallelmachine, and to do this we use the standard MPI message-passinginterface.  You can learn about MPI from the <ahref="http://www-unix.mcs.anl.gov/mpi/index.html">MPI Home Page</a>.Most commercial supercomputers already have an MPI implementationinstalled; two free MPI implementations that you can install yourselfare <a href="http://www-unix.mcs.anl.gov/mpi/mpich/">MPICH</a> and <ahref="http://www.lam-mpi.org/">LAM</a>.  MPI is <i>not required</i>to compile the ordinary, uniprocessor version of MPB.<p>In order for the MPI version of MPB to run successfully, we have aslightly nonstandard requirement: each process must be able to readfrom the disk.  (This way, Guile can boot for each process and theycan all read your control file in parallel.)  Many (most?) commercialsupercomputers, Linux <a href="http://www.beowulf.org">Beowulf</a>clusters, etcetera, satisfy this requirement.<p>Also, in order to get good performance, you'll need fastinterconnect hardware such as Myrinet; 100Mbps Ethernet probably won'tcut it.  The speed bottleneck comes from the FFT, which requires mostof the communications in MPB.  FFTW's MPI transforms (<ahref="#fftw">see below</a>) come with benchmark programs that willgive you a good idea of whether you can get speedups on your system.Of course, even with slow communications, you can still benefit fromthe memory savings per CPU for large problems.<p>As described <a href="#mpb">below</a>, when you configure MPB withMPI support (<code>--with-mpi</code>), it installs itself as<code>mpb-mpi</code>.  See also the <ahref="user-ref.html#mpb-mpi">user reference</a> section forinformation on using MPB on parallel machines.<p>MPI support in MPB is thanks to generous support from <ahref="http://www.clarendonphotonics.com/">Clarendon Photonics</a>.<h2><a name="hdf5">HDF5</a> <i>(optional, strongly advised)</i></h2><p>We require a portable, standard binary format for outputting theelectromagnetic fields and similar volumetric data, and for this we

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?