File: TestTeamReductionScan.hpp

package info (click to toggle)
kokkos 5.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 15,140 kB
  • sloc: cpp: 225,293; sh: 1,250; python: 78; makefile: 16; fortran: 4; ansic: 2
file content (180 lines) | stat: -rw-r--r-- 7,028 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// SPDX-FileCopyrightText: Copyright Contributors to the Kokkos project

#ifndef KOKKOS_TEST_TEAM_REDUCTION_SCAN_HPP
#define KOKKOS_TEST_TEAM_REDUCTION_SCAN_HPP
#include <TestTeam.hpp>

namespace Test {

TEST(TEST_CATEGORY, team_reduction_scan) {
  TestScanTeam<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >(0);
  TestScanTeam<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >(0);
  TestScanTeam<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >(10);
  TestScanTeam<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >(10);
  TestScanTeam<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >(10000);
  TestScanTeam<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >(10000);
}

TEST(TEST_CATEGORY, team_long_reduce) {
#ifdef KOKKOS_ENABLE_OPENMPTARGET  // FIXME_OPENMPTARGET: Not implemented
  if constexpr (!std::is_same<TEST_EXECSPACE,
                              Kokkos::Experimental::OpenMPTarget>::value)
#endif
  {
    TestReduceTeam<long, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >{}
        .run_test(0);
    TestReduceTeam<long, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >{}
        .run_test(0);
    TestReduceTeam<long, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >{}
        .run_test(3);
    TestReduceTeam<long, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >{}
        .run_test(3);
    TestReduceTeam<long, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >{}
        .run_test(100000);
    TestReduceTeam<long, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >{}
        .run_test(100000);
  }
}

TEST(TEST_CATEGORY, team_double_reduce) {
#ifdef KOKKOS_ENABLE_OPENMPTARGET  // FIXME_OPENMPTARGET: Not implemented
  if constexpr (!std::is_same<TEST_EXECSPACE,
                              Kokkos::Experimental::OpenMPTarget>::value)
#endif
  {
    TestReduceTeam<double, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >{}
        .run_test(0);
    TestReduceTeam<double, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >{}
        .run_test(0);
    TestReduceTeam<double, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >{}
        .run_test(3);
    TestReduceTeam<double, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >{}
        .run_test(3);
    TestReduceTeam<double, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >{}
        .run_test(100000);
    TestReduceTeam<double, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >{}
        .run_test(100000);
  }
}

TEST(TEST_CATEGORY, team_long_array_reduce) {
// FIXME_WINDOWS FIXME_32BIT Test is known to fail
#if defined(_WIN32) || defined(KOKKOS_IMPL_32BIT)
  GTEST_SKIP() << "Test known to fail on Windows or in 32-bit builds";
#endif

#ifdef KOKKOS_ENABLE_OPENMPTARGET  // FIXME_OPENMPTARGET: Not implemented
  if constexpr (!std::is_same<TEST_EXECSPACE,
                              Kokkos::Experimental::OpenMPTarget>::value)
#endif
  {
    TestReduceTeam<long, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >{}
        .run_array_test(0);
    TestReduceTeam<long, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >{}
        .run_array_test(0);
    TestReduceTeam<long, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >{}
        .run_array_test(3);
    TestReduceTeam<long, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >{}
        .run_array_test(3);
    TestReduceTeam<long, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >{}
        .run_array_test(100000);
    TestReduceTeam<long, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >{}
        .run_array_test(100000);
  }
}

TEST(TEST_CATEGORY, team_double_array_reduce) {
// FIXME_MSVC FIXME_32BIT Test is known to fail
#if defined(KOKKOS_COMPILER_MSVC) || defined(KOKKOS_IMPL_32BIT)
  GTEST_SKIP() << "Test known to fail on Windows or in 32-bit builds";
#endif

#ifdef KOKKOS_ENABLE_OPENMPTARGET  // FIXME_OPENMPTARGET: Not implemented
  if constexpr (!std::is_same<TEST_EXECSPACE,
                              Kokkos::Experimental::OpenMPTarget>::value)
#endif
  {
    TestReduceTeam<double, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >{}
        .run_array_test(0);
    TestReduceTeam<double, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >{}
        .run_array_test(0);
    TestReduceTeam<double, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >{}
        .run_array_test(3);
    TestReduceTeam<double, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >{}
        .run_array_test(3);
    TestReduceTeam<double, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >{}
        .run_array_test(100000);
    TestReduceTeam<double, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >{}
        .run_array_test(100000);
  }
}

template <typename ExecutionSpace>
struct DummyTeamReductionFunctor {
  using TeamPolicy     = Kokkos::TeamPolicy<ExecutionSpace>;
  using TeamHandleType = typename TeamPolicy::member_type;

  KOKKOS_FUNCTION void operator()(const TeamHandleType&, double&) const {}
};

template <typename ExecutionSpace>
void test_team_parallel_reduce(const int num_loop_size) {
  using TeamPolicy = Kokkos::TeamPolicy<ExecutionSpace>;

  using ReducerType = Kokkos::Sum<double>;
  double result     = 10.;
  ReducerType reducer(result);

  const int bytes_per_team   = 0;
  const int bytes_per_thread = 117;

  TeamPolicy team_exec(num_loop_size, Kokkos::AUTO);
  team_exec.set_scratch_size(1, Kokkos::PerTeam(bytes_per_team),
                             Kokkos::PerThread(bytes_per_thread));

  Kokkos::parallel_reduce(team_exec,
                          DummyTeamReductionFunctor<ExecutionSpace>{}, reducer);
  ASSERT_EQ(result, 0.);
}

TEST(TEST_CATEGORY, team_parallel_dummy_with_reducer_and_scratch_space) {
#ifdef KOKKOS_ENABLE_OPENMPTARGET  // FIXME_OPENMPTARGET: Not implemented
  if constexpr (!std::is_same<TEST_EXECSPACE,
                              Kokkos::Experimental::OpenMPTarget>::value)
#endif
  {
    test_team_parallel_reduce<TEST_EXECSPACE>(0);
    test_team_parallel_reduce<TEST_EXECSPACE>(1);
  }
}

TEST(TEST_CATEGORY, repeated_team_reduce) {
#ifdef KOKKOS_ENABLE_OPENMPTARGET
  if (std::is_same<TEST_EXECSPACE, Kokkos::Experimental::OpenMPTarget>::value)
    GTEST_SKIP() << "skipping since team_reduce for OpenMPTarget is not "
                    "properly implemented";
#endif

#ifdef KOKKOS_IMPL_32BIT
  GTEST_SKIP() << "Failing KOKKOS_IMPL_32BIT";  // FIXME_32BIT
#endif

  TestRepeatedTeamReduce<TEST_EXECSPACE>();
}

TEST(TEST_CATEGORY, nested_team_reduce_functor_as_reducer) {
#ifdef KOKKOS_ENABLE_OPENMPTARGET  // FIXME_OPENMPTARGET: Not implemented
  if (std::is_same<TEST_EXECSPACE, Kokkos::Experimental::OpenMPTarget>::value)
    GTEST_SKIP() << "skipping since team_reduce for OpenMPTarget is not "
                    "properly implemented";
#endif
  {
    TestTeamNestedReducerFunctor<TEST_EXECSPACE>().run_test_team_thread();
    TestTeamNestedReducerFunctor<TEST_EXECSPACE>().run_test_thread_vector();
    TestTeamNestedReducerFunctor<TEST_EXECSPACE>().run_test_team_vector();
  }
}

}  // namespace Test
#endif