Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
Dernière révisionLes deux révisions suivantes
documentation:examples:sommevecvecparopenmp.f90 [2017/01/23 10:24] ltaulelldocumentation:examples:sommevecvecparopenmp.f90 [2020/08/25 15:58] – modification externe 127.0.0.1
Ligne 1: Ligne 1:
 +===== Langage Fortran 90, code parallèle (avec OpenMP) =====
 +
 +Le programme [[documentation:examples:sommevecvecparopenmp.f90|ProgPAR_OpenMP.f90]] qui affiche Hello World pour chaque thread et en plus, le thread maître affiche le nombre de threads.
 +
 <code fortran ProgPAR_OpenMP.f90> <code fortran ProgPAR_OpenMP.f90>
  
-PROGRAM HELLO+program HELLO
    
- INTEGER NTHREADS, TID, OMP_GET_NUM_THREADS, +INTEGER NTHREADS, TID, OMP_GET_NUM_THREADS,OMP_GET_THREAD_NUM
- OMP_GET_THREAD_NUM+
    
-Fork a team of threads giving them their own copies of variables+Fork a team of threads giving them their own copies of variables
 !$OMP PARALLEL PRIVATE(NTHREADS, TID) !$OMP PARALLEL PRIVATE(NTHREADS, TID)
- +  
- +  
-Obtain thread number+Obtain thread number
  TID = OMP_GET_THREAD_NUM()  TID = OMP_GET_THREAD_NUM()
  PRINT *, 'Hello World from thread = ', TID  PRINT *, 'Hello World from thread = ', TID
- +  
-Only master thread does this+Only master thread does this
  IF (TID .EQ. 0) THEN  IF (TID .EQ. 0) THEN
   NTHREADS = OMP_GET_NUM_THREADS()   NTHREADS = OMP_GET_NUM_THREADS()
  PRINT *, 'Number of threads = ', NTHREADS  PRINT *, 'Number of threads = ', NTHREADS
  END IF  END IF
- +  
-All threads join master thread and disband+All threads join master thread and disband
 !$OMP END PARALLEL !$OMP END PARALLEL
  
- END+end program
 </code> </code>