Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit c938a3d

Browse files
committed
[SYCL] Add test cases for muptiplies,bit_or,bit_xor,bit_and subgroup algorithms
These new test cases verify intel/llvm#3267 Signed-off-by: Vyacheslav N Klochkov <[email protected]>
1 parent 0873f91 commit c938a3d

File tree

4 files changed

+157
-4
lines changed

4 files changed

+157
-4
lines changed

SYCL/SubGroup/reduce.hpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void check(queue &Queue, size_t G = 256, size_t L = 64) {
8888
check_op<sycl_subgr<SpecializationKernelName, class KernelName_bPPlfvdGShi>,
8989
T>(Queue, T(0), ONEAPI::maximum<T>(), true, G, L);
9090

91-
#if __cplusplus >= 201402L
91+
// Transparent operator functors.
9292
check_op<sycl_subgr<SpecializationKernelName,
9393
class KernelName_fkOyLRYirfMnvBcnbRFy>,
9494
T>(Queue, T(L), ONEAPI::plus<>(), false, G, L);
@@ -107,5 +107,17 @@ void check(queue &Queue, size_t G = 256, size_t L = 64) {
107107
check_op<
108108
sycl_subgr<SpecializationKernelName, class KernelName_BaCGaWDMFeMFqvotbk>,
109109
T>(Queue, T(0), ONEAPI::maximum<>(), true, G, L);
110-
#endif
110+
111+
// Use small sub-groups to avoid overflow effects for int multiply operations
112+
// and avoid rounding issues for FP multiply.
113+
L = 4;
114+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_MulF>, T>(
115+
Queue, T(G), ONEAPI::multiplies<T>(), false, G, L);
116+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_MulT>, T>(
117+
Queue, T(1), ONEAPI::multiplies<T>(), true, G, L);
118+
119+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_MulFV>, T>(
120+
Queue, T(G), ONEAPI::multiplies<>(), false, G, L);
121+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_MulTV>, T>(
122+
Queue, T(1), ONEAPI::multiplies<>(), true, G, L);
111123
}

SYCL/SubGroup/reduce_bit_ops.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// UNSUPPORTED: cpu
2+
// #2252 Disable until all variants of built-ins are available in OpenCL CPU
3+
// runtime for every supported ISA
4+
//
5+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
6+
// RUN: %HOST_RUN_PLACEHOLDER %t.out
7+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
8+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
9+
// RUN: %ACC_RUN_PLACEHOLDER %t.out
10+
11+
// This test verifies correct handling of reduce() algorithm used with
12+
// integer bitwise OR, XOR, AND operations.
13+
14+
#include "reduce.hpp"
15+
16+
template <typename SpecializationKernelName, typename T>
17+
void check_bit_ops(queue &Queue, size_t G = 256, size_t L = 4) {
18+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_ORF>, T>(
19+
Queue, T(G), ONEAPI::bit_or<T>(), false, G, L);
20+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_ORT>, T>(
21+
Queue, T(0), ONEAPI::bit_or<T>(), true, G, L);
22+
23+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_XORF>, T>(
24+
Queue, T(G), ONEAPI::bit_xor<T>(), false, G, L);
25+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_XORT>, T>(
26+
Queue, T(0), ONEAPI::bit_xor<T>(), true, G, L);
27+
28+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_ANDF>, T>(
29+
Queue, T(G), ONEAPI::bit_and<T>(), false, G, L);
30+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_ANDT>, T>(
31+
Queue, ~T(0), ONEAPI::bit_and<T>(), true, G, L);
32+
33+
// Transparent operator functors
34+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_ORFV>, T>(
35+
Queue, T(G), ONEAPI::bit_or<T>(), false, G, L);
36+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_ORTV>, T>(
37+
Queue, T(0), ONEAPI::bit_or<T>(), true, G, L);
38+
39+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_XORFV>, T>(
40+
Queue, T(G), ONEAPI::bit_xor<T>(), false, G, L);
41+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_XORTV>, T>(
42+
Queue, T(0), ONEAPI::bit_xor<T>(), true, G, L);
43+
44+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_ANDFV>, T>(
45+
Queue, T(G), ONEAPI::bit_and<T>(), false, G, L);
46+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_ANDTV>, T>(
47+
Queue, ~T(0), ONEAPI::bit_and<T>(), true, G, L);
48+
}
49+
50+
int main() {
51+
queue Queue;
52+
if (!core_sg_supported(Queue.get_device())) {
53+
std::cout << "Skipping test\n";
54+
return 0;
55+
}
56+
check_bit_ops<class A, int>(Queue);
57+
check_bit_ops<class B, unsigned int>(Queue);
58+
check_bit_ops<class C, unsigned>(Queue);
59+
check_bit_ops<class D, long>(Queue);
60+
check_bit_ops<class E, unsigned long>(Queue);
61+
check_bit_ops<class F, long long>(Queue);
62+
check_bit_ops<class G, unsigned long long>(Queue);
63+
return 0;
64+
}

SYCL/SubGroup/scan.hpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void check(queue &Queue, size_t G = 256, size_t L = 64) {
115115
Queue, std::numeric_limits<T>::min(), ONEAPI::maximum<T>(), true, G, L);
116116
}
117117

