dash
dash copied to clipboard
Supporting strided ranges
From issue #3:
Consider the following use cases:
// assuming row-major storage
dash::Matrix<double, 2> matrix(...);
auto lcol = matrix.local.col(0);
auto lrow = matrix.local.row(0);
auto n_lcol = std::distance(lcol.begin(), lcol.end());
auto n_lrow = std::distance(lcol.begin(), lrow.end());
std::vector<double> copy_lrow(n_lrow);
std::vector<double> copy_lcol(n_lcol);
// works:
dash::copy(lrow.begin(), lrow.end(), copy_lrow.data());
// fails:
dash::copy(lcol.begin(), lcol.end(), copy_lcol.data());
Slicing columns from a matrix with row-major storage order is fine, but copying this slice is not. This is a missing feature: DASH does not support strided copying yet.
[ 0 1 2 3 ] <- row contiguous in memory | 8 | 4 | 0 | <- column is strided, requires packing
[ 4 5 6 7 ] | 9 | 5 | 1 | into temporary buffer [ 0 4 8 ] or
[ 8 9 0 1 ] -- rot 90° --> | 0 | 6 | 2 | single copy operations for every
| 1 | 7 | 3 | value
This affects the specification of at least the following interfaces:
- Implementations of
dash::copy
should support strided input ranges, the interface must not change -
dash::local_range
should be extended bydash::local_ranges
which resolves a list of local ranges in a global input range -
dash::local_range
should return the first local range in a global input range