From a6841e3f4309bdb271ff9775d5f9eb2e7c87a68d Mon Sep 17 00:00:00 2001 From: Satyanvesh Dittakavi Date: Tue, 6 Feb 2024 08:09:21 +0000 Subject: [PATCH] SWDEV-400448 - SWDEV-392872 - Optimize to add lock only if its null stream Change-Id: Ia905109a295614e8ce4e2bd24261c86ba8138178 --- hipamd/src/hip_device.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hipamd/src/hip_device.cpp b/hipamd/src/hip_device.cpp index 4d18ace5b1..b5d16ee40f 100644 --- a/hipamd/src/hip_device.cpp +++ b/hipamd/src/hip_device.cpp @@ -31,11 +31,11 @@ namespace hip { // ================================================================================================ hip::Stream* Device::NullStream(bool wait) { - { - amd::ScopedLock lock(lock_); - if (null_stream_ == nullptr) { - null_stream_ = new Stream(this, Stream::Priority::Normal, 0, true); - } + if (null_stream_ == nullptr) { + amd::ScopedLock lock(lock_); + if (null_stream_ == nullptr) { + null_stream_ = new Stream(this, Stream::Priority::Normal, 0, true); + } } if (null_stream_ == nullptr) { return nullptr;