diff --git a/rocclr/runtime/device/gpu/gpumemory.hpp b/rocclr/runtime/device/gpu/gpumemory.hpp index 3709091a1a..0b95261598 100644 --- a/rocclr/runtime/device/gpu/gpumemory.hpp +++ b/rocclr/runtime/device/gpu/gpumemory.hpp @@ -205,8 +205,15 @@ public: //! will cause a switch to indirect map for MAP_READ operations bool isDirectMap(uint mapFlags) { - return (isCacheable() || (owner()->getMemFlags() & CL_MEM_ALLOC_HOST_PTR) || - !isHostMemDirectAccess() || !(mapFlags & CL_MAP_READ)); + 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))); } protected: