Skip to content

Commit fa46cbe

Browse files
authored
[SYCL][E2E] Rewrite Tests Containing Deprecated Overloads #2 (#16386)
The overloads for single_task and parallel_for in the sycl_ext_oneapi_kernel_properties extension are being deprecated as mentioned in #14785. So I'm rewriting tests containg such overloads so that they can still run after the deprecation. --------- Signed-off-by: Hu, Peisen <peisen.hu@intel.com>
1 parent d4e3e45 commit fa46cbe

13 files changed

+265
-255
lines changed

sycl/test-e2e/Basic/max_linear_work_group_size_props.cpp

+9-19
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,15 @@ template <size_t I> struct KernelFunctorWithMaxWGSizeProp {
5858
}
5959
};
6060

61-
template <Variant KernelVariant, size_t I, typename PropertiesT,
62-
typename KernelType>
63-
int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
61+
template <Variant KernelVariant, size_t I, typename KernelType>
62+
int test(queue &Q, KernelType KernelFunc) {
6463
constexpr size_t Dims = 1;
6564

6665
// Positive test case: Specify local size that matches required size.
6766
try {
6867
Q.submit([&](handler &CGH) {
6968
CGH.parallel_for<MaxLinearWGSizePositive<KernelVariant, false, I>>(
70-
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(I)), Props,
71-
KernelFunc);
69+
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(I)), KernelFunc);
7270
});
7371
Q.wait_and_throw();
7472
} catch (exception &E) {
@@ -81,8 +79,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
8179
// Same as above but using the queue shortcuts.
8280
try {
8381
Q.parallel_for<MaxLinearWGSizePositive<KernelVariant, true, I>>(
84-
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(I)), Props,
85-
KernelFunc);
82+
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(I)), KernelFunc);
8683
Q.wait_and_throw();
8784
} catch (exception &E) {
8885
std::cerr
@@ -97,7 +94,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
9794
try {
9895
Q.submit([&](handler &CGH) {
9996
CGH.parallel_for<MaxLinearWGSizeNoLocalPositive<KernelVariant, false, I>>(
100-
repeatRange<Dims>(16), Props, KernelFunc);
97+
repeatRange<Dims>(16), KernelFunc);
10198
});
10299
Q.wait_and_throw();
103100
} catch (exception &E) {
@@ -109,7 +106,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
109106

110107
try {
111108
Q.parallel_for<MaxLinearWGSizeNoLocalPositive<KernelVariant, true, I>>(
112-
repeatRange<Dims>(16), Props, KernelFunc);
109+
repeatRange<Dims>(16), KernelFunc);
113110
Q.wait_and_throw();
114111
} catch (exception &E) {
115112
std::cerr << "Test case MaxLinearWGSizeNoLocalPositive shortcut failed: "
@@ -122,7 +119,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
122119
try {
123120
Q.submit([&](handler &CGH) {
124121
CGH.parallel_for<MaxLinearWGSizeNegative<KernelVariant, false, I>>(
125-
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)), Props,
122+
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)),
126123
KernelFunc);
127124
});
128125
Q.wait_and_throw();
@@ -147,7 +144,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
147144
// Same as above but using the queue shortcuts.
148145
try {
149146
Q.parallel_for<MaxLinearWGSizeNegative<KernelVariant, true, I>>(
150-
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)), Props,
147+
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)),
151148
KernelFunc);
152149
Q.wait_and_throw();
153150
std::cerr
@@ -174,17 +171,10 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
174171
}
175172

176173
template <size_t I> int test_max(queue &Q) {
177-
auto Props = ext::oneapi::experimental::properties{
178-
ext::oneapi::experimental::max_linear_work_group_size<I>};
179-
auto KernelFunction = [](auto) {};
180-
181-
auto EmptyProps = ext::oneapi::experimental::properties{};
182174
KernelFunctorWithMaxWGSizeProp<I> KernelFunctor;
183175

184176
int Res = 0;
185-
Res += test<Variant::Function, I>(Q, Props, KernelFunction);
186-
Res += test<Variant::Functor, I>(Q, EmptyProps, KernelFunctor);
187-
Res += test<Variant::FunctorAndProperty, I>(Q, Props, KernelFunctor);
177+
Res += test<Variant::Functor, I>(Q, KernelFunctor);
188178
return Res;
189179
}
190180

