meld.comm

Functions

get_mpi_comm_world()

Helper function to return the comm_world.

mpi_excepthook(type, value, traceback)

timeout(seconds, exception)

Classes

HostInfo(host_name, devices)

MPICommunicator(n_atoms, n_replicas, timeout)

Class to handle communications between master and slaves using MPI.

Quota(seconds)

Exceptions

StateException

class meld.comm.HostInfo(host_name, devices)
count(value) → integer -- return number of occurrences of value
devices

Alias for field number 1

host_name

Alias for field number 0

index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

class meld.comm.MPICommunicator(n_atoms: int, n_replicas: int, timeout: int = 600)[source]

Class to handle communications between master and slaves using MPI.

Parameters
  • n_atoms – number of atoms

  • n_replicas – number of replicas

Note

creating an MPI communicator will not actually initialize MPI. To do that, call initialize().

broadcast_alphas_to_slaves(alphas)[source]

Send the alpha values to the slaves.

Parameters

alphas – a list of alpha values, one for each replica. The master node’s alpha value should be included in this list. The master node will always be at alpha=0.0

Returns

None

broadcast_logger_address_to_slaves(address: Tuple[str, int]) → None[source]

Broadcast the hostname and port of the logger to slaves.

Parameters

address – a tuple (hostname, port)

Returns

const

None

broadcast_states_for_energy_calc_to_slaves(states)[source]

Broadcast states to all slaves. Send all results from this step to every slave so that we can calculate the energies and do replica exchange.

Parameters

states – a list of states

Returns

None

broadcast_states_to_slaves(states)[source]

Send a state to each slave.

Parameters

states – a list of states. The list of states should include the state for the master node. These are the states that will be simulated on each replica for each step.

Returns

the state to run on the master node

exchange_states_for_energy_calc(state)[source]

Exchange states between all processes.

Parameters

state – the state for this node

Returns

a list of states from all nodes

gather_energies_from_slaves(energies_on_master)[source]

Receive a list of energies from each slave.

Parameters

energies_on_master – a list of energies from the master

Returns

a square matrix of every state on every replica to be used for replica exchange

gather_states_from_slaves(state_on_master)[source]

Receive states from all slaves

Parameters

state_on_master – the state on the master after simulating

Returns

A list of states, one from each replica. The returned states are the states after simulating.

initialize() → None[source]

Initialize and start MPI

is_master() → bool[source]

Is this the master node?

Returns

True if we are the master, otherwise False

receive_alpha_from_master()[source]

Receive alpha value from master node.

Returns

a floating point value for alpha in [0,1]

receive_logger_address_from_master() → Tuple[str, int][source]

Receive the hostname and port of the logger from the master

Returns

a (hostname, port) tuple

receive_state_from_master()[source]

Get state to run for this step

Returns

the state to run for this step

receive_states_for_energy_calc_from_master()[source]

Receive all states from master.

Returns

a list of states to calculate the energy of

send_energies_to_master(energies)[source]

Send a list of energies to the master.

Parameters

energies – a list of energies to send to the master

Returns

None

send_state_to_master(state)[source]

Send state to master

Parameters

state – State to send to master. This is the state after simulating this step.

Returns

None

exception meld.comm.StateException[source]
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

meld.comm.get_mpi_comm_world() → mpi4py.MPI.Comm[source]

Helper function to return the comm_world.