Technical data
98
Chapter 5: Fortran Enhancements for Multiprocessors
mp_setup, mp_create, and mp_destroy
The mp_setup(3f), mp_create(3f), and mp_destroy(3f) subroutine calls
create and destroy threads of execution. This can be useful if the job has only
one parallel portion or if the parallel parts are widely scattered. When you
destroy the extra execution threads, they cannot consume system resources;
they must be re-created when needed. Use of these routines is discouraged
because they degrade performance; the mp_block and mp_unblock
routines can be used in almost all cases.
mp_setup takes no arguments. It creates the default number of processes as
defined by previous calls to mp_set_numthreads, by the environment
variable MP_SET_NUMTHREADS, or by the number of CPUs on the
current hardware platform. mp_setup is called automatically when the first
parallel loop is entered in order to initialize the slave threads.
mp_create takes a single integer argument, the total number of execution
threads desired. Note that the total number of threads includes the master
thread. Thus, mp_create(n) creates one thread less than the value of its
argument. mp_destroy takes no arguments; it destroys all the slave
execution threads, leaving the master untouched.
When the slave threads die, they generate a SIGCLD signal. If your program
has changed the signal handler to catch SIGCLD, it must be prepared to deal
with this signal when mp_destroy is executed. This signal also occurs when
the program exits; mp_destroy is called as part of normal cleanup when a
parallel Fortran job terminates.
mp_blocktime
The Fortran slave threads spin wait until there is work to do. This makes
them immediately available when a parallel region is reached. However, this
consumes CPU resources. After enough wait time has passed, the slaves
block themselves through blockproc. Once the slaves are blocked, it requires
a system call to unblockproc to activate the slaves again (refer to the
unblockproc(2) man page for details). This makes the response time much
longer when starting up a parallel region.










