From cd898208d9b23fd77ac028e01863844d61f9768c Mon Sep 17 00:00:00 2001 From: Satyanvesh Dittakavi Date: Wed, 31 Jan 2024 16:24:25 +0000 Subject: [PATCH] SWDEV-400448 - SWDEV-392872 - Add lock to NullStream Fetching null stream's logic has changed earlier from amd::HostQueue to hip::Stream. This seem to cause some timing difference between checking for null stream and creating it due to which issues are observed in multithreaded applications using default stream. Change-Id: Ie02365dec537275d23a1d225de9811e2fd3a9c55 [ROCm/clr commit: 8d265838cb4cc4cbd933b4a47d2b8a726cef82c2] --- projects/clr/hipamd/src/hip_device.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/projects/clr/hipamd/src/hip_device.cpp b/projects/clr/hipamd/src/hip_device.cpp index bcf6830f12..4d18ace5b1 100644 --- a/projects/clr/hipamd/src/hip_device.cpp +++ b/projects/clr/hipamd/src/hip_device.cpp @@ -31,10 +31,12 @@ namespace hip { // ================================================================================================ hip::Stream* Device::NullStream(bool wait) { - if (null_stream_ == nullptr) { - null_stream_ = new Stream(this, Stream::Priority::Normal, 0, true); + { + amd::ScopedLock lock(lock_); + if (null_stream_ == nullptr) { + null_stream_ = new Stream(this, Stream::Priority::Normal, 0, true); + } } - if (null_stream_ == nullptr) { return nullptr; }