Batch jobs are submitted to SGE via scripts. Here is an example of a serial job script, sleep.sh. It basically executes the sleep command.
[sysadm1@frontend-0 sysadm1]$ cat sleep.sh #!/bin/bash # #$ -cwd #$ -j y #$ -S /bin/bash # date sleep 10 date |
Entries which start with #$ will be treated as SGE options.
|
To submit this serial job script, you should use the qsub command.
[sysadm1@frontend-0 sysadm1]$ qsub sleep.sh your job 16 ("sleep.sh") has been submitted |
For a parallel MPI job script, take a look at this script, linpack.sh. Note that you need to put in two SGE variables, $NSLOTS and $TMP/machines within the job script.
[sysadm1@frontend-0 sysadm1]$ cat linpack.sh #!/bin/bash # #$ -cwd #$ -j y #$ -S /bin/bash # MPI_DIR=/opt/mpich/gnu/ HPL_DIR=/opt/hpl/mpich-hpl/ # OpenMPI part. Uncomment the following code and comment the above code # to use OpemMPI rather than MPICH # MPI_DIR=/opt/openmpi/ # HPL_DIR=/opt/hpl/openmpi-hpl/ $MPI_DIR/bin/mpirun -np $NSLOTS -machinefile $TMP/machines \ $HPL_DIR/bin/xhpl |
The command to submit a MPI parallel job script is similar to submitting a serial job script but you will need to use the -pe mpich N. N refers to the number of processes that you want to allocate to the MPI program. Here's an example of submitting a 2 processes linpack program using this HPL.dat file:
[sysadm1@frontend-0 sysadm1]$ qsub -pe mpich 2 linpack.sh your job 17 ("linpack.sh") has been submitted |
If you need to delete an already submitted job, you can use qdel given it's job id. Here's an example of deleting a fluent job under SGE:
[sysadm1@frontend-0 sysadm1]$ qsub fluent.sh your job 31 ("fluent.sh") has been submitted [sysadm1@frontend-0 sysadm1]$ qstat job-ID prior name user state submit/start at queue master ja-task-ID --------------------------------------------------------------------------------------------- 31 0 fluent.sh sysadm1 t 12/24/2003 01:10:28 comp-pvfs- MASTER [sysadm1@frontend-0 sysadm1]$ qdel 31 sysadm1 has registered the job 31 for deletion [sysadm1@frontend-0 sysadm1]$ qstat [sysadm1@frontend-0 sysadm1]$ |
Although the example job scripts are bash scripts, SGE can also accept other types of shell scripts. It is trivial to wrap serial programs into a SGE job script. Similarly, for MPI parallel jobs, you just need to use the correct mpirun launcher and to also add in the two SGE variables, $NSLOTS and $TMP/machines within the job script. For other parallel jobs other than MPI, a Parallel Environment or PE needs to be defined. This is covered withn the SGE documentation.