communicator
Communicator
Bases: ABC
comm = comm
instance-attribute
partitioner = partitioner
instance-attribute
timer = timer if timer is not None else NullTimer()
instance-attribute
tile
abstractmethod
property
rank
property
rank of the current process within this communicator
size
property
Total number of ranks in this communicator
boundaries
property
boundaries of this tile with neighboring tiles
__init__(comm, partitioner, force_cpu=False, timer=None)
from_layout(comm, layout, force_cpu=False, timer=None)
abstractmethod
classmethod
all_reduce(input_quantity, op, output_quantity=None)
all_reduce_per_element(input_quantity, output_quantity, op)
all_reduce_per_element_in_place(quantity, op)
scatter(send_quantity=None, recv_quantity=None)
Transfer subtile regions of a full-tile quantity from the tile root rank to all subtiles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
send_quantity
|
Quantity | None
|
quantity to send, only required/used on the tile root rank |
None
|
recv_quantity
|
Quantity | None
|
if provided, assign received data into this Quantity. |
None
|
Returns: recv_quantity
gather(send_quantity, recv_quantity=None)
Transfer subtile regions of a full-tile quantity from each rank to the tile root rank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
send_quantity
|
Quantity
|
quantity to send |
required |
recv_quantity
|
Quantity | None
|
if provided, assign received data into this Quantity (only used on the tile root rank) |
None
|
Returns: recv_quantity: quantity if on root rank, otherwise None
gather_state(send_state=None, recv_state=None, transfer_type=None)
Transfer a state dictionary from subtile ranks to the tile root rank.
'time' is assumed to be the same on all ranks, and its value will be set to the value from the root rank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
send_state
|
the model state to be sent containing the subtile data |
None
|
|
recv_state
|
the pre-allocated state in which to receive the full tile state. Only variables which are scattered will be written to. |
None
|
Returns: recv_state: on the root rank, the state containing the entire tile
scatter_state(send_state=None, recv_state=None)
Transfer a state dictionary from the tile root rank to all subtiles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
send_state
|
the model state to be sent containing the entire tile, required only from the root rank |
None
|
|
recv_state
|
the pre-allocated state in which to receive the scattered state. Only variables which are scattered will be written to. |
None
|
Returns: rank_state: the state corresponding to this rank's subdomain
halo_update(quantity, n_points)
Perform a halo update on a quantity or quantities
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
quantity
|
Quantity | list[Quantity]
|
the quantity to be updated |
required |
n_points
|
int
|
how many halo points to update, starting from the interior |
required |
start_halo_update(quantity, n_points)
Start an asynchronous halo update on a quantity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
quantity
|
Quantity | list[Quantity]
|
the quantity to be updated |
required |
n_points
|
int
|
how many halo points to update, starting from the interior |
required |
Returns:
| Name | Type | Description |
|---|---|---|
request |
HaloUpdater
|
an asynchronous request object with a .wait() method |
vector_halo_update(x_quantity, y_quantity, n_points)
Perform a halo update of a horizontal vector quantity or quantities.
Assumes the x and y dimension indices are the same between the two quantities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_quantity
|
Quantity | list[Quantity]
|
the x-component quantity to be halo updated |
required |
y_quantity
|
Quantity | list[Quantity]
|
the y-component quantity to be halo updated |
required |
n_points
|
int
|
how many halo points to update, starting at the interior |
required |
start_vector_halo_update(x_quantity, y_quantity, n_points)
Start an asynchronous halo update of a horizontal vector quantity.
Assumes the x and y dimension indices are the same between the two quantities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_quantity
|
Quantity | list[Quantity]
|
the x-component quantity to be halo updated |
required |
y_quantity
|
Quantity | list[Quantity]
|
the y-component quantity to be halo updated |
required |
n_points
|
int
|
how many halo points to update, starting at the interior |
required |
Returns:
| Name | Type | Description |
|---|---|---|
request |
HaloUpdater
|
an asynchronous request object with a .wait() method |
synchronize_vector_interfaces(x_quantity, y_quantity)
Synchronize shared points at the edges of a vector interface variable.
Sends the values on the south and west edges to overwrite the values on adjacent subtiles. Vector must be defined on the Arakawa C grid.
For interface variables, the edges of the tile are computed on both ranks bordering that edge. This routine copies values across those shared edges so that both ranks have the same value for that edge. It also handles any rotation of vector quantities needed to move data across the edge.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_quantity
|
Quantity
|
the x-component quantity to be synchronized |
required |
y_quantity
|
Quantity
|
the y-component quantity to be synchronized |
required |
start_synchronize_vector_interfaces(x_quantity, y_quantity)
Synchronize shared points at the edges of a vector interface variable.
Sends the values on the south and west edges to overwrite the values on adjacent subtiles. Vector must be defined on the Arakawa C grid.
For interface variables, the edges of the tile are computed on both ranks bordering that edge. This routine copies values across those shared edges so that both ranks have the same value for that edge. It also handles any rotation of vector quantities needed to move data across the edge.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_quantity
|
Quantity
|
the x-component quantity to be synchronized |
required |
y_quantity
|
Quantity
|
the y-component quantity to be synchronized |
required |
Returns:
| Name | Type | Description |
|---|---|---|
request |
HaloUpdateRequest
|
an asynchronous request object with a .wait() method |
get_scalar_halo_updater(specifications)
get_vector_halo_updater(specifications_x, specifications_y)
TileCommunicator
Bases: Communicator
Performs communications within a single tile or region of a tile
partitioner = partitioner
instance-attribute
tile
property
__init__(comm, partitioner, force_cpu=False, timer=None)
Initialize a TileCommunicator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
comm
|
Comm
|
communication object behaving like mpi4py.Comm |
required |
partitioner
|
TilePartitioner
|
tile partitioner |
required |
force_cpu
|
bool
|
force all communication to go through central memory |
False
|
timer
|
Timer | None
|
Time communication operations. |
None
|
from_layout(comm, layout, force_cpu=False, timer=None)
classmethod
start_halo_update(quantity, n_points)
Start an asynchronous halo update on a quantity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
quantity
|
Quantity | list[Quantity]
|
the quantity to be updated |
required |
n_points
|
int
|
how many halo points to update, starting from the interior |
required |
Returns:
| Name | Type | Description |
|---|---|---|
request |
HaloUpdater
|
an asynchronous request object with a .wait() method |
start_vector_halo_update(x_quantity, y_quantity, n_points)
Start an asynchronous halo update of a horizontal vector quantity.
Assumes the x and y dimension indices are the same between the two quantities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_quantity
|
Quantity | list[Quantity]
|
the x-component quantity to be halo updated |
required |
y_quantity
|
Quantity | list[Quantity]
|
the y-component quantity to be halo updated |
required |
n_points
|
int
|
how many halo points to update, starting at the interior |
required |
Returns:
| Name | Type | Description |
|---|---|---|
request |
HaloUpdater
|
an asynchronous request object with a .wait() method |
start_synchronize_vector_interfaces(x_quantity, y_quantity)
Synchronize shared points at the edges of a vector interface variable.
Sends the values on the south and west edges to overwrite the values on adjacent subtiles. Vector must be defined on the Arakawa C grid.
For interface variables, the edges of the tile are computed on both ranks bordering that edge. This routine copies values across those shared edges so that both ranks have the same value for that edge. It also handles any rotation of vector quantities needed to move data across the edge.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_quantity
|
Quantity
|
the x-component quantity to be synchronized |
required |
y_quantity
|
Quantity
|
the y-component quantity to be synchronized |
required |
Returns:
| Name | Type | Description |
|---|---|---|
request |
HaloUpdateRequest
|
an asynchronous request object with a .wait() method |
CubedSphereCommunicator
Bases: Communicator
Performs communications within a cubed sphere
timer
instance-attribute
partitioner = partitioner
instance-attribute
tile
property
communicator for within a tile
__init__(comm, partitioner, force_cpu=False, timer=None)
Initialize a CubedSphereCommunicator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
comm
|
Comm
|
mpi4py.Comm object |
required |
partitioner
|
CubedSpherePartitioner
|
cubed sphere partitioner |
required |
force_cpu
|
bool
|
Force all communication to go through central memory. |
False
|
timer
|
Timer | None
|
Time communication operations. |
None
|
from_layout(comm, layout, force_cpu=False, timer=None)
classmethod
to_numpy(array, dtype=None)
Input array can be a numpy array or a cupy array. Returns numpy array.