Author: bugman Date: Fri Mar 23 16:40:03 2012 New Revision: 15618 URL: http://svn.gna.org/viewcvs/relax?rev=15618&view=rev Log: Fixes and clean up of the slave to master transfer mechanism for result commands. The master_queue_command() and master_receive_result() methods are now defined at the Processor level (but call raise_unimplemented()). Full epydoc docstrings and comments have been added everywhere. The 2 methods have now been defined for uni-processor fabric, and simply hold the command in a temporary variable. Modified: 1.3/multi/mpi4py_processor.py 1.3/multi/multi_processor_base.py 1.3/multi/processor.py 1.3/multi/uni_processor.py Modified: 1.3/multi/mpi4py_processor.py URL: http://svn.gna.org/viewcvs/relax/1.3/multi/mpi4py_processor.py?rev=15618&r1=15617&r2=15618&view=diff ============================================================================== --- 1.3/multi/mpi4py_processor.py (original) +++ 1.3/multi/mpi4py_processor.py Fri Mar 23 16:40:03 2012 @@ -162,10 +162,28 @@ def master_queue_command(self, command, dest): + """Slave to master processor data transfer - send the result command from the slave. + + @param command: The results command to send to the master. + @type command: Results_command instance + @param dest: The destination processor's rank. + @type dest: int + """ + + # Use a basic MPI send call to transfer the result command. MPI.COMM_WORLD.send(obj=command, dest=dest) def master_receive_result(self): + """Slave to master processor data transfer - receive the result command from the slave. + + This is invoked by the master processor. + + @return: The result command sent by the slave. + @rtype: Result_command instance + """ + + # Catch and return the result command. return MPI.COMM_WORLD.recv(source=MPI.ANY_SOURCE) Modified: 1.3/multi/multi_processor_base.py URL: http://svn.gna.org/viewcvs/relax/1.3/multi/multi_processor_base.py?rev=15618&r1=15617&r2=15618&view=diff ============================================================================== --- 1.3/multi/multi_processor_base.py (original) +++ 1.3/multi/multi_processor_base.py Fri Mar 23 16:40:03 2012 @@ -91,14 +91,6 @@ return result - def master_queue_command(self, command, dest): - raise_unimplemented(self.master_queue_command) - - - def master_receive_result(self): - raise_unimplemented(self.master_receive_result) - - # FIXME move to lower level def on_master(self): if self.rank() == 0: Modified: 1.3/multi/processor.py URL: http://svn.gna.org/viewcvs/relax/1.3/multi/processor.py?rev=15618&r1=15617&r2=15618&view=diff ============================================================================== --- 1.3/multi/processor.py (original) +++ 1.3/multi/processor.py Fri Mar 23 16:40:03 2012 @@ -362,6 +362,33 @@ return time_delta_str + def master_queue_command(self, command, dest): + """Slave to master processor data transfer - send the result command from the slave. + + This is invoked by the slave processor. + + + @param command: The results command to send to the master. + @type command: Results_command instance + @param dest: The destination processor's rank. + @type dest: int + """ + + raise_unimplemented(self.master_queue_command) + + + def master_receive_result(self): + """Slave to master processor data transfer - receive the result command from the slave. + + This is invoked by the master processor. + + @return: The result command sent by the slave. + @rtype: Result_command instance + """ + + raise_unimplemented(self.master_receive_result) + + def post_run(self): """Method called after the application main loop has finished - designed for overriding. Modified: 1.3/multi/uni_processor.py URL: http://svn.gna.org/viewcvs/relax/1.3/multi/uni_processor.py?rev=15618&r1=15617&r2=15618&view=diff ============================================================================== --- 1.3/multi/uni_processor.py (original) +++ 1.3/multi/uni_processor.py Fri Mar 23 16:40:03 2012 @@ -96,6 +96,40 @@ return True + def master_queue_command(self, command, dest): + """Slave to master processor data transfer - send the result command from the slave. + + This mimics a slave to master data transfer initiated by a slave by holding the result command so that the matching self.master_receive_result(), which is called by the master processor, can return it. As the master and slave processors are one and the same, the command is just held as a private class variable. + + + @param command: The results command to send to the master. + @type command: Results_command instance + @param dest: The destination processor's rank. + @type dest: int + """ + + # Hold the result command so that the matching self.master_receive_result() can return it. + self._result_command_queue = command + + + def master_receive_result(self): + """Slave to master processor data transfer - receive the result command from the slave. + + This mimics a slave to master data transfer initiated by a slave by holding the result command so that the matching self.master_receive_result(), which is called by the master processor, can return it. As the master and slave processors are one and the same, the command is just held as a private class variable. + + + @return: The result command sent by the slave. + @rtype: Result_command instance + """ + + # Remove the command from the class namespace. + command = self._result_command_queue + del self._result_command_queue + + # Return the command + return command + + def post_run(self): """Dummy function for preventing the printing of the run time."""