4.7.10 pde.tools.mpi module

Auxiliary functions and variables for dealing with MPI multiprocessing.

Warning

These functions are mostly no-ops unless MPI is properly installed and python code was started using mpirun or mpiexec. Please refer to the documentation of your MPI distribution for details.

mpi_send

Send data to another MPI node.

mpi_recv

Receive data from another MPI node.

mpi_allreduce

Combines data from all MPI nodes.

initialized: bool = True

Flag determining whether mpi was initialized (and is available)

Type:

bool

is_main: bool = True

Flag indicating whether the current process is the main process (with ID 0)

Type:

bool

mpi_allreduce(data, operator)[source]

Combines data from all MPI nodes.

Note that complex datatypes and user-defined reduction operators are not properly supported in numba-compiled cases.

Parameters:
  • data – Data being send from this node to all others

  • operator (int | str) – The operator used to combine all data. Possible options are summarized in the IntEnum numba_mpi.Operator.

Returns:

The accumulated data

mpi_bcast(data, root=0)[source]

Broadcast data from root node to all other MPI nodes.

Parameters:
  • data (T) – The data being sent

  • root (int) – The ID of the sending node

Return type:

T

mpi_excepthook(exc_type, exc_value, exc_tb)[source]

Print uncaught exceptions with rank information and abort the MPI job.

This function is intended to be assigned to sys.excepthook in MPI runs. It formats the traceback on the local rank, writes the error to stderr, flushes stdio streams, and then calls MPI.Comm.Abort() to terminate all ranks.

Parameters:
  • exc_type – Exception class of the uncaught exception.

  • exc_value – Exception instance.

  • exc_tb – Traceback object of the uncaught exception.

mpi_recv(data, source, tag)[source]

Receive data from another MPI node.

Parameters:
  • data (NumericArray) – A buffer into which the received data is written

  • source (int) – The ID of the sending node

  • tag (int) – A numeric tag identifying the message

Return type:

None

mpi_send(data, dest, tag)[source]

Send data to another MPI node.

Parameters:
  • data (NumericArray) – The data being send

  • dest (int) – The ID of the receiving node

  • tag (int) – A numeric tag identifying the message

Return type:

None

parallel_run: bool = False

Flag indicating whether the current run is using multiprocessing

Type:

bool

rank: int = 0

ID of the current process

Type:

int

size: int = 1

Total process count

Type:

int