Skip to content

Commit 12b4f2c

Browse files
committed
Restore lock and rework test
1 parent 28c0a70 commit 12b4f2c

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

sycl/source/detail/queue_impl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ queue_impl::submit_impl(const detail::type_erased_cgfo_ty &CGF,
355355
!requiresPostProcess;
356356

357357
if (noLastEventPath) {
358+
std::unique_lock<std::mutex> Lock(MMutex);
358359
return finalizeHandlerInOrderNoEventsUnlocked(Handler);
359360
}
360361

sycl/source/detail/queue_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> {
744744

745745
if (Event && !Scheduler::CheckEventReadiness(MContext, Event)) {
746746
MDefaultGraphDeps.LastEventPtr = Event;
747-
MNoLastEventMode = false;
747+
MNoLastEventMode.store(false, std::memory_order_relaxed);
748748
}
749749

750750
return Event;

sycl/test-e2e/InorderQueue/in_order_multi_queue_host_task.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
88
//
99
//===----------------------------------------------------------------------===//
10+
#include <condition_variable>
1011
#include <iostream>
1112

1213
#include <sycl/detail/core.hpp>
@@ -15,7 +16,7 @@
1516

1617
using namespace sycl;
1718

18-
const int dataSize = 1024 * 1024;
19+
const int dataSize = 1024;
1920

2021
int main() {
2122
queue Queue1{property::queue::in_order()};
@@ -25,8 +26,14 @@ int main() {
2526
int *dataB = malloc_host<int>(dataSize, Queue1);
2627
int *dataC = malloc_host<int>(dataSize, Queue1);
2728

29+
bool ready = false;
30+
std::mutex host_task_mtx;
31+
std::condition_variable cv;
32+
2833
auto Event1 = Queue1.submit([&](handler &cgh) {
2934
cgh.host_task([&] {
35+
std::unique_lock<std::mutex> lk(host_task_mtx);
36+
cv.wait(lk, [&] { return ready; });
3037
for (size_t i = 0; i < dataSize; ++i) {
3138
dataA[i] = i;
3239
}
@@ -39,6 +46,12 @@ int main() {
3946
[=](id<1> idx) { dataB[idx[0]] = dataA[idx[0]]; });
4047
});
4148

49+
{
50+
std::unique_lock<std::mutex> lk(host_task_mtx);
51+
ready = true;
52+
}
53+
cv.notify_one();
54+
4255
Queue2.wait();
4356

4457
for (size_t i = 0; i != dataSize; ++i) {

0 commit comments

Comments
 (0)