From 38c1488dfdad61cd2ea35bae777bfce5db15f366 Mon Sep 17 00:00:00 2001 From: foreman Date: Thu, 31 Aug 2017 14:50:36 -0400 Subject: [PATCH] P4 to Git Change 1453901 by gandryey@gera-w8 on 2017/08/31 14:34:49 SWDEV-86035 - Code clean-up - Use TS check first to avoid LogError - Reset VirtualGPU reference if resource was cached - Lock active VirtualGPU on release, since a cached resource can have access to that queue from another thread Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.cpp#32 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#54 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.hpp#30 edit --- rocclr/runtime/device/pal/palresource.cpp | 3 +++ rocclr/runtime/device/pal/palvirtual.cpp | 1 - rocclr/runtime/device/pal/palvirtual.hpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/rocclr/runtime/device/pal/palresource.cpp b/rocclr/runtime/device/pal/palresource.cpp index 9448a1825e..7c4e5b440c 100644 --- a/rocclr/runtime/device/pal/palresource.cpp +++ b/rocclr/runtime/device/pal/palresource.cpp @@ -158,6 +158,7 @@ GpuMemoryReference::~GpuMemoryReference() { } } } else { + amd::ScopedLock l(gpu_->execution()); gpu_->releaseMemory(this, &events_[gpu_->index()]); } if (device_.vgpus().size() != 0) { @@ -1097,6 +1098,7 @@ void Resource::free() { } } else { + amd::ScopedLock l(memRef_->gpu_->execution()); memRef_->gpu_->waitForEvent(&memRef_->events_[memRef_->gpu_->index()]); } } @@ -1975,6 +1977,7 @@ bool ResourceCache::addGpuMemory(Resource::Descriptor* desc, GpuMemoryReference* // Add the current resource to the cache resCache_.push_front(std::make_pair(descCached, ref)); + ref->gpu_ = nullptr; cacheSize_ += size; result = true; } diff --git a/rocclr/runtime/device/pal/palvirtual.cpp b/rocclr/runtime/device/pal/palvirtual.cpp index 29d2bd0c63..0f4097a5b8 100644 --- a/rocclr/runtime/device/pal/palvirtual.cpp +++ b/rocclr/runtime/device/pal/palvirtual.cpp @@ -2281,7 +2281,6 @@ void VirtualGPU::submitMarker(amd::Marker& vcmd) { } void VirtualGPU::releaseMemory(GpuMemoryReference* mem, GpuEvent* event) { - waitForEvent(event); queues_[MainEngine]->removeCmdMemRef(mem); queues_[SdmaEngine]->removeCmdMemRef(mem); } diff --git a/rocclr/runtime/device/pal/palvirtual.hpp b/rocclr/runtime/device/pal/palvirtual.hpp index 15c375a23b..b6e9c4997a 100644 --- a/rocclr/runtime/device/pal/palvirtual.hpp +++ b/rocclr/runtime/device/pal/palvirtual.hpp @@ -104,7 +104,7 @@ class VirtualGPU : public device::VirtualDevice { if (!ibReuse) { start = amd::Os::timeNanos(); } - while (ibReuse || (Pal::Result::Success != (result = iCmdFences_[cbId]->GetStatus()))) { + while ((Pal::Result::Success != (result = iCmdFences_[cbId]->GetStatus())) || ibReuse) { if (result == Pal::Result::ErrorFenceNeverSubmitted) { result = Pal::Result::Success; break;