R.J' Wiki : OpenMPI 在 debian 區網(LAN)上的安裝設定
- 需求
- host mpislave 名稱寫在 /etc/hosts 中
- mpislave 這台電腦最好要裝相同版本的 openmpi
- 程式要 copy 到可執行的路徑下, 或設定好路徑
- 環境
- 兩台 PC (localhost,mpislave) 都是雙核電腦
- 兩台都是 debian GNU/Linux 6.0 stable
- openmpi-bin 版本 1.4.2-4 ( 兩台都要裝 openmpi )
-
安裝(install)
sudo aptitude install libopenmpi-dev openmpi-bin openmpi-doc
-
程式 mpi_hello.c
#include <stdio.h> #include <mpi.h> int main(int argc, char *argv[]) { int numprocs, rank, namelen; char processor_name[MPI_MAX_PROCESSOR_NAME]; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &numprocs); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Get_processor_name(processor_name, &namelen); printf("Process %d of %d on processor %s\n", rank, numprocs, processor_name); MPI_Finalize(); }
mpicc mpi_hello.c -o mpi_hello
scp mpi_hello mpislave:
mpirun --host mpislave,localhost -n 4 mpi_hello或
mpiexec --host mpislave,localhost -n 4 mpi_hello
Process 2 of 4 on processor mpislave Process 0 of 4 on processor mpislave Process 3 of 4 on processor rjc144 Process 1 of 4 on processor rjc144註: 本機名稱 - rjc144
----
沒有留言:
張貼留言