From 898041df908ef07a5f3c43fe21299d86b8138fc2 Mon Sep 17 00:00:00 2001 From: foreman Date: Wed, 20 May 2015 17:28:59 -0400 Subject: [PATCH] P4 to Git Change 1152849 by skudchad@skudchad_test_win_opencl2 on 2015/05/20 17:15:00 EPR #403782 - IOMMU2/SVM - Update the caching and hit logic for resource cache to reflect allocation attributes for SVM. Else it can give wrong hits leading to hangs if a regular surface is used for shader upload etc. IOMMUv2 strictly needs shader and command buffers to have EXECUTE attribute. ReviewBoardURL = http://ocltc.amd.com/reviews/r/7572/diff/ Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuresource.cpp#217 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuresource.hpp#80 edit [ROCm/clr commit: 4f338e55785f48b434b1de42c8876198e33c617d] --- .../rocclr/runtime/device/gpu/gpuresource.cpp | 19 +++++++++++-------- .../rocclr/runtime/device/gpu/gpuresource.hpp | 15 ++++++++------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp b/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp index 84c8585ff9..6f2274faaf 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp @@ -91,6 +91,7 @@ Resource::Resource( cal_.imageType_ = 0; cal_.SVMRes_ = false; cal_.scratch_ = false; + cal_.isAllocExecute_ = false; } Resource::Resource( @@ -135,6 +136,7 @@ Resource::Resource( cal_.imageType_ = imageType; cal_.SVMRes_ = false; cal_.scratch_ = false; + cal_.isAllocExecute_ = false; switch (imageType) { case CL_MEM_OBJECT_IMAGE2D: @@ -363,7 +365,7 @@ Resource::create(MemoryType memType, CreateParams* params, bool heap) if (memType == Shader){ if(dev().settings().svmFineGrainSystem_) { - desc.isAllocExecute = true; + cal_.isAllocExecute_ = desc.isAllocExecute = true; } // force to use remote memory for HW DEBUG or use // local memory once we determine if FGS is supported @@ -2058,13 +2060,14 @@ ResourceCache::findCalResource(Resource::CalResourceDesc* desc) (entry->depth_ == desc->depth_) && (entry->channelOrder_ == desc->channelOrder_) && (entry->format_ == desc->format_) && - (entry->flags_ == desc->flags_)) { - ref = it.second; - delete it.first; - // Remove the found etry from the cache - resCache_.remove(it); - cacheSize_ -= size; - break; + (entry->flags_ == desc->flags_) && + (entry->isAllocExecute_ == desc->isAllocExecute_)) { + ref = it.second; + delete it.first; + // Remove the found etry from the cache + resCache_.remove(it); + cacheSize_ -= size; + break; } } diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuresource.hpp b/projects/clr/rocclr/runtime/device/gpu/gpuresource.hpp index c2c72b7cc6..8eeba3e905 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpuresource.hpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpuresource.hpp @@ -168,13 +168,14 @@ public: cl_mem_object_type imageType_; //!< CL image type union { struct { - uint dimSize_ : 2; //!< Dimension size - uint cardMemory_ : 1; //!< GSL resource is in video memory - uint imageArray_ : 1; //!< GSL resource is an array of images - uint buffer_ : 1; //!< GSL resource is a buffer - uint tiled_ : 1; //!< GSL resource is tiled - uint SVMRes_ : 1; //!< SVM flag to the cal resource - uint scratch_ : 1; //!< Scratch buffer + uint dimSize_ : 2; //!< Dimension size + uint cardMemory_ : 1; //!< GSL resource is in video memory + uint imageArray_ : 1; //!< GSL resource is an array of images + uint buffer_ : 1; //!< GSL resource is a buffer + uint tiled_ : 1; //!< GSL resource is tiled + uint SVMRes_ : 1; //!< SVM flag to the cal resource + uint scratch_ : 1; //!< Scratch buffer + uint isAllocExecute_ : 1; //!< SVM resource allocation attribute for shader\cmdbuf }; uint state_; };