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

STEllAR-GROUP / hpx / #881

05 Feb 2023 11:26PM UTC coverage: 86.546% (+0.6%) from 85.952%
#881

push

StellarBot
Merge #6157

6157: Improve index_queue_spawning r=hkaiser a=hkaiser

- synchronous for_each_partitioner now binds tasks to cores
- add scheduling properties: get_first_core and with_first_core
- index_queue_spawning now supports first_core
- adapt rotate to use first_core for partitions


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

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

174866 of 202049 relevant lines covered (86.55%)

1824233.11 hits per line

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

5.0
/libs/full/segmented_algorithms/tests/unit/partitioned_vector_transform_scan2.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_transform_scan.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
struct conv
20
{
21
    template <typename T>
22
    T operator()(T in) const
144✔
23
    {
24
        return (T) 2 * in;
144✔
25
    }
26
};
27

28
struct op
29
{
30
    template <typename T>
31
    T operator()(T in1, T in2) const
132✔
32
    {
33
        return in1 + in2;
132✔
34
    }
35
};
36

37
template <typename T>
38
void test_transform_inclusive_scan_noinit(
×
39
    hpx::partitioned_vector<T>& xvalues, hpx::partitioned_vector<T>& out)
40
{
41
    hpx::transform_inclusive_scan(
×
42
        xvalues.begin(), xvalues.end(), out.begin(), op(), conv());
×
43
}
×
44

45
template <typename ExPolicy, typename T>
46
void test_transform_inclusive_scan_noinit(ExPolicy&& policy,
×
47
    hpx::partitioned_vector<T>& xvalues, hpx::partitioned_vector<T>& out)
48
{
49
    hpx::transform_inclusive_scan(
×
50
        policy, xvalues.begin(), xvalues.end(), out.begin(), op(), conv());
×
51
}
×
52

53
template <typename T>
54
void test_transform_inclusive_scan(
×
55
    hpx::partitioned_vector<T>& xvalues, hpx::partitioned_vector<T>& out)
56
{
57
    hpx::transform_inclusive_scan(
×
58
        xvalues.begin(), xvalues.end(), out.begin(), op(), conv(), T(0));
×
59
}
×
60

61
template <typename ExPolicy, typename T>
62
void test_transform_inclusive_scan(ExPolicy&& policy,
×
63
    hpx::partitioned_vector<T>& xvalues, hpx::partitioned_vector<T>& out)
64
{
65
    hpx::transform_inclusive_scan(policy, xvalues.begin(), xvalues.end(),
×
66
        out.begin(), op(), conv(), T(0));
×
67
}
×
68

69
template <typename ExPolicy, typename T>
70
void test_transform_inclusive_scan_async(ExPolicy&& policy,
×
71
    hpx::partitioned_vector<T>& xvalues, hpx::partitioned_vector<T>& out)
72
{
73
    hpx::transform_inclusive_scan(
×
74
        policy, xvalues.begin(), xvalues.end(), out.begin(), op(), conv(), T(0))
×
75
        .get();
×
76
}
×
77

78
template <typename T>
79
void test_transform_exclusive_scan(
×
80
    hpx::partitioned_vector<T>& xvalues, hpx::partitioned_vector<T>& out)
81
{
82
    hpx::transform_exclusive_scan(
×
83
        xvalues.begin(), xvalues.end(), out.begin(), T(0), op(), conv());
×
84
}
×
85

86
template <typename ExPolicy, typename T>
87
void test_transform_exclusive_scan(ExPolicy&& policy,
×
88
    hpx::partitioned_vector<T>& xvalues, hpx::partitioned_vector<T>& out)
89
{
90
    hpx::transform_exclusive_scan(policy, xvalues.begin(), xvalues.end(),
×
91
        out.begin(), T(0), op(), conv());
×
92
}
×
93

94
template <typename ExPolicy, typename T>
95
void test_transform_exclusive_scan_async(ExPolicy&& policy,
×
96
    hpx::partitioned_vector<T>& xvalues, hpx::partitioned_vector<T>& out)
97
{
98
    hpx::transform_exclusive_scan(
×
99
        policy, xvalues.begin(), xvalues.end(), out.begin(), T(0), op(), conv())
×
100
        .get();
×
101
}
×
102

103
template <typename T>
104
void transform_scan_tests(std::size_t num, hpx::partitioned_vector<T>& xvalues,
×
105
    hpx::partitioned_vector<T>& out)
106
{
107
    test_transform_inclusive_scan_noinit(xvalues, out);
×
108
    HPX_TEST_EQ((out[num - 1]), T(2 * num));
×
109
    test_transform_inclusive_scan_noinit(hpx::execution::seq, xvalues, out);
×
110
    HPX_TEST_EQ((out[num - 1]), T(2 * num));
×
111
    test_transform_inclusive_scan(xvalues, out);
×
112
    HPX_TEST_EQ((out[num - 1]), T(2 * num));
×
113
    test_transform_inclusive_scan(hpx::execution::seq, xvalues, out);
×
114
    HPX_TEST_EQ((out[num - 1]), T(2 * num));
×
115
    test_transform_inclusive_scan(hpx::execution::par, xvalues, out);
×
116
    HPX_TEST_EQ((out[num - 1]), T(2 * num));
×
117
    test_transform_inclusive_scan_async(
×
118
        hpx::execution::seq(hpx::execution::task), xvalues, out);
×
119
    HPX_TEST_EQ((out[num - 1]), T(2 * num));
×
120
    test_transform_inclusive_scan_async(
×
121
        hpx::execution::par(hpx::execution::task), xvalues, out);
×
122
    HPX_TEST_EQ((out[num - 1]), T(2 * num));
×
123

124
    test_transform_exclusive_scan(xvalues, out);
×
125
    HPX_TEST_EQ((out[num - 1]), T(2 * (num - 1)));
×
126
    test_transform_exclusive_scan(hpx::execution::seq, xvalues, out);
×
127
    HPX_TEST_EQ((out[num - 1]), T(2 * (num - 1)));
×
128
    test_transform_exclusive_scan(hpx::execution::par, xvalues, out);
×
129
    HPX_TEST_EQ((out[num - 1]), T(2 * (num - 1)));
×
130
    test_transform_exclusive_scan_async(
×
131
        hpx::execution::seq(hpx::execution::task), xvalues, out);
×
132
    HPX_TEST_EQ((out[num - 1]), T(2 * (num - 1)));
×
133
    test_transform_exclusive_scan_async(
×
134
        hpx::execution::par(hpx::execution::task), xvalues, out);
×
135
    HPX_TEST_EQ((out[num - 1]), T(2 * (num - 1)));
×
136
}
×
137

138
template <typename T>
139
void transform_scan_tests(std::vector<hpx::id_type>& localities)
×
140
{
141
    std::size_t const num = 12;
×
142
    hpx::partitioned_vector<T> xvalues(
×
143
        num, T(1), hpx::container_layout(localities));
×
144
    hpx::partitioned_vector<T> out(num, hpx::container_layout(localities));
×
145
    transform_scan_tests(num, xvalues, out);
×
146
}
×
147

148
///////////////////////////////////////////////////////////////////////////////
149
int main()
×
150
{
151
    std::vector<hpx::id_type> localities = hpx::find_all_localities();
×
152
    transform_scan_tests<double>(localities);
×
153
    return hpx::util::report_errors();
×
154
}
×
155
#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