Using MPI on Solaris10, Linux with GCC4

Contents

  1. GCC-4.2.2
  2. rsh/rlogin on Linux
  3. openmpi-1.2.4
  4. mpich2-1.0.6p1

Target

Set your environment variable $LD_LIBRARY_PATH as followings:
zsh or bash, Solaris10

    % LD_LIBRARY_PATH=/usr/local/gcc4/lib/amd64:/usr/local/openmpi/lib:/usr/local/mpich2/lib
    % export LD_LIBRARY_PATH

zsh or bash, Linux

    % LD_LIBRARY_PATH=/usr/local/gcc4/lib64:/usr/local/openmpi/lib:/usr/local/mpich2/lib
    % export LD_LIBRARY_PATH

csh or tcsh, Solaris10

    % setenv LD_LIBRARY_PATH /usr/local/gcc4/lib/amd64:/usr/local/openmpi/lib:/usr/local/mpich2/lib

csh or tcsh, Linux

    % setenv LD_LIBRARY_PATH /usr/local/gcc4/lib64:/usr/local/openmpi/lib:/usr/local/mpich2/lib


GMP and MPFR are required for gfortran (GCC4 Fortran).

gmp-4.2.2

% gtar jxf gmp-4.2.2.tar.bz2
% cd gmp-4.2.2
% ./configure --prefix=/usr/local
% gmake
% su
# gmake install

mpfr-2.3.0

% gtar jxf mpfr-2.3.0.tar.bz2
% cd mpfr-2.3.0
% ./configure --prefix=/usr/local
% gmake
% su
# gmake install

GCC-4.2.2

% cd /usr/local/src
% gtar jxf gcc-4.2.2.tar.bz2
% cd gcc-4.2.2
% mkdir obj
% cd obj
Configuration (Solaris 10)
% ../configure --prefix=/usr/local/gcc-4.2.2 \
    --disable-nls --enable-multilib --with-mpfr=/usr/local --with-gmp=/usr/local \
    --enable-languages=c,c++,fortran --enable-threads --enable-shared \
    --with-gnu-as --with-as=/usr/sfw/bin/gas \
    --without-gnu-ld --with-ld=/usr/ccs/bin/ld --with-included-gettext
Configuration (Linux)
% ../configure --prefix=/usr/local/gcc-4.2.2 \
    --enable-nls --enable-multilib --with-mpfr=/usr/local --with-gmp=/usr/local \
    --enable-languages=c,c++,fortran --enable-threads=posix --enable-shared \
    --disable-checking --with-system-zlib --enable-__cxa_atexit \
    --disable-libunwind-exceptions --host=x86_64-redhat-linux
Compilation and Instration
% gmake CFLAGS='-O' LIBCFLAGS='-g -O2'  LIBCXXFLAGS='-g -O2 -fno-implicit-templates' bootstrap
% su
# gmake install
# cd /usr/local
# ln -s gcc-4.2.2 gcc4
(cf) GCC-4.3.0 on Linux (Fedora 8)
% ../configure --prefix=/usr/local/gcc-4.3.0 \
    --enable-nls --enable-multilib --with-mpfr=/usr/local --with-gmp=/usr/local \
    --enable-languages=c,c++,fortran --enable-threads=posix --enable-shared \
    --disable-checking --with-system-zlib --enable-__cxa_atexit \
    --disable-libunwind-exceptions
% gmake CFLAGS='-O' LIBCFLAGS='-g -O2'  LIBCXXFLAGS='-g -O2 -fno-implicit-templates'
Back to Top

rsh, rlogin on Linux

In current Linux distributions, rsh/rlogin are turned off in the default instllation. Following instructions enables you to use the r-series commands.
% su
# cd /usr
# mv kerberos kerberos.orig
# chkconfig rsh on
# chkconfig rlogin on
# chkconfig rexec on
Create the file /etc/hosts.equiv which contains the MPI node name.
host1
host2
host3
Back to Top

openmpi-1.2.4

Download from here

Configuration, Compilation and Installation

