From 593d1e3b8d80ea58836e6dd117489b2dfe27591d Mon Sep 17 00:00:00 2001 From: foreman Date: Thu, 11 Dec 2014 12:07:05 -0500 Subject: [PATCH] P4 to Git Change 1104627 by gandryey@gera-dev-w7 on 2014/12/11 12:01:30 EPR #411058 - [CQE OCL][Lnx][QR][CZ]MultiDevice_Context fails in 2.0 conformance wimpyfull due to CL# 1101352 - The detection of different map types is overcomplicated with possibility of multiple maps and multithreading environment. Thus keep USWC indirect map optimization based on the allocation flags. Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpumemory.cpp#114 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpumemory.hpp#46 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuvirtual.cpp#342 edit --- rocclr/runtime/device/gpu/gpumemory.cpp | 6 ++---- rocclr/runtime/device/gpu/gpumemory.hpp | 20 +++++++------------- rocclr/runtime/device/gpu/gpuvirtual.cpp | 6 ++---- 3 files changed, 11 insertions(+), 21 deletions(-) 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);