From a1f3b619a75cf851b7c9076d1a3e41e5be2efda5 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Thu, 18 May 2023 16:51:30 +0000 Subject: [PATCH] Add mutex when reserving scratch This prevents race condition when creating queues concurrently. Change-Id: I5ea9714926fe06e1719fcb2559cb485063355e4f --- runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp index a606159892..59d21bb2e6 100644 --- a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp +++ b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp @@ -504,6 +504,7 @@ void GpuAgent::InitScratchPool() { void GpuAgent::ReserveScratch() { size_t reserved_sz = core::Runtime::runtime_singleton_->flag().scratch_single_limit(); + ScopedAcquire lock(&scratch_lock_); if (!scratch_cache_.reserved_bytes() && reserved_sz) { HSAuint64 alt_va; void* reserved_base = scratch_pool_.alloc(reserved_sz);