14.11.2014 Views

User Guide

User Guide

User Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Xseed <strong>User</strong> Manual<br />

1.) How to compile and run the MPI program without queuing system<br />

2.) How to submit a job to queuing system<br />

3.) How to submit MPI program to queuing system<br />

MPI<br />

In /apps/MPI_users_help/MPI_examples/ there are some examples (simple mpi apps in c,<br />

c++, and fortran). Copy the files from directory to your directory first using:<br />

mkdir ~/MPI/<br />

mkdir ~/MPI/examples/<br />

cp /apps/MPI_users_help/MPI_examples/* ~/MPI/examples/<br />

cd ~/MPI/examples<br />

Now you have the examples in your directory: /home/$user/MPI/examples. And you are<br />

in this directory too.<br />

Setup environment: - not necessary with runmpi script<br />

To launch the MPI applications from xseed1 the environment must be set up:<br />

export MXMPI_MASTER=10.224.0.1<br />

Make a machine file:<br />

Machine file is a file with every node name you want use listed 1 per line. It would look like<br />

this:<br />

Node1<br />

node1<br />

node2<br />

node2<br />

...<br />

node224<br />

node224


Nodes are listed twice because there are 2 cpus per machine, if you only want 1 cpu per node,<br />

just list them once.<br />

To generate the machine file there was created a script. The script name is gen and it is<br />

located in the directory:<br />

/apps/MPI_users_help/ or /apps/MPI_users_help/MPI_examples/.<br />

The script has two parameters – the first parameter is the first compute node and second<br />

parameter is the last comp node. The script was already copied to your home directory with<br />

the code examples.<br />

Example of using the script:<br />

./gen 1 20,<br />

will generate the machinefile (machlist.mch) with nodes from 1 to 20.<br />

Compile and run the examples<br />

To compile the examples type:<br />

make<br />

To run one of the examples (cpi.c) use:<br />

./runmpi


MPI – First program – helloworld.c<br />

Copy the hello.c source code, Makefile and the rest of necessary files to your directory<br />

using:<br />

mkdir ~/MPI/<br />

mkdir ~/MPI/helloworld/<br />

cp /apps/MPI_users_help/helloworld/* ~/MPI/helloworld/<br />

cd ~/MPI/helloworld<br />

The content of the directory is:<br />

gen<br />

- machinefile generator<br />

hello.c - helloworld source code<br />

machlist.mch - machine file<br />

Makefile - makefile – to compile to source code<br />

runmpi<br />

- program execution script<br />

Edit the source code:<br />

vi hello.c<br />

Compile the program<br />

Create (or edit) the Makefile to compile the source code:<br />

vi Makefile<br />

The Makefile looks like this:<br />

CC<br />

= /opt/mpich-mx/bin/mpicc<br />

CCC<br />

= /opt/mpich-mx/bin/mpicxx<br />

F77<br />

= /opt/mpich-mx/bin/mpif77<br />

CLINKER = /opt/mpich-mx/bin/mpicc<br />

CCLINKER = /opt/mpich-mx/bin/mpicxx<br />

FLINKER = /opt/mpich-mx/bin/mpif77<br />

F90<br />

= /opt/mpich-mx/bin/mpif90<br />

F90LINKER = /opt/mpich-mx/bin/mpif90<br />

MAKE = make --no-print-directory<br />

SHELL = /bin/sh<br />

EXECS = hello #name of your source code without extension (e.g. hello.c)<br />

all:<br />

$(CC) -o $(EXECS) $(EXECS).c -lm<br />

clean:<br />

-rm *.o<br />

All you need to change in the Makefile is the name of your program, which is after EXECS.<br />

The name of the program in the example is hello.c (don’t change the file if you want to<br />

compile hello.c)<br />

If you create a Makefile, type<br />

make<br />

to compile the source code.<br />

If you does not want to use the Makefile type<br />

/opt/mpich-mx/bin/mpicc -o hello hello.c –lm<br />

to compile the source code. The example shows how to compile source code hello.c


Run the program<br />

/opt/mpich-mx/bin/mpirun -np -machinefile<br />

./<br />

Example : Script “runmpi”<br />

The example shows the content of the script runmpi which executes the program hello .<br />

export MXMPI_MASTER=10.224.0.1<br />

/opt/mpich-mx/bin/mpirun -np 20 -machinefile machlist.mch ./hello<br />

To run the script use:<br />

./runmpi<br />

This example runs program hello on 10 dual processor machines (20 processes = -np 20).<br />

The machines are specified by machlist.mch file.


Queuing System on Xseed<br />

The Xseed uses the Torque, Maui as queuing and resource management system. The<br />

following manual will show how to use the system from user point of view. It means how to<br />

submit simple or MPI jog to the queue.<br />

How to submit a job to the queue<br />

The job can be submitted to the queue using following script. Few parameters need to be<br />

changed for different jobs. For example number of used compute nodes or estimated time it<br />

will take to finish the job. All important parameters are described in the script. The<br />

highlighted parts of the script should be changed by the user.<br />

#bin!/bin/bash<br />

## The below lines is how much real (wall clock)<br />

## time it will take for your job to finish<br />

## Format is HH:MM:SS<br />

#PBS -lwalltime=00:05:00<br />

## Define how many nodes your job will take<br />

## by changing the number after -lnodes= leave :ppn=2 unchanged.<br />

## In this example it is set to use 10 nodes and each node has 2 cpus.<br />

#PBS -lnodes=10:ppn=2<br />

## Below here enter the commands to start your job.<br />

## cd $PBS_O_WORKDIR – the directory where the script is run<br />

cd $PBS_O_WORKDIR<br />

## The program you want to run. In this case it is only basic script.<br />

date<br />

echo "Hello world!"<br />

sleep 120<br />

date<br />

## End of the program.<br />

exit;<br />

The output of the scripts will not be shown on the console. All outputs are saved to the two<br />

files:<br />

.e - error output<br />

.o - program output


Run MPI program using queuing system<br />

To run the MPI program using Torque and Maui the following script can be used. Before the<br />

script can be run the MPI program must be compiled. The script does not need any machine<br />

list because it takes the machine list from Torque. Highlighted parts of the script should be<br />

changed by the user.<br />

#!/bin/bash<br />

## The below lines is how much real (wall clock)<br />

## time it will take for your job to finish<br />

## Format is HH:MM:SS<br />

#PBS -lwalltime=00:05:00<br />

## Define how many nodes your job will take<br />

## by changing the number after -lnodes= leave :ppn=2 unchanged.<br />

## In this example it is set to use 10 nodes and each node has 2 cpus.<br />

#PBS -lnodes=10:ppn=2<br />

## The following lines are for the MPI it self<br />

## Gives to the MPI number of nodes which will be used<br />

NUM_NODES=`cat $PBS_NODEFILE | wc -l | sed "s/ //g"`<br />

## run the MPI program “/home/kutik/mpi/examples/cpi”<br />

/opt/mpich-mx/bin/mpirun -np $NUM_NODES -machinefile $PBS_NODEFILE<br />

/home/kutik/mpi/examples/cpi<br />

Run the script<br />

/apps/packages/torque-2.3.2/bin/qsub qsubtest.sh

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!