forked from intel/llvm-test-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreduction_range_1d_s0_dw.cpp
More file actions
56 lines (46 loc) · 2.26 KB
/
Copy pathreduction_range_1d_s0_dw.cpp
File metadata and controls
56 lines (46 loc) · 2.26 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
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// 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<1>, reduction, func)
// with reductions initialized with 0-dimensional discard_write accessor
// accessing 1 element buffer.
#include "reduction_range_scalar.hpp"
using namespace cl::sycl;
template <typename Name, typename T, class BinaryOperation>
void tests(queue &Q, T Identity, T Init, BinaryOperation BOp, size_t NWItems) {
constexpr access::mode DW = access::mode::discard_write;
test<Name, false, DW, T, 0>(Q, Identity, Init, BOp, range<1>{NWItems});
}
int main() {
queue Q;
printDeviceInfo(Q);
size_t MaxWGSize =
Q.get_device().get_info<info::device::max_work_group_size>();
// Fast-reduce and Fast-atomics. Try various range types/sizes.
tests<class A1, int>(Q, 0, 99, std::plus<>{}, 1);
tests<class A2, int>(Q, 0, 99, std::plus<>{}, 2);
tests<class A3, int64_t>(Q, 0, 99, std::plus<>{}, 7);
tests<class A4, int64_t>(Q, 0, 99, std::plus<>{}, 64);
tests<class A5, int>(Q, 0, 99, std::plus<>{}, MaxWGSize * 2);
tests<class A6, int>(Q, 0, 99, std::plus<>{}, MaxWGSize * 2 + 5);
// Try various types & ranges.
tests<class B1, int>(Q, ~0, ~0, std::bit_and<>{}, 8);
tests<class B2, int>(Q, 0, 0x12340000, std::bit_xor<>{}, 16);
tests<class B3, int>(Q, 0, 0x3400, std::bit_or<>{}, MaxWGSize * 4);
tests<class B4, int>(Q, 1, 2, std::multiplies<>{}, 256);
tests<class B5, int>(Q, 1, 3, std::multiplies<>{}, MaxWGSize + 1);
tests<class B6, int>(Q, (std::numeric_limits<int>::max)(), -99,
ext::oneapi::minimum<>{}, MaxWGSize * 2);
tests<class B7, int>(Q, (std::numeric_limits<int>::min)(), 99,
ext::oneapi::maximum<>{}, 8);
tests<class B8, uint64_t>(Q, 1, 99, std::multiplies<>{}, 37);
// Check with CUSTOM type.
using CV = CustomVec<long long>;
tests<class C1>(Q, CV(0), CV(99), CustomVecPlus<long long>{}, 64);
tests<class C2>(Q, CV(0), CV(99), CustomVecPlus<long long>{}, MaxWGSize * 3);
std::cout << "Test passed\n";
return 0;
}