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...

Create successful ePaper yourself

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

OpenMP Directives for <strong>Fortran</strong>UsageA master thread is a single thread of control that begins an OpenMP program and which ispresent for the duration of the program. In a parallel region of code, there may be a sub-region ofcode that should execute only on the master thread. Instead of ending the parallel region beforethis subregion and then starting it up again after this subregion, the MASTER... END MASTERdirective pair allows the user to conveniently designate code that executes on the master threadand is skipped by the other threads.‣ <strong>The</strong>re is no implied barrier on entry to or exit from a master section of code.‣ Nested master sections are ignored.‣ Branching into or out of a master section is not supported.ExamplesExample of <strong>Fortran</strong> MASTER...END MASTER directivePROGRAM MASTER_USEINTEGER A(0:1)INTEGER omp_get_thread_numA=-1!$OMP PARALLELA(omp_get_thread_num()) = omp_get_thread_num()!$OMP MASTERPRINT *, "YOU SHOULD ONLY SEE THIS ONCE"!$OMP END MASTER!$OMP END PARALLELPRINT *, "A(0)=", A(0), " A(1)=", A(1)END8.7.8. ORDERED<strong>The</strong> OpenMP ORDERED directive allows the user to identify a portion of code within anordered code block that must be executed in the original, sequential order, while allowing parallelexecution of statements outside the code block.Syntax!$OMP ORDERED< <strong>Fortran</strong> code block executed by processor >!$OMP END ORDEREDUsage<strong>The</strong> ORDERED directive can appear only in the dynamic extent of a DO or PARALLELDO directive that includes the ORDERED clause. <strong>The</strong> structured code block between theORDERED / END ORDERED directives is executed by only one thread at a time, and in theorder of the loop iterations. This sequentializes the ordered code block while allowing parallelexecution of statements outside the code block. <strong>The</strong> following additional restrictions apply to theORDERED directive:‣ <strong>The</strong> ordered code block must be a structured block.<strong>PGI</strong> <strong>Fortran</strong> <strong>Reference</strong> Guide 170

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

Saved successfully!

Ooh no, something went wrong!