• 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

2.86
/libs/full/segmented_algorithms/tests/unit/partitioned_vector_minmax_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)
230✔
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_minmax_element(ExPolicy&& policy, hpx::partitioned_vector<T>& xvalues,
×
42
    Func&& f, T expected_result_min, T expected_result_max)
43
{
44
    auto result =
45
        hpx::minmax_element(policy, xvalues.begin(), xvalues.end(), f);
×
46
    HPX_TEST_EQ(*result.min, expected_result_min);
×
47
    HPX_TEST_EQ(*result.max, expected_result_max);
×
48
}
×
49

50
template <typename ExPolicy, typename T, typename Func>
51
void test_minmax_element_async(ExPolicy&& policy,
×
52
    hpx::partitioned_vector<T>& xvalues, Func&& f, T expected_result_min,
53
    T expected_result_max)
54
{
55
    auto result =
56
        hpx::minmax_element(policy, xvalues.begin(), xvalues.end(), f).get();
×
57
    HPX_TEST_EQ(*result.min, expected_result_min);
×
58
    HPX_TEST_EQ(*result.max, expected_result_max);
×
59
}
×
60

61
template <typename T>
62
void minmax_element_tests(std::vector<hpx::id_type>& localities)
×
63
{
64
    hpx::partitioned_vector<T> xvalues(
×
65
        SIZE, T(0), hpx::container_layout(localities));
×
66
    initialize(xvalues);
×
67

68
    test_minmax_element(
×
69
        hpx::execution::seq, xvalues, std::less<T>(), T(1), T(8));
70
    test_minmax_element(
×
71
        hpx::execution::par, xvalues, std::less<T>(), T(1), T(8));
72
    test_minmax_element_async(hpx::execution::seq(hpx::execution::task),
×
73
        xvalues, std::less<T>(), T(1), T(8));
74
    test_minmax_element_async(hpx::execution::par(hpx::execution::task),
×
75
        xvalues, std::less<T>(), T(1), T(8));
76

77
    test_minmax_element(
×
78
        hpx::execution::seq, xvalues, std::greater<T>(), T(8), T(1));
79
    test_minmax_element(
×
80
        hpx::execution::par, xvalues, std::greater<T>(), T(8), T(1));
81
    test_minmax_element_async(hpx::execution::seq(hpx::execution::task),
×
82
        xvalues, std::greater<T>(), T(8), T(1));
83
    test_minmax_element_async(hpx::execution::par(hpx::execution::task),
×
84
        xvalues, std::greater<T>(), T(8), T(1));
85
}
×
86

87
///////////////////////////////////////////////////////////////////////////////
88
int main()
×
89
{
90
    std::vector<hpx::id_type> localities = hpx::find_all_localities();
×
91
    minmax_element_tests<int>(localities);
×
92
    return hpx::util::report_errors();
×
93
}
×
94
#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