romtools.linalg.parallel_utils#
Helper functions for testing and writing parallel code with the romtools.linalg module.
Functions
|
Simple helper function to assert that the given axis is valid for the given array. |
|
Splts an np.array and distributes to all available MPI processes as evenly as possible. |
Generates and returns the local and global arrays built from the example tensors in the documentation. |
|
Randomly generates a global array of the specified shape and distributes to all available MPI processes. |
- romtools.linalg.parallel_utils.assert_axis_is_none_or_within_rank(a, axis)[source]#
Simple helper function to assert that the given axis is valid for the given array.
- romtools.linalg.parallel_utils.distribute_array_impl(global_array, comm, dist_axis=0)[source]#
Splts an np.array and distributes to all available MPI processes as evenly as possible.
For example, distributing an array with 6 rows over 3 processes will result in 2 rows per process. If the array has 7 rows, 2 processors will hold 2 rows, and the third will hold 3 rows.
- Inputs:
global_array: The global np.array to be distributed. comm: The MPI communicator dist_axis: The axis along which to split the input array. By default, splits along the first axis (rows).
- Returns:
The subset of global_array sent to the current MPI process.
- Return type:
local_array