From 900f906827e09cd050d43aba1a4231b95c58a3fd Mon Sep 17 00:00:00 2001 From: Rahul Manocha Date: Wed, 28 Aug 2024 14:03:20 -0700 Subject: [PATCH] SWDEV-462192 SWDEV-459056 Check if m_streams is empty 1) Since g_devices is not initialized when stream_per_thread constructor is called on windows, m_streams is empty when hipDeviceReset is called. 2) clear_spt tries to access empty vector causing segfaults in hipDeviceReset call. 3) on linux ROCCLR_INIT_PRIORITY makes sure that g_devices is initialized first before tls constructor creates stream_per_thread object. Change-Id: Ib2ba643d1278d820287ea3b242ed0878d7529165 [ROCm/clr commit: 450eca293b1f529e72eab27ced4b05d850a2c86c] --- projects/clr/hipamd/src/hip_stream.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/clr/hipamd/src/hip_stream.cpp b/projects/clr/hipamd/src/hip_stream.cpp index 72af505a41..233db0b05f 100644 --- a/projects/clr/hipamd/src/hip_stream.cpp +++ b/projects/clr/hipamd/src/hip_stream.cpp @@ -237,7 +237,9 @@ hipStream_t stream_per_thread::get() { } void stream_per_thread::clear_spt() { - m_streams[getCurrentDevice()->deviceId()] = nullptr; + if (!m_streams.empty()) { + m_streams[getCurrentDevice()->deviceId()] = nullptr; + } }