oneTBB icon indicating copy to clipboard operation
oneTBB copied to clipboard

[Feature Request] Add aligned_blocked_range

Open Lastique opened this issue 7 years ago • 3 comments

It would be useful to have an aligned version of blocked_range:

template< typename Iterator, std::size_t Alignment >
class aligned_blocked_range;

The idea is that the aligned_blocked_range should divide the range on boundaries that are a multiple of Alignment from the beginning of the range. It should still provide support for grain size, which should be not less than Alignment and should be rounded up to the nearest multiple of Alignment. The range is splittable if its size is at least 2 grain sizes (i.e. the split must never produce a range that is less than Alignment).

The existing blocked_range doesn't provide that guarantee because even if you specify an aligned grain size because it will split the range in halves and thus will lose alignment if the range size is not exactly an even multiple of the grain size. Also, the current blocked_range split can produce a range that is less than the grain size.

The aligned_blocked_range is useful when the input range is already aligned, and threaded processing should also preferably be aligned. For example, in image processing, the image rows might be cache line aligned, and each chunk of row suitable for threaded processing should also be aligned to a cache line to avoid false sharing effects.

Lastique avatar Mar 08 '18 13:03 Lastique

+1 This is very desired extension which simplifies writing high-performance SIMD code.

anton-malakhov avatar Apr 04 '18 13:04 anton-malakhov

@anton-malakhov is this issue still relevant?

arunparkugan avatar Aug 13 '24 11:08 arunparkugan

yes

anton-malakhov avatar Aug 14 '24 11:08 anton-malakhov