Develop parallel programs in Linux (2)

Source: Internet
Author: User
Article title: Developing Parallel Programs in Linux (2 ). Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Install and configure MPICH
  
  
MPICH is a specific implementation of MPI. The following uses version 1.2.4 as an example to describe how to install and configure MPICH on Linux. the operating system used here is Red Hat 7.3.
  
1. download the MPICH software package
  
Depending on your needs and machine configurations, you can download the appropriate mpichsoftware package from http://www.mcs.anl.gov/mpi/mpich/download.html. The software package in this example is mpich-1.2.4.tar.gz.
  
$ Tar xzvf mpich-1.2.4.tar.gz
$ Mpich-1.2.4 cd
  
$./Configure -- prefix =/usr/local
$ Make
  
4. verify the compilation.
  
$ Cd examples/basic/
$ Make cpi
$.../Bin/mpirun-np 4 cpi
  
  
  
If the program runs correctly, it indicates that the entire MPI software package is compiled correctly. Note: If the "Permission denied." error message appears when you run the test program, you can try another user or log on again before running the test program.
  
5. install the MPICH software package
  
If the test program runs correctly, it indicates that the entire compilation process is correct. you can run the following command to install the MPICH Software $ cd ../../
$ Su-c "make install"
  
6. permission settings
  
In order to run the MPI program on multiple machines, other machines are required to authorize the machine that starts the MPI program, that is, allow the machine that starts the MPI program to access other machines. There are two methods to set permissions: one is to add the machine name that starts the MPI program to the/etc/hosts. equiv file of all other machines. For example, to start the MPI process on node1, while node2 and node3 are used in the computing process, the/etc/hosts on node2 and node3 is required. add the following line to the equiv file:
  
Node1
  
  
  
In this way, node2 and node3 both allow node1 to be accessed through commands such as rlogin and rsh. To enable a single machine to run multiple node1.
  
If the/etc/hosts. equiv file does not exist, you must first create the file.
  
Another way to set permissions is through the. rhosts file. The specific method is to create. the rhosts file, which specifies the accounts on which hosts are allowed to access.
  
For example, if you have the gary account on node1, node2, and node3 machines, you must allow the gary account on node1
  
For simplicity, it is best to create the same account name on each machine so that the MPI program can run under the same account. The above configurations are based on the R series commands (including rlogin, rsh, and rexec). This configuration is sufficient for general applications. However, if the parallel computing environment requires high security, you should consider using SSH instead of the R series commands. for specific practices, see the relevant MPICH documentation.
  
7. host settings
  
To enable parallel execution on multiple hosts after the MPI program is started, you must also set the available hosts. the corresponding configuration file is/usr/local/share/machines. LINUX. Edit the file and write the available machine names in each row. For example, you only need to add the following lines to the file:
  
Node1
Node2
Node3
  
Three computers can be used by MPI.
  
So far, the installation and configuration process of MPICH on one machine is basically over. After applying the same steps to other computers in the parallel computing environment, a MPICH-based parallel computing platform can be constructed.
  
Installation and configuration of PVM
  
The free and open features of PVM make it a widely accepted parallel program development environment. It can be installed on Linux, Unix, Windows, and other operating systems. The following uses version 3.4.4 as an example to describe how to install and configure PVM on Linux.
  
1. download the PVM package
  
You can download the corresponding pvmsoftware package from http://www.netlib.org/pvm3/index.htmlbased on your needs and machine configurations. The software package used here is pvm3.4.4.tgz.
  
$ Cp pvm3.4.tgz/usr/local/src/
$ Cd/usr/local/src/
$ Tar xzvf pvm3.4.4.tgz
  
3. set environment variables
  
PVM requires the environment variables PVM_ROOT and PVM_ARCH during startup and running. Every user who wants to use PVM needs to set these two environment variables. The environment variable PVM_ROOT value is the location of the root directory after the PVM package is expanded. it should be set to "/usr/local/src/pvm3 ". The value of the environment variable PVM_ARCH indicates the architecture of the host. for a host running the Linux operating system, this value is "LINUX ".
  
If bash is used, add these two environment variables to all users on the master machine by adding the following two scripts to the/etc/bashrc file:
  
Export PVM_ROOT =/usr/local/src/pvm3
Export PVM_ARCH = LINUX
  
If csh is used, add the following two lines of scripts to the/etc/csh. cshrc file:
  
Setenv PVM_ROOT/usr/local/src/pvm3
Setenv PVM_ARCH LINUX
  
$ Source/etc/bashrc
  
4. Compile the PVM software package
  
After the set environment variables take effect, run the following command to compile the entire software package:
  
$ Cd/usr/local/src/pvm3
$ Make
  
5. create a symbolic connection
  
If the compilation process is normal, an executable script pvm is generated in the/usr/local/src/pvm3/lib directory. For future convenience, you can establish a symbolic connection for it:
  
$ Su-c "ln-s/usr/local/src/pvm3/lib/pvm \
>/Usr/local/bin/pvm"
  
6. permission settings
  
PVM has the same permission settings as MPICH. you can directly modify the/etc/hosts. equiv file, or modify the. rhosts file in the Home directory of each account. For example, if you want to start the PVM process on node1 and node2 and node3.
  
In this way, node1 can access node2 and node3 through commands such as rlogin and rsh.
  
7. host settings
  
In most Linux distributions, the host name is added to the 127.0.0.1 line as the alias of the local return address in the/etc/hosts file, with 127.0.0.1 node1 localhost
  
127.0.0.1 localhost
  
So far, the installation and configuration process of PVM on one machine has basically ended. After applying the same steps to other computers in the parallel computing environment, we can construct a parallel computing platform based on PVM.
  
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.