MPI job
From MediaWiki
(Difference between revisions)
(New page: '''Submiting MPI job how-to''' This is simple MPI job submiting example. For demonstration use attached file. 1.Extract file with: [ngrkic@ui ~]$ unzip mpi.zip 2.Enter directory m...) |
|||
(2 intermediate revisions not shown) | |||
Line 16: | Line 16: | ||
3.List directory: | 3.List directory: | ||
- | + | [ngrkic@ui mpi]$ ll | |
+ | -rw-r--r-- 1 ngrkic ngrkic 561 Aug 22 2007 test-mpi.c | ||
+ | -rw-r--r-- 1 ngrkic ngrkic 295 Oct 2 10:21 test-mpi.jdl | ||
+ | -rw-r--r-- 1 ngrkic ngrkic 1751 Aug 22 2007 test-mpi.sh | ||
+ | |||
- | - | + | Content of file test-mpi.c |
- | - | + | |
- | - | + | [ngrkic@ui mpi]$ cat test-mpi.c |
- | - | + | /* hello.c |
+ | * | ||
+ | * Simple "Hello World" program in MPI. | ||
+ | * | ||
+ | */ | ||
+ | |||
+ | #include "mpi.h" | ||
+ | #include <stdio.h> | ||
+ | int main(int argc, char *argv[]) | ||
+ | { | ||
+ | int numprocs; /* Number of processors */ | ||
+ | int procnum; /* Processor number */ | ||
+ | /* Initialize MPI */ | ||
+ | MPI_Init(&argc, &argv); | ||
+ | /* Find this processor number */ | ||
+ | MPI_Comm_rank(MPI_COMM_WORLD, &procnum); | ||
+ | /* Find the number of processors */ | ||
+ | MPI_Comm_size(MPI_COMM_WORLD, &numprocs); | ||
+ | printf ("Hello world! from processor %d out of %d\n", procnum, numprocs); | ||
+ | /* Shut down MPI */ | ||
+ | MPI_Finalize(); | ||
+ | return 0; | ||
+ | } | ||
+ | This is content of file test-mpi.jdl | ||
+ | [ngrkic@ui mpi]$ cat test-mpi.jdl | ||
+ | Type = "Job"; | ||
+ | JobType = "MPICH"; | ||
+ | CpuNumber = 2; | ||
+ | Executable = "test-mpi.sh"; | ||
+ | Arguments = "test-mpi"; | ||
+ | StdOutput = "test-mpi.out"; | ||
+ | StdError = "test-mpi.err"; | ||
+ | InputSandbox = {"test-mpi.sh","test-mpi.c"}; | ||
+ | OutputSandbox = {"test-mpi.err","test-mpi.out","mpiexec.out"}; | ||
+ | Requirements = Member("MPICH"); | ||
+ | |||
+ | This is content of file test-mpi.sh | ||
+ | |||
+ | [ngrkic@ui mpi]$ cat test-mpi.sh | ||
+ | #!/bin/sh -x | ||
+ | |||
+ | # the binary to execute | ||
+ | EXE=$1 | ||
+ | |||
+ | echo "***********************************************************************" | ||
+ | echo "Running on: $HOSTNAME" | ||
+ | echo "As: " `whoami` | ||
+ | echo "***********************************************************************" | ||
+ | |||
+ | echo "***********************************************************************" | ||
+ | echo "Compiling binary: $EXE" | ||
+ | echo mpicc -o ${EXE} ${EXE}.c | ||
+ | mpicc -o ${EXE} ${EXE}.c | ||
+ | echo "*************************************" | ||
+ | |||
+ | if [ "x$PBS_NODEFILE" != "x" ] ; then | ||
+ | echo "PBS Nodefile: $PBS_NODEFILE" | ||
+ | HOST_NODEFILE=$PBS_NODEFILE | ||
+ | fi | ||
+ | |||
+ | if [ "x$LSB_HOSTS" != "x" ] ; then | ||
+ | echo "LSF Hosts: $LSB_HOSTS" | ||
+ | HOST_NODEFILE=`pwd`/lsf_nodefile.$$ | ||
+ | for host in ${LSB_HOSTS} | ||
+ | do | ||
+ | echo $host >> ${HOST_NODEFILE} | ||
+ | done | ||
+ | fi | ||
+ | |||
+ | if [ "x$HOST_NODEFILE" = "x" ]; then | ||
+ | echo "No hosts file defined. Exiting..." | ||
+ | exit | ||
+ | fi | ||
+ | |||
+ | echo "***********************************************************************" | ||
+ | CPU_NEEDED=`cat $HOST_NODEFILE | wc -l` | ||
+ | echo "Node count: $CPU_NEEDED" | ||
+ | echo "Nodes in $HOST_NODEFILE: " | ||
+ | cat $HOST_NODEFILE | ||
+ | echo "***********************************************************************" | ||
+ | |||
+ | echo "***********************************************************************" | ||
+ | CPU_NEEDED=`cat $HOST_NODEFILE | wc -l` | ||
+ | echo "Checking ssh for each node:" | ||
+ | NODES=`cat $HOST_NODEFILE` | ||
+ | for host in ${NODES} | ||
+ | do | ||
+ | echo "Checking $host..." | ||
+ | ssh $host hostname | ||
+ | done | ||
+ | echo "***********************************************************************" | ||
+ | |||
+ | echo "***********************************************************************" | ||
+ | echo "Executing $EXE with mpiexec" | ||
+ | chmod 755 $EXE | ||
+ | mpiexec `pwd`/$EXE > mpiexec.out 2>&1 | ||
+ | echo "***********************************************************************" | ||
+ | |||
+ | 4.Creating VOMS proxy: | ||
+ | |||
+ | [ngrkic@ui single]$ voms-proxy-init -voms aegis | ||
+ | |||
+ | Cannot find file or dir: /home/ngrkic/.glite/vomses | ||
+ | Enter GRID pass phrase: | ||
+ | Your identity: /C=RS/O=AEGIS/OU=Institute of Physics Belgrade/CN=Nikola Grkic | ||
+ | Creating temporary proxy ......................... Done | ||
+ | Contacting voms.ipb.ac.rs:15001 [/C=RS/O=AEGIS/OU=Institute of Physics Belgrade/CN=host/voms.ipb.ac.rs] "aegis" Done | ||
+ | Creating proxy ..................................................... Done | ||
+ | Your proxy is valid until Fri Oct 2 01:11:00 2009 </code> | ||
+ | |||
+ | |||
+ | Now we are ready to submit job. | ||
+ | |||
- | + | 5.Submiting single job: |
Latest revision as of 13:33, 12 October 2009
Submiting MPI job how-to
This is simple MPI job submiting example.
For demonstration use attached file.
1.Extract file with:
[ngrkic@ui ~]$ unzip mpi.zip
2.Enter directory mpi with:
[ngrkic@ui ~]$ cd mpi
3.List directory:
[ngrkic@ui mpi]$ ll -rw-r--r-- 1 ngrkic ngrkic 561 Aug 22 2007 test-mpi.c -rw-r--r-- 1 ngrkic ngrkic 295 Oct 2 10:21 test-mpi.jdl -rw-r--r-- 1 ngrkic ngrkic 1751 Aug 22 2007 test-mpi.sh
Content of file test-mpi.c
[ngrkic@ui mpi]$ cat test-mpi.c /* hello.c * * Simple "Hello World" program in MPI. * */ #include "mpi.h" #include <stdio.h> int main(int argc, char *argv[]) { int numprocs; /* Number of processors */ int procnum; /* Processor number */ /* Initialize MPI */ MPI_Init(&argc, &argv); /* Find this processor number */ MPI_Comm_rank(MPI_COMM_WORLD, &procnum); /* Find the number of processors */ MPI_Comm_size(MPI_COMM_WORLD, &numprocs); printf ("Hello world! from processor %d out of %d\n", procnum, numprocs); /* Shut down MPI */ MPI_Finalize(); return 0; }
This is content of file test-mpi.jdl
[ngrkic@ui mpi]$ cat test-mpi.jdl Type = "Job"; JobType = "MPICH"; CpuNumber = 2; Executable = "test-mpi.sh"; Arguments = "test-mpi"; StdOutput = "test-mpi.out"; StdError = "test-mpi.err"; InputSandbox = {"test-mpi.sh","test-mpi.c"}; OutputSandbox = {"test-mpi.err","test-mpi.out","mpiexec.out"}; Requirements = Member("MPICH");
This is content of file test-mpi.sh
[ngrkic@ui mpi]$ cat test-mpi.sh #!/bin/sh -x # the binary to execute EXE=$1 echo "***********************************************************************" echo "Running on: $HOSTNAME" echo "As: " `whoami` echo "***********************************************************************" echo "***********************************************************************" echo "Compiling binary: $EXE" echo mpicc -o ${EXE} ${EXE}.c mpicc -o ${EXE} ${EXE}.c echo "*************************************" if [ "x$PBS_NODEFILE" != "x" ] ; then echo "PBS Nodefile: $PBS_NODEFILE" HOST_NODEFILE=$PBS_NODEFILE fi if [ "x$LSB_HOSTS" != "x" ] ; then echo "LSF Hosts: $LSB_HOSTS" HOST_NODEFILE=`pwd`/lsf_nodefile.$$ for host in ${LSB_HOSTS} do echo $host >> ${HOST_NODEFILE} done fi if [ "x$HOST_NODEFILE" = "x" ]; then echo "No hosts file defined. Exiting..." exit fi echo "***********************************************************************" CPU_NEEDED=`cat $HOST_NODEFILE | wc -l` echo "Node count: $CPU_NEEDED" echo "Nodes in $HOST_NODEFILE: " cat $HOST_NODEFILE echo "***********************************************************************" echo "***********************************************************************" CPU_NEEDED=`cat $HOST_NODEFILE | wc -l` echo "Checking ssh for each node:" NODES=`cat $HOST_NODEFILE` for host in ${NODES} do echo "Checking $host..." ssh $host hostname done echo "***********************************************************************" echo "***********************************************************************" echo "Executing $EXE with mpiexec" chmod 755 $EXE mpiexec `pwd`/$EXE > mpiexec.out 2>&1 echo "***********************************************************************"
4.Creating VOMS proxy:
[ngrkic@ui single]$ voms-proxy-init -voms aegis
Cannot find file or dir: /home/ngrkic/.glite/vomses Enter GRID pass phrase: Your identity: /C=RS/O=AEGIS/OU=Institute of Physics Belgrade/CN=Nikola Grkic Creating temporary proxy ......................... Done Contacting voms.ipb.ac.rs:15001 [/C=RS/O=AEGIS/OU=Institute of Physics Belgrade/CN=host/voms.ipb.ac.rs] "aegis" Done Creating proxy ..................................................... Done Your proxy is valid until Fri Oct 2 01:11:00 2009 </code>
Now we are ready to submit job.
5.Submiting single job: