• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

STEllAR-GROUP / hpx / #854

18 Dec 2022 11:19PM UTC coverage: 86.511% (+0.2%) from 86.287%
#854

push

StellarBot
Merge #6111

6111: Modernize all modules from module level 8 r=hkaiser a=hkaiser

modules: datastructures, hashing, memory, checkpointing_base

- flyby: adding `hpx::construct_at`

working towards https://github.com/STEllAR-GROUP/hpx/issues/5497

Co-authored-by: Hartmut Kaiser <hartmut.kaiser@gmail.com>

127 of 127 new or added lines in 33 files covered. (100.0%)

174410 of 201605 relevant lines covered (86.51%)

1917096.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/libs/full/segmented_algorithms/tests/unit/partitioned_vector_fill.cpp
1
//  Copyright (c) 2014-2017 Hartmut Kaiser
2
//
3
//  SPDX-License-Identifier: BSL-1.0
4
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
5
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6

7
#include <hpx/config.hpp>
8
#if !defined(HPX_COMPUTE_DEVICE_CODE)
9
#include <hpx/hpx_main.hpp>
10
#include <hpx/include/parallel_fill.hpp>
11
#include <hpx/include/partitioned_vector_predef.hpp>
12
#include <hpx/include/runtime.hpp>
13
#include <hpx/modules/testing.hpp>
14

15
#include <cstddef>
16
#include <vector>
17

18
///////////////////////////////////////////////////////////////////////////////
19
// The vector types to be used are defined in partitioned_vector module.
20
// HPX_REGISTER_PARTITIONED_VECTOR(double)
21
// HPX_REGISTER_PARTITIONED_VECTOR(int)
22

23
///////////////////////////////////////////////////////////////////////////////
24
template <typename T>
25
void iota_vector(hpx::partitioned_vector<T>& v, T val)
×
26
{
27
    typename hpx::partitioned_vector<T>::iterator it = v.begin(), end = v.end();
×
28
    for (/**/; it != end; ++it)
×
29
        *it = val++;
×
30
}
×
31

32
///////////////////////////////////////////////////////////////////////////////
33
template <typename T, typename InIter>
34
void verify_values(
×
35
    InIter first, InIter last, T const& val, bool must_be_equal = true)
36
{
37
    for (InIter it = first; it != last; ++it)
×
38
    {
39
        if (must_be_equal)
×
40
        {
41
            HPX_TEST_EQ(*it, val);
×
42
        }
×
43
        else
44
        {
45
            HPX_TEST_NEQ(*it, val);
×
46
        }
47
    }
×
48
}
×
49

50
///////////////////////////////////////////////////////////////////////////////
51
template <typename T>
52
void verify_vector(hpx::partitioned_vector<T> const& v, T const& val,
×
53
    bool /* must_be_equal */ = true)
54
{
55
    typedef typename hpx::partitioned_vector<T>::const_iterator const_iterator;
56

57
    std::size_t size = 0;
×
58

59
    const_iterator end = v.end();
×
60
    for (const_iterator it = v.begin(); it != end; ++it, ++size)
×
61
    {
62
        HPX_TEST_EQ(*it, val);
×
63
    }
×
64

65
    HPX_TEST_EQ(size, v.size());
×
66
}
×
67

68
///////////////////////////////////////////////////////////////////////////////
69
template <typename T, typename DistPolicy, typename ExPolicy>
70
void fill_algo_tests_with_policy(
×
71
    std::size_t size, DistPolicy const& policy, ExPolicy const& fill_policy)
72
{
73
    hpx::partitioned_vector<T> c(size, policy);
×
74
    iota_vector(c, T(1234));
×
75

76
    const T v(42);
×
77
    hpx::fill(fill_policy, c.begin(), c.end(), v);
×
78
    verify_vector(c, v);
×
79

80
    const T v1(43);
×
81
    hpx::fill(fill_policy, c.begin() + 1, c.end() - 1, v1);
×
82
    verify_values(c.begin() + 1, c.end() - 1, v1);
×
83
    verify_values(c.begin(), c.begin() + 1, v1, false);
×
84
    verify_values(c.end() - 1, c.end(), v1, false);
×
85
}
×
86

87
template <typename T, typename DistPolicy, typename ExPolicy>
88
void fill_algo_tests_with_policy_async(
×
89
    std::size_t size, DistPolicy const& policy, ExPolicy const& fill_policy)
90
{
91
    hpx::partitioned_vector<T> c(size, policy);
×
92
    iota_vector(c, T(1234));
×
93

94
    const T v(42);
×
95
    hpx::future<void> f = hpx::fill(fill_policy, c.begin(), c.end(), v);
×
96
    f.wait();
×
97

98
    verify_vector(c, v);
×
99

100
    const T v1(43);
×
101
    hpx::future<void> f1 =
102
        hpx::fill(fill_policy, c.begin() + 1, c.end() - 1, v1);
×
103
    f1.wait();
×
104

105
    verify_values(c.begin() + 1, c.end() - 1, v1);
×
106
    verify_values(c.begin(), c.begin() + 1, v1, false);
×
107
    verify_values(c.end() - 1, c.end(), v1, false);
×
108
}
×
109

110
template <typename T, typename DistPolicy>
111
void fill_tests_with_policy(
×
112
    std::size_t size, std::size_t /* localities */, DistPolicy const& policy)
113
{
114
    using namespace hpx::execution;
115

116
    fill_algo_tests_with_policy<T>(size, policy, seq);
×
117
    fill_algo_tests_with_policy<T>(size, policy, par);
×
118

119
    //async
120
    fill_algo_tests_with_policy_async<T>(size, policy, seq(task));
×
121
    fill_algo_tests_with_policy_async<T>(size, policy, par(task));
×
122
}
×
123

124
template <typename T>
125
void fill_tests()
×
126
{
127
    std::size_t const length = 12;
×
128
    std::vector<hpx::id_type> localities = hpx::find_all_localities();
×
129

130
    fill_tests_with_policy<T>(length, 1, hpx::container_layout);
×
131
    fill_tests_with_policy<T>(length, 3, hpx::container_layout(3));
×
132
    fill_tests_with_policy<T>(length, 3, hpx::container_layout(3, localities));
×
133
    fill_tests_with_policy<T>(
×
134
        length, localities.size(), hpx::container_layout(localities));
×
135
}
×
136

137
///////////////////////////////////////////////////////////////////////////////
138
int main()
×
139
{
140
    fill_tests<double>();
×
141
    fill_tests<int>();
×
142

143
    return 0;
×
144
}
145
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc