Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
documentation:examples:submit_scripts [2020/04/16 14:50] – [job parallèle] ltaulell | documentation:examples:submit_scripts [2023/01/13 09:39] (Version actuelle) – supprimée ccalugar | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | ====== Exemples de scripts de soumission ====== | ||
- | <note warning> | ||
- | |||
- | |||
- | ===== job parallèle ===== | ||
- | |||
- | * Soumission avec un seul script | ||
- | * Usage du ''/ | ||
- | * Configuration de l' | ||
- | |||
- | **Le script suivant se lance avec la commande** : '' | ||
- | |||
- | <code bash parexample.sh> | ||
- | #!/bin/bash | ||
- | ### variables SGE | ||
- | HOMEDIR=$SGE_O_WORKDIR | ||
- | ### shell du job | ||
- | #$ -S /bin/bash | ||
- | ### nom du job (a changer) | ||
- | #$ -N testbash | ||
- | ### file d' | ||
- | #$ -q E5-2670deb68A | ||
- | ### parallel environnement & nslots (a changer) | ||
- | #$ -pe mpi8_debian 8 | ||
- | ### charger l' | ||
- | #$ -cwd | ||
- | ### exporte les variables d' | ||
- | #$ -V | ||
- | ### mails en debut et fin d' | ||
- | #$ -m b | ||
- | #$ -m e | ||
- | |||
- | |||
- | ### sinon SGE travaille dans ~/ | ||
- | cd ${HOMEDIR} | ||
- | |||
- | ### environment modules | ||
- | source / | ||
- | module load GCC/ | ||
- | |||
- | ### definition SCRATCHDIR | ||
- | SCRATCH="/ | ||
- | SCRATCHDIR=${SGE_O_WORKDIR/" | ||
- | ### verif SCRATCHDIR | ||
- | echo " | ||
- | |||
- | BINDIR="/ | ||
- | EXEC=" | ||
- | |||
- | ### PREFIX doit matcher le modele openmpi (ligne 18) | ||
- | PREFIX=/ | ||
- | MPIRUN=${PREFIX}/ | ||
- | ### necessaire si plusieurs noeuds | ||
- | ### HOSTFILE=${TMPDIR}/ | ||
- | |||
- | ### creation du repertoire de travail dans le /scratch | ||
- | if [[ ! -d " | ||
- | then | ||
- | /bin/mkdir -p ${SCRATCHDIR} | ||
- | fi | ||
- | |||
- | |||
- | ### copie des fichiers input dans le /scratch | ||
- | for FICHIER in INPUT.hdf5 MATHRICE cube3x3 | ||
- | do | ||
- | cp ${FICHIER} ${SCRATCHDIR}/ | ||
- | done | ||
- | |||
- | ### nettoyage d' | ||
- | ### lancement du programme, si necessaire | ||
- | for FICHIER in OUTPUT.hdf5 mathrice.o | ||
- | do | ||
- | if [[ -e " | ||
- | then | ||
- | /bin/rm -f ${SCRATCHDIR}/ | ||
- | fi | ||
- | done | ||
- | |||
- | ### hostfile SGE si repartition sur plusieurs noeuds | ||
- | ### ${TMPDIR}/ | ||
- | /bin/cat ${TMPDIR}/ | ||
- | /bin/rm -f ${HOMEDIR}/ | ||
- | Master=" | ||
- | /bin/echo $Master >> ${HOMEDIR}/ | ||
- | |||
- | ### se placer dans le repertoire d' | ||
- | cd ${SCRATCHDIR} | ||
- | |||
- | ##${MPIRUN} -prefix ${PREFIX} -mca btl sm, | ||
- | ${MPIRUN} -prefix ${PREFIX} -mca btl vader, | ||
- | |||
- | ### recuperation des resultats à la fin du calcul | ||
- | for FICHIER in OUTPUT.hdf5 mathrice.o | ||
- | do | ||
- | cp ${SCRATCHDIR}/ | ||
- | done | ||
- | |||
- | ### | ||
- | |||
- | </ | ||
- | |||
- | <code bash test_scratch.sh> | ||
- | |||
- | #!/bin/bash | ||
- | # | ||
- | ### variables SGE | ||
- | ### shell du job | ||
- | #$ -S /bin/bash | ||
- | ### nom du job (a changer) | ||
- | #$ -N test1 | ||
- | ### file d' | ||
- | #$ -q AMD7702deb512 | ||
- | ### charger l' | ||
- | #$ -cwd | ||
- | ### exporter les variables d' | ||
- | #$ -V | ||
- | ### mails en debut et fin d' | ||
- | #$ -m b | ||
- | #$ -m e | ||
- | |||
- | # aller dans le repertoire de travail/ | ||
- | # important, sinon, le programme est lancé depuis ~/ | ||
- | cd ${SGE_O_WORKDIR} | ||
- | |||
- | ### configurer l' | ||
- | source / | ||
- | module load IntelComp/ | ||
- | |||
- | ### definition SCRATCHDIR | ||
- | # | ||
- | # | ||
- | SCRATCHDIR="/ | ||
- | ### verif SCRATCHDIR | ||
- | echo " | ||
- | |||
- | ### creation du repertoire de travail dans le /scratch | ||
- | if [[ ! -d " | ||
- | then | ||
- | / | ||
- | else | ||
- | if [[ " | ||
- | then | ||
- | # cette commande est DANGEREUSE ! | ||
- | # | ||
- | / | ||
- | fi | ||
- | fi | ||
- | |||
- | ### copie des fichiers sources dans le /scratch | ||
- | /bin/cp ${HOMEDIR}/ | ||
- | |||
- | ### se placer dans le repertoire d' | ||
- | cd ${SCRATCHDIR} | ||
- | |||
- | ### execution du programme | ||
- | ## | ||
- | ## | ||
- | ./test1.exe | ||
- | |||
- | ### recuperation des resultats à la fin du calcul | ||
- | /bin/cp ${SCRATCHDIR}/ | ||
- | |||
- | ### delete le dossier sur /scratch | ||
- | if [[ " | ||
- | then | ||
- | /bin/rm -rf ${SCRATCHDIR} | ||
- | fi | ||
- | |||
- | ### | ||
- | # fin | ||
- | |||
- | </ | ||
- | ===== job parallèle, variantes ===== | ||
- | |||
- | |||
- | * variante utilisant [[documentation: | ||
- | |||
- | |||
- | <code bash> | ||
- | #!/bin/bash | ||
- | #[...] | ||
- | |||
- | source / | ||
- | module load R/3.2.4 | ||
- | |||
- | #[...] | ||
- | </ | ||
- | |||
- | * variante du script : Appel à plusieurs queues (même cluster) | ||
- | |||
- | <code bash> | ||
- | #!/bin/bash | ||
- | ### SGE | ||
- | #$ -q E5-2670deb64A, | ||
- | #$ -pe mpi16_debian 32 | ||
- | |||
- | #[...] | ||
- | </ | ||
- | |||
- | * variante : Appel à plusieurs queues (de clusters différents) | ||
- | |||
- | <code bash> | ||
- | #!/bin/bash | ||
- | ### SGE | ||
- | #$ -q dl165_debian, | ||
- | #$ -pe openmp8 8 | ||
- | |||
- | #[...] | ||
- | </ | ||
- | |||
- | * variante : Retirer un node (host) des nodes autorisés | ||
- | |||
- | <code bash> | ||
- | #!/bin/bash | ||
- | ### SGE | ||
- | #$ -q dl165_debian | ||
- | #$ -pe openmp8 8 | ||
- | ## node HS : | ||
- | #$ -l h=!dl165lin2 | ||
- | |||
- | #[...] | ||
- | </ | ||
- | |||
- | * variante : Copie des inputs dans ''/ | ||
- | |||
- | <code bash> | ||
- | #!/bin/bash | ||
- | #[...] | ||
- | |||
- | # Copy input from home to scratch (pick bash or tcsh version) | ||
- | cd $SGE_O_WORKDIR | ||
- | # for bash: | ||
- | SCRATCH="/ | ||
- | SCRATCHDIR=${SGE_O_WORKDIR/" | ||
- | # for tcsh/csh: | ||
- | #set SCRATCHDIR = `echo $SGE_O_WORKDIR | awk -F "/" | ||
- | /bin/mkdir -p $SCRATCHDIR | ||
- | /bin/cp -rf $INPUT $SCRATCHDIR/ | ||
- | |||
- | # go to scratch (instead of workdir) before running binary | ||
- | cd ${SCRATCHDIR} | ||
- | |||
- | # run whatever binary | ||
- | whatever < $INPUT > $OUTPUT | ||
- | |||
- | # copy results from scratch to home | ||
- | /bin/cp -r $SCRATCHDIR/ | ||
- | |||
- | </ | ||
- | |||
- | * variante : Vérification de l' | ||
- | |||
- | <code bash> | ||
- | #!/bin/bash | ||
- | #[...] | ||
- | |||
- | cd $SGE_O_WORKDIR | ||
- | # for bash: | ||
- | SCRATCH="/ | ||
- | SCRATCHDIR=${SGE_O_WORKDIR/" | ||
- | |||
- | if [[ -d "/ | ||
- | then | ||
- | mkdir -p ${SCRATCHDIR} | ||
- | else | ||
- | echo "/ | ||
- | exit 1 | ||
- | fi | ||
- | |||
- | /bin/cp -rf $INPUT $SCRATCHDIR/ | ||
- | |||
- | # go to scratch (instead of workdir) before running binary | ||
- | cd ${SCRATCHDIR} | ||
- | |||
- | </ | ||
- | |||
- | * variante : Vérification de l' | ||
- | |||
- | <code bash> | ||
- | ### creation avec verification scratch global | ||
- | if [[ -d "/ | ||
- | then | ||
- | # pour scratch X5 / queues X5* | ||
- | if [[ -e "/ | ||
- | SCRATCH="/ | ||
- | # pour scratch E5N / queues E5* | ||
- | # if [[ -e "/ | ||
- | # SCRATCH="/ | ||
- | then | ||
- | SCRATCHDIR=${SGE_O_WORKDIR/" | ||
- | mkdir -p ${SCRATCHDIR} | ||
- | else | ||
- | echo "/ | ||
- | exit 1 | ||
- | fi | ||
- | else | ||
- | echo "/ | ||
- | exit 1 | ||
- | fi | ||
- | </ | ||
- | |||
- | |||
- | * variante : Job gaussian sur 8 coeurs ou 4 coeurs (mais réservation d'un noeud entier à 8 coeurs) | ||
- | |||
- | <code bash> | ||
- | #!/bin/bash | ||
- | ### SGE | ||
- | #$ -q x41zlin32gb | ||
- | #$ -pe gaussian8 8 | ||
- | |||
- | #[...] | ||
- | </ | ||
- | |||
- | * variante : Job gaussian dans le ''/ | ||
- | |||
- | <code bash> | ||
- | #!/bin/bash | ||
- | #[...] | ||
- | |||
- | cd ${SCRATCHDIR} | ||
- | export GAUSS_SCRDIR=${SCRATCHDIR} | ||
- | |||
- | #[...] | ||
- | </ | ||
- | |||
- | |||
- | * variante : Directives particulières, | ||
- | |||
- | <code bash> | ||
- | #!/bin/bash | ||
- | ### SGE | ||
- | #$ -q sl390lin48 | ||
- | #$ -pe gaussian8 8 | ||
- | #$ -cwd | ||
- | #$ -V | ||
- | # | ||
- | NPERSOCKET=" | ||
- | # | ||
- | ${MPIRUN} -prefix ${PREFIX} -mca btl vader, | ||
- | |||
- | </ | ||
- | |||
- | |||
- | * variante : Programme pseudo-parallèle, | ||
- | |||
- | <code bash> | ||
- | #!/bin/bash | ||
- | ### variables SGE | ||
- | HOMEDIR=$SGE_O_WORKDIR | ||
- | ### shell du job: | ||
- | #$ -S /bin/bash | ||
- | ### nom du job: | ||
- | #$ -N testbash | ||
- | ### file d' | ||
- | #$ -q monoamddeb25 | ||
- | ### parallel environnement & nslots | ||
- | #$ -pe openmp8 8 | ||
- | ### charger l' | ||
- | #$ -cwd | ||
- | ### exporte les variables d' | ||
- | #$ -V | ||
- | |||
- | #[...] | ||
- | |||
- | # Variables pour OPENMP | ||
- | #export OMP_NUM_THREADS=8 | ||
- | export OMP_NUM_THREADS=$NSLOTS | ||
- | |||
- | |||
- | ${EXEC_DIR}/ | ||
- | |||
- | </ | ||
- | |||
- | ===== Références ===== | ||
- | |||
- | * https:// | ||
- | * https:// |