def exchangePressure(self, communicator=None):

        if communicator is None:
            import mpi
            world = mpi.world()

        rank = communicator.rank

        if not communicator:
            communicator = world

        self._info.log("exchanging pressure %d -> %d" %
                       (self.source, self.sink))
        if rank == self.source:
            self._info.log("at barrier: waiting to read")
            communicator.barrier()
            self._info.log("receiving pressures from node %d" % self.sink)
            self.receivePressures()

        elif rank == self.sink:
            self._info.log("sending pressures to node %d" % self.source)
            self.sendPressures()
            self._info.log("at barrier: done writing")
            communicator.barrier()
        else:
            # other processors can skip this exchange
            self._info.log("rank %d: innocent bystander" % rank)
            import mpi
            if communicator == mpi.world():
                communicator.barrier()

        self._info.log("done exchanging pressure %d -> %d" %
                       (self.source, self.sink))

        return
예제 #2
0
    def exchangePressure(self, communicator=None):

        if communicator is None:
            import mpi
            world = mpi.world()

        rank = communicator.rank

        if not communicator:
            communicator = world

        self._info.log("exchanging pressure %d -> %d" % (self.source, self.sink))
        if rank == self.source:
            self._info.log("at barrier: waiting to read")
            communicator.barrier()
            self._info.log("receiving pressures from node %d" % self.sink)
            self.receivePressures()

        elif rank == self.sink:
            self._info.log("sending pressures to node %d" % self.source)
            self.sendPressures()
            self._info.log("at barrier: done writing")
            communicator.barrier()
        else:
            # other processors can skip this exchange
            self._info.log("rank %d: innocent bystander" % rank)
            import mpi
            if communicator == mpi.world():
                communicator.barrier()
        
        self._info.log("done exchanging pressure %d -> %d" % (self.source, self.sink))

        return
    def process(self, neutrons):
        import mpi
        rank = mpi.world().rank

        s = ['%s' % n for n in neutrons]
        print 'node %d: %s' % (rank, ', '.join(s))
        return neutrons
예제 #4
0
    def reportConfiguration(self):

        import mpi
        rank = mpi.world().rank

        if rank != 0:
            return

        self._info.line("configuration:")
        self._info.line("  properties:")
        self._info.line("    name: %r" % self.name)
        self._info.line("    steps: %d" % self.inventory.steps)

        self._info.line("  facilities:")
        self._info.line("    journal: %r" % self.inventory.journal.name)
        self._info.line("    launcher: %r" % self.inventory.launcher.name)
        self._info.line("    layout: %r" % self.inventory.layout.name)
        self._info.line("    controller: %r" % self.inventory.controller.name)
        self._info.line("    coupler: %r" % self.inventory.coupler.name)
        self._info.line("    coarse: %r" % self.inventory.coarse.name)
        self._info.line("    fine: %r" % self.inventory.fine.name)
        self._info.line("    cge: %r" % self.inventory.cge.name)
        self._info.line("    fge: %r" % self.inventory.fge.name)

        return
예제 #5
0
 def process(self, neutrons):
     import mpi
     rank = mpi.world().rank
     
     s = [ '%s'% n for n in neutrons ]
     print 'node %d: %s' % (rank, ', '.join(s) )
     return neutrons
예제 #6
0
 def discover(self):
     '''Find the size/rank of the whole application.
     '''
     import mpi
     self.comm = mpi.world()
     self.rank = self.comm.rank
     self.nodes = self.comm.size
     return
예제 #7
0
 def findLayout(self):
     '''Assign controller/solver/communicator to this process.
     '''
     self.controller = self.inventory.controller
     self.solver = self.inventory.solver
     import mpi
     self.solverCommunicator = mpi.world()
     return
예제 #8
0
 def findLayout(self):
     '''Assign controller/solver/communicator to this process.
     '''
     self.controller = self.inventory.controller
     self.solver = self.inventory.solver
     import mpi
     self.solverCommunicator = mpi.world()
     return
예제 #9
0
 def discover(self):
     '''Find the size/rank of the whole application.
     '''
     import mpi
     self.comm = mpi.world()
     self.rank = self.comm.rank
     self.nodes = self.comm.size
     return
