Skip to content

make_grid_shape / normalize_grid_shape refactoring #406

@kwmsmith

Description

@kwmsmith

The make_grid_shape() and normalize_grid_shape() have to deal with a lot of edge cases currently. They should also be more flexible with respect to comm_size.

Both make_grid_shape and normalize_grid_shape will take shape, dist, and comm_size as arguments. normalize_grid_shape also takes a grid_shape argument.

Preconditions for both (result in exception if not satisfied):

  • comm_size >= 1
  • len(shape) == len(dist)
  • shape is a sequence of non-negative integers.
  • dist is a sequence of 'b', 'c', 'n' strings.

Extra precondition for normalize_grid_shape:

  • grid_shape is a sequence of positive integers.
  • len(grid_shape) <= len(dist)

Postconditions for both:

  • len(grid_shape) == len(shape) == len(dist)
  • all(gs >= 1 for gs in grid_shape)
  • all(gs == 1 for (d, gs) in zip(dist, grid_shape) if d == 'n')
  • all(gs <= s for (s, gs) in zip(shape, grid_shape) if s > 0)
  • reduce(operator.mul, grid_shape, 1) <= comm_size

These postconditions ensure grid_shape is well-behaved, and ensures that there are no empty localarrays.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions