mailr7714 - in /branches/multi_processor_merge: multi/mpi4py_processor.py relax


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on October 15, 2008 - 21:55:
Author: bugman
Date: Wed Oct 15 21:55:41 2008
New Revision: 7714

URL: http://svn.gna.org/viewcvs/relax?rev=7714&view=rev
Log:
Manually ported r3237 from the multi_processor branch.

The command used was:
svn merge -r3236:3237 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/branches/multi_processor .

.....
  r3237 | varioustoxins | 2007-03-19 16:13:15 +0100 (Mon, 19 Mar 2007) | 2 
lines
  Changed paths:
     M /branches/multi_processor/multi/mpi4py_processor.py
     M /branches/multi_processor/relax

  implimentation of basic command structure and simplistic processor name 
command
.....


Modified:
    branches/multi_processor_merge/multi/mpi4py_processor.py
    branches/multi_processor_merge/relax

Modified: branches/multi_processor_merge/multi/mpi4py_processor.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/multi/mpi4py_processor.py?rev=7714&r1=7713&r2=7714&view=diff
==============================================================================
--- branches/multi_processor_merge/multi/mpi4py_processor.py (original)
+++ branches/multi_processor_merge/multi/mpi4py_processor.py Wed Oct 15 
21:55:41 2008
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 import sys
-
+import os
 
 
 # load mpi
@@ -23,14 +23,22 @@
 
 def exit_mpi():
     if MPI.Is_initialized() and not MPI.Is_finalized() and MPI.rank == 0:
-        sendbuf  = ['close']
+        sendbuf = Exit_command()
         for i in range(MPI.size):
             if i != 0:
                 MPI.COMM_WORLD.Send(buf=sendbuf,dest=i)
 
+#FIXME do some inheritance
+class Exit_command(object):
+    def run(self,processor):
+        processor.do_quit=True
 
+class Get_name_command(object):
+    def run(self,processor):
+        result = '%s-%s' % (MPI.Get_processor_name(),os.getpid())
+        MPI.COMM_WORLD.Send(buf=result, dest=0)
 
-
+#FIXME do some inheritance
 class Mpi4py_processor:
 
 
@@ -41,6 +49,35 @@
         # wrap sys.exit to close down mpi before exiting
         sys.exit= exit
         self.do_quit=False
+
+    def exit(self):
+        exit_mpi()
+
+    def run_command(self,command):
+        for i in range(1,MPI.size):
+            if i != 0:
+                MPI.COMM_WORLD.Send(buf=command,dest=i)
+        for i in range(1,MPI.size):
+            buf=[]
+            if i !=0:
+                elem = MPI.COMM_WORLD.Recv(source=i)
+                if type(elem) == 'object':
+                    elem.run(relax_instance)
+                else:
+                    #FIXME can't cope with multiple lines
+                    print i,elem
+
+
+#        for i in range(MPI.size):
+#            buf=[]
+#            if i !=0:
+#                print 'try',i
+#                MPI.COMM_WORLD.Recv(buf=buf, source=i)
+#                for i,elem in enumerate(buf):
+#                    if elem.type!='object':
+#                        print i,elem
+#                    else:
+#                        elem.run()
 
     def run(self):
 
@@ -53,10 +90,13 @@
             self.relax_instance.run()
             sys.exit()
         else:
-            data = MPI.COMM_WORLD.Recv(source=0)
-            if data=='close':
-                exit_mpi()
-                return
+            while not self.do_quit:
+                data = MPI.COMM_WORLD.Recv(source=0)
+                data.run(self)
+
+            #if data=='close':
+            #    exit_mpi()
+            #    return
 
 
 

Modified: branches/multi_processor_merge/relax
URL: 
http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/relax?rev=7714&r1=7713&r2=7714&view=diff
==============================================================================
--- branches/multi_processor_merge/relax (original)
+++ branches/multi_processor_merge/relax Wed Oct 15 21:55:41 2008
@@ -493,7 +493,9 @@
         clazz =  getattr(modules[-1], class_name)
     else:
         raise RelaxError("can't load class %s from module %s" % 
(class_name,module_path))
+
     object = clazz(relax_instance)
+    relax_instance.processor =  object
     return object
 
 if __name__ == "__main__":




Related Messages


Powered by MHonArc, Updated Wed Oct 15 22:20:03 2008