Parallel Programming Guide for HP-UX Systems

MPI
Running
Chapter 224
Running on multiple hosts using remote shell
This example teaches you to run the hello_world.c application that you built in Building
Applications (above) using two hosts to achieve four-way parallelism. For this example, the
local host is named jawbone and a remote host is named wizard. To run hello_world.c on two
hosts, use the following procedure, replacing jawbone and wizard with the names of your
machines:
Step 1. Edit the .rhosts file on jawbone and wizard.
Add an entry for wizard in the .rhosts file on jawbone and an entry for jawbone in
the .rhosts file on wizard. In addition to the entries in the .rhosts file, ensure that
your remote machine permissions are set up so that you can use the remsh
command to that machine. Refer to the HP-UX remsh(1) man page for details.
You can use the MPI_REMSH environment variable to specify a command other than
remsh to start your remote processes. Refer to “MPI_REMSH” on page 35. Ensure
that the correct commands and permissions are set up on all hosts.
Step 2. Insure that the executable is accessible from each host either by placing it in a
shared directory or by copying it to a local directory on each host.
Step 3. Create an appfile.
An appfile is a text file that contains process counts and a list of programs. In this
example, create an appfile named my_appfile containing the following two lines:
-h jawbone -np 2 /path/to/hello_world
-h wizard -np 2 /path/to/hello_world
The appfile file should contain a separate line for each host. Each line specifies the
name of the executable file and the number of processes to run on the host. The -h
option is followed by the name of the host where the specified processes must be
run. Instead of using the host name, you may use its IP address.
Step 4. Run the hello_world executable file:
% $MPI_ROOT/bin/mpirun -f my_appfile
The -f option specifies the filename that follows it is an appfile. mpirun parses the
appfile, line by line, for the information to run the program. In this example,
mpirun runs the hello_world program with two processes on the local machine,
jawbone, and two processes on the remote machine, wizard, as dictated by the -np
2 option on each line of the appfile.
Step 5. Analyze hello_world output.