File tree Expand file tree Collapse file tree 2 files changed +8
-16
lines changed Expand file tree Collapse file tree 2 files changed +8
-16
lines changed Original file line number Diff line number Diff line change @@ -351,17 +351,11 @@ queue_impl::submit_impl(const detail::type_erased_cgfo_ty &CGF,
351
351
352
352
auto requiresPostProcess = SubmitInfo.PostProcessorFunc () || Streams.size ();
353
353
auto noLastEventPath = !isHostTask && !isGraphSubmission &&
354
- MNoLastEventMode.load (std::memory_order_relaxed ) &&
354
+ MNoLastEventMode.load (std::memory_order_acquire ) &&
355
355
!requiresPostProcess;
356
356
357
357
if (noLastEventPath) {
358
- std::unique_lock<std::mutex> Lock (MMutex);
359
-
360
- // Check if we are still in no last event mode. There could
361
- // have been a concurrent submit.
362
- if (MNoLastEventMode.load (std::memory_order_relaxed)) {
363
- return finalizeHandlerInOrderNoEventsUnlocked (Handler);
364
- }
358
+ return finalizeHandlerInOrderNoEventsUnlocked (Handler);
365
359
}
366
360
367
361
detail::EventImplPtr EventImpl;
@@ -751,10 +745,11 @@ ur_native_handle_t queue_impl::getNative(int32_t &NativeHandleDesc) const {
751
745
bool queue_impl::queue_empty () const {
752
746
// If we have in-order queue with non-empty last event, just check its status.
753
747
if (isInOrder ()) {
754
- std::lock_guard<std::mutex> Lock (MMutex);
755
- if (MEmpty)
748
+ if (MEmpty.load (std::memory_order_acquire))
756
749
return true ;
757
750
751
+ std::lock_guard<std::mutex> Lock (MMutex);
752
+
758
753
if (MDefaultGraphDeps.LastEventPtr &&
759
754
!MDefaultGraphDeps.LastEventPtr ->isDiscarded ())
760
755
return MDefaultGraphDeps.LastEventPtr
Original file line number Diff line number Diff line change @@ -735,11 +735,8 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> {
735
735
detail::EventImplPtr
736
736
finalizeHandlerInOrderNoEventsUnlocked (HandlerType &Handler) {
737
737
assert (isInOrder ());
738
- assert (MGraph.expired ());
739
- assert (MDefaultGraphDeps.LastEventPtr == nullptr );
740
- assert (MNoLastEventMode);
741
738
742
- MEmpty = false ;
739
+ MEmpty. store ( false , std::memory_order_release) ;
743
740
744
741
synchronizeWithExternalEvent (Handler);
745
742
@@ -826,7 +823,7 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> {
826
823
const CGType Type = getSyclObjImpl (Handler)->MCGType ;
827
824
std::lock_guard<std::mutex> Lock{MMutex};
828
825
829
- MEmpty = false ;
826
+ MEmpty. store ( false , std::memory_order_release) ;
830
827
831
828
// The following code supports barrier synchronization if host task is
832
829
// involved in the scenario. Native barriers cannot handle host task
@@ -1048,7 +1045,7 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> {
1048
1045
std::atomic<bool > MNoLastEventMode = false ;
1049
1046
1050
1047
// Used exclusively in getLastEvent and queue_empty() implementations
1051
- bool MEmpty = true ;
1048
+ std::atomic< bool > MEmpty = true ;
1052
1049
1053
1050
std::vector<EventImplPtr> MStreamsServiceEvents;
1054
1051
std::mutex MStreamsServiceEventsMutex;
You can’t perform that action at this time.
0 commit comments