Skip to content

Commit 082a959

Browse files
[SYCLomatic] Update the migration as API queue::ext_oneapi_get_last_event() changed in SYCL-OS (#2646)
1 parent b6776aa commit 082a959

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

clang/lib/DPCT/AnalysisInfo.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6667,8 +6667,19 @@ KernelPrinter &KernelCallExpr::SubmitStmtsList::print(KernelPrinter &Printer) {
66676667
Printer.line("cgh.depends_on(dpct::get_current_device().get_in_order_"
66686668
"queues_last_events());");
66696669
} else {
6670+
Printer.line("#ifdef __INTEL_LLVM_COMPILER");
6671+
Printer.newLine();
66706672
Printer.line("cgh.depends_on(dpct::get_default_queue().ext_oneapi_get_"
66716673
"last_event());");
6674+
Printer.newLine();
6675+
Printer.line("#else");
6676+
Printer.newLine();
6677+
Printer.line("auto e_opt = dpct::get_default_queue().ext_oneapi_get_last_"
6678+
"event();");
6679+
Printer.newLine();
6680+
Printer.line("if (e_opt) cgh.depends_on(*e_opt);");
6681+
Printer.newLine();
6682+
Printer.line("#endif");
66726683
}
66736684
Printer.newLine();
66746685
}

clang/runtime/dpct-rt/include/dpct/device.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,14 @@ class device_ext : public sycl::device {
592592
lock.unlock();
593593
for (const auto &q : current_queues) {
594594
if (q->is_in_order()) {
595+
#ifdef __INTEL_LLVM_COMPILER
595596
last_events.push_back(q->ext_oneapi_get_last_event());
597+
#else
598+
auto last_event = q->ext_oneapi_get_last_event();
599+
if (last_event) {
600+
last_events.push_back(*last_event);
601+
}
602+
#endif
596603
}
597604
}
598605
// Guard the destruct of current_queues to make sure the ref count is safe.

clang/test/dpct/kernel_implicit_sync.cu

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ int main() {
2727

2828
// CHECK: s1->submit(
2929
// CHECK: [&](sycl::handler &cgh) {
30+
// CHECK:#ifdef __INTEL_LLVM_COMPILER
3031
// CHECK: cgh.depends_on(dpct::get_default_queue().ext_oneapi_get_last_event());
32+
// CHECK:#else
33+
// CHECK: auto e_opt = dpct::get_default_queue().ext_oneapi_get_last_event();
34+
// CHECK: if (e_opt) cgh.depends_on(*e_opt);
35+
// CHECK:#endif
3136
// CHECK: cgh.parallel_for(
3237
// CHECK: sycl::nd_range<3>(sycl::range<3>(1, 1, 1), sycl::range<3>(1, 1, 1)),
3338
// CHECK: [=](sycl::nd_item<3> item_ct1) {

0 commit comments

Comments
 (0)