2013年8月19日 星期一

Message Passing Interface

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. We can use it for creating programmes for distributed computing systems (parallel computing).

MPI特點:
  1. 所有的節點(node,為一台電腦)串接在一起,各自有獨立的記憶體及CPU。
  2. 各節點間會透過互相傳遞訊息來了解彼此的進度。

  3. MPI是利用C語言或Fortran等程式的命令,達到節點間的接收訊息與傳達訊息。

Install MPI environment for you ubuntu
sudo apt-get install libcr-dev mpich2 mpich2-doc

MPI Hello Wrold example

/* C Example */
#include <mpi.h>
#include <stdio.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 mpi_hello.c -o hello
mpirun -np 2 ./hello

不過有點奇怪, 我目前在我的ubuntu上跑這個code, size回傳居然是1@@
這個部份要再研究一下.
MPI tutorial

資料來源:
http://jetcracker.wordpress.com/2012/03/01/how-to-install-mpi-in-ubuntu/

沒有留言: