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

STEllAR-GROUP / hpx / #855

20 Dec 2022 09:59PM UTC coverage: 86.55% (+0.04%) from 86.511%
#855

push

StellarBot
Merge #6112

6112: Modernize modules from levels 9 and 10 r=hkaiser a=hkaiser

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

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

185 of 185 new or added lines in 30 files covered. (100.0%)

174495 of 201611 relevant lines covered (86.55%)

1898061.31 hits per line

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

5.56
/libs/full/segmented_algorithms/tests/unit/partitioned_vector_find.cpp
1
//  Copyright (c) 2017 Ajai V George
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_find.hpp>
11
#include <hpx/include/parallel_scan.hpp>
12
#include <hpx/include/partitioned_vector_predef.hpp>
13
#include <hpx/include/runtime.hpp>
14
#include <hpx/modules/testing.hpp>
15

16
#include <cstddef>
17
#include <iostream>
18
#include <vector>
19

20
///////////////////////////////////////////////////////////////////////////////
21
template <typename T>
22
struct cond1
23
{
24
    bool operator()(T v) const
100✔
25
    {
26
        return v > T(511);
100✔
27
    }
28
};
29

30
template <typename T>
31
struct cond2
32
{
33
    bool operator()(T v) const
100✔
34
    {
35
        return v < T(512);
100✔
36
    }
37
};
38

39
template <typename T>
40
void test_find(hpx::partitioned_vector<T>& xvalues, T val)
×
41
{
42
    auto last = hpx::find(xvalues.begin(), xvalues.end(), val);
×
43
    HPX_TEST_EQ(*last, val);
×
44
}
×
45

46
template <typename ExPolicy, typename T>
47
void test_find(ExPolicy&& policy, hpx::partitioned_vector<T>& xvalues, T val)
×
48
{
49
    auto last = hpx::find(policy, xvalues.begin(), xvalues.end(), val);
×
50
    HPX_TEST_EQ(*last, val);
×
51
}
×
52

53
template <typename ExPolicy, typename T>
54
void test_find_async(
×
55
    ExPolicy&& policy, hpx::partitioned_vector<T>& xvalues, T val)
56
{
57
    auto last = hpx::find(policy, xvalues.begin(), xvalues.end(), val).get();
×
58
    HPX_TEST_EQ(*last, val);
×
59
}
×
60

61
template <typename T>
62
void test_find_if(hpx::partitioned_vector<T>& xvalues, T val)
×
63
{
64
    auto last = hpx::find_if(xvalues.begin(), xvalues.end(), cond1<T>());
×
65
    HPX_TEST_EQ(*last, val);
×
66
}
×
67

68
template <typename ExPolicy, typename T>
69
void test_find_if(ExPolicy&& policy, hpx::partitioned_vector<T>& xvalues, T val)
×
70
{
71
    auto last =
72
        hpx::find_if(policy, xvalues.begin(), xvalues.end(), cond1<T>());
×
73
    HPX_TEST_EQ(*last, val);
×
74
}
×
75

76
template <typename ExPolicy, typename T>
77
void test_find_if_async(
×
78
    ExPolicy&& policy, hpx::partitioned_vector<T>& xvalues, T val)
79
{
80
    auto last =
81
        hpx::find_if(policy, xvalues.begin(), xvalues.end(), cond1<T>()).get();
×
82
    HPX_TEST_EQ(*last, val);
×
83
}
×
84

85
template <typename T>
86
void test_find_if_not(hpx::partitioned_vector<T>& xvalues, T val)
×
87
{
88
    auto last = hpx::find_if_not(xvalues.begin(), xvalues.end(), cond2<T>());
×
89
    HPX_TEST_EQ(*last, val);
×
90
}
×
91

92
template <typename ExPolicy, typename T>
93
void test_find_if_not(
×
94
    ExPolicy&& policy, hpx::partitioned_vector<T>& xvalues, T val)
95
{
96
    auto last =
97
        hpx::find_if_not(policy, xvalues.begin(), xvalues.end(), cond2<T>());
×
98
    HPX_TEST_EQ(*last, val);
×
99
}
×
100

101
template <typename ExPolicy, typename T>
102
void test_find_if_not_async(
×
103
    ExPolicy&& policy, hpx::partitioned_vector<T>& xvalues, T val)
104
{
105
    auto last =
106
        hpx::find_if_not(policy, xvalues.begin(), xvalues.end(), cond2<T>())
×
107
            .get();
×
108
    HPX_TEST_EQ(*last, val);
×
109
}
×
110

111
template <typename T>
112
void find_tests(std::vector<hpx::id_type>& localities)
×
113
{
114
    std::size_t const num = 1000;
×
115
    hpx::partitioned_vector<T> xvalues(
×
116
        num, T(1), hpx::container_layout(localities));
×
117
    hpx::inclusive_scan(hpx::execution::seq, xvalues.begin(), xvalues.end(),
×
118
        xvalues.begin(), std::plus<T>(), T(0));
×
119

120
    test_find(xvalues, T(512));
×
121
    test_find(hpx::execution::seq, xvalues, T(512));
×
122
    test_find(hpx::execution::par, xvalues, T(512));
×
123
    test_find_async(hpx::execution::seq(hpx::execution::task), xvalues, T(512));
×
124
    test_find_async(hpx::execution::par(hpx::execution::task), xvalues, T(512));
×
125

126
    test_find_if(xvalues, T(512));
×
127
    test_find_if(hpx::execution::seq, xvalues, T(512));
×
128
    test_find_if(hpx::execution::par, xvalues, T(512));
×
129
    test_find_if_async(
×
130
        hpx::execution::seq(hpx::execution::task), xvalues, T(512));
×
131
    test_find_if_async(
×
132
        hpx::execution::par(hpx::execution::task), xvalues, T(512));
×
133

134
    test_find_if_not(xvalues, T(512));
×
135
    test_find_if_not(hpx::execution::seq, xvalues, T(512));
×
136
    test_find_if_not(hpx::execution::par, xvalues, T(512));
×
137
    test_find_if_not_async(
×
138
        hpx::execution::seq(hpx::execution::task), xvalues, T(512));
×
139
    test_find_if_not_async(
×
140
        hpx::execution::par(hpx::execution::task), xvalues, T(512));
×
141
}
×
142

143
///////////////////////////////////////////////////////////////////////////////
144
int main()
×
145
{
146
    std::vector<hpx::id_type> localities = hpx::find_all_localities();
×
147
    find_tests<int>(localities);
×
148
    return hpx::util::report_errors();
×
149
}
×
150
#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