Parallel Programming in Fortran 95 using OpenMP - People
Parallel Programming in Fortran 95 using OpenMP - People
Parallel Programming in Fortran 95 using OpenMP - People
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
20 2. <strong>OpenMP</strong> constructs<br />
• If the WORKSHARE directive is applied to a forall statement, the evaluation of the<br />
mask expression, expressions occurr<strong>in</strong>g <strong>in</strong> the specification of the iteration space,<br />
and the masked assignments are workshared.<br />
• For ATOMIC directives and their correspond<strong>in</strong>g assignments, the update of each scalar<br />
variable is a s<strong>in</strong>gle unit of work.<br />
• For CRITICAL constructs, each construct is a s<strong>in</strong>gle unit of work.<br />
• If none of the rules above applies to a portion of the statement <strong>in</strong> the block of code,<br />
then this portion is treated as a s<strong>in</strong>gle unit of work.<br />
Therefore, the application of the previous rules delivers a large amount of units of work<br />
which are distributed over the different threads; how they are distributed is <strong>OpenMP</strong>implementation<br />
dependent.<br />
In order to correctly use the !$OMP WORKSHARE directive, it is necessary to take <strong>in</strong>to<br />
account the follow<strong>in</strong>g restrictions:<br />
• Thecodeenclosed<strong>in</strong>sidethe!$OMP WORKSHARE/!$OMP END WORKSHARE directive-pair<br />
must be a structured block; no branch<strong>in</strong>g <strong>in</strong>to or out of the block of code is allowed.<br />
• The enclosed code must only conta<strong>in</strong> array assignment statements, scalar assignment<br />
statements, forall and where statements and !$OMP ATOMIC and !$OMP CRITICAL<br />
directives.<br />
• The enclosed code must not conta<strong>in</strong> any user def<strong>in</strong>ed function calls unless the function<br />
is pure, which means it is free of side effects and has been declared with the<br />
keyword elemental.<br />
• Variables, which are referenced or modified <strong>in</strong>side the scope of the !$OMP WORKSHARE/!$OMP<br />
END WORKSHARE directive-pair, must have the SHARED attribute; otherwise, the results<br />
are unspecified.<br />
The scope of the !$OMP WORKSHARE directive is limited to the lexical extent of the<br />
directive-pair.<br />
2.2 Comb<strong>in</strong>ed parallel work-shar<strong>in</strong>g constructs<br />
The comb<strong>in</strong>ed parallel work-shar<strong>in</strong>g constructs are shortcuts for specify<strong>in</strong>g a parallel<br />
region that conta<strong>in</strong>s only one work-shar<strong>in</strong>g construct. The behavior of these directives is<br />
identical to that of explicitly specify<strong>in</strong>g an !$OMP PARALLEL/!$OMP END PARALLEL directivepair<br />
enclos<strong>in</strong>g a s<strong>in</strong>gle work-shar<strong>in</strong>g construct.<br />
The reason of existence of these shortcuts is to give the <strong>OpenMP</strong>-implementation a<br />
way of reduc<strong>in</strong>g the overhead cost associated to both <strong>OpenMP</strong> directive-pairs, when they<br />
appear together.