sycl/test-e2e/Basic/max_work_group_size_props.cpp

+9-19
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,15 @@ template <size_t... Is> struct KernelFunctorWithMaxWGSizeProp {
4949
}
5050
};
5151

52-
template <Variant KernelVariant, size_t... Is, typename PropertiesT,
53-
typename KernelType>
54-
int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
52+
template <Variant KernelVariant, size_t... Is, typename KernelType>
53+
int test(queue &Q, KernelType KernelFunc) {
5554
constexpr size_t Dims = sizeof...(Is);
5655

5756
// Positive test case: Specify local size that matches required size.
5857
try {
5958
Q.submit([&](handler &CGH) {
6059
CGH.parallel_for<MaxWGSizePositive<KernelVariant, false, Is...>>(
61-
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), Props,
62-
KernelFunc);
60+
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), KernelFunc);
6361
});
6462
Q.wait_and_throw();
6563
} catch (exception &E) {
@@ -71,8 +69,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
7169
// Same as above but using the queue shortcuts.
7270
try {
7371
Q.parallel_for<MaxWGSizePositive<KernelVariant, true, Is...>>(
74-
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), Props,
75-
KernelFunc);
72+
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), KernelFunc);
7673
Q.wait_and_throw();
7774
} catch (exception &E) {
7875
std::cerr << "Test case MaxWGSizePositive shortcut failed: unexpected "
@@ -86,7 +83,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
8683
try {
8784
Q.submit([&](handler &CGH) {
8885
CGH.parallel_for<MaxWGSizeNoLocalPositive<KernelVariant, false, Is...>>(
89-
repeatRange<Dims>(16), Props, KernelFunc);
86+
repeatRange<Dims>(16), KernelFunc);
9087
});
9188
Q.wait_and_throw();
9289
} catch (exception &E) {
@@ -98,7 +95,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
9895

9996
try {
10097
Q.parallel_for<MaxWGSizeNoLocalPositive<KernelVariant, true, Is...>>(
101-
repeatRange<Dims>(16), Props, KernelFunc);
98+
repeatRange<Dims>(16), KernelFunc);
10299
Q.wait_and_throw();
103100
} catch (exception &E) {
104101
std::cerr << "Test case MaxWGSizeNoLocalPositive shortcut failed: "
@@ -111,7 +108,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
111108
try {
112109
Q.submit([&](handler &CGH) {
113110
CGH.parallel_for<MaxWGSizeNegative<KernelVariant, false, Is...>>(
114-
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)), Props,
111+
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)),
115112
KernelFunc);
116113
});
117114
Q.wait_and_throw();
@@ -134,7 +131,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
134131
// Same as above but using the queue shortcuts.
135132
try {
136133
Q.parallel_for<MaxWGSizeNegative<KernelVariant, true, Is...>>(
137-
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)), Props,
134+
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)),
138135
KernelFunc);
139136
Q.wait_and_throw();
140137
std::cerr << "Test case MaxWGSizeNegative shortcut failed: no exception "
@@ -159,17 +156,10 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
159156
}
160157

161158
template <size_t... Is> int test_max(queue &Q) {
162-
auto Props = ext::oneapi::experimental::properties{
163-
ext::oneapi::experimental::max_work_group_size<Is...>};
164-
auto KernelFunction = [](auto) {};
165-
166-
auto EmptyProps = ext::oneapi::experimental::properties{};
167159
KernelFunctorWithMaxWGSizeProp<Is...> KernelFunctor;
168160

169161
int Res = 0;
170-
Res += test<Variant::Function, Is...>(Q, Props, KernelFunction);
171-
Res += test<Variant::Functor, Is...>(Q, EmptyProps, KernelFunctor);
172-
Res += test<Variant::FunctorAndProperty, Is...>(Q, Props, KernelFunctor);
162+
Res += test<Variant::Functor, Is...>(Q, KernelFunctor);
173163
return Res;
174164
}
175165

