Download User Manual - Support

Transcript
14
Using MPI
[fred@bright70 ~]$ cat hello.c
#include <stdio.h>
#include <mpi.h>
int main (int argc, char *argv[])
{
int id, np, i;
char processor_name[MPI_MAX_PROCESSOR_NAME];
int processor_name_len;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &np);
MPI_Comm_rank(MPI_COMM_WORLD, &id);
MPI_Get_processor_name(processor_name, &processor_name_len);
for(i=1;i<2;i++)
{printf(
"Hello world from process %03d out of %03d, processor name %s\n",
id, np, processor_name
);}
MPI_Finalize();
return 0;
}
[fred@bright70 ~]$ module add openmpi/gcc
#or as appropriate
[fred@bright70 ~]$ mpicc hello.c -o hello
[fred@bright70 ~]$ ./hello
Hello world from process 000 out of 001, processor name bright70.cm.cluster
However, it still runs on a single processor unless it is submitted to
the system in a special way.
Running An MPI Executable In Parallel Without A Workload Manager
Compute node environment provided by user’s .bashrc: After the
relevant module files are chosen (section 3.3) for MPI, an executable compiled with MPI libraries runs on nodes in parallel when submitted with
mpirun. The executable running on other nodes loads environmental
modules on those other nodes by sourcing the .bashrc file of the user
(section 2.3.3). It is therefore important to ensure that the environmental
module stack used on the compute node is clean and consistent.
Example
Supposing the .bashrc loads two MPI stacks—the mpich stack, followed by the Open MPI stack—then that can cause errors because the
compute node may use parts of the wrong MPI implementation.
The environment of the user from the interactive shell prompt is not
normally carried over automatically to the compute nodes during an
mpirun submission. That is, compiling and running the executable will
normally work only on the local node without a special treatment. To
have the executable run on the compute nodes, the right environment
modules for the job must be made available on the compute nodes too, as
part of the user login process to the compute nodes for that job. Usually
© Bright Computing, Inc.