From 21014b2703949ff133509da8ffc7ae97984b4d5b Mon Sep 17 00:00:00 2001 From: foreman Date: Tue, 20 Oct 2015 18:37:35 -0400 Subject: [PATCH] P4 to Git Change 1201783 by gandryey@gera-w8 on 2015/10/20 18:03:34 SWDEV-79151 - clenqueuereadImage is slow when using a pinned buffer and a row_picth!0 - Add a check if the provided rowPitch is equal to the actual transfer width. SDMA doesn't support row/slice pitches, thus runtime still has to fall back to compute in other cases Affected files ... ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_memobj.cpp#78 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpublit.cpp#120 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/memory.cpp#122 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/memory.hpp#92 edit [ROCm/clr commit: 922e14c46df3575d6d8843786ce5e5de3a611f72] --- projects/clr/rocclr/runtime/device/gpu/gpublit.cpp | 12 ++++++++++-- projects/clr/rocclr/runtime/platform/memory.cpp | 14 +++++++++----- projects/clr/rocclr/runtime/platform/memory.hpp | 9 +++++---- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/projects/clr/rocclr/runtime/device/gpu/gpublit.cpp b/projects/clr/rocclr/runtime/device/gpu/gpublit.cpp index 768022a193..ebd13b0885 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpublit.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpublit.cpp @@ -938,6 +938,8 @@ KernelBlitManager::copyBufferToImage( static const bool CopyRect = false; // Flush DMA for ASYNC copy static const bool FlushDMA = true; + size_t imgRowPitch = size[0] * gpuMem(dstMemory).elementSize(); + size_t imgSlicePitch = imgRowPitch * size[1]; if (setup_.disableCopyBufferToImage_) { result = DmaBlitManager::copyBufferToImage( @@ -948,7 +950,9 @@ KernelBlitManager::copyBufferToImage( } // Check if buffer is in system memory with direct access else if (gpuMem(srcMemory).isHostMemDirectAccess() && - (rowPitch == 0) && (slicePitch == 0)) { + (((rowPitch == 0) && (slicePitch == 0)) || + ((rowPitch == imgRowPitch) && + ((slicePitch == 0) || (slicePitch == imgSlicePitch))))) { // First attempt to do this all with DMA, // but there are restriciton with older hardware if (dev().settings().imageDMA_) { @@ -1330,6 +1334,8 @@ KernelBlitManager::copyImageToBuffer( static const bool CopyRect = false; // Flush DMA for ASYNC copy static const bool FlushDMA = true; + size_t imgRowPitch = size[0] * gpuMem(srcMemory).elementSize(); + size_t imgSlicePitch = imgRowPitch * size[1]; if (setup_.disableCopyImageToBuffer_) { result = HostBlitManager::copyImageToBuffer( @@ -1340,7 +1346,9 @@ KernelBlitManager::copyImageToBuffer( } // Check if buffer is in system memory with direct access else if (gpuMem(dstMemory).isHostMemDirectAccess() && - (rowPitch == 0) && (slicePitch == 0)) { + (((rowPitch == 0) && (slicePitch == 0)) || + ((rowPitch == imgRowPitch) && + ((slicePitch == 0) || (slicePitch == imgSlicePitch))))) { // First attempt to do this all with DMA, // but there are restriciton with older hardware if (dev().settings().imageDMA_) { diff --git a/projects/clr/rocclr/runtime/platform/memory.cpp b/projects/clr/rocclr/runtime/platform/memory.cpp index 808dcf31da..a2e5516289 100644 --- a/projects/clr/rocclr/runtime/platform/memory.cpp +++ b/projects/clr/rocclr/runtime/platform/memory.cpp @@ -1226,17 +1226,21 @@ Image::validateRegion(const Coord3D& origin, const Coord3D& region) const } bool -Image::isSliceValid( - const size_t& rowPitch, - const size_t& slice, - const size_t& height) const +Image::isRowSliceValid( + size_t rowPitch, + size_t slice, + size_t width, + size_t height) const { size_t tmpHeight = (getType() == CL_MEM_OBJECT_IMAGE1D_ARRAY) ? 1 : height; + bool valid = (rowPitch == 0) || ((rowPitch != 0) && + (rowPitch >= width * getImageFormat().getElementSize())); + return ((slice == 0) || ((slice != 0) && - (slice >= rowPitch * tmpHeight))) ? true : false; + (slice >= rowPitch * tmpHeight))) ? valid : false; } void diff --git a/projects/clr/rocclr/runtime/platform/memory.hpp b/projects/clr/rocclr/runtime/platform/memory.hpp index a8edbc09d0..441b9d0039 100644 --- a/projects/clr/rocclr/runtime/platform/memory.hpp +++ b/projects/clr/rocclr/runtime/platform/memory.hpp @@ -577,10 +577,11 @@ public: ) const; //! Returns true if the slice value for the image is valid - bool isSliceValid( - const size_t& rowPitch, //!< The row pitch value - const size_t& slicePitch, //!< The slice pitch value - const size_t& height //!< The height of the copy region + bool isRowSliceValid( + size_t rowPitch, //!< The row pitch value + size_t slicePitch, //!< The slice pitch value + size_t width, //!< The width of the copy region + size_t height //!< The height of the copy region ) const; //! Creates a view memory object