From 255a645c3b13fb4b37399ed47391c3cad59d5396 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 [ROCm/ROCR-Runtime commit: a1f3b619a75cf851b7c9076d1a3e41e5be2efda5] --- .../runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp index a606159892..59d21bb2e6 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp +++ b/projects/rocr-runtime/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);