예제 #10
0
    def main(self):
        import mpi
        import socket

        hostname = socket.gethostname()
        world = mpi.world()
        print "[%03d/%03d] Hello world from '%s'!" % (world.rank, world.size, hostname)

        return
예제 #11
0
def test():
    import mpi
    world = mpi.world()
    
    printGroup("world", world, world.group())
    testExclude("world", world)
    testInclude("world", world)

    return
예제 #12
0
    def initialize(self, communicator=None):
        if communicator is None:
            import mpi
            communicator = mpi.world()
            
        self.communicator = communicator
        self.rank = self.communicator.rank

        return
예제 #13
0
def test():
    import mpi
    world = mpi.world()
    
    printGroup("world", world, world.group())
    testExclude("world", world)
    testInclude("world", world)

    return
예제 #14
0
    def initialize(self, communicator=None):
        if communicator is None:
            import mpi
            communicator = mpi.world()

        self.communicator = communicator
        self.rank = self.communicator.rank

        return
예제 #15
0
파일: basic.py 프로젝트: bmi-forum/bmi-pyre
def test():
    import mpi

    world = mpi.world()
    rank = world.rank
    size = world.size

    print "Hello: this is %03d/%03d" % (rank, size)
    
    return
예제 #16
0
    def main(self):
        import mpi
        import socket

        hostname = socket.gethostname()
        world = mpi.world()
        print "[%03d/%03d] Hello world from '%s'!" % (world.rank, world.size,
                                                      hostname)

        return
예제 #17
0
def test():
    import mpi

    world = mpi.world()
    rank = world.rank
    size = world.size

    print "Hello: this is %03d/%03d" % (rank, size)

    return
예제 #18
0
    def applyBoundaryConditions(self):
        Solver.applyBoundaryConditions(self)

        import mpi
        rank = mpi.world().rank

        self.coupler.exchangeBoundary()
        self.generator.updatePressure(self.coupler.boundary)
        self.coupler.exchangeFields()

        return
예제 #19
0
    def run(self):
        start_time = CPU_time()
        self.launch()

        import mpi
        if not mpi.world().rank:
            import sys
            print >> sys.stderr, "initialization time = %f" % \
                  (CPU_time() - start_time)

	return
예제 #20
0
    def run(self):
        start_time = CPU_time()
        self.launch()

        import mpi
        if not mpi.world().rank:
            import sys
            print >> sys.stderr, "initialization time = %f" % \
                  (CPU_time() - start_time)

        return
예제 #21
0
    def applyBoundaryConditions(self):
        Solver.applyBoundaryConditions(self)
    
        import mpi
        rank = mpi.world().rank

        self.coupler.exchangeBoundary()
        self.generator.updatePressure(self.coupler.boundary)
        self.coupler.exchangeFields()
    
        return
예제 #22
0
def _mpi():
    global size, rank, world
    try:
        import mpi
        sys.stderr.write( "* pyre mpi available\n" )
    except ImportError:
        sys.stderr.write( "** pyre mpi NOT available\n" )
        rank = 0
        return
    world = mpi.world()
    rank = world.rank
    size = world.size
    return
예제 #23
0
def _mpi():
    global size, rank, world
    try:
        import mpi
        sys.stderr.write("* pyre mpi available\n")
    except ImportError:
        sys.stderr.write("** pyre mpi NOT available\n")
        rank = 0
        return
    world = mpi.world()
    rank = world.rank
    size = world.size
    return
예제 #24
0
def mpiRank():
    try:
        import mpi
        world = mpi.world()
        mpiRank = world.rank; mpiSize = world.size
        if mpiSize < 1:
            mpiSize = 1
            parallel = False
        else:
            parallel = True
    except:
        mpiRank = 0
        mpiSize = 1
        parallel = False
        pass
    return mpiRank
예제 #25
0
    def createCommunicators(self):
	import mpi
        world = mpi.world()
        fineGroup = self.inventory.fine
        coarseGroup = self.inventory.coarse

        self.fine = world.include(fineGroup)
        self.coarse = world.include(coarseGroup)

        for each in coarseGroup:
            self.finePlus.append(world.include(fineGroup + [each]))

        for each in fineGroup:
            self.coarsePlus.append(world.include(coarseGroup + [each]))

        return
