150 likes | 311 Views
Programming on Cluster Platform. Recall the Parallel Programming Environment Installed on Cluster. Cluster Parallel Programming Environment – MPI Package. MPI – Message Passing Interface (Provide a standard for interprocessor communication in a parallel environment)
E N D
Recall the Parallel Programming Environment Installed on Cluster
Cluster Parallel Programming Environment – MPI Package • MPI – Message Passing Interface (Provide a standard for interprocessor communication in a parallel environment) • Several vendors have implmented MPI packages, such as • MPICH2 (is one of the most popular implmentations of MPI. It serves as the foundation for many other indsutry implmentations, such as Cray MPI, IBM MPI, Intel MPI, MS MPI). • OpenMPI (Open Souorce MPI-2 implementaiton that is developed and maintained by a consortium of academic, research, and industry partners)
MPI Programming Copy from https://computing.llnl.gov/tutorials/mpi/
The first example Example copied with minor modification from http://geco.mines.edu/workshop/class2/examples/mpi/index.html
MPI_Init(&argc,&argv); • Initializes the MPI execution environment. • MPI_Finalize(); • Terminates the MPI execution environment.
MPI_Comm_size(MPI_COMM_WORLD,&numprocs); • set the total number of MPI processes in the specified communicator in the second parameter. • MPI communicator • Specify a group of processes that participate in the communication. • MPI_COMM_WORLD • The default communicator that include all processes initialized by mpirun
The second example Example copied with minor modification from http://geco.mines.edu/workshop/class2/examples/mpi/index.html
MPI_Send(&buffer,count,MPI_INT,destination,tag,MPI_COMM_WORLD);MPI_Send(&buffer,count,MPI_INT,destination,tag,MPI_COMM_WORLD); • MPI_Recv(&buffer,count,MPI_INT,source,tag,MPI_COMM_WORLD,&status);
The third example Example copied with minor modification from http://geco.mines.edu/workshop/class2/examples/mpi/index.html
The fourth program Example copied with minor modification from http://geco.mines.edu/workshop/class2/examples/mpi/index.html
Information copied from https://computing.llnl.gov/tutorials/mpi/