[Pympi-users] Answer to: Is there any way to gather a local variable into a list on the root?
Status: Alpha
Brought to you by:
patmiller
From: Julian C. <rjc...@cs...> - 2005-07-22 01:15:53
|
This is just a post to document something Pat emailed to me 1. You call a parallel function and get back a double called FinalVal e.g. >>> FinalVal = McTermIncrAccCall(dictInputs) 2. FinalVal is a local variable on each CPU. You can view them all with: >>> mpi.synchronizedWrite( mpi.rank, FinalVal, "\n" ) 0 -291.326756623 1 12.493514467 2 -184.882043854 3 -508.240980905 4 -300.15308712 5 -240.614966934 6 -71.3924387702 7 -113.294540179 8 -462.743023119 9 -269.701236158 2. What you really want to do is concatenate them into a list on the root processor. To do this you use; >>> allValues = mpi.gather([FinalVal]) allValues is now a list containing all the local values of FinalVal. "allvalues" only exists on the machine who's mpi.rank == 0. Don't ask me why you need to address FinalVal as [FinalVal], possibly a one element list?, but it definitely works. Pat Miller: "this is equivalent to mpi.gather([finalVal],0) and there is an allgather equivalent too." Julian Cook |