diff --git a/SYCL/Basic/host_task_depends.cpp b/SYCL/Basic/host_task_depends.cpp new file mode 100644 index 0000000000..ad0dccf47f --- /dev/null +++ b/SYCL/Basic/host_task_depends.cpp @@ -0,0 +1,31 @@ +// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out +// RUN: %CPU_RUN_PLACEHOLDER %t.out + +#include + +using namespace sycl; +using namespace sycl::access; + +void test() { + queue Q; + std::shared_ptr Mutex(new std::mutex()); + Mutex->lock(); + { + auto E = Q.submit([&](handler &CGH) { + CGH.host_task([=]() { std::lock_guard Guard(*Mutex); }); + }); + // Host task should block kernel enqueue but not cause dead lock here + Q.submit([&](handler &CGH) { + CGH.depends_on(E); + CGH.single_task([=]() {}); + }); + } + // Unblock kernel execution + Mutex->unlock(); + Q.wait(); +} + +int main() { + test(); + return 0; +}