Skip to content

Commit 90333c3

Browse files
mlychkovbader
authored andcommitted
[SYCL] Avoid iteration through empty wait list in GraphProcessor (#432)
Signed-off-by: Viktoria Maksimova <[email protected]>
1 parent 8792320 commit 90333c3

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

sycl/source/detail/scheduler/graph_processor.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ static Command *getCommand(const EventImplPtr &Event) {
2323

2424
std::vector<EventImplPtr>
2525
Scheduler::GraphProcessor::getWaitList(EventImplPtr Event) {
26-
std::vector<EventImplPtr> Result;
2726
Command *Cmd = getCommand(Event);
27+
// Command can be nullptr if user creates cl::sycl::event explicitly,
28+
// as such event is not mapped to any SYCL task.
29+
if (!Cmd)
30+
return {};
31+
std::vector<EventImplPtr> Result;
2832
for (const DepDesc &Dep : Cmd->MDeps) {
2933
if (Dep.MDepCommand)
3034
Result.push_back(Dep.MDepCommand->getEvent());

sycl/test/scheduler/GetWaitList.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %clangxx -fsycl %s -o %t.out -lOpenCL
2+
// RUN: %t.out
3+
//==------------------- GetWaitList.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+
11+
#include <CL/sycl.hpp>
12+
13+
void foo() {
14+
cl::sycl::event start;
15+
start.wait_and_throw();
16+
return;
17+
}
18+
19+
int main() {
20+
cl::sycl::queue Q;
21+
Q.submit([&](cl::sycl::handler &CGH) {
22+
foo();
23+
});
24+
return 0;
25+
}

0 commit comments

Comments
 (0)