12.07.2015 Views

PGI Fortran - Servidor WWW del Cluster Ladon-Hidra

PGI Fortran - Servidor WWW del Cluster Ladon-Hidra

PGI Fortran - Servidor WWW del Cluster Ladon-Hidra

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

the parallel region redundantly. These threads share work by means of work-sharing constructssuch as parallel DO loops in the following example. The number of threads in the team iscontrolled by the OMP_NUM_THREADS environment variable. If OMP_NUM_THREADS is notdefined, the program will execute parallel regions using only one processor. Branching into or outof a parallel region is not supported.All other shared-memory parallelization directives must occur within the scope of a parallelregion. Nested PARALLEL...END PARALLEL directive pairs are not supported and areignored. The END PARALLEL directive denotes the end of the parallel region, and is an implicitbarrier. When all threads have completed execution of the parallel region, a single thread resumesexecution of the statements that follow.Note that, by default, there is no work distribution in a parallel region. Each active thread executesthe entire region redundantly until it encounters a directive that specifies work distribution. Forwork distribution, see the DO, PARALLEL DO, or DOACROSS directives.PROGRAM WHICH_PROCESSOR_AM_IINTEGER A(0:1)INTEGER omp_get_thread_numA(0) = -1A(1) = -1!$OMP PARALLELA(omp_get_thread_num()) = omp_get_thread_num()!$OMP END PARALLELPRINT *, “A(0)=”,A(0), “ A(1)=”,A(1)ENDThe variables specified in a PRIVATE list are private to each thread in a team. In effect, thecompiler creates a separate copy of each of these variables for each thread in the team. When anassignment to a private variable occurs, each thread assigns to its local copy of the variable. Whenoperations involving a private variable occur, each thread performs the operations using its localcopy of the variable.Important points about private variables are:• Variables declared private in a parallel region are undefined upon entry to theparallel region. If the first use of a private variable within the parallel region is in aright-hand side expression, the results of the expression will be undefined (i.e., this isprobably a coding error).• Likewise, variables declared private in a parallel region are undefined when serialexecution resumes at the end of the parallel region.The variables specified in a SHARED list are shared between all threads in a team, meaning that allthreads access the same storage area for SHARED data.OpenMP Directives for Fortran 289

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

Saved successfully!

Ooh no, something went wrong!