26.06.2015 Views

Parallel Programming in Fortran 95 using OpenMP - People

Parallel Programming in Fortran 95 using OpenMP - People

Parallel Programming in Fortran 95 using OpenMP - People

SHOW MORE
SHOW LESS

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

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

5.3. OMP DYNAMIC 71<br />

5.3 OMP DYNAMIC<br />

In large SMP mach<strong>in</strong>es it is common that several different programs share the available<br />

resources of the mach<strong>in</strong>e. Under such conditions it can happen that fix<strong>in</strong>g the number of<br />

threads to be used <strong>in</strong>side the parallel regions of a program may lead to unefficient use of<br />

the resources.<br />

Therefore, it is possible to enable the run-time environment of the SMP mach<strong>in</strong>e to<br />

adjust the number of threads dynamically, <strong>in</strong> order to maximize the use of the mach<strong>in</strong>e.<br />

This is done through the present environment variable which can be set equal to TRUE, if<br />

dynamic assignment is allowed, or equal to FALSE, if a fixed number of threads are to be<br />

used.<br />

The default value for the OMP DYNAMIC environment variable is <strong>OpenMP</strong>-implementation<br />

dependent, so it is necessary to look at its documentation <strong>in</strong> order to know that.<br />

Examples show<strong>in</strong>g the syntaxis correspond<strong>in</strong>g to L<strong>in</strong>ux/Unix systems us<strong>in</strong>g the csh<br />

and bash shells are, respectively:<br />

> setenv OMP_DYNAMIC TRUE<br />

> OMP_DYNAMIC=FALSE<br />

> export OMP_DYNAMIC<br />

5.4 OMP NESTED<br />

This environment variable specifies what the run-time environment has to do, when nested<br />

<strong>OpenMP</strong> directives are found.<br />

If its value is set equal to TRUE, nested parallelism is enabled and a new set of threads<br />

form<strong>in</strong>g a new team is created to work on the nested directive. The result is a tree<br />

structure as shown <strong>in</strong> figure 1.2, for the case of us<strong>in</strong>g two threads at each level of nest<strong>in</strong>g.<br />

If the environment variable OMP NESTED is set equal to FALSE, then the nested directives<br />

are serialized; that is, they are executed by a team with only one thread.<br />

Examples show<strong>in</strong>g the syntaxis correspond<strong>in</strong>g to L<strong>in</strong>ux/Unix systems us<strong>in</strong>g the csh<br />

and bash shells are, respectively:<br />

> setenv OMP_NESTED TRUE<br />

> OMP_NESTED=FALSE<br />

> export OMP_NESTED

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

Saved successfully!

Ooh no, something went wrong!