Technical data

104
Chapter 5: Fortran Enhancements for Multiprocessors
DOACROSS Implementation
This section discusses how multiprocessing is implemented in a
DOACROSS routine. This information is useful when you use the debugger
and interpret the results of an execution prole.
Loop Transformation
When the Fortran compiler encounters a C$DOACROSS statement, it
spools the corresponding DO loop into a separate subroutine and replaces
the loop statement with a call to a special library routine. Exactly which
routine is called depends on the value of MP_SCHEDTYPE. For discussion
purposes, assume SIMPLE scheduling, so the library routine is
mp_simple_sched.
The newly created subroutine is named using the following conventions.
First, underscores are prepended and appended to the original routine
name. For example, for a routine named foo, the rst part of the name is
_foo_. The next part of the name is the line number where the loop begins.
This is the line number in the le, not the line number in the procedure. The
last part of the name is a unique, four-character, alphabetic identier. The
rst loop in a procedure uses aaaa, the second uses aaab, and so on. This
counter is restarted to aaaa at the beginning of each procedure (not each
le). So if the rst parallel loop is at line 1234 in the routine named foo, the
loop is named _foo_1234_aaaa. The second parallel loop, at line 1299, is
named _foo_1299_aaab, and so on.
If a loop occurs in the main routine and if that routine has not been given a
name by the PROGRAM statement, its name is assumed to be main. Any
variables declared to be LOCAL in the original C$DOACROSS statement
are declared as local variables in the spooled routine. References to SHARE
variables are resolved by referring back to the original routine.
Because the spooled routine is now just a DO loop, the mp_simple_sched
routine species, through subroutine arguments, which part of the loop a
particular process is to execute. The spooled routine has four arguments: the
starting value for the index, the number of times to execute the loop, the
amount to increment the index, and a special ag word.