numpy - MPI for python broadcast -


hi guys new here please excuse me if make errors. use python write code masters project , started using mpi4py make code parallel since have available 12 cores , time purposes. cannot reason bcast function work. want work out t2 in root process broadcast other processes. code follows:

from mpi4py import mpi qutip import* scipy import* pylab import* numpy import*  comm = mpi.comm_world rank = comm.get_rank() size = comm.get_size()  n0=10 n1=n0 n2=n0 d_ep=0.031 i_s=qeye(2)  if rank==0:     t2=0     k in range (0,n1):         n1=basis(n1+n2,k+n1)         kk=k+1         t2=t2+kk*(n1*n1.dag())     t2=(d_ep/n1)*tensor(i_s,t2) else:     t2=0  comm.bcast(t2, root=0)  print t2,rank 

but when run code output looks this:

0 1 0 2 0 3 0 4 quantum object: dims = [[2, 4], [2, 4]], shape = [8, 8], type = oper, isherm = true qobj data = [[ 0.      0.      0.      0.      0.      0.      0.      0.    ]  [ 0.      0.      0.      0.      0.      0.      0.      0.    ]  [ 0.      0.      0.0155  0.      0.      0.      0.      0.    ]  [ 0.      0.      0.      0.031   0.      0.      0.      0.    ]  [ 0.      0.      0.      0.      0.      0.      0.      0.    ]  [ 0.      0.      0.      0.      0.      0.      0.      0.    ]  [ 0.      0.      0.      0.      0.      0.      0.0155  0.    ]  [ 0.      0.      0.      0.      0.      0.      0.      0.031 ]] 0 

it did work out t2 in root didn't broadcast others 0. can please tell me doing wrong thank you.

you have use:

t2 = comm.bcast(t2, root=0) 

this correct usage of bcast according mpi4py tutorial.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -