Instructions on using the Beowulf


Beowulf specifications
Caveats (Important!)
Logging in
Compiling programs
Running programs
Timing your runs
Installed Libraries
MPI Example
OpenMP Example





Beowulf specifications





Caveats

Your account will be disabled on 6/1/2005, so move your stuff off the Beowulf before 6/1 to avoid trouble.
ALWAYS backup your data on another machine. Computers are NOT to be trusted.




Logging In


ssh to beowulf.lcs.mit.edu

When you log in for the first time , it will ask for a passphrase for your private key. Hit enter (i.e. no passphrase), otherwise mpirun would be unhappy. If you have entered a passphrase, erase the contents of ~/.ssh and log in again to create new keys.

If you are on a windows machine, download SecureCRT (available
here , MIT certificate required).

Putty is another windows SSH client and it's freely available, although it's not as feature-rich as SecureCRT.

After logging in, use passwd to change your password from the initial one I sent out. Then, you could use chfn to fill in your own details, although this is not necessary. If you prefer a different login shell (default is bash), use chsh to change it.




Compiling Programs

For MPI programs, use mpicc for C programs, mpiCC for C++ programs, mpif77 for fortran programs, as follows:
mpicc -O -o test mytest.c
or,
mpiCC -O -o test mytest.cc
or,
mpif77 -O -o test mytest.f

For OpenMP programs you need to use the Intel Fortran/C Compilers. Do the following:
source /opt/intel_cc_80/bin/iccvars.sh
then,
icc -O -openmp -o test mytest.cc
or,
ifc -O -openmp -o test mytest.f




Running code

PBS is now running on the beowulf. Please go here for instructions on using PBS. Usage is REQUIRED . Any jobs found running without reservations will be killed without warning. Repeated offenders will be penalized.

For running interactive jobs, the script /share/getresv could be used. /share/getresv 2 will return a shell to a 2 nodes allocation.

Although we now have all 8 compute nodes available, giving us 16 processors, please refrain from using -np 16 unless you really need the 16 processors. Usually an -np 4 is good enough.


For OpenMP program, you can just run it.




Timing your runs


You can use the command time to time your runs. For example,

time ./myprog

returns something like

real 0m0.958s
user 0m0.180s
sys 0m0.170s

real is the wall clock time elapsed.

Timing MPI programs is similar,

time mpirun -np 4 ./hello++

This method is not very accurate. For accurate timing, use the function MPI_WTime


Installed Libraries


The following libraries are installed on the beowulf



MPI example

#include "mpi.h"
#include "unistd.h"
#include "stdio.h"

int main(int argc, char **argv) {

  size_t len=256;
  char *hostname = new char[len];
  int size,rank;

  MPI_Init(&argc, &argv);

  MPI_Comm_size(MPI_COMM_WORLD, &size);
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);

  gethostname(hostname, len);

  printf("Hi, I am %d of %d and my hostname is %s\n", rank, size, hostname);

  MPI_Finalize();

}


There are more examples in /usr/local/mpich/examples
Copy the files to your home directory and compile there.




OpenMP example


#include <math.h>
#include <stdio.h>

#define N 16384
#define M 10

double dotproduct(int, double *);


double dotproduct(int i, double *x) {
  
  double temp=0.0, denom;
  int j;

  for (j=0; j<N; j++) {
    // zero based!!
    denom = (i+j)*(i+j+1)/2 + i+1;
    temp = temp + x[j]*(1/denom);  
  }

  return temp;
}


int main() {


  double *x = new double[N];
  double *y = new double[N];
  double eig = sqrt(N);
  double denom,temp;
  int i,j,k;

  for (i=0; i<N; i++) {
    x[i] = 1/eig;
  }

  for (k=0;k<M;k++) {

    y[i]=0;

    // compute y = Ax
#pragma omp parallel for shared(y)
    for (i=0; i<N; i++) {     
      y[i] = dotproduct(i,x);
    }
    
    // find largest eigenvalue of y
    eig = 0;    
    for (i=0; i<N; i++) {
      eig = eig + y[i]*y[i];
    }    
    eig = sqrt(eig);
   
    printf("The largest eigenvalue after %2d iteration is %16.15e\n",k+1, eig);


    // normalize
    for (i=0; i<N; i++) {
      x[i] = y[i]/eig;
    }

  }



}


Note that you need to use mpiCC for this program since it is in C++.
Try to compile it with and without openMP.



Ron Choy
Last modified: Tue Feb 4 09:45:22 GMT 2003