• 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

91.18
/libs/full/collectives/tests/unit/exclusive_scan_.cpp
1
//  Copyright (c) 2019-2022 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

9
#if !defined(HPX_COMPUTE_DEVICE_CODE)
10
#include <hpx/hpx.hpp>
11
#include <hpx/hpx_init.hpp>
12
#include <hpx/modules/collectives.hpp>
13
#include <hpx/modules/testing.hpp>
14

15
#include <cstdint>
16
#include <string>
17
#include <utility>
18
#include <vector>
19

20
using namespace hpx::collectives;
21

22
constexpr char const* exclusive_scan_basename = "/test/exclusive_scan/";
23

24
void test_one_shot_use()
1✔
25
{
26
    std::uint32_t num_localities = hpx::get_num_localities(hpx::launch::sync);
1✔
27
    std::uint32_t here = hpx::get_locality_id();
1✔
28

29
    // test functionality based on immediate local result value
30
    for (int i = 0; i != 10; ++i)
11✔
31
    {
32
        std::uint32_t value = here;
10✔
33

34
        hpx::future<std::uint32_t> overall_result =
35
            exclusive_scan(exclusive_scan_basename, value,
10✔
36
                std::plus<std::uint32_t>{}, num_sites_arg(num_localities),
10✔
37
                this_site_arg(here), generation_arg(i + 1));
10✔
38

39
        if (here == 0)
10✔
40
        {
41
            // root_site is special
42
            HPX_TEST_EQ(std::uint32_t(0), overall_result.get());
×
43
        }
×
44
        else
45
        {
46
            std::uint32_t sum = 0;
10✔
47
            for (std::uint32_t j = 0; j != value; ++j)
20✔
48
            {
49
                sum += j;
10✔
50
            }
10✔
51
            HPX_TEST_EQ(sum, overall_result.get());
10✔
52
        }
53
    }
10✔
54
}
1✔
55

56
void test_multiple_use()
1✔
57
{
58
    std::uint32_t num_localities = hpx::get_num_localities(hpx::launch::sync);
1✔
59
    std::uint32_t here = hpx::get_locality_id();
1✔
60

61
    auto exclusive_scan_client = create_communicator(exclusive_scan_basename,
1✔
62
        num_sites_arg(num_localities), this_site_arg(here));
1✔
63

64
    // test functionality based on immediate local result value
65
    for (int i = 0; i != 10; ++i)
11✔
66
    {
67
        std::uint32_t value = here;
10✔
68

69
        hpx::future<std::uint32_t> overall_result = exclusive_scan(
10✔
70
            exclusive_scan_client, value, std::plus<std::uint32_t>{});
10✔
71

72
        if (here == 0)
10✔
73
        {
74
            // root_site is special
75
            HPX_TEST_EQ(std::uint32_t(0), overall_result.get());
×
76
        }
×
77
        else
78
        {
79
            std::uint32_t sum = 0;
10✔
80
            for (std::uint32_t j = 0; j != value; ++j)
20✔
81
            {
82
                sum += j;
10✔
83
            }
10✔
84
            HPX_TEST_EQ(sum, overall_result.get());
10✔
85
        }
86
    }
10✔
87
}
1✔
88

89
void test_multiple_use_with_generation()
1✔
90
{
91
    std::uint32_t num_localities = hpx::get_num_localities(hpx::launch::sync);
1✔
92
    std::uint32_t here = hpx::get_locality_id();
1✔
93

94
    auto exclusive_scan_client = create_communicator(exclusive_scan_basename,
1✔
95
        num_sites_arg(num_localities), this_site_arg(here));
1✔
96

97
    // test functionality based on immediate local result value
98
    for (int i = 0; i != 10; ++i)
11✔
99
    {
100
        std::uint32_t value = here;
10✔
101

102
        hpx::future<std::uint32_t> overall_result =
103
            exclusive_scan(exclusive_scan_client, value,
20✔
104
                std::plus<std::uint32_t>{}, generation_arg(i + 1));
10✔
105

106
        if (here == 0)
10✔
107
        {
108
            // root_site is special
109
            HPX_TEST_EQ(std::uint32_t(0), overall_result.get());
×
110
        }
×
111
        else
112
        {
113
            std::uint32_t sum = 0;
10✔
114
            for (std::uint32_t j = 0; j != value; ++j)
20✔
115
            {
116
                sum += j;
10✔
117
            }
10✔
118
            HPX_TEST_EQ(sum, overall_result.get());
10✔
119
        }
120
    }
10✔
121
}
1✔
122

123
int hpx_main()
1✔
124
{
125
    test_one_shot_use();
1✔
126
    test_multiple_use();
1✔
127
    test_multiple_use_with_generation();
1✔
128

129
    return hpx::finalize();
1✔
130
}
131

132
int main(int argc, char* argv[])
1✔
133
{
134
    std::vector<std::string> const cfg = {"hpx.run_hpx_main!=1"};
1✔
135

136
    hpx::init_params init_args;
1✔
137
    init_args.cfg = cfg;
1✔
138

139
    HPX_TEST_EQ(hpx::init(argc, argv, init_args), 0);
1✔
140
    return hpx::util::report_errors();
1✔
141
}
1✔
142

143
#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

© 2026 Coveralls, Inc