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

STEllAR-GROUP / hpx / #872

24 Jan 2023 07:29PM UTC coverage: 85.694% (-0.9%) from 86.624%
#872

push

StellarBot
Merge #6148

6148: Investigate the failure of the LCI parcelport. r=hkaiser a=JiakunYan



Co-authored-by: Jiakun Yan <jiakunyan1998@gmail.com>

173076 of 201969 relevant lines covered (85.69%)

2110584.0 hits per line

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

14.29
/libs/full/segmented_algorithms/tests/unit/partitioned_vector_all_of1.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_all_any_none_of.hpp>
11
#include <hpx/include/partitioned_vector.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 the vector types to be used.
21
HPX_REGISTER_PARTITIONED_VECTOR(int)
173✔
22

23
///////////////////////////////////////////////////////////////////////////////
24
#define SIZE 64
25

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

38
struct op5
39
{
40
    template <typename T>
41
    bool operator()(T& value)
4✔
42
    {
43
        return value > 5;
4✔
44
    }
45
};
46

47
struct op0
48
{
49
    template <typename T>
50
    bool operator()(T& value)
128✔
51
    {
52
        return value > 0;
128✔
53
    }
54
};
55

56
struct op8
57
{
58
    template <typename T>
59
    bool operator()(T& value)
4✔
60
    {
61
        return value > 8;
4✔
62
    }
63
};
64

65
template <typename ExPolicy, typename T, typename Func>
66
void test_all(ExPolicy&& policy, hpx::partitioned_vector<T>& xvalues, Func&& f,
×
67
    bool expected_result)
68
{
69
    bool result = hpx::all_of(policy, xvalues.begin(), xvalues.end(), f);
×
70
    HPX_TEST_EQ(result, expected_result);
×
71
}
×
72

73
template <typename ExPolicy, typename T, typename Func>
74
void test_all_async(ExPolicy&& policy, hpx::partitioned_vector<T>& xvalues,
×
75
    Func&& f, bool expected_result)
76
{
77
    bool result = hpx::all_of(policy, xvalues.begin(), xvalues.end(), f).get();
×
78
    HPX_TEST_EQ(result, expected_result);
×
79
}
×
80

81
template <typename T>
82
void all_of_tests(std::vector<hpx::id_type>& localities)
×
83
{
84
    hpx::partitioned_vector<T> xvalues(
×
85
        SIZE, T(0), hpx::container_layout(localities));
×
86
    initialize(xvalues);
×
87

88
    test_all(hpx::execution::seq, xvalues, op8(), false);
×
89
    test_all(hpx::execution::par, xvalues, op8(), false);
×
90
    test_all_async(
×
91
        hpx::execution::seq(hpx::execution::task), xvalues, op8(), false);
×
92
    test_all_async(
×
93
        hpx::execution::par(hpx::execution::task), xvalues, op8(), false);
×
94

95
    test_all(hpx::execution::seq, xvalues, op5(), false);
×
96
    test_all(hpx::execution::par, xvalues, op5(), false);
×
97
    test_all_async(
×
98
        hpx::execution::seq(hpx::execution::task), xvalues, op5(), false);
×
99
    test_all_async(
×
100
        hpx::execution::par(hpx::execution::task), xvalues, op5(), false);
×
101

102
    test_all(hpx::execution::seq, xvalues, op0(), true);
×
103
    test_all(hpx::execution::par, xvalues, op0(), true);
×
104
    test_all_async(
×
105
        hpx::execution::seq(hpx::execution::task), xvalues, op0(), true);
×
106
    test_all_async(
×
107
        hpx::execution::par(hpx::execution::task), xvalues, op0(), true);
×
108
}
×
109

110
///////////////////////////////////////////////////////////////////////////////
111
int main()
×
112
{
113
    std::vector<hpx::id_type> localities = hpx::find_all_localities();
×
114
    all_of_tests<int>(localities);
×
115
    return hpx::util::report_errors();
×
116
}
×
117
#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