Skip to content

Commit 60110b6

Browse files
authored
SWDEV-518831 - fix streams' sync issue in mthreads (#123)
* SWDEV-518831 - fix streams' sync issue in mthreads 1. Fix sync issue of null stream and non-null streams in multithreads. 2. Remove assert(GetSubmissionBatch() == nullptr) as it is invalid in multithreads. 3. Update getActiveQueues() to deal with the state of being terminated. [ROCm/clr commit: 27aad09]
1 parent 45b7501 commit 60110b6

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

projects/clr/hipamd/src/hip_device.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ void Device::WaitActiveStreams(hip::Stream* blocking_stream, bool wait_null_stre
201201
// Get the last valid command
202202
waitForStream(active_stream);
203203
}
204+
command->release();
204205
}
205206
}
206207

projects/clr/hipamd/src/hip_stream.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ bool Stream::Create() {
7373

7474
// ================================================================================================
7575
void Stream::Destroy(hip::Stream* stream, bool forceDestroy) {
76+
stream->device().removeFromActiveQueues(stream);
7677
stream->device_->RemoveStream(stream);
7778
stream->SetForceDestroy(forceDestroy);
7879
stream->release();

projects/clr/rocclr/device/device.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,21 @@ void Device::IpcDetach(void* dev_ptr) const {
11071107
}
11081108
}
11091109

1110+
std::vector<amd::CommandQueue*> Device::getActiveQueues() {
1111+
amd::ScopedLock lock(activeQueuesLock_);
1112+
for (auto it = activeQueues.begin(); it != activeQueues.end();) {
1113+
if ((*it)->referenceCount() == 0) {
1114+
// It is being terminated in HostQueue::terminate().
1115+
// We should not wait for commands in a queue being terminated.
1116+
it = activeQueues.erase(it);
1117+
} else {
1118+
// In case the queue will be destroyed in Stream::Destroy().
1119+
(*it)->retain();
1120+
++it;
1121+
}
1122+
}
1123+
return std::vector<amd::CommandQueue*>(activeQueues.begin(), activeQueues.end());
1124+
}
11101125
} // namespace amd
11111126

11121127
namespace amd::device {

projects/clr/rocclr/device/device.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,10 +2119,7 @@ class Device : public RuntimeObject {
21192119
}
21202120

21212121
//! Returns the queues that have at least one submitted command
2122-
std::vector<amd::CommandQueue*> getActiveQueues() {
2123-
amd::ScopedLock lock(activeQueuesLock_);
2124-
return std::vector<amd::CommandQueue*>(activeQueues.begin(), activeQueues.end());
2125-
}
2122+
std::vector<amd::CommandQueue*> getActiveQueues();
21262123

21272124
//! Adds the queue to the set of active command queues
21282125
void addToActiveQueues(amd::CommandQueue* commandQueue) {

0 commit comments

Comments
 (0)