Skip to content

Commit e539c8c

Browse files
committed
[SYCL] Revise cache_config.cpp
Signed-off-by: Hu, Peisen <[email protected]>
1 parent a128213 commit e539c8c

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

sycl/test-e2e/Properties/cache_config.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// REQUIRES: gpu, level_zero
22

3-
// TODO: Currently using the -Wno-deprecated-declarations flag due to issue
4-
// https://github.com/intel/llvm/issues/16320. Remove the flag once the issue is
5-
// resolved.
6-
// RUN: %{build} -o %t.out -Wno-deprecated-declarations
3+
// RUN: %{build} -o %t.out
74
// RUN: env UR_L0_DEBUG=1 %{run} %t.out 2>&1 | FileCheck %s
85

96
#include <numeric>
@@ -16,34 +13,39 @@ using namespace sycl::ext::intel::experimental;
1613
using namespace sycl::ext::oneapi::experimental;
1714

1815
struct KernelFunctor {
19-
20-
KernelFunctor() {}
21-
2216
void operator()() const {}
2317
auto get(properties_tag) const { return properties{cache_config(large_slm)}; }
2418
};
2519

2620
struct KernelFunctorND {
27-
28-
KernelFunctorND() {}
29-
3021
void operator()(nd_item<2> i) const {}
3122
auto get(properties_tag) const { return properties{cache_config(large_slm)}; }
3223
};
3324

3425
struct NegativeKernelFunctor {
35-
36-
NegativeKernelFunctor() {}
37-
3826
void operator()(nd_item<2> i) const {}
3927
auto get(properties_tag) const { return properties{}; }
4028
};
4129

4230
struct RangeKernelFunctor {
31+
void operator()(id<2> i) const {}
32+
auto get(properties_tag) const { return properties{cache_config(large_slm)}; }
33+
};
34+
35+
struct WorkGroupFunctor {
36+
void operator()(group<1> g) const {
37+
g.parallel_for_work_item([&](h_item<1>) {});
38+
}
39+
auto get(properties_tag) const { return properties{cache_config(large_slm)}; }
40+
};
4341

44-
RangeKernelFunctor() {}
42+
template <typename T1> struct ReductionKernelFunctor {
43+
T1 mInput_values;
44+
ReductionKernelFunctor(T1 &Input_values) : mInput_values(Input_values) {}
4545

46-
void operator()(id<2> i) const {}
46+
template <typename sumT> void operator()(id<1> idx, sumT &sum) const {
47+
sum += mInput_values[idx];
48+
}
4749
auto get(properties_tag) const { return properties{cache_config(large_slm)}; }
4850
};
4951

@@ -63,18 +65,16 @@ int main() {
6365
// CHECK: zeKernelSetCacheConfig
6466
std::cout << "parallel_for_work_group(range, func)" << std::endl;
6567
q.submit([&](handler &cgh) {
66-
cgh.parallel_for_work_group<class hpar_range>(
67-
range<1>(8), properties,
68-
[=](group<1> g) { g.parallel_for_work_item([&](h_item<1> i) {}); });
68+
cgh.parallel_for_work_group<class hpar_range>(range<1>(8),
69+
WorkGroupFunctor{});
6970
});
7071

7172
// CHECK: parallel_for_work_group(range, range, func)
7273
// CHECK: zeKernelSetCacheConfig
7374
std::cout << "parallel_for_work_group(range, range, func)" << std::endl;
7475
q.submit([&](handler &cgh) {
7576
cgh.parallel_for_work_group<class hpar_range_range>(
76-
range<1>(8), range<1>(4), properties,
77-
[=](group<1> g) { g.parallel_for_work_item([&](h_item<1> i) {}); });
77+
range<1>(8), range<1>(4), WorkGroupFunctor{});
7878
});
7979

8080
buffer<int> values_buf{1024};
@@ -92,8 +92,8 @@ int main() {
9292
q.submit([&](handler &cgh) {
9393
auto input_values = values_buf.get_access<access_mode::read>(cgh);
9494
auto sum_reduction = reduction(sum_buf, cgh, plus<>());
95-
cgh.parallel_for(range<1>{1024}, properties, sum_reduction,
96-
[=](id<1> idx, auto &sum) { sum += input_values[idx]; });
95+
cgh.parallel_for(range<1>{1024}, sum_reduction,
96+
ReductionKernelFunctor(input_values));
9797
});
9898

9999
// CHECK: KernelFunctor single_task
@@ -111,7 +111,7 @@ int main() {
111111
// CHECK-NOT: zeKernelSetCacheConfig
112112
std::cout << "negative parallel_for with sycl::nd_range" << std::endl;
113113
q.parallel_for(nd_range<2>{range<2>(4, 4), range<2>(2, 2)},
114-
[=](nd_item<2> i) {})
114+
NegativeKernelFunctor{})
115115
.wait();
116116

117117
// CHECK: negative parallel_for with KernelFunctor

0 commit comments

Comments
 (0)