Inom
Hitta mer dokumentation
Supportresurser som ingår
| Ladda ner denna bok i PDF (1347 KB)
Appendix D Fortran Directives Summary
This appendix
summarizes the directives recognized by f95 Fortran
compiler:
-
General Fortran Directives
-
Sun Parallelization Directives
-
Cray Parallelization Directives
-
OpenMP Fortran 95 Directives, Library Routines, and Environment
D.1 General Fortran Directives
General directives accepted by f95 are described
in 2.3 Directives.
Table D–1 Summary of General Fortran Directives
|
Format
|
|
C$PRAGMA keyword ( a [ , a ] … ) [ , keyword ( a [ , a ] … ) ] ,…
C$PRAGMA SUN keyword ( a [ , a ] … ) [ , keyword ( a [ , a ] … ) ] ,…
C$PRAGMA SPARC keyword ( a [ , a ] … ) [ , keyword ( a [ , a ] … ) ] ,…
Comment-indicator in column 1 may be c, C, !, or *. (We use C in these examples. f95 free-format must
use !.)
|
|
C Directive
|
C$PRAGMA C(list)
Declares a list of names of external functions as C language routines.
|
|
IGNORE_TKR Directive
|
C$PRAGMA IGNORE_TKR {name {, name} ...}
The compiler ignores the type, kind, and rank of the specified dummy
argument names appearing in a generic procedure interface when resolving a
specific call.
|
|
UNROLL Directive
|
C$PRAGMA SUN UNROLL=n
Advises the compiler that the following loop can be unrolled to a length n.
|
|
WEAK Directive
|
C$PRAGMA WEAK(name[=name2])
Declares name to be a weak symbol, or an
alias for name2.
|
|
OPT Directive
|
C$PRAGMA SUN OPT=n
Set optimization level for a subprogram to n.
|
|
NOMEMDEP Directive
|
C$PRAGMA SUN NOMEMDEP
Assert there are no memory dependencies in the following loop.
(Requires -parallel or -explicitpar.)
|
|
PIPELOOP Directive
|
C$PRAGMA SUN PIPELOOP=n
Assert dependency in loop between iterations n apart.
|
|
PREFETCH Directives
|
C$PRAGMA SUN_PREFETCH_READ_ONCE (name)
C$PRAGMA SUN_PREFETCH_READ_MANY (name)
C$PRAGMA SUN_PREFETCH_WRITE_ONCE (name)
C$PRAGMA SUN_PREFETCH_WRITE_MANY (name)
Request compiler generate prefetch instructions for references to name.
(Requires -xprefetch option, which is enabled by default.
Prefetch directives can be disabled by compiling with —xprefetch=no. Target architecture must also support prefetch instructions,
and the compiler optimization level must be set greater than —xO2.)
|
|
ASSUME Directives
|
C$PRAGMA [BEGIN} ASSUME (expression [,probability])
C$PRAGMA END ASSUME
Make assertions about conditions at certain points in the program that
the compiler can assume are true.
|
D.2 Special Fortran 95 Directives
The following directives are only available with f95.
See 4.8.2 FIXED and FREE Directives for details.
Table D–2 Special Fortran 95 Directives
|
Format
|
!DIR$ directive
: initial line
!DIR$& ... : continuation line
With fixed-format source, C is also accepted
as a directive-indicator:
CDIR$ directive...
The line must start in column 1. With free-format source, the line may
be preceded by blanks.
|
|
FIXED/FREE Directives
|
!DIR$ FREE!DIR$ FIXED
These directives specify the source format of the lines following the
directive. They apply to the rest of the source file in which they appear,
up to the next FREE or FIXED directive.
|
D.3 Fortran 95 OpenMP Directives
The Sun Fortran 95 compiler supports the OpenMP 2.5 Fortran API. The -openmp compiler flag enables these directives. (See 3.4.155 –xopenmp[={parallel|noopt|none}]).
See the OpenMP API User’s Guide for complete
details.
D.4 Sun Parallelization Directives
Note –
Legacy Sun and Cray parallelization directives are now deprecated.
Use of the OpenMP API for parallelization on Solaris SPARC and x86 platforms
is preferred. See the OpenMP API User’s Guide for information on migrating
legacy applications to OpenMP.
OpenMP parallelization is the preferred parallelization model with Fortran
95. Sun-style parallelization directives are described here for legacy applications,
and are detailed in the chapter on parallelization in the Fortran
Programming Guide.
Table D–3 Sun-Style Parallelization Directives Summary
|
Format
|
C$PAR directive [optional_qualifiers]
: initial lineC$PAR& [more_qualifiers] : continuation
line
Fixed format, the directive-indicator may be C (as
shown), c, *, or !.
Separate multiple qualifiers with commas. Characters beyond column 72 ignored
unless -e compiler option specified.
|
|
TASKCOMMON Directive
|
C$PAR TASKCOMMON block_name
Declares variables in common block block_name as
thread-private: private to a thread, but global within the thread. Declaring
a common block TASKCOMMON requires that this directive
appear after every common declaration of that block.
|
|
DOALL Directive
|
C$PAR DOALL [qualifiers]
Parallelize DO loop that follows. Qualifiers are:
PRIVATE(list) declare
names on list PRIVATE
SHARED(list) declare
names on list SHARED
MAXCPUS(n) use
no more than n threads
READONLY(list)
listed variables not modified in loop
SAVELAST save last value of all private variables
STOREBACK(list)
save last value of listed variables
REDUCTION(list)
listed variables are reduction variables
SCHEDTYPE(type)
use scheduling type: (default is STATIC)
STATIC
SELF(nchunk)
FACTORING[(m)]
GSS[(m)]
|
|
DOSERIAL Directive
|
C$PAR DOSERIAL
Disables parallelization of the loop that follows.
|
|
DOSERIAL* Directive
|
C$PAR DOSERIAL*
Disables parallelization of the loop nest that follows.
|
D.5 Cray Parallelization Directives
Note –
Legacy Sun and Cray parallelization directives are now deprecated.
Use of the OpenMP API for parallelization on Solaris SPARC and x86 platforms
is preferred. See the OpenMP API User’s Guide for information on migrating
legacy applications to OpenMP.
Cray-style parallelization directives are detailed in the chapter on
parallelization in the Fortran Programming Guide. Requires -mp=cray compiler option.
Table D–4 Cray Parallelization Directives Summary
|
Format
|
CMIC$ directive qualifiers :
initial line
CMIC$& [more_qualifiers] : continuation line
Fixed format. Directive-indicator may be C (as
shown here), c, *, or !.
With f95 free-format, leading blanks can appear before !MIC$.
|
|
DOALL Directive
|
CMIC$ DOALL SHARED(list), PRIVATE(list) [, more_qualifiers]
Parallelize loop that follows. Qualifiers are:
Scoping qualifiers are required (unless list is
empty)—all variables in the loop must appear in a PRIVATE or SHARED clause:
PRIVATE(list) declare
names on list PRIVATE
SHARED(list) declare
names on list SHARED
AUTOSCOPE automatically determine scope of variables
The following are optional:
MAXCPUS(n) use
no more than n threads
SAVELAST save last value of all private variables.
Only one scheduling qualifier may appear:
GUIDED equivalent to Sun-style GSS(64)
SINGLE equivalent to Sun-style SELF(1)
CHUNKSIZE(n) equivalent to Sun-style SELF(n)
NUMCHUNKS(m) equivalent to Sun-style SELF(n/m)
The default scheduling is Sun-style STATIC, for
which there is no Cray-style equivalent. Interpretations of these scheduling
qualifiers differ between Sun and Cray style. Check the Fortran
Programming Guide for details.
|
|
TASKCOMMON Directive
|
CMIC$ TASKCOMMON block_name
Declares variables in the named common block as thread-private—
private to a thread, but global within the thread. Declaring a common block TASKCOMMON requires that this directive appear immediately after every common declaration of that block.
|
|
DOSERIAL Directive
|
CMIC$ DOSERIAL
Disables parallelization of the loop that follows.
|
|
DOSERIAL* Directive
|
CMIC$ DOSERIAL*
Disables parallelization of the loop nest that follows.
|
|