From 566684b6f4aa1bcccfd41205893e8951c752fac6 Mon Sep 17 00:00:00 2001 From: German Andryeyev Date: Fri, 5 Jun 2020 01:09:34 -0400 Subject: [PATCH] Add the sync of the current queue Make sure runtime waits for the current queue before synching with device queue Change-Id: I753b6fc0bb15a3a3d4bf03fef1152842550850c0 [ROCm/clr commit: 86e0f337fc065ba7a8849e98d08995da4d438a1f] --- projects/clr/rocclr/device/rocm/rocvirtual.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/projects/clr/rocclr/device/rocm/rocvirtual.cpp b/projects/clr/rocclr/device/rocm/rocvirtual.cpp index cc5dc4d3e2..326c896fb3 100644 --- a/projects/clr/rocclr/device/rocm/rocvirtual.cpp +++ b/projects/clr/rocclr/device/rocm/rocvirtual.cpp @@ -1525,6 +1525,10 @@ void VirtualGPU::submitMapMemory(amd::MapMemoryCommand& cmd) { // If we have host memory, use it if ((devMemory->owner()->getHostMem() != nullptr) && (devMemory->owner()->getSvmPtr() == nullptr)) { + if (!devMemory->isHostMemDirectAccess()) { + // Make sure GPU finished operation before synchronization with the backing store + releaseGpuMemoryFence(); + } // Target is the backing store, so just ensure that owner is up-to-date devMemory->owner()->cacheWriteBack(); @@ -1809,6 +1813,10 @@ void VirtualGPU::submitMigrateMemObjects(amd::MigrateMemObjectsCommand& vcmd) { Memory* memory = dev().getRocMemory(&(*itr)); if (vcmd.migrationFlags() & CL_MIGRATE_MEM_OBJECT_HOST) { + if (!memory->isHostMemDirectAccess()) { + // Make sure GPU finished operation before synchronization with the backing store + releaseGpuMemoryFence(); + } memory->mgpuCacheWriteBack(); } else if (vcmd.migrationFlags() & CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED) { // Synchronize memory from host if necessary. @@ -1838,7 +1846,8 @@ bool VirtualGPU::createSchedulerParam() } while(true) { - schedulerParam_ = new (dev().context()) amd::Buffer(dev().context(), CL_MEM_ALLOC_HOST_PTR, sizeof(SchedulerParam) + sizeof(AmdAqlWrap)); + schedulerParam_ = new (dev().context()) amd::Buffer(dev().context(), + CL_MEM_ALLOC_HOST_PTR, sizeof(SchedulerParam) + sizeof(AmdAqlWrap)); if ((nullptr != schedulerParam_) && !schedulerParam_->create(nullptr)) { break;