2010年6月18日 星期五

MPI 簡述

1. 說明:
MPI 是個標準, 而目前最新版是 MPICH2.

在 MPI1 時, 有 MPICH 與 OPENMPI 前身兩大陣營提供.

而在 MPICH2 時, 由 MPICH2 與 OPENMPI 兩大函式庫提供.


底下用 OPENMPI 說明:

2. 執行過程:
MPIsourecode
|
MPICC
|
mpirun

而 mpirun 能用 qsub 送到底層的 Cluster


3. 範例:
I
hello.c
{{{
#include
#include

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 on %s out of %d\n", rank, processor_name, numprocs);

MPI_Finalize();
}

}}}

II.
/afs/slac.stanford.edu/package/mpich/bin/mpicc hello.c -o hello

III.
mpirun -np 4 -machinefile machinefile.morab hello
其中 machinefile 是跨 node 才須要, 若一顆是 8 code, 且只要 4 個 process 就不用,
且也是在 cluster 才要 machinefile.







4. 注意:


5. 參考:
MPI

沒有留言:

張貼留言