[cig-commits] r7604 - mc/3D/CitcomS/trunk/CitcomS

hlin at geodynamics.org hlin at geodynamics.org
Thu Jul 5 16:45:19 PDT 2007


Author: hlin
Date: 2007-07-05 16:45:19 -0700 (Thu, 05 Jul 2007)
New Revision: 7604

Added:
   mc/3D/CitcomS/trunk/CitcomS/MultiLayout.py
Modified:
   mc/3D/CitcomS/trunk/CitcomS/MultiCoupledApp.py
Log:
add MultiLayout
not sure about number of processor, currently assign 1-10 for ccom
11 for ecom1, and 12 for ecom2


Modified: mc/3D/CitcomS/trunk/CitcomS/MultiCoupledApp.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/MultiCoupledApp.py	2007-07-05 22:36:06 UTC (rev 7603)
+++ mc/3D/CitcomS/trunk/CitcomS/MultiCoupledApp.py	2007-07-05 23:45:19 UTC (rev 7604)
@@ -2,13 +2,13 @@
 #
 #
 #
+#need to work on myPlus and remotePlus
 #
 #
 #
 #
 #
 #
-#
 
 from BasApplication import Base Application
 import journal
@@ -106,6 +106,24 @@
     
     def report Configuration(self):
 
+        rank = self.comm.rank
+
+        if rank != 0:
+            return
+
+        self._info.line("configuration:")
+
+        self._info.line("  facilities:")
+        self._info.line("    launcher: %r" % self.inventory.launcher.name)
+
+        self._info.line("    csolver: %r" % self.inventory.csolver.name)
+        self._info.line("    esolver: %r" % self.inventory.esolver.name)
+        self._info.line("    ccontroller: %r" % self.inventory.ccontroller.name)
+        self._info.line("    econtroller: %r" % self.inventory.econtroller.name)
+        self._info.line("    ccoupler: %r" % self.inventory.ccoupler.name)
+        self._info.line("    ecoupler: %r" % self.inventory.ecoupler.name)
+        self._info.line("    layout: %r" % self.inventory.layout.name)
+    
         return
 
     class Invertory(BaseApplication.Inventory):
@@ -147,7 +165,7 @@
                                        factory=Solver.coupledRegionalSolver,
                                        args=("esolver", "esolver"))
 
-        layout = pyre.inventory.facility("layout", factory=Layout.Layout,
+        layout = pyre.inventory.facility("layout", factory=MultiLayout.MultiLayout,
                                          args=("layout", "layout"))
 
         steps = pyre.inventory.int("steps", default=1)

Added: mc/3D/CitcomS/trunk/CitcomS/MultiLayout.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/MultiLayout.py	2007-07-05 22:36:06 UTC (rev 7603)
+++ mc/3D/CitcomS/trunk/CitcomS/MultiLayout.py	2007-07-05 23:45:19 UTC (rev 7604)
@@ -0,0 +1,151 @@
+#!/usr/bin/env python
+
+#
+# Layout for MultiCoupled Application
+#
+#
+
+
+from pyre.components.Compenent import Component
+
+class MultiLayout(Component):
+
+
+    def __init(self, name, facility):
+        Compoent.__init__(self, name, facility)
+
+        # flag specifying that we are using
+        # containing communicator
+        self.ccomm = None
+
+        # flag specifying that we are using
+        # embedded comminicator1
+        self.ecomm1 = None
+
+        # flag specifying that we are using
+        # embedded comminicator2
+         self.ecomm2 = None
+
+        # list of communicators created to pass imformation
+        # between different solvers
+        self.ccomPlus1 = []
+        self.ccomPlus2 = []
+        self.ecommPlus1 = []
+        self.ecommPlus2 = []
+
+        self.comm = None
+        self.rank = 0
+        self.nodes = 0
+        return
+
+    def initialize(self, application):
+        self.discover()
+        self.verify(application)
+        self.createCommunicators()
+        return
+
+    def discover(self):
+        #Find the size and rank of the whole application
+        import mpi
+        self.comm = mpi.world()
+        self.rank = self.comm.rank
+        self.nodes = self.comm.size
+        return
+
+    def verify(self, application):
+        # check that we have at least 3 processor
+        if self.nodes <3:
+            import journal
+            firewall = journal.firewall("MultiLayout")
+            firewall.log("'%s' requires at least 3 processors" \
+                         % application.name)
+
+
+        containing_group = self.inventory.containing_group
+        embedded_group1 = self.inventory.embedded_group1
+        embedded_group2 = self.inventory.embedded_group2
+
+        # check for duplicated elements in the group
+        self.check_duplicated(containing_group)
+        self.check_duplicated(embedded_group1)
+        self.check_duplicated(embedded_group2)
+
+        # check that the three groups are disjoint
+        self.check_disjoint(containing_group, embedded_group1)
+        self.check_disjoint(containing_group, embedded_group2)
+        self.check_disjoint(embedded_group1, embedded_group2)
+
+        return
+
+    
+    def check_duplicated(self, group):
+        s = set(group)
+        if len(s) != len(group):
+            import journal
+            firewall = journal.firewall("layout")
+            firewall.log('Duplicated element in group: %s' % group)
+        return
+            
+            
+     def check_disjoint(self, group0, group1):
+        s0 = set(group0)
+        s1 = set(group1)
+        if s0.intersection(s1):
+            import journal
+            firewall = journal.firewall("layout")
+            firewall.log('Groups are not disjoint: %s and %s' % (group0, group1))
+        return
+          
+
+    def createCommunicators(self):
+        # Create communicators for solvers and couplerd
+
+        world = self.comm
+        myrank = self.rank
+        containing_group = self.inventory.containing_group
+        embedded_group1 = self.inventory.embedded_group1
+        embedded_group2 = self.inventory.embedded_group2
+
+        # Communicator for solvers
+        self.ccomm = world.include(containing_group)
+        self.ecomm1 = world.include(embedded_group1)
+        self.ecomm2 = world.include(embedded_group2)
+
+        # Communicator for inter-solver communication
+        # ecommPlus1 is a list of communicators, with each communicator
+        # contains a node in embedded_group1 and the whole containing_group
+
+        # ecommPlus2 is similar 
+        for node in containing_group:
+            self.ecommPlus1.append(world.include(embedded_group1 + [node]))
+            self.ecommPlus2.append(world.include(embedded_group2 + [node]))
+
+        # ccommPlus1 is a list of communicators, with each communicator
+        # contains a node in containing group and the whole embedded_group1
+
+        # commPlus2 is similar
+        for node in embedded_group1:
+            self.ccommPlus.append(world.include(containing_group + [node]))
+        for node in embedded_group2:
+            self.ccommPlus.append(world.include(containing_group + [node]))
+
+        return
+       
+    class Inventory(Component.Inventory):
+
+        import pyre.inventory
+
+        # The containing solver will run on these nodes
+        containing_group = pyre.inventory.slice("containing_group",
+                                                default=range(11))
+
+        # The embedded solver1 will run on these nodes
+        embedded_group1 = pyre.inventory.slice("embedded_group",
+                                              default=[11])
+
+        # The embedded solver2 will run on these nodes
+        embedded_group2 = pyre.inventory.slice("embedded_group",
+                                              default=[12])
+
+
+# End of file



More information about the cig-commits mailing list