Original Address:MPIRun MPD mpiexec
Author:The leaves are flying 2. Install the configuration file and set it up
Run command 1:touch mpd.conf
Run command 2:chmod mpd.conf
In the mpd.conf file, enter the following text content and save:
Mpd_secretword=mr.chen
3. Turn on the MPI server and compile and execute the MPI file
3.1 Open MPI Environment: Mpdboot
3.2 Compiling the MPI file (-o-hello Specifies the name of the output file): Mpicc-o Hello hello.c
3.3 Executing the generated binaries (-NP 4: Representing 4 processes): MPIRUN-NP 4./hello
The results of the operation are as follows:
user@ubuntu:~/test_mpi_examples$ MPIRUN-NP 4./hello
Hello world! Processor 0 of 4 on Ubuntu
Hello world! Processor 1 of 4 on Ubuntu
Hello world! Processor 3 of 4 on Ubuntu
Hello world! Processor 2 of 4 on Ubuntu
4. Close the MPI server
Run command: Mpdcleanup
6 Modifying the PATH environment variable
Path= "$PATH:/usr/local/mpich/bin"
7 Test environment variable settings
#which MPD
#which MPICC
#which mpiexec
#which MPIRun
All the above commands should point to the bin subdirectory of the installation directory. In addition, if you do not share the installation directory with NFS, you will need to copy the bin subdirectory to each of the other machines.
8 Modify the/etc/mpd.conf file with the content of Secretword=myword
#vi/etc/mpd.conf
Set file Read permissions to read and write to only yourself
#chmod 600/etc/mpd.conf
Non-root users at home directories create the same content. mpd.conf
9 Creating a Host name collection file/root/mpd.hosts
#vi mpd.hosts
The contents of the file are as follows:
Station1
Station3
Station6
Station8
Use
MPICH2 uses the MPD service to manage processes and runs MPI programs using Mpiexec.
Mpd
Start the MPD service on a single machine
# MPD &
View MPD Services
# Mpdtrace View Host Name
Or
#mpdtrace –l View host name and port number
Turn off MPD process management
#mpdallexit
Start the MPD service on the cluster
# mpdboot–n Process-num–f mpd.hosts
Start Process-num process, mpd.hosts is the file created earlier.
MPICH2 default is to use SSH to log on to other machines in the cluster, or to use Rsh to log in to other machines in the cluster to start the MPD service
Use the-rsh option to specify SSH or rsh
#mpdboot-rsh=rsh–n process-num–f Hostfile
or #mpdboot-rsh=ssh–n process-num–f hostfile
Turn off the MPD service
#mpdallexit
Mpiexec
Use Mpiexec to perform MPI tasks
#mpiexec –NP 3./cpi
or Mpiexec–machinefile FILENAME–NP 4./cpi
1, MPICH2 1.0.3 in the presence of MPD such things, Mpich developers claim that this is the MPI program communication and computing separate. In MPICH1, we use MPIRun directly to perform a task, at this time, to first use rsh these things to communicate, and then start the process, error debugging, program startup speed and so on. So, in the MPICH2, this part of the communication is made separately, that is MPD, and in Python writing, easy to understand, so as to solve the above problem.
2, MPICH2 recommended to use mpiexec to perform tasks rather than mpirun, because indeed, mpiexec compared to MPIRun, there are a lot of practical feature, such as:
Mpiexec-n 1-host Loginnode Master:-n 32-host SMP slave
Mpiexec can do different task release strategies for different nodes. The above command can see that we are going to publish a process on Loginnode, the executable of the process is master, and 32 processes are published on a machine called SMP (obviously this hostname SMP machine is a 32-CPU machine). It is OK to separate the different parameters with a colon.
3, through the above example, you can see that mpiexec can do a lot of customization for the node. such as-N,-path,-wdir,-host,-file,-configfile These parameters are commonly used, such as-wdir can be customized working directory. Moreover, Mpiexec also supports the customization of environment variables, which is very useful, that is to say, for different processes, they can be defined different list of environment variables. Like this example:
Mpiexec-n 1-env FOO BAR a.out:-N 2-env bazz fazz b.out
As you can see, we have defined an environment variable (value bar) of Foo for a.out and defined a bazz for b.out
Mpiexec-genv FOO bar-n 2 a.out:-N 4 b.out
With genv (global env), you can have this environment variable take effect in all processes.
With-envall,-genvall these two option to publish the list of environment variables on the machine where the program executes mpiexec to the specified process (all processes).
With-envnone,-genvnone can empty the environment variables for the specified process (all processes). This allows us to define a clean list of environment variables, such as:
Mpiexec-genvnone-env FOO bar-n a.out
Thus, the environment variable of the a.out process has only one environment variable of foo.
Mpiexec-genvnone-envlist path,ld_search_path-n a.out
This example shows that the path on the mpiexec machine, ld_search_path the two environment variables are published to the a.out process, and the other environment variables are emptied.
This thing is still very useful, especially ld_library_path this environment variable, it is likely to be customized according to different processes.
4, Mpiexec also has many useful options, such as:
-l:provides rank labels for lines of stdout and stderr.
is good for debugging because in the stdout and stderr information, you can see which process the message is printed out of.
-machinefile:
Mpiexec a little bit more than machinefile in Machinefile and MPICH1, here's an example:
# comment Line
H Osta
Hostb:2
hostc ifhn=hostc-gige
hostd:4 ifhn=hostd-gige
can be seen not only to define machine, but also to define what network interface to use for multiple networks The cluster of the paragraph is good. When Mpiexec publishes a task, it is released according to the list.
-s:can is used to direct the stdin of mpiexec to specific processes in a parallel job. This is also a useful option for
. This option allows us to make input on the machine that executes mpiexec and then send these inputs to the specified process, which is useful.
Mpiexec-s all-n 5 a.out # Pass the input to all processes
Mpiexec-s 4-n 5 a.out # Enter the process to rank 4
Mpiexec-s 1, 3-n 5 A.out # passed to 1,3 process
Mpiexec-s 0-3-N 5 a.out #传给0, 1, 2, 3 processes
MPD provides other more useful commands, such as Mpdsigjob, which allows us to send signal to the process, which is much better than when we were in MPICH1, to terminate a process and press CTRL + C, which is the benefit of making the communication a separate module. Now we can use mpdsigjob, for one or a batch of processes to publish the specified signal, such as SIGINT is equivalent to CTRL + C OH.
5. MPICH2 supports debugging parallel programs with GDB. However, I do not know how to support, you can see this example in the User guide, you can see that in the GdB debugging process, will show the current execution of this code will be executed in which process. Also, by using the z command, you can go into the specified single process for debugging. Setting breakpoints, stepping is also availalable.
6, the last is some FAQs, here excerpt some valuable:
(1) What is the difference between MPD & SMPD process Manager?
MPD is the default process manager for MPICH2 on Unix platforms. It's written in Python. SMPD is the primary process manager for MPICH2 on Windows. It is also used for running on a combination of Windows and Linux machines. It's written in C.
(2) When I use the g95 Fortran compiler on a 64-bit platform, some of the tests fail
A:The g95 Compiler incorrectly defines the default Fortran integer as a 64-bit integer while defining Fortran reals as 32 -bit values (the Fortran requires that INTEGER and REAL is the same size). This is apparently done to allow a Fortran INTEGER to hold the value of a pointer, rather than requiring the programmer T o Select an INTEGER of a suitable KIND. To force the G95 compiler to correctly implement the Fortran, use THE-I4 flag. For example, set the environment variable f90flags before configuring MPICH2:
setenv f90flags "-i4"
G95 users should note that there (at this writing) is the distributions of g95 for 64-bit Linux platforms. One uses 32-bit integers and reals (and conforms to the Fortran) and one uses 32-bit integers and 64-bit reals. We recommend using the one, conforms to the standard (note that the standard specifies the ratio of sizes, not the ABS Olute sizes, so a Fortran-compiler that used-bits for both integers and REAL would also conform to the Fortran Standa Rd. However, such a compiler would need to use the bits for DOUBLE PRECISION quantities).
(3) q:how do I pass environment variables to the processes of my parallel program when using the MPD process Manager?
A:by default, all the environment variables in the shell where Mpiexec is run be passed to all processes of the Applicat Ion program. (The one exception is LD LIBRARY, PATH when the MPD's is being run as root.) This default can is overridden in many ways, and individual environment variables can is passed to specific processes Usin g arguments to Mpiexec.
Note that, as mentioned above, mpiexec can customize the environment variables, but here's the exception to the Ld_library_path in the root-initiated MPD ring.