Exemplo n.º 1
0
 def main_mpi(self, *args, **kwds):
     # access the mpi package
     import mpi
     # find out how many tasks were launched
     size = mpi.world.size
     # find out my rank
     rank = mpi.world.rank
     # figure out how many samples to do and pass that on to my integrator
     self.integrator.samples = self.samples / size
     # integrate: average the estimates produced by each task
     integral = mpi.sum(self.integrator.integrate()) / size
     # node 0: print the answer
     if rank == 0: print("integral = {}".format(integral))
     # all done
     return 0
Exemplo n.º 2
0
 def main_mpi(self, *args, **kwds):
     # access the mpi package
     import mpi
     # find out how many tasks were launched
     size = mpi.world.size
     # find out my rank
     rank = mpi.world.rank
     # figure out how many samples to do and pass that on to my integrator
     self.integrator.samples = self.samples / size
     # integrate: average the estimates produced by each task
     integral = mpi.sum(self.integrator.integrate())/size
     # node 0: print the answer
     if rank == 0: print("integral = {}".format(integral))
     # all done
     return 0