Skip to content

Commit d5716c7

Browse files
committed
[SYCL][E2E] implement in-order queue test for cross-queue dependency
on host-task. This covers case not properly handled by in-order no event mode optimization.
1 parent 1680dc6 commit d5716c7

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// RUN: %{build} -o %t.out
2+
// RUN: %{run} %t.out
3+
//==-------- in_order_multi_queue_host_task.cpp ---------------------------==//
4+
//
5+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6+
// See https://llvm.org/LICENSE.txt for license information.
7+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8+
//
9+
//===----------------------------------------------------------------------===//
10+
#include <iostream>
11+
12+
#include <sycl/detail/core.hpp>
13+
#include <sycl/properties/all_properties.hpp>
14+
#include <sycl/usm.hpp>
15+
16+
using namespace sycl;
17+
18+
const int dataSize = 1024 * 1024;
19+
20+
int main() {
21+
queue Queue1{property::queue::in_order()};
22+
queue Queue2{property::queue::in_order()};
23+
24+
int *dataA = malloc_host<int>(dataSize, Queue1);
25+
int *dataB = malloc_host<int>(dataSize, Queue1);
26+
int *dataC = malloc_host<int>(dataSize, Queue1);
27+
28+
auto Event1 = Queue1.submit([&](handler &cgh) {
29+
cgh.host_task([&] {
30+
for (size_t i = 0; i < dataSize; ++i) {
31+
dataA[i] = i;
32+
}
33+
});
34+
});
35+
36+
Queue2.submit([&](handler &cgh) {
37+
cgh.depends_on(Event1);
38+
cgh.parallel_for(range<1>(dataSize),
39+
[=](id<1> idx) { dataB[idx[0]] = dataA[idx[0]]; });
40+
});
41+
42+
Queue2.wait();
43+
44+
for (size_t i = 0; i != dataSize; ++i) {
45+
if (dataB[i] != i) {
46+
std::cout << "Result mismatches " << dataB[i] << " vs expected " << i
47+
<< " for index " << i << std::endl;
48+
return 1;
49+
}
50+
}
51+
52+
return 0;
53+
}

0 commit comments

Comments
 (0)