Observed softhang while running hipStreamAddCallbackCatch SWDEV-236746

Workaround hipStream deadlock issue as the same lock was used twice SWDEV-236746

Change-Id: Icc60104ce6edf4cfd2a3a889bab78a6caadd50b7


[ROCm/hip commit: a524f13c97]
Tá an tiomantas seo le fáil i:
Payam údaraithe agus Payam Ghafari tiomanta 2020-06-04 14:11:22 -04:00
1 tuismitheoir 9aa9282f89
tiomantas dac652e8df
2 comhad athraithe
+11 -9

Níor tháinig aon chomhaid le do chuardach

+8 -6
Féach ar an gComhad
@@ -51,15 +51,17 @@ Stream::Stream(hip::Device* dev, amd::CommandQueue::Priority p,
// ================================================================================================
bool Stream::Create() {
cl_command_queue_properties properties = CL_QUEUE_PROFILING_ENABLE;
queue_ = new amd::HostQueue(*device_->asContext(), *device_->devices()[0], properties,
amd::HostQueue* queue = new amd::HostQueue(*device_->asContext(), *device_->devices()[0], properties,
amd::CommandQueue::RealTimeDisabled, priority_, cuMask_);
// Create a host queue
bool result = (queue_ != nullptr) ? queue_->create() : false;
bool result = (queue != nullptr) ? queue->create() : false;
// Insert just created stream into the list of the blocking queues
if (result) {
amd::ScopedLock lock(streamSetLock);
streamSet.insert(this);
queue_ = queue;
} else {
queue_ = queue;
Destroy();
}
return result;
@@ -67,6 +69,9 @@ bool Stream::Create() {
// ================================================================================================
amd::HostQueue* Stream::asHostQueue(bool skip_alloc) {
if (queue_ != nullptr) {
return queue_;
}
// Access to the stream object is lock protected, because possible allocation
amd::ScopedLock l(Lock());
if (queue_ == nullptr) {
@@ -159,10 +164,7 @@ void iHipWaitActiveStreams(amd::HostQueue* blocking_queue, bool wait_null_stream
void CL_CALLBACK ihipStreamCallback(cl_event event, cl_int command_exec_status, void* user_data) {
hipError_t status = hipSuccess;
StreamCallback* cbo = reinterpret_cast<StreamCallback*>(user_data);
{
amd::ScopedLock lock(reinterpret_cast<hip::Stream*>(cbo->stream_)->Lock());
cbo->callBack_(cbo->stream_, status, cbo->userData_);
}
cbo->callBack_(cbo->stream_, status, cbo->userData_);
cbo->command_->release();
delete cbo;
}