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

STEllAR-GROUP / hpx / #851

16 Dec 2022 12:27PM UTC coverage: 86.568% (+0.2%) from 86.404%
#851

push

StellarBot
Merge #6104

6104: Adding parameters API: measure_iteration r=hkaiser a=hkaiser

- split `get_chunk_size` CP into `measure_iteration` and modified `get_chunk_size`
- introducing a breaking change to `get_chunk_size` and `processing_units_count` customization point, those now expect the time for one iteration

The new APIs are:
```
    template <typename Target, typename F>
    hpx::chrono::steady_duration measure_iteration(
        Target&&, F&&, std::size_t num_tasks);

    template <typename Target>
    std::size_t processing_units_count(
        Target&&, hpx::chrono::steady_duration const&, std::size_t num_tasks);

    template <typename Target>
    std::size_t get_chunk_size(Target&&,
        hpx::chrono::steady_duration const&, std::size_t num_cores,
        std::size_t num_tasks);
```
This also moves all executor parameter objects to `namespace hpx::execution::experimental`. 

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

209 of 209 new or added lines in 34 files covered. (100.0%)

174475 of 201546 relevant lines covered (86.57%)

1888115.1 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_element1.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(int)
202✔
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<int>(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

© 2025 Coveralls, Inc