Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" A sampler implementation extending the regular sampler in order to allow for distributing the computation with MPI.
:param kwargs: key word arguments passed to the CosmoHammerSampler
""" """ CosmoHammer sampler implementation
""" self.pool = MpiPool(self._getMapFunction()) self.rank = self.pool.rank
super(MpiCosmoHammerSampler, self).__init__(pool=self.pool, **kwargs)
""" Returns the build in map function """ return map
""" Returns a new instance of a File Util """ return SampleFileUtil(self.filePrefix, self.isMaster(), reuseBurnin=self.reuseBurnin)
""" Starts the sampling process. The master node (mpi rank = 0) persists the result to the disk """ p0 = mpiBCast(p0)
self.log("MPI Process rank "+ str(self.rank)+" starts sampling") return super(MpiCosmoHammerSampler, self).sampleBurnin(p0);
""" Starts the sampling process. The master node (mpi rank = 0) persists the result to the disk """ burninPos = mpiBCast(burninPos) burninProb = mpiBCast(burninProb) burninRstate = mpiBCast(burninRstate)
self.log("MPI Process rank "+ str(self.rank)+" starts sampling") super(MpiCosmoHammerSampler, self).sample(burninPos, burninProb, burninRstate, datas);
""" loads the burn in form the file system """ if(self.isMaster()): pos, prob, rstate = super(MpiCosmoHammerSampler, self).loadBurnin() else: pos, prob, rstate = []
pos = mpiBCast(pos) prob = mpiBCast(prob) rstate = mpiBCast(rstate)
self.log("loading done") return pos, prob, rstate
""" Factory method to create initial positions """ #bcast the positions to ensure that all mpi nodes start at the same position return mpiBCast(super(MpiCosmoHammerSampler, self).createInitPos())
""" Returns true if the rank is 0 """ return self.pool.isMaster() |