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

STEllAR-GROUP / hpx / #850

15 Dec 2022 03:00PM UTC coverage: 86.404% (+0.7%) from 85.715%
#850

push

StellarBot
Merge #6098

6098: Forking Boost.Lockfree r=hkaiser a=hkaiser

Working towards #3440 

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

1285 of 1285 new or added lines in 18 files covered. (100.0%)

174060 of 201449 relevant lines covered (86.4%)

1882623.65 hits per line

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

5.41
/libs/full/segmented_algorithms/tests/unit/partitioned_vector_adjacent_find1.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 accompadjacent_finding
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_adjacent_find.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 <iostream>
17
#include <vector>
18

19
///////////////////////////////////////////////////////////////////////////////
20
#define SIZE 64
21

22
struct pred
23
{
24
    template <typename T>
25
    bool operator()(const T& prev, const T& curr) const
8✔
26
    {
27
        return curr < prev;
8✔
28
    }
29
};
30

31
template <typename T>
32
void initialize(hpx::partitioned_vector<T>& xvalues)
×
33
{
34
    T init_array[SIZE] = {1, 2, 3, 4, 5, 1, 2, 3, 1, 5, 2, 3, 4, 2, 3, 2, 1, 2,
×
35
        3, 4, 5, 6, 5, 6, 1, 2, 3, 4, 2, 1, 2, 3, 3, 5, 4, 3, 2, 1, 1, 2, 3, 4,
36
        1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 7, 6, 5, 7, 5, 4, 2, 3, 4, 5, 2};
37
    for (int i = 0; i < SIZE; i++)
×
38
    {
39
        xvalues.set_value(i, init_array[i]);
×
40
    }
×
41
}
×
42

43
template <typename ExPolicy, typename T>
44
void test_adjacent_find(ExPolicy&& policy, hpx::partitioned_vector<T>& xvalues)
×
45
{
46
    auto result = hpx::adjacent_find(policy, xvalues.begin(), xvalues.end());
×
47
    HPX_TEST_EQ(std::distance(xvalues.begin(), result), 31);
×
48

49
    result = hpx::adjacent_find(policy, xvalues.begin(), xvalues.end(), pred());
×
50
    HPX_TEST_EQ(std::distance(xvalues.begin(), result), 4);
×
51
}
×
52

53
template <typename ExPolicy, typename T>
54
void test_adjacent_find_async(
×
55
    ExPolicy&& policy, hpx::partitioned_vector<T>& xvalues)
56
{
57
    auto result =
58
        hpx::adjacent_find(policy, xvalues.begin(), xvalues.end()).get();
×
59
    HPX_TEST_EQ(std::distance(xvalues.begin(), result), 31);
×
60

61
    result = hpx::adjacent_find(policy, xvalues.begin(), xvalues.end(), pred())
×
62
                 .get();
×
63
    HPX_TEST_EQ(std::distance(xvalues.begin(), result), 4);
×
64
}
×
65

66
template <typename T>
67
void adjacent_find_tests(std::vector<hpx::id_type>& localities)
×
68
{
69
    hpx::partitioned_vector<T> xvalues(
×
70
        SIZE, T(0), hpx::container_layout(localities));
×
71
    initialize(xvalues);
×
72

73
    test_adjacent_find(hpx::execution::seq, xvalues);
×
74
    test_adjacent_find(hpx::execution::par, xvalues);
×
75
    test_adjacent_find_async(
×
76
        hpx::execution::seq(hpx::execution::task), xvalues);
×
77
    test_adjacent_find_async(
×
78
        hpx::execution::par(hpx::execution::task), xvalues);
×
79
}
×
80

81
///////////////////////////////////////////////////////////////////////////////
82
int main()
×
83
{
84
    std::vector<hpx::id_type> localities = hpx::find_all_localities();
×
85
    adjacent_find_tests<int>(localities);
×
86
    return hpx::util::report_errors();
×
87
}
×
88
#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