49#ifdef TBB_OLD_BLOCKED_RANGE_ND
51template<
typename Value,
unsigned int N,
typename = detail::make_index_sequence<N>>
53class blocked_rangeNd_impl;
55template<
typename Value,
unsigned int N, std::size_t... Is>
57class blocked_rangeNd_impl<Value,
N, detail::index_sequence<Is...>> {
60 using value_type = Value;
81 blocked_rangeNd_impl() =
delete;
103 blocked_rangeNd_impl(
106 typename tbb::blocked_range<value_type>::size_type grainsize
109 for (
int d=0; d<
N; d++) {
113 __TBB_ASSERT(
my_dims.size()==
N,
"range is not properly initialised" );
117 static constexpr unsigned int ndims() {
return N; }
120 const tbb::blocked_range<value_type>& dim(
unsigned int dimension)
const {
121 __TBB_ASSERT(dimension <
N,
"out of bound");
122 __TBB_ASSERT(
my_dims.size()==
N,
"range is not properly initialised" );
132 return std::any_of(
my_dims.begin(),
my_dims.end(), [](
const tbb::blocked_range<value_type>& d) {
139 return std::any_of(
my_dims.begin(),
my_dims.end(), [](
const tbb::blocked_range<value_type>& d) {
140 return d.is_divisible();
144 blocked_rangeNd_impl(blocked_rangeNd_impl& r, proportional_split proportion) :
my_dims(r.my_dims) {
146 __TBB_ASSERT(
my_dims.size()==
N,
"range is not properly initialised" );
149 blocked_rangeNd_impl(blocked_rangeNd_impl& r, split proportion) :
my_dims(r.my_dims) {
151 __TBB_ASSERT(
my_dims.size()==
N,
"range is not properly initialised" );
155 static_assert(
N != 0,
"zero dimensional blocked_rangeNd can't be constructed");
162 std::vector<tbb::blocked_range<value_type>>
my_dims;
164 template<
typename split_type>
165 void do_split(blocked_rangeNd_impl& r, split_type proportion) {
166 static_assert((std::is_same<split_type, split>::value || std::is_same<split_type, proportional_split>::value),
"type of split object is incorrect");
167 __TBB_ASSERT(r.is_divisible(),
"can't split not divisible range");
169 auto my_it = std::max_element(
my_dims.begin(),
my_dims.end(), [](
const tbb::blocked_range<value_type>& first,
const tbb::blocked_range<value_type>& second) {
170 return (first.size() * second.grainsize() < second.size() * first.grainsize());
173 auto r_it = r.my_dims.begin() + (my_it -
my_dims.begin());
175 my_it->my_begin = tbb::blocked_range<value_type>::do_split(*r_it, proportion);
179 __TBB_ASSERT(!(my_it->my_begin < r_it->my_end) && !(r_it->my_end < my_it->my_begin),
180 "blocked_range has been split incorrectly");
184template<
typename Value,
unsigned int N>
189template<
typename Value,
unsigned int N,
typename = detail::make_index_sequence<N>>
193template<
typename Value,
unsigned int N, std::size_t... Is>
198 using value_type = Value;
244 typename tbb::blocked_range<value_type>::size_type grainsize
247 for (
int d=0; d<
N; d++) {
251 __TBB_ASSERT(
my_dims.size()==
N,
"range is not properly initialised" );
255 static constexpr unsigned int ndims() {
return N; }
258 const tbb::blocked_range<value_type>&
dim(
unsigned int dimension)
const {
259 __TBB_ASSERT(dimension <
N,
"out of bound");
260 __TBB_ASSERT(
my_dims.size()==
N,
"range is not properly initialised" );
270 return std::any_of(
my_dims.begin(),
my_dims.end(), [](
const tbb::blocked_range<value_type>& d) {
277 return std::any_of(
my_dims.begin(),
my_dims.end(), [](
const tbb::blocked_range<value_type>& d) {
278 return d.is_divisible();
284 __TBB_ASSERT(
my_dims.size()==
N,
"range is not properly initialised" );
289 __TBB_ASSERT(
my_dims.size()==
N,
"range is not properly initialised" );
293 static_assert(
N != 0,
"zero dimensional blocked_nd_range can't be constructed");
300 std::vector<tbb::blocked_range<value_type>>
my_dims;
302 template<
typename split_type>
304 static_assert((std::is_same<split_type, split>::value || std::is_same<split_type, proportional_split>::value),
"type of split object is incorrect");
305 __TBB_ASSERT(r.is_divisible(),
"can't split not divisible range");
307 auto my_it = std::max_element(
my_dims.begin(),
my_dims.end(), [](
const tbb::blocked_range<value_type>& first,
const tbb::blocked_range<value_type>& second) {
308 return (first.size() * second.grainsize() < second.size() * first.grainsize());
311 auto r_it = r.my_dims.begin() + (my_it -
my_dims.begin());
313 my_it->my_begin = tbb::blocked_range<value_type>::do_split(*r_it, proportion);
317 __TBB_ASSERT(!(my_it->my_begin < r_it->my_end) && !(r_it->my_end < my_it->my_begin),
318 "blocked_range has been split incorrectly");
322template<
typename Value,
unsigned int N>