Pages

Subscribe:

Ads 468x60px

Labels

martes, 7 de febrero de 2012

Message Passing Interface (MPI) [Contribution]



Message Passing Interface (MPI) is a standardized and portable message-passing system designed by a group of researchers from academia and industry to function on a wide variety of parallel computers. The standard defines the syntax and semantics of a core of library routines useful to a wide range of users writing portable message-passing programs in Fortran 77 or the C programming language. Several well-tested and efficient implementations of MPI include some that are free and in the public domain. These fostered the development of a parallel software industry, and there encouraged development of portable and scalable large-scale parallel applications.

To start your first code with MPI, you must include the library
 #include <mpi.h> /*para C/C++*/  


Install MPI

//   sudo aptitude install mpich-bin libmpich1.0-dev ssh

//   sudo /etc/init.d/ssh start


Configure SSH

$ ssh-keygen -t dsa
$ cd ~/.ssh
$ cat id_dsa.pub >> authorized_keys


Going to do a hello world as an example:
Hello World C
/* C Example */
#include <stdio.h>
#include <mpi.h>

int main (int argc, char** argv)
{
  int rank, size;

  MPI_Init (&argc, &argv);   /* starts MPI */
  MPI_Comm_rank (MPI_COMM_WORLD, &rank);        /* get current process id */
  MPI_Comm_size (MPI_COMM_WORLD, &size);        /* get number of processes */
  printf( "Hello world from process %d of %d\n", rank, size );
  MPI_Finalize();
  return 0;
}
 //  mpicc hello.c -o hellompi
//  mpiexec -n 5 hellompi 
 Where the four numbers is the process 
Hello world C ++
/* C++ Example */
#include <mpi.h>
#include <iostream>
#include <stdio.h>

using namespace std;

int main (int argc,char *argv[])
{int rank,size;
 MPI_Init(&argc,&argv);
 MPI_Comm_size(MPI_COMM_WORLD, &size);
 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 printf("Hola Mundo desde procesador %d\n",rank);
 MPI_Finalize();
 return 0;
}  
mpic++ -o Hola HolaMundo.cpp
mpirun -np 4 Hola 
have to generate something like this
user@user ~$ mpirun -np 4 ./hellompi 
Hello world from process 0 of 4
Hello world from process 2 of 4
Hello world from process 1 of 4
Hello world from process 3 of 4 

http://www.open-mpi.org/
http://www.mancera.org/2010/12/08/montar-un-cluster-en-linux-ubuntu/
http://www.cs.ucsb.edu/~hnielsen/cs140/openmpi-install.html


Contribution : http://elisa.dyndns-web.com/progra/MPI

I make a contribution on MPI is run a sample MPI program in my next contribution will explain in detail

1 comentarios:

Elisa dijo...

Sería bueno que la URL al Wiki sería en sí una liga. Te pongo los 5 por los avances.

Publicar un comentario