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

Commit 48c2fc1

Browse files
authored
[SYCL] Removed the remained handler::codeplay_host_task (#451)
Signed-off-by: mdimakov <[email protected]>
1 parent 640bbe5 commit 48c2fc1

File tree

2 files changed

+35
-55
lines changed

2 files changed

+35
-55
lines changed

SYCL/Basic/accessor/Inputs/host_task_accessor.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ int main() {
5454

5555
#if defined(accessor_new_api_test) || defined(buffer_new_api_test)
5656
cgh.host_task([=]() {
57-
#else
58-
cgh.codeplay_host_task([=]() {
59-
#endif
6057
acc_7[6] = acc_1[0];
6158
acc_8[7] = acc_2[1];
6259
acc_9[7] = acc_3[1];
@@ -65,6 +62,7 @@ int main() {
6562
acc_3[1] = acc_6[4];
6663
});
6764
});
65+
#endif
6866
Queue.wait();
6967

7068
#if defined(accessor_new_api_test)
@@ -115,16 +113,14 @@ int main() {
115113

116114
#if defined(accessor_new_api_test) || defined(buffer_new_api_test)
117115
cgh.host_task([=]() {
118-
#else
119-
cgh.codeplay_host_task([=]() {
120-
#endif
121116
acc_7[6] = acc_1[0];
122117
acc_8[7] = acc_2[1];
123118
acc_9[7] = acc_3[1];
124119
acc_1[0] = 4;
125120
acc_2[1] = 5;
126121
acc_3[1] = 6;
127122
});
123+
#endif
128124
});
129125
Queue.wait();
130126

SYCL/HostInteropTask/interop-task.cpp

Lines changed: 33 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ template <typename T> class Modifier;
1818

1919
template <typename T> class Init;
2020

21-
template <bool B, typename T> class NameGen;
22-
2321
template <typename BufferT, typename ValueT>
2422
void checkBufferValues(BufferT Buffer, ValueT Value) {
2523
auto Acc = Buffer.template get_access<mode::read>();
@@ -32,7 +30,7 @@ void checkBufferValues(BufferT Buffer, ValueT Value) {
3230
}
3331
}
3432

35-
template <bool UseSYCL2020HostTask, typename DataT>
33+
template <typename DataT>
3634
void copy(buffer<DataT, 1> &Src, buffer<DataT, 1> &Dst, queue &Q) {
3735
Q.submit([&](handler &CGH) {
3836
auto SrcA = Src.template get_access<mode::read>(CGH);
@@ -61,10 +59,7 @@ void copy(buffer<DataT, 1> &Src, buffer<DataT, 1> &Dst, queue &Q) {
6159
"interop_handle::get_backend() returned a wrong value",
6260
CL_INVALID_VALUE);
6361
};
64-
if constexpr (UseSYCL2020HostTask)
65-
CGH.host_task(Func);
66-
else
67-
CGH.codeplay_host_task(Func);
62+
CGH.host_task(Func);
6863
});
6964
}
7065

@@ -96,7 +91,7 @@ void init(buffer<DataT, 1> &B1, buffer<DataT, 1> &B2, queue &Q) {
9691
// kernel that modifies the data in place for B, e.g. increment one, then copy
9792
// back to buffer A. Run it on a loop, to ensure the dependencies and the
9893
// reference counting of the objects is not leaked.
99-
template <bool UseSYCL2020HostTask> void test1(queue &Q) {
94+
void test1(queue &Q) {
10095
static constexpr int COUNT = 4;
10196
buffer<int, 1> Buffer1{BUFFER_SIZE};
10297
buffer<int, 1> Buffer2{BUFFER_SIZE};
@@ -106,9 +101,9 @@ template <bool UseSYCL2020HostTask> void test1(queue &Q) {
106101

107102
// Repeat a couple of times
108103
for (size_t Idx = 0; Idx < COUNT; ++Idx) {
109-
copy<UseSYCL2020HostTask>(Buffer1, Buffer2, Q);
104+
copy(Buffer1, Buffer2, Q);
110105
modify(Buffer2, Q);
111-
copy<UseSYCL2020HostTask>(Buffer2, Buffer1, Q);
106+
copy(Buffer2, Buffer1, Q);
112107
}
113108

114109
checkBufferValues(Buffer1, COUNT - 1);
@@ -118,7 +113,7 @@ template <bool UseSYCL2020HostTask> void test1(queue &Q) {
118113
// Same as above, but performing each command group on a separate SYCL queue
119114
// (on the same or different devices). This ensures the dependency tracking
120115
// works well but also there is no accidental side effects on other queues.
121-
template <bool UseSYCL2020HostTask> void test2(queue &Q) {
116+
void test2(queue &Q) {
122117
static constexpr int COUNT = 4;
123118
buffer<int, 1> Buffer1{BUFFER_SIZE};
124119
buffer<int, 1> Buffer2{BUFFER_SIZE};
@@ -128,16 +123,16 @@ template <bool UseSYCL2020HostTask> void test2(queue &Q) {
128123

129124
// Repeat a couple of times
130125
for (size_t Idx = 0; Idx < COUNT; ++Idx) {
131-
copy<UseSYCL2020HostTask>(Buffer1, Buffer2, Q);
126+
copy(Buffer1, Buffer2, Q);
132127
modify(Buffer2, Q);
133-
copy<UseSYCL2020HostTask>(Buffer2, Buffer1, Q);
128+
copy(Buffer2, Buffer1, Q);
134129
}
135130
checkBufferValues(Buffer1, COUNT - 1);
136131
checkBufferValues(Buffer2, COUNT - 1);
137132
}
138133

139134
// Same as above but with queue constructed out of context
140-
template <bool UseSYCL2020HostTask> void test2_1(queue &Q) {
135+
void test2_1(queue &Q) {
141136
static constexpr int COUNT = 4;
142137
buffer<int, 1> Buffer1{BUFFER_SIZE};
143138
buffer<int, 1> Buffer2{BUFFER_SIZE};
@@ -149,9 +144,9 @@ template <bool UseSYCL2020HostTask> void test2_1(queue &Q) {
149144

150145
// Repeat a couple of times
151146
for (size_t Idx = 0; Idx < COUNT; ++Idx) {
152-
copy<UseSYCL2020HostTask>(Buffer1, Buffer2, Q);
147+
copy(Buffer1, Buffer2, Q);
153148
modify(Buffer2, Q);
154-
copy<UseSYCL2020HostTask>(Buffer2, Buffer1, Q);
149+
copy(Buffer2, Buffer1, Q);
155150
}
156151
checkBufferValues(Buffer1, COUNT - 1);
157152
checkBufferValues(Buffer2, COUNT - 1);
@@ -161,15 +156,15 @@ template <bool UseSYCL2020HostTask> void test2_1(queue &Q) {
161156
// captured outside the command group. The OpenCL event can be set after the
162157
// command group finishes. Must not deadlock according to implementation and
163158
// proposal
164-
template <bool UseSYCL2020HostTask> void test3(queue &Q) {
159+
void test3(queue &Q) {
165160
// Want some large buffer for operation to take long
166161
buffer<int, 1> Buffer{BUFFER_SIZE * 128};
167162

168163
event Event = Q.submit([&](handler &CGH) {
169164
auto Acc1 = Buffer.get_access<mode::write>(CGH);
170165

171-
CGH.parallel_for<NameGen<UseSYCL2020HostTask, class Init3>>(
172-
BUFFER_SIZE, [=](item<1> Id) { Acc1[Id] = 123; });
166+
CGH.parallel_for<class Init3>(BUFFER_SIZE,
167+
[=](item<1> Id) { Acc1[Id] = 123; });
173168
});
174169

175170
Q.submit([&](handler &CGH) {
@@ -181,40 +176,33 @@ template <bool UseSYCL2020HostTask> void test3(queue &Q) {
181176
if (RC != CL_SUCCESS)
182177
throw runtime_error("Can't wait for events", RC);
183178
};
184-
if constexpr (UseSYCL2020HostTask)
185-
CGH.host_task(Func);
186-
else
187-
CGH.codeplay_host_task(Func);
179+
CGH.host_task(Func);
188180
});
189181
}
190182

191183
// Check that a single host-interop-task with a buffer will work
192-
template <bool UseSYCL2020HostTask> void test4(queue &Q) {
184+
void test4(queue &Q) {
193185
buffer<int, 1> Buffer{BUFFER_SIZE};
194186

195187
Q.submit([&](handler &CGH) {
196188
auto Acc = Buffer.get_access<mode::write>(CGH);
197189
auto Func = [=](interop_handle IH) { /*A no-op */ };
198-
if constexpr (UseSYCL2020HostTask)
199-
CGH.host_task(Func);
200-
else
201-
CGH.codeplay_host_task(Func);
190+
CGH.host_task(Func);
202191
});
203192
}
204193

205-
template <bool UseSYCL2020HostTask> void test5(queue &Q) {
194+
void test5(queue &Q) {
206195
buffer<int, 1> Buffer1{BUFFER_SIZE};
207196
buffer<int, 1> Buffer2{BUFFER_SIZE};
208197

209198
Q.submit([&](handler &CGH) {
210199
auto Acc = Buffer1.template get_access<mode::write>(CGH);
211200

212201
auto Kernel = [=](item<1> Id) { Acc[Id] = 123; };
213-
CGH.parallel_for<NameGen<UseSYCL2020HostTask, class Test5Init>>(
214-
Acc.get_count(), Kernel);
202+
CGH.parallel_for<class Test5Init>(Acc.get_count(), Kernel);
215203
});
216204

217-
copy<UseSYCL2020HostTask>(Buffer1, Buffer2, Q);
205+
copy(Buffer1, Buffer2, Q);
218206

219207
checkBufferValues(Buffer2, static_cast<int>(123));
220208
}
@@ -223,7 +211,7 @@ template <bool UseSYCL2020HostTask> void test5(queue &Q) {
223211
// when properly registered in the command group.
224212
// It also checks that an exception is thrown if the placeholder accessor
225213
// is not registered.
226-
template <bool UseSYCL2020HostTask> void test6(queue &Q) {
214+
void test6(queue &Q) {
227215
// Placeholder accessor that is properly registered in CGH.
228216
try {
229217
size_t size = 1;
@@ -233,8 +221,7 @@ template <bool UseSYCL2020HostTask> void test6(queue &Q) {
233221
PHAcc(Buf);
234222
Q.submit([&](sycl::handler &CGH) {
235223
CGH.require(PHAcc);
236-
CGH.codeplay_host_task(
237-
[=](interop_handle IH) { (void)IH.get_native_mem(PHAcc); });
224+
CGH.host_task([=](interop_handle IH) { (void)IH.get_native_mem(PHAcc); });
238225
});
239226
Q.wait_and_throw();
240227
} catch (sycl::exception &E) {
@@ -251,10 +238,7 @@ template <bool UseSYCL2020HostTask> void test6(queue &Q) {
251238
PHAcc(Buf);
252239
Q.submit([&](sycl::handler &CGH) {
253240
auto Func = [=](interop_handle IH) { (void)IH.get_native_mem(PHAcc); };
254-
if constexpr (UseSYCL2020HostTask)
255-
CGH.host_task(Func);
256-
else
257-
CGH.codeplay_host_task(Func);
241+
CGH.host_task(Func);
258242
});
259243
Q.wait_and_throw();
260244
assert(!"Expected exception was not caught");
@@ -265,14 +249,14 @@ template <bool UseSYCL2020HostTask> void test6(queue &Q) {
265249
}
266250
}
267251

268-
template <bool UseSYCL2020HostTask> void tests(queue &Q) {
269-
test1<UseSYCL2020HostTask>(Q);
270-
test2<UseSYCL2020HostTask>(Q);
271-
test2_1<UseSYCL2020HostTask>(Q);
272-
test3<UseSYCL2020HostTask>(Q);
273-
test4<UseSYCL2020HostTask>(Q);
274-
test5<UseSYCL2020HostTask>(Q);
275-
test6<UseSYCL2020HostTask>(Q);
252+
void tests(queue &Q) {
253+
test1(Q);
254+
test2(Q);
255+
test2_1(Q);
256+
test3(Q);
257+
test4(Q);
258+
test5(Q);
259+
test6(Q);
276260
}
277261

278262
int main() {
@@ -283,8 +267,8 @@ int main() {
283267
}
284268
std::rethrow_exception(*ExceptionList.begin());
285269
});
286-
tests<true>(Q);
287-
tests<false>(Q);
270+
tests(Q);
271+
tests(Q);
288272
std::cout << "Test PASSED" << std::endl;
289273
return 0;
290274
}

0 commit comments

Comments
 (0)