예제 #26
0
    def main(self):
        import mpi
        import socket

        hostname = socket.gethostname()
        world = mpi.world()

        rank = world.rank
        if rank == 0:
            port = world.port(peer=1, tag=17)
            port.send("Hello")
        elif rank == 1:
            port = world.port(peer=0, tag=17)
            message = port.receive()
            print "[%d/%d]: received {%s}" % (rank, world.size, message)

        return
예제 #27
0
        def main(self, *args, **kwds):
            import mpi
            world = mpi.world()
            rank = world.rank

            self.coupler.servers(0, 1)
            self.coupler.initialize(communicator=world)

            if rank == 0:
                self.onSource()
            elif rank == 1:
                self.onSink()
            else:
                import journal
                journal.firewall("exchange").log("too many processors....")

            return
예제 #28
0
파일: use_pyre.py 프로젝트: mcvine/mcvine
def _mpi():
    global size, rank, world
    try:
        import mpi
        if not mpi.inParallel():
            logger.warn( "** pyre mpi binding: failed to load\n" )
            rank = 0
            return
        logger.info( "* pyre mpi available\n" )
    except ImportError:
        logger.warn( "** pyre mpi NOT available\n" )
        rank = 0
        return
    world = mpi.world()
    rank = world.rank
    size = world.size
    return
예제 #29
0
파일: ports.py 프로젝트: bmi-forum/bmi-pyre
    def main(self):
        import mpi
        import socket

        hostname = socket.gethostname()
        world = mpi.world()

        rank = world.rank
        if rank == 0:
            port = world.port(peer=1, tag=17)
            port.send("Hello")
        elif rank == 1:
            port = world.port(peer=0, tag=17)
            message = port.receive()
            print "[%d/%d]: received {%s}" % (rank, world.size, message)

        return
예제 #30
0
def _init():
    global neutron_storage_path, ntotneutrons
    try:
        import mpi
    except:
        pass
    else:
        rank = mpi.world().rank
        neutron_storage_path = 'neutrons-%d' % rank
        import os
        if os.path.exists(neutron_storage_path):
            os.remove(neutron_storage_path)
    ntotneutrons = 53

    neutron = mcni.neutron( r = (0,0,0),
                            v = (1000,2000,3000),
                            time = 0,
                            prob = 1,
                            )
예제 #31
0
	def reportConfiguration( self ):
		rank = mpi.world().rank

		if rank != 0:
			return

		self._info.line("configuration:" )
#		self._info.line("  properties:" )
#		self._info.line("     name: %r" % self.inventory.name )
#		self._info.line("     full name: %r" % self.inventory.fullname )

		self._info.line( "  facilities:" )
		self._info.line( "    journal: %r" % self.inventory.journal.name )
		self._info.line( "    launcher: %r" % self.inventory.launcher.name )

		self._info.line( "    solver: %r" % self.inventory.solver.name )
		self._info.line( "    controller: %r" % self.inventory.controller.name )
		self._info.line( "    layout: %r" % self.inventory.controller.name )
		return
예제 #32
0
    def reportConfiguration(self):
        rank = mpi.world().rank

        if rank != 0:
            return

        self._info.line("configuration:")
        #		self._info.line("  properties:" )
        #		self._info.line("     name: %r" % self.inventory.name )
        #		self._info.line("     full name: %r" % self.inventory.fullname )

        self._info.line("  facilities:")
        self._info.line("    journal: %r" % self.inventory.journal.name)
        self._info.line("    launcher: %r" % self.inventory.launcher.name)

        self._info.line("    solver: %r" % self.inventory.solver.name)
        self._info.line("    controller: %r" % self.inventory.controller.name)
        self._info.line("    layout: %r" % self.inventory.controller.name)
        return
