像這樣的程式:

$ cat test/helloworld.py
from mpi4py import MPI

message = "Hello, World!! I am process %d of %d on %s."

print  message % (MPI.rank,
                  MPI.size,
                  MPI.Get_processor_name())

會得到這樣的結果:

$ mpirun -np 2 ~/opt/python-2.4-parallel/bin/bwpython \
 test/helloworld.py
Hello, World!! I am process 0 of 2 on apr.chen.local.
Hello, World!! I am process 1 of 2 on apr.chen.local.

是阿根廷 CIMEC 的研究人員所貢獻的成果。mpi4py 採用了 OOMPI 裡部分的類別結構,相容於 MPI 規格,可以和 LAMMPI 與 MPICH 配合使用。比起 Scientific Python,mpi4py 功能完整得多,更適合為運算程式進行 scripting。

Posted by yungyuc at 22:18, 2 comments, 0 trackback.
Change to page (10 entries in each page): 1
© hover year to navigate month: powered by django