sycl/test-e2e/Basic/work_group_size_prop.cpp

+9-19
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ template <size_t... Is> struct KernelFunctorWithWGSizeProp {
4545
}
4646
};
4747

48-
template <Variant KernelVariant, size_t... Is, typename PropertiesT,
49-
typename KernelType>
50-
int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
48+
template <Variant KernelVariant, size_t... Is, typename KernelType>
49+
int test(queue &Q, KernelType KernelFunc) {
5150
constexpr size_t Dims = sizeof...(Is);
5251

5352
bool IsOpenCL = (Q.get_backend() == backend::opencl);
@@ -56,8 +55,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
5655
try {
5756
Q.submit([&](handler &CGH) {
5857
CGH.parallel_for<ReqdWGSizePositiveA<KernelVariant, false, Is...>>(
59-
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), Props,
60-
KernelFunc);
58+
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), KernelFunc);
6159
});
6260
Q.wait_and_throw();
6361
} catch (exception &E) {
@@ -69,8 +67,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
6967
// Same as above but using the queue shortcuts.
7068
try {
7169
Q.parallel_for<ReqdWGSizePositiveA<KernelVariant, true, Is...>>(
72-
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), Props,
73-
KernelFunc);
70+
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), KernelFunc);
7471
Q.wait_and_throw();
7572
} catch (exception &E) {
7673
std::cerr << "Test case ReqdWGSizePositiveA shortcut failed: unexpected "
@@ -87,7 +84,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
8784
Q.submit([&](handler &CGH) {
8885
CGH.parallel_for<
8986
ReqdWGSizeNoLocalPositive<KernelVariant, false, Is...>>(
90-
repeatRange<Dims>(16), Props, KernelFunc);
87+
repeatRange<Dims>(16), KernelFunc);
9188
});
9289
Q.wait_and_throw();
9390
} catch (exception &E) {
@@ -99,7 +96,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
9996

10097
try {
10198
Q.parallel_for<ReqdWGSizeNoLocalPositive<KernelVariant, true, Is...>>(
102-
repeatRange<Dims>(16), Props, KernelFunc);
99+
repeatRange<Dims>(16), KernelFunc);
103100
Q.wait_and_throw();
104101
} catch (exception &E) {
105102
std::cerr << "Test case ReqdWGSizeNoLocalPositive shortcut failed: "
@@ -113,7 +110,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
113110
try {
114111
Q.submit([&](handler &CGH) {
115112
CGH.parallel_for<ReqdWGSizeNegativeA<KernelVariant, false, Is...>>(
116-
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)), Props,
113+
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)),
117114
KernelFunc);
118115
});
119116
Q.wait_and_throw();
@@ -137,7 +134,7 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
137134
// Same as above but using the queue shortcuts.
138135
try {
139136
Q.parallel_for<ReqdWGSizeNegativeA<KernelVariant, true, Is...>>(
140-
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)), Props,
137+
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)),
141138
KernelFunc);
142139
Q.wait_and_throw();
143140
std::cerr << "Test case ReqdWGSizeNegativeA shortcut failed: no exception "
@@ -162,17 +159,10 @@ int test(queue &Q, PropertiesT Props, KernelType KernelFunc) {
162159
}
163160

164161
template <size_t... Is> int test(queue &Q) {
165-
auto Props = ext::oneapi::experimental::properties{
166-
ext::oneapi::experimental::work_group_size<Is...>};
167-
auto KernelFunction = [](auto) {};
168-
169-
auto EmptyProps = ext::oneapi::experimental::properties{};
170162
KernelFunctorWithWGSizeProp<Is...> KernelFunctor;
171163

172164
int Res = 0;
173-
Res += test<Variant::Function, Is...>(Q, Props, KernelFunction);
174-
Res += test<Variant::Functor, Is...>(Q, EmptyProps, KernelFunctor);
175-
Res += test<Variant::FunctorAndProperty, Is...>(Q, Props, KernelFunctor);
165+
Res += test<Variant::Functor, Is...>(Q, KernelFunctor);
176166
return Res;
177167
}
178168

