Re: [Pympi-users] Mpi and mpi.allreduce inside a function
Status: Alpha
Brought to you by:
patmiller
|
From: Pat M. <pat...@ll...> - 2005-07-21 18:59:57
|
I tend to write things the second way
def localComputation(...):
...
localValue = localCompuation()
globalValue = mpi.allreduce(localValue)
I do this because it is more clear what is done
locally and simplifies the collection.
But, it is better encapsulation to do something like:
try:
import mpi
except ImportError:
mpi = None
...
def Compuatation(...):
value = ...
if mpi is not None:
value = mpi.allreduce(value)
return value
That way, you can call computation even if pyMPI isn't
running.
Pat
Julian wrote:
> Would it have to be something like:
>
> GSum = mpi.allreduce(CalculateMcPrice(nSims,nSteps, Spot, Strike, Drift , vSqrdt ),mpi.SUM)
> GPrice = GSum/nSims
>
> or simply?
>
> Local_price = CalculateMcPrice(nSims,nSteps, Spot, Strike, Drift , vSqrdt )
> GSum = mpi.allreduce(Local_price, mpi.SUM)
> GPrice = GSum/nSims
--
Pat Miller | (925) 423-0309 | http://www.llnl.gov/CASC/people/pmiller
Access to power must be confined to those who are not in love with it.
-- Plato
|