Hp XC System 2.x Software Manuel d'utilisateur Page 113

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 154
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 112
parallelism. For inform ation about running more complex applications, refer to the H P- M PI
user documentation.
8.3.2.1 E
xample Application hello_world
To quickly become familiar with compi lin g and running HP- M P I programs, start with the C
version of a familiar hello_world pro gram. This program is called hello_world.c and
prints out the text string Hello world! I’m r of s on host”. I n this text string:
r is the rank of the process
s is the size of the co mmunicator
host is the host on which the program is run
The processor n ame is the host name for this implementation.
The source code for hello_world.c is stored in $MPI_ROOT/help and is shown below.
#include <stdio.h>
#
include <mpi.h>
v
oid main(argc, argv)
i
nt argc; char *argv[];
{
in
t rank, size, len;
ch
ar name[MPI_MAX_PROCESSOR_NAME];
MPI
_Init(&argc, &argv);
MPI
_Comm_rank(MPI_COMM_WORLD, &rank);
MPI
_Comm_size(MPI_COMM_WORLD, &size);
MPI
_Get_processor_name(name, &len);
prin
tf("Hello world! I’m %d of %d on %s\n", rank, size, name);
MPI_
Finalize();
exit
(0);
}
8.3.2.2 Building and Running hello_world
To build and run hello_world.c on a local host, n amed penguin2 in this example,
perform the following steps:
1. Change to a writable directory.
2. Compile the hello_world executable file:
$ $MPI_ROOT/bin/mpicc -o hello_world $MPI_ROOT/help/hello_world.c
If /opt/hpmpi/bin is in the PATH, a s it should be, this command can be simplified to
the following:
$ mpicc -o hello_world $MPI_ROOT/help/hello_world.c
3. Run the hello_world executable f ile:
$ $MPI_ROOT/bin/mpirun -srun -n4 hello_world
If /opt/hpmpi/bin is in the PATH, this command can be sim plified to the following:
$ mpirun -srun -n4 hello_world
In this comm and, -n4 specifies that the number of processes to run is four, and the
allocated nodes from SLURM are to be used.
4. Analyze hello_world output.
HP-MPI prints the output from running the hello_world executable in nondetermin istic
order. The following is an example of the output:
Using HP-MPI 8-3
Vue de la page 112
1 2 ... 108 109 110 111 112 113 114 115 116 117 118 ... 153 154

Commentaires sur ces manuels

Pas de commentaire