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

STEllAR-GROUP / hpx / #865

13 Jan 2023 11:46PM UTC coverage: 86.431% (+0.08%) from 86.354%
#865

push

StellarBot
Merge #6132

6132: Fixing to_non_par() for parallel simd policies r=hkaiser a=hkaiser



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

64 of 64 new or added lines in 3 files covered. (100.0%)

174506 of 201901 relevant lines covered (86.43%)

1999640.87 hits per line

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

0.0
/libs/full/segmented_algorithms/tests/unit/partitioned_vector_reduce.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_reduce.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
// The vector types to be used are defined in partitioned_vector module.
20
// HPX_REGISTER_PARTITIONED_VECTOR(double)
21
// HPX_REGISTER_PARTITIONED_VECTOR(int)
22

23
///////////////////////////////////////////////////////////////////////////////
24
template <typename ExPolicy, typename T>
25
T test_reduce(ExPolicy&& policy, hpx::partitioned_vector<T> const& xvalues)
×
26
{
27
    return hpx::reduce(
×
28
        policy, xvalues.begin(), xvalues.end(), T(1), std::plus<T>());
×
29
}
30

31
template <typename ExPolicy, typename T>
32
hpx::future<T> test_reduce_async(
×
33
    ExPolicy&& policy, hpx::partitioned_vector<T> const& xvalues)
34
{
35
    return hpx::reduce(
×
36
        policy, xvalues.begin(), xvalues.end(), T(1), std::plus<T>());
×
37
}
38

39
template <typename T>
40
void reduce_tests(std::size_t num, hpx::partitioned_vector<T> const& xvalues)
×
41
{
42
    HPX_TEST_EQ(test_reduce(hpx::execution::seq, xvalues), T(num + 1));
×
43
    HPX_TEST_EQ(test_reduce(hpx::execution::par, xvalues), T(num + 1));
×
44

45
    HPX_TEST_EQ(
×
46
        test_reduce_async(hpx::execution::seq(hpx::execution::task), xvalues)
47
            .get(),
48
        T(num + 1));
49
    HPX_TEST_EQ(
×
50
        test_reduce_async(hpx::execution::par(hpx::execution::task), xvalues)
51
            .get(),
52
        T(num + 1));
53
}
×
54

55
template <typename T>
56
void reduce_tests(std::vector<hpx::id_type>& localities)
×
57
{
58
    std::size_t const num = 10007;
×
59
    hpx::partitioned_vector<T> xvalues(
×
60
        num, T(1), hpx::container_layout(localities));
×
61
    reduce_tests(num, xvalues);
×
62
}
×
63

64
///////////////////////////////////////////////////////////////////////////////
65
int main()
×
66
{
67
    std::vector<hpx::id_type> localities = hpx::find_all_localities();
×
68
    reduce_tests<int>(localities);
×
69
    reduce_tests<double>(localities);
×
70
    return hpx::util::report_errors();
×
71
}
×
72
#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