Beispiel #1
0
def _updateIteration(self):
    deltaE = mpitools.Allreduce_DoubleSum(self.deltaE)
    totalE = mpitools.Allreduce_DoubleSum(self.totalE)
    nok = mpitools.Allreduce_IntSum(self.nok)
    nbad = mpitools.Allreduce_IntSum(self.nbad)
    if nok + nbad > 0:
        self.iteration.update(deltaE, totalE, (1.0 * nok) / (nok + nbad),
                              self.count)
    else:
        self.iteration.update(None, None, None, self.count)
Beispiel #2
0
def _postProcess(self, context):
    if _rank == 0:
        pBar = progressbar.getProgress()
        pBar.set_message(self.header)

    skeleton = context.getObject()
    before = mpitools.Allreduce_DoubleSum(
        skeleton.energyTotal(self.criterion.alpha))

    if _rank == 0:
        if self.pbar_type == "continuous":
            n = self.iteration.iterations

    self.count = 0
    while self.iteration.goodToGo():
        self.count += 1
        # the context to acquires the writing persmissions
        # inside coreProcess.

        mpitools.Barrier()
        self.coreProcess_parallel(context)
        self.updateIteration_parallel()

        if _rank == 0:
            if pBar.query_stop():
                pBar.set_failure()
                pBar.set_message("Failed")
                # Sending a break signal
                mpitools.Isend_Bool(False, range(1, _size))
                break
            else:
                if self.pbar_type == "continuous":
                    pBar.set_progress(1.0 * self.count / n)
                    # does this ever get displayed?
                    pBar.set_message("%s%d/%d" % (self.header, self.count, n))
                    # Sending a continue signal
                    mpitools.Isend_Bool(True, range(1, _size))
        else:
            if not mpitools.Recv_Bool(0):
                break

    switchboard.notify("skeleton nodes moved", context)

    if _rank == 0:
        if pBar.query_stop():  # or pBar.get_success() <0:
            pBar.set_failure()
            pBar.set_message("Failed")
            mpitools.Isend_Bool(False, range(1, _size))
            return
        else:
            mpitools.Isend_Bool(True, range(1, _size))
    else:
        if not mpitools.Recv_Bool(0):
            return

    mpitools.Barrier()
    after = mpitools.Allreduce_DoubleSum(
        skeleton.energyTotal(self.criterion.alpha))

    # Reporting to the message window
    if _rank == 0:
        if before:
            rate = 100.0 * (before - after) / before
        else:
            rate = 0.0
        diffE = after - before
        reporter.report("%s deltaE = %10.4e (%6.3f%%)" %
                        (self.outro, diffE, rate))