분산 식-ubuntu 12.04 에 mpi 설치

참조 링크:http://jetcracker.wordpress.com/2012/03/01/how-to-install-mpi-in-ubuntu/
1.설치:
sudo apt-get install libcr-dev mpich2 mpich2-doc
2.예:
mpi_hello.c
/* 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
", rank, size ); MPI_Finalize(); return 0; }

3.컴 파일 및 실행:
mpicc mpi_hello.c -o hello mpirun -np 2 ./hello

좋은 웹페이지 즐겨찾기