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

STEllAR-GROUP / hpx / #850

15 Dec 2022 03:00PM UTC coverage: 86.404% (+0.7%) from 85.715%
#850

push

StellarBot
Merge #6098

6098: Forking Boost.Lockfree r=hkaiser a=hkaiser

Working towards #3440 

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

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

174060 of 201449 relevant lines covered (86.4%)

1882623.65 hits per line

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

3.03
/libs/full/segmented_algorithms/tests/unit/partitioned_vector_min_element2.cpp
1
//  Copyright (c) 2017 Ajai V George
2
//  Copyright (c) 2020 Akhil J Nair
3
//
4
//  SPDX-License-Identifier: BSL-1.0
5
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
6
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7

8
#include <hpx/config.hpp>
9
#include <hpx/runtime.hpp>
10
#if !defined(HPX_COMPUTE_DEVICE_CODE)
11
#include <hpx/hpx_main.hpp>
12
#include <hpx/include/parallel_minmax.hpp>
13
#include <hpx/include/partitioned_vector.hpp>
14

15
#include <hpx/modules/testing.hpp>
16

17
#include <cstddef>
18
#include <iostream>
19
#include <vector>
20

21
///////////////////////////////////////////////////////////////////////////////
22
// Define the vector types to be used.
23
HPX_REGISTER_PARTITIONED_VECTOR(double)
207✔
24

25
///////////////////////////////////////////////////////////////////////////////
26
#define SIZE 64
27

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

40
template <typename ExPolicy, typename T, typename Func>
41
void test_min_element(ExPolicy&& policy, hpx::partitioned_vector<T>& xvalues,
×
42
    Func&& f, T expected_result)
43
{
44
    auto result = hpx::min_element(policy, xvalues.begin(), xvalues.end(), f);
×
45
    HPX_TEST_EQ(*result, expected_result);
×
46
}
×
47

48
template <typename ExPolicy, typename T, typename Func>
49
void test_min_element_async(ExPolicy&& policy,
×
50
    hpx::partitioned_vector<T>& xvalues, Func&& f, T expected_result)
51
{
52
    auto result =
53
        hpx::min_element(policy, xvalues.begin(), xvalues.end(), f).get();
×
54
    HPX_TEST_EQ(*result, expected_result);
×
55
}
×
56

57
template <typename T>
58
void min_element_tests(std::vector<hpx::id_type>& localities)
×
59
{
60
    hpx::partitioned_vector<T> xvalues(
×
61
        SIZE, T(0), hpx::container_layout(localities));
×
62
    initialize(xvalues);
×
63

64
    test_min_element(hpx::execution::seq, xvalues, std::less<T>(), T(1));
×
65
    test_min_element(hpx::execution::par, xvalues, std::less<T>(), T(1));
×
66
    test_min_element_async(hpx::execution::seq(hpx::execution::task), xvalues,
×
67
        std::less<T>(), T(1));
68
    test_min_element_async(hpx::execution::par(hpx::execution::task), xvalues,
×
69
        std::less<T>(), T(1));
70

71
    test_min_element(hpx::execution::seq, xvalues, std::greater<T>(), T(8));
×
72
    test_min_element(hpx::execution::par, xvalues, std::greater<T>(), T(8));
×
73
    test_min_element_async(hpx::execution::seq(hpx::execution::task), xvalues,
×
74
        std::greater<T>(), T(8));
75
    test_min_element_async(hpx::execution::par(hpx::execution::task), xvalues,
×
76
        std::greater<T>(), T(8));
77
}
×
78

79
///////////////////////////////////////////////////////////////////////////////
80
int main()
×
81
{
82
    std::vector<hpx::id_type> localities = hpx::find_all_localities();
×
83
    min_element_tests<double>(localities);
×
84
    return hpx::util::report_errors();
×
85
}
×
86
#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