Parcourir la source

tuto job Arrays

Ph. Marion il y a 6 ans
Parent
commit
f7175faae3
5 fichiers modifiés avec 119 ajouts et 2 suppressions
  1. 0 1
      .gitignore
  2. 37 1
      OAR_array/README.md
  3. 23 0
      OAR_array/hello-openmp.c
  4. 42 0
      OAR_array/hello-openmp.oar
  5. 17 0
      checkpoint/compteurminute.m

+ 0 - 1
.gitignore

@@ -6,4 +6,3 @@
 *.out
 *.err
 *.exe
-

Fichier diff supprimé car celui-ci est trop grand
+ 37 - 1
OAR_array/README.md


+ 23 - 0
OAR_array/hello-openmp.c

@@ -0,0 +1,23 @@
+#include <omp.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+/* src de l'exemple: http://igrida.gforge.inria.fr/tutorial.html */
+
+ 
+int main (int argc, char *argv[]) {
+  int th_id, nthreads;
+  #pragma omp parallel private(th_id)
+  {
+    th_id = omp_get_thread_num();
+    printf("Hello World from thread %d\n", th_id);
+    sleep(60);
+    #pragma omp barrier
+    if ( th_id == 0 ) {
+      nthreads = omp_get_num_threads();
+      printf("There are %d threads\n",nthreads);
+    }
+  }
+  return EXIT_SUCCESS;
+}

+ 42 - 0
OAR_array/hello-openmp.oar

@@ -0,0 +1,42 @@
+#!/bin/bash
+
+#-----------------------------------------------------------
+# Les directives OAR
+#-----------------------------------------------------------
+# donner un nom au job
+
+#OAR -n hello_array
+# les ressources 
+#OAR -l /core=2,walltime=00:05:00
+
+# array simple : on lance 5 fois le même programme 
+#OAR --array 5
+
+# la file de soumission
+# besteffort: priorité nulle (mais illimité en ressources)
+#OAR -t besteffort
+# idempotent: si un des jobs est tué, il sera relancé automatiquement.
+#OAR -t idempotent
+
+
+#OAR -O hello.%jobid%.stdout
+#OAR -E hello.%jobid%.stderror
+
+# quelques variables d'environnement accessibles:
+echo "array_id: $OAR_ARRAY_ID"
+echo
+echo OAR_JOB_ID : $OAR_JOB_ID
+echo
+echo OAR_NODE_FILE : $ OAR_NODE_FILE 
+
+# choix d'un nombre de threads cohérent avec les ressources demandés (core=2)
+export OMP_NUM_THREADS=2
+
+# nom du programme
+# à compier avant exécution de ce script!
+# gcc hello-openmp.c -fopenmp -o hello-openmp
+PROG="hello-openmp"
+
+./$PROG
+
+echo OK

+ 17 - 0
checkpoint/compteurminute.m

@@ -0,0 +1,17 @@
+function [x] = compteurminute(n)
+i=1;
+%max=60;
+if nargin < 1
+    n=2;
+end
+
+fid = fopen('compteur_matlab.out','w');
+while i < n*60
+  fprintf(fid,'%2d secondes\n',i);
+  %fprintf(" i = %d \n",i);
+  i = i + 1;
+  pause(1);
+end
+fclose(fid);
+end
+