Trees | Indices | Help |
|
---|
|
The central class of the multi processor framework.
This provides facilities for process management, command queueing, command scheduling, remote execution of commands, and handling of results and error from commands. The class is abstract and should be overridden to implement new interprocess communication methods, however, even then users are encouraged to override the more full implemented multi.multi_processor.Multi_processor class. Most users should instantiate instances of this class by calling the static method Processor.load_multiprocessor.
The class is designed to be subclassed and has abstract methods that a subclass needs to override. Methods which can be overridden are clearly marked with a note annotation stating that they can be overridden.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
anything |
|
||
str |
|
||
str |
|
||
list of 2 str |
|
||
str |
|
||
bool |
|
||
|
|||
Result_command instance |
|
||
|
|||
|
|||
int |
|
||
int |
|
||
str |
|
||
int |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
|||
NULL_RESULT Empty result command used by commands which do not return a result (a singleton?). |
|||
_processor_size Number of slave processors available in this processor. |
|||
callback Callback to interface to the host application |
|||
data_store The processor data store. |
|||
grainyness The number of sub jobs to queue for each processor if we have more jobs than processors. |
|||
threaded_result_processing Flag for the handling of result processing via self.run_command_queue(). |
|
Initialise the processor.
|
Shutdown the multi processor in exceptional conditions - designed for overriding. This method is called after an exception from the master or slave has been raised and processed and is responsible for the shutdown of the multi processor fabric and terminating the application. The functions should be called as the last thing that Application_callback.handle_exception does. As an example of the methods use see Mpi4py_processor.abort which calls MPI.COMM_WORLD.Abort() to cleanly shutdown the mpi framework and remove dangling processes. The default action is to call the special self.exit() method.
|
Add a command for remote execution to the queue - an abstract method.
|
Make sure that this is the master processor and not a slave.
|
Exit the processor with the given status. This default method allows the program to drop off the end and terminate as it normally would - i.e. this method does nothing.
|
Fetch the data structure of the given name from the data store. This can be run on the master or slave processors.
|
Get a string describing the multi processor - designed for overriding. The string should be suitable for display at application startup and should be less than 100 characters wide. A good example is the string returned by mpi4py_processor:
>>> MPI running via mpi4py with <n> slave processors & 1 master, mpi version = <x>.<y>
See Also: multi.processor.mpi4py_processor.Mpi4py_processor.get_intro_string. |
Get the name of the current processor - an abstract method. The string should identify the current master or slave processor uniquely but is purely for information and debugging. For example the mpi implementation uses the string <host-name>-<process-id> whereas the thread implementation uses the id of the current thread as provided by python.
|
Get the strings used prepend STDOUT and STDERR dependant on the current rank. For processors with only one slave the result should be ('', '') - designed for overriding.
Note: The defaults are ('M S|', 'M E|') and ('NN S|' , 'NN E|') for masters and slaves respectively with NN replaced by the rank of the processor. |
Utility function called to format the difference between application start and end times.
To Do: Check my format is correct. |
Determine if any slave commands are queued.
|
Slave to master processor data transfer - send the result command from the slave. This is invoked by the slave processor.
|
Slave to master processor data transfer - receive the result command from the slave. This is invoked by the master processor.
|
Method called after the application main loop has finished - designed for overriding. The default implementation outputs the application runtime to STDOUT. All subclasses should call the base method as their last action via super(). Only called on the master on normal exit from the applications run loop. |
Method called before starting the application main loop - designed for overriding. The default implementation just saves the start time for application timing. All subclasses should call the base method via super(). Only called on the master. |
Get the number of slave processors - designed for overriding.
|
Get the rank of this processor - an abstract method. The rank of the processor should be a number between 0 and n where n is the number of slave processors, the rank of 0 is reserved for the master processor.
|
Get a formatted string with the rank of a slave. Only called on slaves.
|
Get the width of the string designating the rank of a slave process. Typically this will be the number of digits in the slaves rank.
|
Return a result to the master processor from a slave - an abstract method.
|
Run the processor - an abstract method. This function runs the processor main loop and is called after all processor setup has been completed. It does remote execution setup and teardown (via self.pre_run() and self.post_run()) round either side of a call to Application_callback.init_master. See Also: multi.processor.Application_callback. |
Run the same command on all slave processors.
See Also: multi.processor.processor.Slave_command. |
Process all commands on the queue and wait for completion.
|
Run the processor queue - an abstract method. All commands queued with add_to_queue will be executed, this function causes the current thread to block until the command has completed. |
Transfer the given data from the master to all slaves.
|
Enable capture of the STDOUT and STDERR. This is currently used to capture the IO streams of the slaves to return back to the master. |
|
callbackCallback to interface to the host application See Also: Application_callback. |
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Jun 8 10:44:14 2024 | http://epydoc.sourceforge.net |