Parallel Programming in Fortran 95 using OpenMP - People
Parallel Programming in Fortran 95 using OpenMP - People
Parallel Programming in Fortran 95 using OpenMP - People
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
70 5. The environment variables<br />
5.1 OMP NUM THREADS<br />
This environment variable specifies the number of threads to be used dur<strong>in</strong>g execution of<br />
the parallel regions <strong>in</strong>side an <strong>OpenMP</strong>-parallel program.<br />
In pr<strong>in</strong>ciple, any <strong>in</strong>teger number greater than 0 can be set as the number of threads to<br />
be used, although if this number is larger than the number of available physical processors,<br />
then the parallel runn<strong>in</strong>g program will <strong>in</strong> general be very slow!<br />
When dynamic adjustment of the number of threads is enabled, the value given <strong>in</strong><br />
OMP NUM THREADS represents the maximum number of threads allowed.<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_NUM_THREADS 16<br />
> OMP_NUM_THREADS=16<br />
> export OMP_NUM_THREADS<br />
5.2 OMP SCHEDULE<br />
This environment variable affects the way <strong>in</strong> which !$OMP DO and !$OMP PARALLEL DO<br />
directives work, if they have their schedul<strong>in</strong>g set to RUNTIME:<br />
!$OMP DO SCHEDULE(RUNTIME)<br />
The schedule type and chunk size for all such loops can be specified at run time<br />
by sett<strong>in</strong>g this environment variable to any of the recognized schedule types and to an<br />
optional chunk size, us<strong>in</strong>g the same notation as <strong>in</strong>side the SCHEDULE clause. The possible<br />
schedule types are STATIC, DYNAMIC or GUIDED: descriptions of them can be found <strong>in</strong> the<br />
explanation of the !$OMP DO directive.<br />
The default value for the OMP SCHEDULE 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 />
If the optional chunk size is not set, a chunk size of 1 is assumed, except <strong>in</strong> the case of<br />
a STATIC schedule, where the default chunk size is set equal to the total number of do-loop<br />
iterations divided by the number of threads which act on the parallelized do-loop.<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_SCHEDULE "GUIDED,4"<br />
> OMP_SCHEDULE=dynamic<br />
> export OMP_SCHEDULE