Qsub

From HPC

Revision as of 12:03, 21 October 2008 by Aitsswhi (Talk | contribs)
Jump to: navigation, search

Contents

qsub

qsub is the part of the Sun Grid Engine that allows you to submit you work to the cluster job queue. There are many command options for it i.e. setting up the enviroment, job name, array jobs, email alerts etc.

The two import switches to use are -cwd (makes the job start from the current working directory) and -V (makes the job run with the current enviroment variables)

qsub options program

Example

qsub -cwd -V myprog

Options

-V (set enviroment variables to those when job is submitted)
-cwd (run the job from current working directory)
-N name (sets name of job) 
-M email@address (set email address for job notifaction)
-m options (when to send email notification)
   b (begining of job)
   e (end of job)
   a (abortion or rescheduling of job)
   n (never email)
   s (suspention of job)
   example -m ase 
-t start-end:step Array job  (i.e. 1-5), :step is optional and is the step increment (1-6:2 would be 1 2 4 6). Environment variable $SGE_TASK_ID hold current position.

Array Jobs

You can submit one job with multiple tasks using the option qstat option -t. This is an ideal method if you have a single program to run and multiple separate datasets to be processed. You can however use it in much more complicated setups, especially when combined with job dependancies.

When an array job is submitted an environment variable $SGE_TASK_ID is populated with current position in the array. So the value of this variable will change each time the job scheduler steps through the array.

The $SGE_TASK_ID variable can either be used in the script you create to submit your job or from within your application (i.e. within the C, Java, R code).

Example array job scripts

Simple 10 iteration loop (-t 1-10)

#!/bin/bash
#$ -N ARRAY_TEST_JOB
#$ -cwd -V
#$ -t 1-10

myProgram dataset.${SGE_TASK_ID}.dat

This example would submit 10 tasks to the job queue, the effective output would be:

myProgram dataset.1.dat
myProgram dataset.2.dat
myProgram dataset.3.dat
myProgram dataset.4.dat
myProgram dataset.5.dat
myProgram dataset.6.dat
myProgram dataset.7.dat 
myProgram dataset.8.dat 
myProgram dataset.9.dat 
myProgram dataset.10.dat

Simple 12 in steps of 2 (-t 2-12:2)

#!/bin/bash
#$ -N ARRAY_TEST_JOB
#$ -cwd -V
#$ -t 2-12:2

myProgram dataset.${SGE_TASK_ID}.dat

This example would submit 6 task to the job queue, the effective output would be:

myProgram dataset.2.dat
myProgram dataset.4.dat
myProgram dataset.6.dat
myProgram dataset.8.dat
myProgram dataset.10.dat
myProgram dataset.12.dat

Job Dependencies

You can specify that your job will not run until another job has completed

qsub -hold_jid <jobids> myscript

Examples

qsub -hold_jid 5204 myscript
qsub -hold_jib 5230,5236,5302 myscript
Personal tools