参考链接: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\n", rank, size ); MPI_Finalize(); return 0; }
mpicc mpi_hello.c -o hello
mpirun -np 2 ./hello