sycl/test-e2e/Graph/Inputs/work_group_size_prop.cpp

+7-17
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ template <size_t... Is> struct KernelFunctorWithWGSizeProp {
4040
}
4141
};
4242

43-
template <Variant KernelVariant, size_t... Is, typename PropertiesT,
44-
typename KernelType>
45-
int test(queue &Queue, PropertiesT Props, KernelType KernelFunc) {
43+
template <Variant KernelVariant, size_t... Is, typename KernelType>
44+
int test(queue &Queue, KernelType KernelFunc) {
4645
constexpr size_t Dims = sizeof...(Is);
4746

4847
// Positive test case: Specify local size that matches required size.
@@ -52,15 +51,13 @@ int test(queue &Queue, PropertiesT Props, KernelType KernelFunc) {
5251

5352
add_node(Graph, Queue, [&](handler &CGH) {
5453
CGH.parallel_for<ReqdWGSizePositiveA<KernelVariant, false, Is...>>(
55-
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), Props,
56-
KernelFunc);
54+
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), KernelFunc);
5755
});
5856

5957
#ifdef GRAPH_E2E_RECORD_REPLAY
6058
Graph.begin_recording(Queue);
6159
Queue.parallel_for<ReqdWGSizePositiveA<KernelVariant, true, Is...>>(
62-
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), Props,
63-
KernelFunc);
60+
nd_range<Dims>(repeatRange<Dims>(8), range<Dims>(Is...)), KernelFunc);
6461
Graph.end_recording(Queue);
6562
#endif
6663

@@ -83,7 +80,7 @@ int test(queue &Queue, PropertiesT Props, KernelType KernelFunc) {
8380
try {
8481
add_node(GraphN, Queue, [&](handler &CGH) {
8582
CGH.parallel_for<ReqdWGSizeNegativeA<KernelVariant, false, Is...>>(
86-
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)), Props,
83+
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)),
8784
KernelFunc);
8885
});
8986
auto ExecGraph = GraphN.finalize();
@@ -119,7 +116,7 @@ int test(queue &Queue, PropertiesT Props, KernelType KernelFunc) {
119116
GraphN.begin_recording(Queue);
120117

121118
Queue.parallel_for<ReqdWGSizeNegativeA<KernelVariant, true, Is...>>(
122-
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)), Props,
119+
nd_range<Dims>(repeatRange<Dims>(16), repeatRange<Dims>(8)),
123120
KernelFunc);
124121

125122
GraphN.end_recording(Queue);
@@ -156,17 +153,10 @@ int test(queue &Queue, PropertiesT Props, KernelType KernelFunc) {
156153
}
157154

158155
template <size_t... Is> int test(queue &Queue) {
159-
auto Props = sycl::ext::oneapi::experimental::properties{
160-
sycl::ext::oneapi::experimental::work_group_size<Is...>};
161-
auto KernelFunction = [](auto) {};
162-
163-
auto EmptyProps = sycl::ext::oneapi::experimental::properties{};
164156
KernelFunctorWithWGSizeProp<Is...> KernelFunctor;
165157

166158
int Res = 0;
167-
Res += test<Variant::Function, Is...>(Queue, Props, KernelFunction);
168-
Res += test<Variant::Functor, Is...>(Queue, EmptyProps, KernelFunctor);
169-
Res += test<Variant::FunctorAndProperty, Is...>(Queue, Props, KernelFunctor);
159+
Res += test<Variant::Functor, Is...>(Queue, KernelFunctor);
170160
return Res;
171161
}
172162

0 commit comments

Comments
 (0)