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

Commit 2f47593

Browse files
[SYCL][LIT]Update kernel-functor test (#212)
1 parent c7d3d33 commit 2f47593

File tree

1 file changed

+5
-31
lines changed

1 file changed

+5
-31
lines changed

SYCL/Functor/kernel_functor.cpp

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
// RUN: %CPU_RUN_PLACEHOLDER %t.out
55
// RUN: %GPU_RUN_PLACEHOLDER %t.out
66

7-
//==--- kernel_functor.cpp - Functors as SYCL kernel test ------------------==//
7+
//==--- kernel_functor.cpp -
8+
// This test illustrates defining kernels as named function objects (functors)
89
//
910
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
1011
// See https://llvm.org/LICENSE.txt for license information.
@@ -20,27 +21,6 @@ constexpr auto sycl_read_write = cl::sycl::access::mode::read_write;
2021
constexpr auto sycl_global_buffer = cl::sycl::access::target::global_buffer;
2122

2223
// Case 1:
23-
// - functor class is defined in an anonymous namespace
24-
// - the '()' operator:
25-
// * does not have parameters (to be used in 'single_task').
26-
// * has the 'const' qualifier
27-
namespace {
28-
class Functor1 {
29-
public:
30-
Functor1(
31-
int X_,
32-
cl::sycl::accessor<int, 1, sycl_read_write, sycl_global_buffer> &Acc_)
33-
: X(X_), Acc(Acc_) {}
34-
35-
void operator()() const { Acc[0] += X; }
36-
37-
private:
38-
int X;
39-
cl::sycl::accessor<int, 1, sycl_read_write, sycl_global_buffer> Acc;
40-
};
41-
} // namespace
42-
43-
// Case 2:
4424
// - functor class is defined in a namespace
4525
// - the '()' operator:
4626
// * does not have parameters (to be used in 'single_task').
@@ -62,7 +42,7 @@ class Functor2 {
6242
};
6343
} // namespace ns
6444

65-
// Case 3:
45+
// Case 2:
6646
// - functor class is templated and defined in the translation unit scope
6747
// - the '()' operator:
6848
// * has a parameter of type cl::sycl::id<1> (to be used in 'parallel_for').
@@ -80,7 +60,7 @@ template <typename T> class TmplFunctor {
8060
cl::sycl::accessor<T, 1, sycl_read_write, sycl_global_buffer> Acc;
8161
};
8262

83-
// Case 4:
63+
// Case 3:
8464
// - functor class is templated and defined in the translation unit scope
8565
// - the '()' operator:
8666
// * has a parameter of type cl::sycl::id<1> (to be used in 'parallel_for').
@@ -105,12 +85,6 @@ int foo(int X) {
10585
cl::sycl::queue Q;
10686
cl::sycl::buffer<int, 1> Buf(A, 1);
10787

108-
Q.submit([&](cl::sycl::handler &cgh) {
109-
auto Acc = Buf.get_access<sycl_read_write, sycl_global_buffer>(cgh);
110-
Functor1 F(X, Acc);
111-
112-
cgh.single_task(F);
113-
});
11488
Q.submit([&](cl::sycl::handler &cgh) {
11589
auto Acc = Buf.get_access<sycl_read_write, sycl_global_buffer>(cgh);
11690
ns::Functor2 F(X, Acc);
@@ -169,7 +143,7 @@ template <typename T> T bar(T X) {
169143
int main() {
170144
const int Res1 = foo(10);
171145
const int Res2 = bar(10);
172-
const int Gold1 = 40;
146+
const int Gold1 = 30;
173147
const int Gold2 = 80;
174148

175149
assert(Res1 == Gold1);

0 commit comments

Comments
 (0)