Parallel Programming Guide for HP-UX Systems

UPC
Running
Chapter 5102
prun command.) If this happens, you need to modify one or more modules to correct the
consistency problem, recompile one or more modules with a consistent value for -fthreads ,
and reissue the prun command with -n value consistent with the value used for -fthreads . If
all modules compile successfully without specifying -fthreads , then any value for the -n
option of prun may be used.
Running programs in multithread mode using the UPC runtime
environment
HP UPC provides its own job control mechanism for SMP machines that do not have Quadrics
RMS software, or as an alternative to Quadrics RMS software for jobs that can run on a single
SMP node. This job control mechanism is called the UPC Run-Time Environment (RTE) and
comprises the UPC job control daemon (upcrund) and the upcrun command.
For a program to run on an SMP system (where all processors share the same physical
memory), the shared data must be made visible to all threads. To do this, use the -smp_local
or the -smp compiler option. The -smp option provides better performance. Note that you can
include the desired option in the comp.config file (see Section 3.6).
On HP-UX, the default is to run in SMP mode. It is not necessary to specify the -smp option
Input and output
Each UPC thread is a separate process. Input/output operations on files are exactly the same
as the case where multiple programs access the same files, and should be programmed
accordingly. Regarding stdin and stdout , unless program file input and output is confined to a
single thread (for example, using an if (MYTHREAD == 0) test), then some means of
partitioning the file activity into separate streams, one for each thread, is needed to produce
coherent program behavior.
Example 5-2 below illustrates a method of partitioning input from stdin from several
specially-named files, one for each thread. It does this by running the UPC program as a
command to the shell (the Bourne shell in the example) and making use of the environment
variable RMS_PROCID . This environment variable is set for each thread to its thread
number, and is the equivalent to MYTHREAD inside the UPC program. (When using the UPC
Run Time Environment, the equivalent environment variable is UPC_PEER_PID.) The same
technique is then used to redirect output. The shell -c option indicates that what follows is a
command string; single quotes then delimit the command.
Example 5-2 Partitioning I/O from stdin and stdout
prun -n 4 sh -c ‘myprogram < inputfile.$RMS_PROCID’
prun -n 4 sh -c ‘myprogram < outputfile.$RMS_PROCID’