diff --git a/rocclr/runtime/device/pal/palresource.cpp b/rocclr/runtime/device/pal/palresource.cpp index 15bab952b6..6c5e85fa83 100644 --- a/rocclr/runtime/device/pal/palresource.cpp +++ b/rocclr/runtime/device/pal/palresource.cpp @@ -168,15 +168,12 @@ GpuMemoryReference::~GpuMemoryReference() { device_.vgpus()[0]->releaseMemory(this, &events_[0]); } - { - amd::ScopedLock lk(device_.lockPAL()); - if (cpuAddress_ != nullptr) { - iMem()->Unmap(); - } - if (0 != iMem()) { - iMem()->Destroy(); - gpuMem_ = nullptr; - } + if (cpuAddress_ != nullptr) { + iMem()->Unmap(); + } + if (0 != iMem()) { + iMem()->Destroy(); + gpuMem_ = nullptr; } device_.removeResource(this); } @@ -415,8 +412,6 @@ bool Resource::create(MemoryType memType, CreateParams* params) { // This is a thread safe operation const_cast(dev()).initializeHeapResources(); - amd::ScopedLock lk(dev().lockPAL()); - if (memType == Shader) { if (dev().settings().svmFineGrainSystem_) { desc_.isAllocExecute_ = true; diff --git a/rocclr/runtime/device/pal/palvirtual.cpp b/rocclr/runtime/device/pal/palvirtual.cpp index 0f4097a5b8..33a65eaf5a 100644 --- a/rocclr/runtime/device/pal/palvirtual.cpp +++ b/rocclr/runtime/device/pal/palvirtual.cpp @@ -1478,12 +1478,14 @@ void VirtualGPU::submitMapMemory(amd::MapMemoryCommand& vcmd) { } void VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd) { + bool unmapMip = false; + amd::Image* amdImage; +{ // Make sure VirtualGPU has an exclusive access to the resources amd::ScopedLock lock(execution()); pal::Memory* memory = dev().getGpuMemory(&vcmd.memory()); amd::Memory* owner = memory->owner(); - bool unmapMip = false; const device::Memory::WriteMapInfo* writeMapInfo = memory->writeMapInfo(vcmd.mapPtr()); if (nullptr == writeMapInfo) { LogError("Unmap without map call"); @@ -1492,7 +1494,7 @@ void VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd) { profilingBegin(vcmd, true); // Check if image is a mipmap and assign a saved view - amd::Image* amdImage = owner->asImage(); + amdImage = owner->asImage(); if ((amdImage != nullptr) && (amdImage->getMipLevels() > 1) && (writeMapInfo->baseMip_ != nullptr)) { // Assign mip level view @@ -1571,11 +1573,14 @@ void VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd) { // Clear unmap flags memory->clearUnmapInfo(vcmd.mapPtr()); + profilingEnd(vcmd); +} // Release a view for a mipmap map if (unmapMip) { + // Memory release should be outside of the execution lock, + // because mapMemory_ isn't marked for a specifc GPU amdImage->release(); } - profilingEnd(vcmd); } bool VirtualGPU::fillMemory(cl_command_type type, amd::Memory* amdMemory, const void* pattern,