예제 #33
0
def test():
    import mpi

    axes = (2, 1, 1)
    periods = (0, 0, 0)

    world = mpi.world()

    if world.rank == 0:
        import journal
        journal.debug("mpi.fini").activate()
        journal.debug("mpi.cartesian").activate()
        
    cartesian = world.cartesian(axes, periods)

    wr, ws = world.rank, world.size
    cr, cs = cartesian.rank, cartesian.size
    coordinates = cartesian.coordinates()

    print "Hello: world(%03d/%03d), cartesian(%03d/%03d -> %s)" % (
        wr, ws, cr, cs, coordinates)

    return
예제 #34
0
def test():
    import mpi

    axes = (2, 1, 1)
    periods = (0, 0, 0)

    world = mpi.world()

    if world.rank == 0:
        import journal
        journal.debug("mpi.fini").activate()
        journal.debug("mpi.cartesian").activate()

    cartesian = world.cartesian(axes, periods)

    wr, ws = world.rank, world.size
    cr, cs = cartesian.rank, cartesian.size
    coordinates = cartesian.coordinates()

    print "Hello: world(%03d/%03d), cartesian(%03d/%03d -> %s)" % (
        wr, ws, cr, cs, coordinates)

    return
예제 #35
0
파일: exchange.py 프로젝트: QuLogic/citcoms
                                         args=("coarse", "coarse"))
        fine = pyre.inventory.facility("fine", factory=Coupler.embeddedcoupler,
                                         args=("fine","fine"))




# main

if __name__ == "__main__":

    import mpi

    # testing Exchangermodule.so
    import ExchangerLib
    if not mpi.world().rank:
        print ExchangerLib.copyright()
        print dir(ExchangerLib)

    import journal
    #journal.debug("Array2D").activate()
    journal.debug("Exchanger").activate()
    journal.info("  X").activate()
    journal.info("  proc").activate()
    journal.info("  bid").activate()

    app = TestExchanger("test")
    app.main()


예제 #36
0
	def discover( self ):
		self.comm = mpi.world()
		self.rank = self.comm.rank
		self.nodes = self.comm.size

		return
예제 #37
0
#
#</LicenseText>
# 
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 

if __name__ == "__main__":

    import CitcomS 
#    import CitcomS.Full as Full
    import CitcomS.Regional as Regional
    from CitcomS.Components.Const import Const
    from CitcomS.Components.Visc import Visc

    import mpi
    Regional.citcom_init(mpi.world().handle())

    #const=Const()
    #print dir(const.inventory)
    #print const.inventory.radius.value
    #Regional.Const_set_properties(const.inventory)

    #visc=Visc()
    #print dir(visc.inventory) 
    #print visc.inventory.sdepv_expt
    #Regional.Visc_set_properties(visc.inventory)

    #Regional.set_signal()
    #Regional.set_convection_defaults()

    print "copyright information:"
예제 #38
0
                                         factory=Coupler.containingcoupler,
                                         args=("coarse", "coarse"))
        fine = pyre.inventory.facility("fine",
                                       factory=Coupler.embeddedcoupler,
                                       args=("fine", "fine"))


# main

if __name__ == "__main__":

    import mpi

    # testing Exchangermodule.so
    import ExchangerLib
    if not mpi.world().rank:
        print ExchangerLib.copyright()
        print dir(ExchangerLib)

    import journal
    #journal.debug("Array2D").activate()
    journal.debug("Exchanger").activate()
    journal.info("  X").activate()
    journal.info("  proc").activate()
    journal.info("  bid").activate()

    app = TestExchanger("test")
    app.main()

# version
__id__ = "$Id$"
예제 #39
0
파일: signon.py 프로젝트: QwZhang/citcoms
#
#</LicenseText>
# 
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 

if __name__ == "__main__":

    import CitcomS 
#    import CitcomS.Full as Full
    import CitcomS.Regional as Regional
    from CitcomS.Components.Const import Const
    from CitcomS.Components.Visc import Visc

    import mpi
    Regional.citcom_init(mpi.world().handle())

    #const=Const()
    #print dir(const.inventory)
    #print const.inventory.radius.value
    #Regional.Const_set_properties(const.inventory)

    #visc=Visc()
    #print dir(visc.inventory) 
    #print visc.inventory.sdepv_expt
    #Regional.Visc_set_properties(visc.inventory)

    #Regional.set_signal()
    #Regional.set_convection_defaults()

    print "copyright information:"