diff --git a/rocclr/device/rocm/rocmemory.cpp b/rocclr/device/rocm/rocmemory.cpp index 664bc62b63..0e0b021c99 100644 --- a/rocclr/device/rocm/rocmemory.cpp +++ b/rocclr/device/rocm/rocmemory.cpp @@ -352,6 +352,7 @@ bool Memory::pinSystemMemory(void* hostPtr, size_t size) { } void Memory::syncCacheFromHost(VirtualGPU& gpu, device::Memory::SyncFlags syncFlags) { + amd::ScopedLock lock(owner()->lockMemoryOps()); // If the last writer was another GPU, then make a writeback if (!isHostMemDirectAccess() && (owner()->getLastWriter() != nullptr) && (&dev() != owner()->getLastWriter())) { @@ -407,7 +408,6 @@ void Memory::syncCacheFromHost(VirtualGPU& gpu, device::Memory::SyncFlags syncFl syncFlagsTmp.skipEntire_ = syncFlags.skipEntire_; } - amd::ScopedLock lock(owner()->lockMemoryOps()); for (auto& sub : owner()->subBuffers()) { //! \note Don't allow subbuffer's allocation in the worker thread. //! It may cause a system lock, because possible resource @@ -462,6 +462,8 @@ void Memory::syncCacheFromHost(VirtualGPU& gpu, device::Memory::SyncFlags syncFl } } + gpu.releaseGpuMemoryFence(); + // Should never fail assert(result && "Memory synchronization failed!"); }