10.07.2015 Views

PGI Fortran Reference manual - The Portland Group

PGI Fortran Reference manual - The Portland Group

PGI Fortran Reference manual - The Portland Group

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

OpenMP Directives for <strong>Fortran</strong>‣ An active parallel region is a parallel region that is executed by a team consisting of morethan one thread.<strong>The</strong> definition of an active parallel region changed between OpenMP 2.5 and OpenMP 3.0. InOpenMP 2.5, the definition was a parallel region whose IF clause evaluates to true. To examinethe significance of this change, look at the following example:program testlogical omp_in_parallel!$omp parallelprint *, omp_in_parallel()!$omp end parallelstopendSuppose we run this program with OMP_NUM_THREADS set to one. In OpenMP 2.5, thisprogram yields T while in OpenMP 3.0, the program yields F. In OpenMP 3.0, execution is notoccurring by more than one thread. <strong>The</strong>refore, change in this definition may mean previousprograms require modification.TaskA specific instance of executable code and its data environment, generated when a threadencounters a task construct or a parallel construct.8.1.3. OpenMP ExampleLook at the following simple OpenMP example involving loops.OpenMP Loop ExamplePROGRAM MAININTEGER I, N, OMP_GET_THREAD_NUMREAL*8 V(1000), GSUM, LSUMGSUM = 0.0D0N = 1000DO I = 1, NV(I) = DBLE(I)ENDDO!$OMP PARALLEL PRIVATE(I,LSUM) SHARED(V,GSUM,N)LSUM = 0.0D0!$OMP DODO I = 1, NLSUM = LSUM + V(I)ENDDO!$OMP END DO!$OMP CRITICALprint *, "Thread ",OMP_GET_THREAD_NUM()," local sum: ",LSUMGSUM = GSUM + LSUM!$OMP END CRITICAL!$OMP END PARALLELPRINT *, "Global Sum: ",GSUMSTOPEND<strong>PGI</strong> <strong>Fortran</strong> <strong>Reference</strong> Guide 152

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!