Skip to content

partitioner

DEFAULT_CACHE_SIZE = None module-attribute

T = TypeVar('T') module-attribute

Partitioner

Bases: ABC

tile = tile instance-attribute

layout = tuple(layout) instance-attribute

total_ranks abstractmethod property

__init__(tile, layout)

boundary(boundary_type, rank) abstractmethod

tile_index(rank) abstractmethod

global_extent(rank_metadata) abstractmethod

Return the shape of a full tile representation for the given dimensions.

Parameters:

Name Type Description Default
rank_metadata QuantityMetadata

quantity metadata

required

Returns:

Name Type Description
extent tuple[int, ...]

shape of full tile representation

subtile_slice(rank, global_dims, global_extent, overlap=False) abstractmethod

Return the subtile slice of a given rank on an array.

Global refers to the domain being partitioned. For example, for a partitioning of a tile, the tile would be the "global" domain.

Parameters:

Name Type Description Default
rank int

the rank of the process

required
global_dims Sequence[str]

dimensions of the global quantity being partitioned

required
global_extent Sequence[int]

extent of the global quantity being partitioned

required
overlap optional

if True, for interface variables include the part of the array shared by adjacent ranks in both ranks. If False, ensure only one of those ranks (the greater rank) is assigned the overlapping section. Default is False.

False

Returns:

Name Type Description
subtile_slice tuple[int | slice, ...]

the slice of the global compute domain corresponding to the subtile compute domain

subtile_extent(global_metadata, rank) abstractmethod

Return the shape of a single rank representation for the given dimensions.

Parameters:

Name Type Description Default
global_metadata QuantityMetadata

quantity metadata.

required
rank int

rank of the process.

required

Returns:

Name Type Description
extent tuple[int, ...]

shape of a single rank representation for the given dimensions.

TilePartitioner

Bases: Partitioner

edge_interior_ratio = edge_interior_ratio instance-attribute

total_ranks property

__init__(layout, edge_interior_ratio=1.0)

Create an object for fv3gfs tile decomposition.

tile_index(rank)

from_namelist(namelist) classmethod

Initialize a TilePartitioner from a Fortran namelist.

Parameters:

Name Type Description Default
namelist dict

the Fortran namelist

required

subtile_index(rank)

Return the (y, x) subtile position of a given rank as an integer number of subtiles.

global_extent(rank_metadata)

Return the shape of a full tile representation for the given dimensions.

Parameters:

Name Type Description Default
rank_metadata Quantity | QuantityMetadata

quantity metadata

required

Returns:

Name Type Description
extent tuple[int, ...]

shape of full tile representation

subtile_extent(global_metadata, rank)

Return the shape of a single rank representation for the given dimensions.

Parameters:

Name Type Description Default
global_metadata QuantityMetadata

quantity metadata.

required
rank int

rank of the process.

required

Returns:

Name Type Description
extent tuple[int, ...]

shape of a single rank representation for the given dimensions.

subtile_slice(rank, global_dims, global_extent, overlap=False)

Return the subtile slice of a given rank on an array.

Global refers to the domain being partitioned. For example, for a partitioning of a tile, the tile would be the "global" domain.

Parameters:

Name Type Description Default
rank int

the rank of the process

required
global_dims Sequence[str]

dimensions of the global quantity being partitioned

required
global_extent Sequence[int]

extent of the global quantity being partitioned

required
overlap optional

if True, for interface variables include the part of the array shared by adjacent ranks in both ranks. If False, ensure only one of those ranks (the greater rank) is assigned the overlapping section. Default is False.

False

Returns:

Name Type Description
subtile_slice tuple[slice, ...]

the slice of the global compute domain corresponding to the subtile compute domain

on_tile_top(rank)

on_tile_bottom(rank)

on_tile_left(rank)

on_tile_right(rank)

boundary(boundary_type, rank)

Returns a boundary of the requested type for a given rank.

Target ranks will be on the same tile as the given rank, wrapping around as in a doubly-periodic boundary condition.

Parameters:

Name Type Description Default
boundary_type int

the type of boundary

required
rank int

the processor rank

required

Returns:

Type Description
SimpleBoundary | None

boundary

fliplr_rank(rank)

rotate_rank(rank, n_clockwise_rotations)

CubedSpherePartitioner

Bases: Partitioner

total_ranks property

the number of ranks on the cubed sphere

__init__(tile)

Create an object for fv3gfs cubed-sphere domain decomposition.

Parameters:

Name Type Description Default
tile TilePartitioner

partitioner for the cube faces

required

from_namelist(namelist) classmethod

Initialize a CubedSpherePartitioner from a Fortran namelist.

Parameters:

Name Type Description Default
namelist dict

the Fortran namelist

required

tile_index(rank)

Returns the tile index of a given rank