% ./configure --prefix=/usr/local/openmpi-1.2.4 \
    --enable-mpi-f77 --enable-mpi-f90 \
    CC=/usr/local/gcc4/bin/gcc CFLAGS="-m64 -O2" \
    CXX=/usr/local/gcc4/bin/g++ CXXFLAGS="-m64 -O2" \
    F77=/usr/local/gcc4/bin/gfortran FFLAGS="-m64 -O2" \
    FC=/usr/local/gcc4/bin/gfortran FCFLAGS="-m64 -O2"
% su
# gmake install
# cd /usr/local
# ln -s openmpi-1.2.4 openmpi

Using openmpi

  1. Create the file 'machines'
    host1 slots=4
    host2 slots=3
    host3 slots=1
    
    In this example, 4 processes will run on the host1 at maximum, 3 processes will run on the host2, and so on.
  2. Compile your program.
    % /usr/local/openmpi/bin/mpicc -m64 -O2 sample.c
    % /usr/local/openmpi/bin/mpicxx -m64 -O2 sample.cxx
    % /usr/local/openmpi/bin/mpif77 -m64 -O2 sample.f
    % /usr/local/openmpi/bin/mpif90 -m64 -O2 sample.f90
    
  3. Run your program.
    % /usr/local/openmpi/bin/mpiexec -mca pls_rsh_agent "rsh" \
        -machinefile machines -np 8 -x LD_LIBRARY_PATH=$LD_LIBRARY_PATH \
        a.out
    
If you have the error "mca_btl_tcp_endpoint_complete_connect", you may have multiple TCP interfaces on some nodes. Turn off (by ifdown) interfaces, and please retry!

Back to Top


mpich2-1.0.6p1

Download from here

Configuration, Compilation and Installation

% CC='/usr/local/gcc4/bin/gcc' CFLAGS='-m64 -O2' \
    CXX='/usr/local/gcc4/bin/g++' CXXFLAGS='-m64 -O2' \
    F77='/usr/local/gcc4/bin/gfortran' FFLAGS='-m64 -O2' \
    F90='/usr/local/gcc4/bin/gfortran' F90FLAGS='-m64 -O2' \
    ./configure --prefix=/usr/local/mpich2-1.0.6p1 --enable-f90 --enable-f77 -enable-cxx -enable-fast
% gmake
% su
# gmake install
# ln -s mpich2-1.0.6p1 mpich2

Using mpich2

  1. Create $(HOME)/.mpd.conf which contains the following line
    MPD_SECRETWORD=hogehoge
    
  2. Set permissiong of the file $(HOME)/.mpd.conf to '600'
    % chmod 600 ~/.mpd.conf
    
  3. Create the file mpd.hosts which contains node names on which you want to run mpich2.
    host1
    host2
    host3
    
  4. Launch the daemon.
    % /usr/local/mpich2/bin/mpdboot -v -r rsh -n 3 -f ./mpd.hosts
    
    where the argument '3' is the number of the MPI hosts.
  5. Create the file 'machines' which contains the computer names.
    host1
    host1
    host1
    host1
    host2
    host2
    host2
    host3
    
    In this example, 4 processes will run on the host1 at maximum, 3 processes will run on the host2, and so on.
  6. Compile your program.
    % /usr/local/mpich2/bin/mpicc -m64 -O2 sample.c
    % /usr/local/mpich2/bin/mpicxx -m64 -O2 -DMPICH_IGNORE_CXX_SEEK sample.cxx
    % /usr/local/mpich2/bin/mpif77 -m64 -O2 sample.f
    % /usr/local/mpich2/bin/mpif90 -m64 -O2 sample.f90
    
  7. Run your programs.
    % /usr/local/mpich2/bin/mpiexec -machinefile machines -np 8 \
        -env LD_LIBRARY_PATH $LD_LIBRARY_PATH ./a.out
    
  8. Exit the daemon.
    % /usr/local/mpich2/bin/mpdtrace -l
    % /usr/local/mpich2/bin/mpdexit host2_0000
    % /usr/local/mpich2/bin/mpdexit host1_0000
    
    where you can know 'host2_0000' and 'host1_0000' by 'mpdtrace' output.
Back to Top
FUJIWARA, Hiroshi <fujiwara (at mark) acs.i.kyoto-u.ac.jp>