118-
#if __cplusplus >= 201402L
118+
// Transparent operator functors.
119119
check_op<sycl_subgr<SpecializationKernelName, class KernelName_TPWS>, T>(
120120
Queue, T(L), ONEAPI::plus<>(), false, G, L);
121121
check_op<sycl_subgr<SpecializationKernelName, class KernelName_hWZv>, T>(
@@ -150,5 +150,17 @@ void check(queue &Queue, size_t G = 256, size_t L = 64) {
150150
T>(Queue, std::numeric_limits<T>::min(), ONEAPI::maximum<>(), true, G,
151151
L);
152152
}
153-
#endif
153+
154+
// Use small sub-groups to avoid overflow effects for int multiply operations
155+
// and avoid rounding issues for FP multiply.
156+
L = 4;
157+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_MulF>, T>(
158+
Queue, T(L), ONEAPI::multiplies<T>(), false, G, L);
159+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_MulT>, T>(
160+
Queue, T(1), ONEAPI::multiplies<>(), true, G, L);
161+
162+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_MulFV>, T>(
163+
Queue, T(L), ONEAPI::multiplies<T>(), false, G, L);
164+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_MulTV>, T>(
165+
Queue, T(1), ONEAPI::multiplies<>(), true, G, L);
154166
}

SYCL/SubGroup/scan_bit_ops.cpp

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// UNSUPPORTED: cpu
2+
// #2252 Disable until all variants of built-ins are available in OpenCL CPU
3+
// runtime for every supported ISA
4+
//
5+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
6+
// RUN: %HOST_RUN_PLACEHOLDER %t.out
7+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
8+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
9+
// RUN: %ACC_RUN_PLACEHOLDER %t.out
10+
11+
// This test verifies correct handling of exclusive_scan and inclusive_scan
12+
// sub-group algorithm used with integer bitwise OR, XOR, AND operations.
13+
14+
#include "scan.hpp"
15+
16+
template <typename SpecializationKernelName, typename T>
17+
void check_bit_ops(queue &Queue, size_t G = 256, size_t L = 4) {
18+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_ORF>, T>(
19+
Queue, T(L), ONEAPI::bit_or<T>(), false, G, L);
20+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_ORT>, T>(
21+
Queue, T(0), ONEAPI::bit_or<T>(), true, G, L);
22+
23+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_XORF>, T>(
24+
Queue, T(L), ONEAPI::bit_xor<T>(), false, G, L);
25+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_XORT>, T>(
26+
Queue, T(0), ONEAPI::bit_xor<T>(), true, G, L);
27+
28+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_ANDF>, T>(
29+
Queue, T(L), ONEAPI::bit_and<T>(), false, G, L);
30+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_ANDT>, T>(
31+
Queue, ~T(0), ONEAPI::bit_and<T>(), true, G, L);
32+
33+
// Transparent operator functors.
34+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_ORFV>, T>(
35+
Queue, T(L), ONEAPI::bit_or<>(), false, G, L);
36+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_ORTV>, T>(
37+
Queue, T(0), ONEAPI::bit_or<>(), true, G, L);
38+
39+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_XORFV>, T>(
40+
Queue, T(L), ONEAPI::bit_xor<>(), false, G, L);
41+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_XORTV>, T>(
42+
Queue, T(0), ONEAPI::bit_xor<>(), true, G, L);
43+
44+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_ANDFV>, T>(
45+
Queue, T(L), ONEAPI::bit_and<>(), false, G, L);
46+
check_op<sycl_subgr<SpecializationKernelName, class KernelName_ANDTV>, T>(
47+
Queue, ~T(0), ONEAPI::bit_and<>(), true, G, L);
48+
}
49+
50+
int main() {
51+
queue Queue;
52+
if (!core_sg_supported(Queue.get_device())) {
53+
std::cout << "Skipping test\n";
54+
return 0;
55+
}
56+
check_bit_ops<class A, int>(Queue);
57+
check_bit_ops<class B, unsigned int>(Queue);
58+
check_bit_ops<class C, unsigned>(Queue);
59+
check_bit_ops<class D, long>(Queue);
60+
check_bit_ops<class E, unsigned long>(Queue);
61+
check_bit_ops<class F, long long>(Queue);
62+
check_bit_ops<class G, unsigned long long>(Queue);
63+
std::cout << "Test passed." << std::endl;
64+
return 0;
65+
}

0 commit comments

Comments
 (0)