Server

Server for DEVS simulation

class server.Server(name, total_size)[source]

A server to host MPI, will delegate all of its calls to the active simulation kernel.

__init__(name, total_size)[source]

Constructor

Parameters:
  • name – the name of the server, used for addressing (in MPI terms, this is the rank)
  • total_size – the total size of the network in which the model lives
bootMPI()[source]

Boot the MPI receivers when necessary, on an other thread to prevent blocking

checkLoadCheckpoint(name, gvt)[source]

Reconstruct the server from a checkpoint.

Parameters:
  • name – name of the checkpoint
  • gvt – the GVT to restore to
Returns:

bool – whether or not the checkpoint was successfully loaded

finish()[source]

Stop the currently running simulation

finishWaitingPool()[source]

Stop the complete MPI request queue from blocking, used when stopping simulation is necessary while requests are still outstanding.

flushQueuedMessages()[source]

Flush all queued messages to the controller. This will block until all of them are queued. It is required to flush all messages right after all of them happened and this should happen within the critical section!

getName()[source]

Returns the name of the server

Is practically useless, since the server is previously addressed using its name. This does have a use as a ping function though.

getProxy(rank)[source]

Get a proxy to a specified rank.

This rank is allowed to be the local server, in which case a local shortcut is created.

Parameters:rank – the rank to return a proxy to, should be an int
Returns:proxy to the server, either of type MPIRedirect or LocalRedirect
listenMPI()[source]

Listen for incomming MPI messages and process them as soon as they are received

loadCheckpoint(name, gvt)[source]

Reconstruct the server from a checkpoint.

Parameters:
  • name – name of the checkpoint
  • gvt – the GVT to restore to
prepare(scheduler)[source]

Prepare the server to receive the complete model over MPI

Parameters:scheduler – the scheduler to use
processMPI(data, comm, remote)[source]

Process an incomming MPI message and reply to it if necessary

Parameters:
  • data – the data that was received
  • comm – the MPI COMM object
  • remote – the location from where the message was received
queueMessage(time, model_id, action)[source]

Queue a delayed action from being sent, to make it possible to batch them.

Will raise an exception if previous messages form a different time were not yet flushed! This flushing is not done automatically, as otherwise the data would be received at a further timestep which causes problems with the GVT algorithm.

Parameters:
  • time – the time at which the action happens
  • model_id – the model_id that executed the action
  • action – the action to execute (as a string)
saveAndProcessModel(pickled_model, scheduler)[source]

Receive the model and set it on the server, but also saves it for further reinitialisation.

Parameters:
  • pickled_model – pickled representation of the model
  • scheduler – the scheduler to use
sendModel(data, scheduler)[source]

Receive a complete model and set it.

Parameters:
  • data – a tuple containing the model, the model_ids dictionary, scheduler name, and a flag for whether or not the model was flattened to allow pickling
  • scheduler – the scheduler to use
setPickledData(pickled_data)[source]

Set the pickled representation of the model.

For use on the controller itself, as this doesn’t need to unpickle the model.

Parameters:pickled_data – the pickled model