diff --git a/rocclr/runtime/device/gpu/gpumemory.cpp b/rocclr/runtime/device/gpu/gpumemory.cpp index e70cc0b60b..5f77777391 100644 --- a/rocclr/runtime/device/gpu/gpumemory.cpp +++ b/rocclr/runtime/device/gpu/gpumemory.cpp @@ -922,8 +922,7 @@ Memory::allocMapTarget( incIndMapCount(); // If host memory exists, use it - if ((owner()->getHostMem() != NULL) && - isDirectMap(mapFlags)) { + if ((owner()->getHostMem() != NULL) && isDirectMap()) { mapAddress = reinterpret_cast
(owner()->getHostMem()); } // If resource is a persistent allocation, we can use it directly @@ -1248,8 +1247,7 @@ Image::allocMapTarget( incIndMapCount(); // If host memory exists, use it - if ((owner()->getHostMem() != NULL) && - isDirectMap(mapFlags)) { + if ((owner()->getHostMem() != NULL) && isDirectMap()) { useRemoteResource = false; mapAddress = reinterpret_cast
(owner()->getHostMem()); amd::Image* amdImage = owner()->asImage(); diff --git a/rocclr/runtime/device/gpu/gpumemory.hpp b/rocclr/runtime/device/gpu/gpumemory.hpp index 0b95261598..11d4f088ad 100644 --- a/rocclr/runtime/device/gpu/gpumemory.hpp +++ b/rocclr/runtime/device/gpu/gpumemory.hpp @@ -200,20 +200,14 @@ public: //! Returns the interop resource for this memory object const Memory* parent() const { return parent_; } - //! Returns TRUE if direct map is acceaptable - //! The method detects forced USWC memory on APU and - //! will cause a switch to indirect map for MAP_READ operations - bool isDirectMap(uint mapFlags) + //! Returns TRUE if direct map is acceaptable. The method detects + //! forced USWC memory on APU and will cause a switch to + //! indirect map for allocations with a possibility of host read + bool isDirectMap() { - return (((isCacheable() || (owner()->getMemFlags() & CL_MEM_ALLOC_HOST_PTR) || - !isHostMemDirectAccess() || !(mapFlags & CL_MAP_READ)) && - // If map(indirect) memory isn't NULL, - // then it's a double map from the app with different map flags. - // If runtime will provide different regions, - // then it won't be able to guarantee coherency - (mapMemory_ == NULL)) || - // Keep direct map always if the first map was direct already - ((indirectMapCount_ > 1) && (mapMemory_ == NULL))); + return (isCacheable() || !isHostMemDirectAccess() || + (owner()->getMemFlags() & + (CL_MEM_ALLOC_HOST_PTR | CL_MEM_HOST_WRITE_ONLY | CL_MEM_READ_ONLY))); } protected: diff --git a/rocclr/runtime/device/gpu/gpuvirtual.cpp b/rocclr/runtime/device/gpu/gpuvirtual.cpp index d4085903d2..757344b798 100644 --- a/rocclr/runtime/device/gpu/gpuvirtual.cpp +++ b/rocclr/runtime/device/gpu/gpuvirtual.cpp @@ -1090,8 +1090,7 @@ VirtualGPU::submitMapMemory(amd::MapMemoryCommand& vcmd) vcmd.mapFlags(), vcmd.isEntireMemory()); // If we have host memory, use it - if ((memory->owner()->getHostMem() != NULL) && - memory->isDirectMap(vcmd.mapFlags())) { + if ((memory->owner()->getHostMem() != NULL) && memory->isDirectMap()) { if (!memory->isHostMemDirectAccess()) { // Make sure GPU finished operation before // synchronization with the backing store @@ -1176,8 +1175,7 @@ VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd) amd::Memory* owner = memory->owner(); // We used host memory - if ((owner->getHostMem() != NULL) && - memory->isDirectMap(memory->isUnmapRead() ? CL_MAP_READ : 0)) { + if ((owner->getHostMem() != NULL) && memory->isDirectMap()) { if (memory->isUnmapWrite()) { // Target is the backing store, so sync owner->signalWrite(NULL);