Commit 2bbb7f95 authored by Paul's avatar Paul
Browse files

Fix tidy issue

parent 392ed8e5
...@@ -160,6 +160,30 @@ struct index ...@@ -160,6 +160,30 @@ struct index
return f(i); return f(i);
} }
template <bool Unroll, class F, class N, class Stride>
static constexpr void for_stride_loop_unroll(index_int start, N n, Stride stride, F f)
{
sequence(max_stride_iterations(n, stride), [&](auto... ks) {
fold([&](auto d, auto k) {
auto i = start + stride * k;
if(i < n)
invoke_loop(f, i, d);
return d + _c<1>;
})(_c<0>, ks...);
});
}
template <bool Unroll, class F, class N, class Stride>
static constexpr void for_stride_loop(index_int start, N n, Stride stride, F f)
{
index_int k = 0;
for(index_int i = start; i < n; i += stride)
{
invoke_loop(f, i, k);
k++;
}
}
template <bool Unroll, class F, class N, class Stride> template <bool Unroll, class F, class N, class Stride>
static constexpr void for_stride(index_int start, N n, Stride stride, F f) static constexpr void for_stride(index_int start, N n, Stride stride, F f)
{ {
...@@ -182,34 +206,17 @@ struct index ...@@ -182,34 +206,17 @@ struct index
{ {
MIGRAPHX_STATIC_ASSERT_FOR(max_stride_iterations(n, stride) < 256) MIGRAPHX_STATIC_ASSERT_FOR(max_stride_iterations(n, stride) < 256)
{ {
sequence(max_stride_iterations(n, stride), [&](auto... ks) { for_stride_loop_unroll(start, n, stride, f);
fold([&](auto d, auto k) {
auto i = start + stride * k;
if(i < n)
invoke_loop(f, i, d);
return d + _c<1>;
})(_c<0>, ks...);
});
} }
} }
else else
{ {
index_int k = 0; for_stride_loop(start, n, stride, f);
for(index_int i = start; i < n; i += stride)
{
invoke_loop(f, i, k);
k++;
}
} }
} }
else else
{ {
index_int k = 0; for_stride_loop(start, n, stride, f);
for(index_int i = start; i < n; i += stride)
{
invoke_loop(f, i, k);
k++;
}
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment