Package multi :: Module mpi4py_processor :: Class Mpi4py_processor
[hide private]
[frames] | no frames]

Class Mpi4py_processor

source code


The mpi4py multi-processor class.

Instance Methods [hide private]
 
__init__(self, processor_size, callback)
Initialise the mpi4py processor.
source code
 
_broadcast_command(self, command) source code
 
_ditch_all_results(self) source code
 
abort(self)
Shutdown the multi processor in exceptional conditions - designed for overriding.
source code
 
assert_on_master(self)
Make sure that this is the master processor and not a slave.
source code
 
exit(self, status=0)
Exit the mpi4py processor with the given status.
source code
str
get_intro_string(self)
Return the string to append to the end of the relax introduction string.
source code
str
get_name(self)
Get the name of the current processor - an abstract method.
source code
 
master_queue_command(self, command, dest)
Slave to master processor data transfer - send the result command from the slave.
source code
Result_command instance
master_receive_result(self)
Slave to master processor data transfer - receive the result command from the slave.
source code
int
rank(self)
Get the rank of this processor - an abstract method.
source code
 
return_result_command(self, result_object) source code
 
run(self)
Run the processor - an abstract method.
source code
 
slave_receive_commands(self) source code

Inherited from multi_processor_base.Multi_processor: add_to_queue, chunk_queue, on_master, on_slave, post_run, pre_run, process_result, return_object

Inherited from processor.Processor: fetch_data, get_stdio_pre_strings, get_time_delta, processor_size, rank_format_string, rank_format_string_width, run_command_globally, run_command_queue, run_queue, send_data_to_slaves, stdio_capture, stdio_restore

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]

Inherited from processor.Processor: NULL_RESULT, callback, data_store, grainyness, threaded_result_processing

Inherited from processor.Processor (private): _processor_size

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, processor_size, callback)
(Constructor)

source code 

Initialise the mpi4py processor.

Parameters:
  • processor_size - The requested number of __slave__processors, if the number of processors is set by the environment (e.g. in the case of MPI via mpiexec -np <n-processors> on the command line the processor is free free to ignore this value. The default value from the command line is -1, and subclasses on receiving this value either raise and exception or determine the correct number of slaves to create (e.g. on a multi-cored machine using a threaded implementation the correct number of slaves would be equal to the number of cores available).
  • callback - The application callback which allows the host application to start its main loop and handle exceptions from the processor.
Overrides: object.__init__

abort(self)

source code 

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.

Overrides: processor.Processor.abort
(inherited documentation)

assert_on_master(self)

source code 

Make sure that this is the master processor and not a slave.

Raises:
  • Exception - If not on the master processor.
Overrides: processor.Processor.assert_on_master

exit(self, status=0)

source code 

Exit the mpi4py processor with the given status.

Parameters:
  • status (int) - The program exit status.
Overrides: processor.Processor.exit

get_intro_string(self)

source code 

Return the string to append to the end of the relax introduction string.

Returns: str
The string describing this Processor fabric.
Overrides: processor.Processor.get_intro_string

get_name(self)

source code 

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.

Returns: str
The processor identifier.
Overrides: processor.Processor.get_name
(inherited documentation)

master_queue_command(self, command, dest)

source code 

Slave to master processor data transfer - send the result command from the slave.

Parameters:
  • command (Results_command instance) - The results command to send to the master.
  • dest (int) - The destination processor's rank.
Overrides: processor.Processor.master_queue_command

master_receive_result(self)

source code 

Slave to master processor data transfer - receive the result command from the slave.

This is invoked by the master processor.

Returns: Result_command instance
The result command sent by the slave.
Overrides: processor.Processor.master_receive_result

rank(self)

source code 

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.

Returns: int
The rank of the processor.
Overrides: processor.Processor.rank
(inherited documentation)

return_result_command(self, result_object)

source code 
Overrides: multi_processor_base.Multi_processor.return_result_command

run(self)

source code 

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.

Overrides: processor.Processor.run
(inherited documentation)

slave_receive_commands(self)

source code 
Overrides: multi_processor_base.Multi_processor.slave_receive_commands