forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreduction_range_3d_rw.cpp
More file actions
107 lines (88 loc) · 4.91 KB
/
reduction_range_3d_rw.cpp
File metadata and controls
107 lines (88 loc) · 4.91 KB
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
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out -Xsycl-target-backend=nvptx64-nvidia-cuda --cuda-gpu-arch=sm_60
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// TODO: accelerator may not suport atomics required by the current
// implementation. Enable testing when implementation is fixed.
// RUNx: %ACC_RUN_PLACEHOLDER %t.out
// This test performs basic checks of parallel_for(range<3>, reduction, func)
// with reductions initialized with a one element buffer.
#include "reduction_utils.hpp"
using namespace sycl;
int NumErrors = 0;
template <typename Name, typename T, typename... ArgTys>
void tests(ArgTys &&...Args) {
NumErrors += test<Name, T>(std::forward<ArgTys>(Args)...);
}
int main() {
queue Q;
printDeviceInfo(Q);
size_t MaxWGSize =
Q.get_device().get_info<info::device::max_work_group_size>();
tests<class A1, int>(Q, 0, 99, std::plus<>{}, range<3>{1, 1, 1});
tests<class A2, int>(Q, 0, 99, std::plus<>{}, range<3>{2, 2, 2});
tests<class A3, int>(Q, 0, 99, std::plus<>{}, range<3>{2, 3, 4});
tests<class A4, int64_t>(Q, 0, 99, std::plus<>{},
range<3>{1, 1, MaxWGSize + 1});
tests<class A5, int64_t>(Q, 0, 99, std::plus<>{},
range<3>{1, MaxWGSize + 1, 1});
tests<class A6, int64_t>(Q, 0, 99, std::plus<>{},
range<3>{MaxWGSize + 1, 1, 1});
tests<class A7, int64_t>(Q, 0, 99, std::plus<>{},
range<3>{2, 5, MaxWGSize * 2});
tests<class A8, int64_t>(Q, 0, 99, std::plus<>{},
range<3>{3, MaxWGSize * 3, 2});
tests<class A9, int64_t>(Q, 0, 99, std::plus<>{},
range<3>{MaxWGSize * 3, 8, 4});
tests<class B1, int>(Q, 0, 0x2021ff99, std::bit_xor<>{},
range<3>{2, MaxWGSize * 3, 3});
tests<class B2, int>(Q, ~0, 99, std::bit_and<>{},
range<3>{MaxWGSize * 3, 4, 3});
tests<class B3, int>(Q, 0, 99, std::bit_or<>{},
range<3>{2, 2, MaxWGSize * 3});
tests<class B4, uint64_t>(Q, 1, 3, std::multiplies<>{}, range<3>{2, 3, 5});
tests<class B5, uint64_t>(Q, 1, 3, std::multiplies<>{}, range<3>{5, 2, 3});
tests<class B6, int>(Q, (std::numeric_limits<int>::max)(), -99,
ext::oneapi::minimum<>{}, range<3>{MaxWGSize, 8, 3});
tests<class B7, int>(Q, (std::numeric_limits<int>::min)(), 99,
ext::oneapi::maximum<>{}, range<3>{3, MaxWGSize, 3});
tests<class B8, float>(Q, 1, 99, std::multiplies<>{}, range<3>{3, 3, 4});
tests<class C1, CustomVec<long long>>(Q, 0, 99, CustomVecPlus<long long>{},
range<3>{2, 33, MaxWGSize});
tests<class C2, CustomVec<long long>>(Q, 99, CustomVecPlus<long long>{},
range<3>{2, 33, MaxWGSize});
tests<class D1, int>(Q, 99, PlusWithoutIdentity<int>{}, range<3>{1, 1, 1});
tests<class D2, int>(Q, 99, PlusWithoutIdentity<int>{}, range<3>{2, 2, 2});
tests<class D3, int>(Q, 99, PlusWithoutIdentity<int>{}, range<3>{2, 3, 4});
tests<class D4, int64_t>(Q, 99, PlusWithoutIdentity<int64_t>{},
range<3>{1, 1, MaxWGSize + 1});
tests<class D5, int64_t>(Q, 99, PlusWithoutIdentity<int64_t>{},
range<3>{1, MaxWGSize + 1, 1});
tests<class D6, int64_t>(Q, 99, PlusWithoutIdentity<int64_t>{},
range<3>{MaxWGSize + 1, 1, 1});
tests<class D7, int64_t>(Q, 99, PlusWithoutIdentity<int64_t>{},
range<3>{2, 5, MaxWGSize * 2});
tests<class D8, int64_t>(Q, 99, PlusWithoutIdentity<int64_t>{},
range<3>{3, MaxWGSize * 3, 2});
tests<class D9, int64_t>(Q, 99, PlusWithoutIdentity<int64_t>{},
range<3>{MaxWGSize * 3, 8, 4});
tests<class E1, int>(Q, 99, MultipliesWithoutIdentity<int>{},
range<3>{1, 1, 1});
tests<class E2, int>(Q, 99, MultipliesWithoutIdentity<int>{},
range<3>{2, 2, 2});
tests<class E3, int>(Q, 99, MultipliesWithoutIdentity<int>{},
range<3>{2, 3, 4});
tests<class E4, int64_t>(Q, 99, MultipliesWithoutIdentity<int64_t>{},
range<3>{1, 1, MaxWGSize + 1});
tests<class E5, int64_t>(Q, 99, MultipliesWithoutIdentity<int64_t>{},
range<3>{1, MaxWGSize + 1, 1});
tests<class E6, int64_t>(Q, 99, MultipliesWithoutIdentity<int64_t>{},
range<3>{MaxWGSize + 1, 1, 1});
tests<class E7, int64_t>(Q, 99, MultipliesWithoutIdentity<int64_t>{},
range<3>{2, 5, MaxWGSize * 2});
tests<class E8, int64_t>(Q, 99, MultipliesWithoutIdentity<int64_t>{},
range<3>{3, MaxWGSize * 3, 2});
tests<class E9, int64_t>(Q, 99, MultipliesWithoutIdentity<int64_t>{},
range<3>{MaxWGSize * 3, 8, 4});
printFinalStatus(NumErrors);
return NumErrors;
}