Skip to content

Commit 45b7501

Browse files
authored
SWDEV-516050 - Fix monitor hang in OCL (#75)
Fix monitor hang in cts integer_ops. Improve notify(). Won't affect notifyAll() and Hip in direct dispatch mode. Change-Id: I95a458358e1cab9c76aefde117db09cdbd1fd3af [ROCm/clr commit: 78f9290]
1 parent c773755 commit 45b7501

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

projects/clr/rocclr/thread/monitor.hpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,7 @@ class Monitor {
223223
// fast path
224224
c = 0;
225225
while (c < maxCount_ &&
226-
(notifyState_.load(std::memory_order_acquire) != notifyState::allNotified &&
227-
!notifyState_.compare_exchange_weak(expextedNotifyState, notifyState::notNotified,
228-
std::memory_order_acq_rel, std::memory_order_acquire))) {
226+
(notifyState_.load(std::memory_order_acquire) == notifyState::notNotified)) {
229227
// First, be SMT friendly
230228
if (c < maxReadSpinIter_) {
231229
Os::spinPause();
@@ -261,10 +259,8 @@ class Monitor {
261259
// the mutex is locked again before exiting...
262260
lk.release(); // Release the ownership so that the caller should unlock the mutex
263261
if (waits_.fetch_sub(1, std::memory_order_acq_rel) == 1) {
264-
if (notifyState_.load(std::memory_order_acquire) == notifyState::allNotified) {
265-
// No waiter indicates that notifyAll() processing has ended
266-
notifyState_.store(notifyState::notNotified, std::memory_order_release);
267-
}
262+
// No waiter indicates that notify() or notifyAll() processing has ended
263+
notifyState_.store(notifyState::notNotified, std::memory_order_release);
268264
}
269265
}
270266

0 commit comments

Comments
 (0)