diff --git a/rocclr/runtime/device/pal/palmemory.cpp b/rocclr/runtime/device/pal/palmemory.cpp index f6ca8bab8e..010628f6e3 100644 --- a/rocclr/runtime/device/pal/palmemory.cpp +++ b/rocclr/runtime/device/pal/palmemory.cpp @@ -123,7 +123,6 @@ bool Memory::create(Resource::MemoryType memType, Resource::CreateParams* params switch (memoryType()) { case Resource::Pinned: case Resource::ExternalPhysical: - case Resource::P2PAccess: // Marks memory object for direct GPU access to the host memory flags_ |= HostMemoryDirectAccess; break; @@ -407,13 +406,13 @@ Memory::~Memory() { void Memory::syncCacheFromHost(VirtualGPU& gpu, device::Memory::SyncFlags syncFlags) { // If the last writer was another GPU, then make a writeback - if (!isHostMemDirectAccess() && (owner()->getLastWriter() != nullptr) && + if (isChacheCoherencySync() && (owner()->getLastWriter() != nullptr) && (&dev() != owner()->getLastWriter())) { mgpuCacheWriteBack(); } // If host memory doesn't have direct access, then we have to synchronize - if (!isHostMemDirectAccess() && (nullptr != owner()->getHostMem())) { + if (isChacheCoherencySync() && (nullptr != owner()->getHostMem())) { bool hasUpdates = true; // Make sure the parent of subbuffer is up to date @@ -526,7 +525,7 @@ void Memory::syncHostFromCache(device::Memory::SyncFlags syncFlags) { assert(owner() != nullptr); // If host memory doesn't have direct access, then we have to synchronize - if (!isHostMemDirectAccess()) { + if (isChacheCoherencySync()) { bool hasUpdates = true; // Make sure the parent of subbuffer is up to date diff --git a/rocclr/runtime/device/pal/palmemory.hpp b/rocclr/runtime/device/pal/palmemory.hpp index 54c74f20ab..c9dbf58e3e 100644 --- a/rocclr/runtime/device/pal/palmemory.hpp +++ b/rocclr/runtime/device/pal/palmemory.hpp @@ -152,6 +152,11 @@ class Memory : public device::Memory, public Resource { Resource::updateView(view, offset, size); } + //! Check if memory object requires cache coherency sync + bool isChacheCoherencySync() const { + return (!isHostMemDirectAccess() && (memoryType() != P2PAccess)); + } + protected: //! Decrement map count void decIndMapCount();