tile_root_rank(rank)

Returns the lowest rank on the same tile as a given rank.

boundary(boundary_type, rank)

Returns a boundary of the requested type for a given rank, or None.

On tile corners, the boundary across that corner does not exist.

Parameters:

Name Type Description Default
boundary_type int

the type of boundary

required
rank int

the processor rank

required

Returns:

Type Description
SimpleBoundary | None

boundary

global_extent(rank_metadata)

Return the shape of a full cube representation for the given dimensions.

Parameters:

Name Type Description Default
rank_metadata QuantityMetadata

quantity metadata

required

Returns:

Name Type Description
extent tuple[int, ...]

shape of full cube representation

subtile_extent(cube_metadata, rank)

Return the shape of a single rank representation for the given dimensions.

Parameters:

Name Type Description Default
cube_metadata QuantityMetadata

quantity metadata.

required
rank int

rank of the process.

required

Returns:

Name Type Description
extent tuple[int, ...]

shape of a single rank representation for the given dimensions.

subtile_slice(rank, global_dims, global_extent, overlap=False)

Return the subtile slice of a given rank on an array.

Global refers to the domain being partitioned. For example, for a partitioning of a tile, the tile would be the "global" domain.

Parameters:

Name Type Description Default
rank int

the rank of the process

required
global_dims Sequence[str]

dimensions of the global quantity being partitioned

required
global_extent Sequence[int]

extent of the global quantity being partitioned

required
overlap optional

if True, for interface variables include the part of the array shared by adjacent ranks in both ranks. If False, ensure only one of those ranks (the greater rank) is assigned the overlapping section. Default is False.

False

Returns:

Name Type Description
subtile_slice tuple[int | slice, ...]

the tuple slice of the global compute domain corresponding to the subtile compute domain

get_tile_index(rank, total_ranks)

Returns the zero-indexed tile number, given a rank and total number of ranks.

on_tile_left(subtile_index)

on_tile_right(subtile_index, layout)

on_tile_top(subtile_index, layout)

on_tile_bottom(subtile_index)

rotate_subtile_rank(rank, layout, n_clockwise_rotations)

Returns the rank position where this rank would be if you rotated the tile n_clockwise_rotations times.

transpose_subtile_rank(rank, layout)

Returns the rank position where this rank would be if you transposed the tile.

fliplr_subtile_rank(rank, layout)

Returns the rank position where this rank would be if you flipped the tile along a vertical axis

flipud_subtile_rank(rank, layout)

Returns the rank position where this rank would be if you flipped the tile along a horizontal axis

transform_subtile_rank(transform_func, rank, layout)

Returns the rank position where this rank would be if you performed a transformation on the tile which strictly moves ranks.

subtile_index(rank, ranks_per_tile, layout)

is_even(value)

tile_extent_from_rank_metadata(dims, rank_extent, layout, edge_interior_ratio=1.0)

Returns the extent of a tile given data about a single rank, and the tile layout.

Parameters:

Name Type Description Default
dims Sequence[str]

dimension names

required
rank_extent Sequence[int]

the extent of one rank

required
layout tuple[int, int]

the (y, x) number of ranks along each tile axis

required
edge_interior_ratio float

target value for the relative 1-dimensional extent of the compute domains of ranks on tile edges and corners compared to ranks on the tile interior. In all cases, the closest valid value will be used, which enables some previously invalid configurations (e.g. C128 on a 3 by 3 layout will use the closest valid edge_interior_ratio to 1.0).

1.0

Returns:

Name Type Description
tile_extent tuple[int, ...]

the extent of one tile

rank_slice_from_tile_metadata(dims, *, extent, layout, subtile_index, edge_interior_ratio, overlap)

discard_dimension(dims, dim_name, data)

extent_from_metadata(dims, extent, layout_factors)

subtile_slice(dims, global_extent, layout, subtile_index, edge_interior_ratio=1.0, overlap=False)

Returns the slice of data within a tile's computational domain belonging to a single rank.

Parameters:

Name Type Description Default
dims Sequence[str]

dimension names for each axis

required
global_extent Sequence[int]

size of the tile or cube's computational domain

required
layout tuple[int, int]

the (y, x) number of ranks along each tile axis

required
subtile_index tuple[int, int]

the (y, x) position of the rank on the tile

required
edge_interior_ratio float

target value for the relative 1-dimensional extent of the compute domains of ranks on tile edges and corners compared to ranks on the tile interior. In all cases, the closest valid value will be used, which enables some previously invalid configurations (e.g. C128 on a 3 by 3 layout will use the closest valid edge_interior_ratio to 1.0).

1.0
overlap optional

if True, for interface variables include the part of the array shared by adjacent ranks in both ranks. If False, ensure only one of those ranks (the greater rank) is assigned the overlapping section. Default is False.

False