MPI (taurex.mpi)

Module for wrapping MPI functions. Most functions will do nothing if mpi4py is not present.

allgather(value)[source]
allocate_as_shared(arr, logger=None, force_shared=False)[source]

Converts a numpy array into an MPI shared memory. This allow for things like opacities to be loaded only once per node when using MPI. Only activates if mpi4py installed and when enabled via the mpi_use_shared input:

[Global]
mpi_use_shared = True

or force_shared=True otherwise does nothing and returns the same array back

Parameters
  • arr (numpy array) – Array to convert

  • logger (Logger) – Logger object to print outputs

  • force_shared (bool) – Force conversion to shared memory

Returns

If enabled and MPI present, shared memory version of array otherwise the original array

Return type

array

allreduce(value, op)[source]
barrier(comm=None)[source]

Waits for all processes to finish. Does nothing if mpi4py not present

Parameters

comm (int, optional) – MPI communicator, default is MPI_COMM_WORLD

broadcast(array, rank=0)[source]
convert_op(operation)[source]
get_rank[source]

Gets rank or returns 0 if mpi is not installed

Parameters

comm (int, optional) – MPI communicator, default is MPI_COMM_WORLD

Returns

Rank of process in communitor or 0 if MPI is not installed

Return type

int

nprocs[source]

Gets number of processes or returns 1 if mpi is not installed

Returns

Rank of process or 1 if MPI is not installed

Return type

int

only_master_rank(f)[source]

A decorator to ensure only the master MPI rank can run it

shared_comm[source]

Returns the process id within a node. Used for shared memory

shared_rank[source]