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.
The
make_grid_shape()andnormalize_grid_shape()have to deal with a lot of edge cases currently. They should also be more flexible with respect tocomm_size.Both
make_grid_shapeandnormalize_grid_shapewill takeshape,dist, andcomm_sizeas arguments.normalize_grid_shapealso takes agrid_shapeargument.Preconditions for both (result in exception if not satisfied):
comm_size >= 1len(shape) == len(dist)shapeis a sequence of non-negative integers.distis a sequence of 'b', 'c', 'n' strings.Extra precondition for
normalize_grid_shape:grid_shapeis 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_sizeThese postconditions ensure
grid_shapeis well-behaved, and ensures that there are no empty localarrays.