Distributed Ranges
Loading...
Searching...
No Matches
iota.hpp
1// SPDX-FileCopyrightText: Intel Corporation
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#pragma once
6
7#include <algorithm>
8#include <execution>
9#include <type_traits>
10#include <utility>
11
12#include <dr/concepts/concepts.hpp>
13#include <dr/detail/logger.hpp>
14#include <dr/detail/onedpl_direct_iterator.hpp>
15#include <dr/detail/ranges_shim.hpp>
16#include <dr/mp/global.hpp>
17
18namespace dr::mp {
19
21template <dr::distributed_range R, std::integral T> void iota(R &&r, T value) {
22 auto iota_view = rng::views::iota(value, T(value + rng::distance(r)));
23
24 for_each(views::zip(iota_view, r), [](auto &&elem) {
25 auto &&[idx, v] = elem;
26 v = idx;
27 });
28}
29
31template <dr::distributed_iterator Iter, std::integral T>
32void iota(Iter begin, Iter end, T value) {
33 auto r = rng::subrange(begin, end);
34 iota(r, value);
35}
36
37} // namespace dr::mp