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

STEllAR-GROUP / hpx / #878

30 Jan 2023 09:52PM UTC coverage: 86.523% (-0.07%) from 86.595%
#878

push

StellarBot
Merge #6159

6159: Fix minor spelling mistake in generate_issue_pr_list.sh r=hkaiser a=gonidelis



Co-authored-by: gonidelis <gonidelis@hotmail.com>

174750 of 201970 relevant lines covered (86.52%)

1855193.81 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_transform_reduce_binary1.cpp
1
//  Copyright (c) 2014-2017 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
#if !defined(HPX_COMPUTE_DEVICE_CODE)
9
#include <hpx/hpx_main.hpp>
10
#include <hpx/include/parallel_for_each.hpp>
11
#include <hpx/include/parallel_transform_reduce.hpp>
12
#include <hpx/include/partitioned_vector_predef.hpp>
13
#include <hpx/include/runtime.hpp>
14
#include <hpx/modules/testing.hpp>
15
#include <hpx/parallel/segmented_algorithms/traits/zip_iterator.hpp>
16
#include <hpx/parallel/util/zip_iterator.hpp>
17

18
#include <cstddef>
19
#include <iterator>
20
#include <type_traits>
21
#include <vector>
22

23
///////////////////////////////////////////////////////////////////////////////
24
struct multiply
25
{
26
    template <typename T>
27
    typename std::decay<T>::type operator()(hpx::tuple<T, T> const& r) const
28
    {
29
        using hpx::get;
30
        return get<0>(r) * get<1>(r);
31
    }
32
};
33

34
///////////////////////////////////////////////////////////////////////////////
35
template <typename ExPolicy, typename T>
36
T test_transform_reduce_binary(ExPolicy&& policy,
×
37
    hpx::partitioned_vector<T> const& xvalues,
38
    hpx::partitioned_vector<T> const& yvalues)
39
{
40
    return hpx::transform_reduce(policy, xvalues.begin(), xvalues.end(),
×
41
        yvalues.begin(), T(1), std::plus<T>(), std::multiplies<T>());
×
42
}
43

44
template <typename ExPolicy, typename T>
45
hpx::future<T> test_transform_reduce_binary_async(ExPolicy&& policy,
×
46
    hpx::partitioned_vector<T>& xvalues, hpx::partitioned_vector<T>& yvalues)
47
{
48
    return hpx::transform_reduce(policy, xvalues.begin(), xvalues.end(),
×
49
        yvalues.begin(), T(1), std::plus<T>(), std::multiplies<T>());
×
50
}
51

52
template <typename T>
53
void transform_reduce_binary_tests(std::size_t num,
×
54
    hpx::partitioned_vector<T>& xvalues, hpx::partitioned_vector<T>& yvalues)
55
{
56
    HPX_TEST_EQ(
×
57
        test_transform_reduce_binary(hpx::execution::seq, xvalues, yvalues),
58
        T(num + 1));
59
    HPX_TEST_EQ(
×
60
        test_transform_reduce_binary(hpx::execution::par, xvalues, yvalues),
61
        T(num + 1));
62

63
    HPX_TEST_EQ(test_transform_reduce_binary_async(
×
64
                    hpx::execution::seq(hpx::execution::task), xvalues, yvalues)
65
                    .get(),
66
        T(num + 1));
67
    HPX_TEST_EQ(test_transform_reduce_binary_async(
×
68
                    hpx::execution::par(hpx::execution::task), xvalues, yvalues)
69
                    .get(),
70
        T(num + 1));
71
}
×
72

73
template <typename T>
74
void transform_reduce_binary_tests(std::vector<hpx::id_type>& localities)
×
75
{
76
    std::size_t const num = 10007;
×
77
    {
78
        hpx::partitioned_vector<T> xvalues(num, T(1));
×
79
        hpx::partitioned_vector<T> yvalues(num, T(1));
×
80
        transform_reduce_binary_tests(num, xvalues, yvalues);
×
81
    }
×
82

83
    {
84
        hpx::partitioned_vector<T> xvalues(
×
85
            num, T(1), hpx::container_layout(localities));
×
86
        hpx::partitioned_vector<T> yvalues(
×
87
            num, T(1), hpx::container_layout(localities));
×
88
        transform_reduce_binary_tests(num, xvalues, yvalues);
×
89
    }
×
90
}
×
91

92
///////////////////////////////////////////////////////////////////////////////
93
int main()
×
94
{
95
    std::vector<hpx::id_type> localities = hpx::find_all_localities();
×
96
    transform_reduce_binary_tests<int>(localities);
×
97
    return hpx::util::report_errors();
×
98
}
×
99
#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