MPI (Message Passing Interface) 是平行運算標準介面。Ubuntu 透過 apt-get install mpich2 快速部署,使用 mpicc 編譯、mpiexec -n N 指定進程數運行,三步驟完成環境就緒。

sudo apt-get install mpich2
# 安裝 mpich2 1.4.1 版本
mpicc mpi_hello.c -g -Wall -o mpi_hello
mpiexec -n 4 ./mpi_hello
# 以 4 個進程平行執行
machinefile 列出節點 IP/槽位。MPICH_HOME、PATH 加入 $MPICH_HOME/bin。MPICH_NEMESIS_NETMOD=tcp、MPICH_MAX_SHORT_MSG_SIZE 等。mpiexec 找不到:重新登入或 source /etc/profile。