Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Corrected accessing the last event in the in_order queue #2646

Open
wants to merge 2 commits into
base: SYCLomatic
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions clang/lib/DPCT/AnalysisInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6667,8 +6667,19 @@ KernelPrinter &KernelCallExpr::SubmitStmtsList::print(KernelPrinter &Printer) {
Printer.line("cgh.depends_on(dpct::get_current_device().get_in_order_"
"queues_last_events());");
} else {
Printer.line("#ifdef __INTEL_LLVM_COMPILER");
Printer.newLine();
Printer.line("cgh.depends_on(dpct::get_default_queue().ext_oneapi_get_"
"last_event());");
Printer.newLine();
Printer.line("#else");
Printer.newLine();
Printer.line("auto e_opt = dpct::get_default_queue().ext_oneapi_get_last_"
"event();");
Printer.newLine();
Printer.line("if (e_opt) cgh.depends_on(*e_opt);");
Printer.newLine();
Printer.line("#endif");
}
Printer.newLine();
}
Expand Down
7 changes: 7 additions & 0 deletions clang/runtime/dpct-rt/include/dpct/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,14 @@ class device_ext : public sycl::device {
lock.unlock();
for (const auto &q : current_queues) {
if (q->is_in_order()) {
#ifdef __INTEL_LLVM_COMPILER
last_events.push_back(q->ext_oneapi_get_last_event());
#else
auto last_event = q->ext_oneapi_get_last_event();
if (last_event) {
last_events.push_back(*last_event);
}
#endif
}
}
// Guard the destruct of current_queues to make sure the ref count is safe.
Expand Down
5 changes: 5 additions & 0 deletions clang/test/dpct/kernel_implicit_sync.cu
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ int main() {

// CHECK: s1->submit(
// CHECK: [&](sycl::handler &cgh) {
// CHECK:#ifdef __INTEL_LLVM_COMPILER
// CHECK: cgh.depends_on(dpct::get_default_queue().ext_oneapi_get_last_event());
// CHECK:#else
// CHECK: auto e_opt = dpct::get_default_queue().ext_oneapi_get_last_event();
// CHECK: if (e_opt) cgh.depends_on(*e_opt);
// CHECK:#endif
// CHECK: cgh.parallel_for(
// CHECK: sycl::nd_range<3>(sycl::range<3>(1, 1, 1), sycl::range<3>(1, 1, 1)),
// CHECK: [=](sycl::nd_item<3> item_ct1) {
Expand Down