From f1aac67ca8d69443b900ddd43c8f0c00b9fdb8ec Mon Sep 17 00:00:00 2001 From: foreman Date: Tue, 13 Dec 2016 20:42:16 -0500 Subject: [PATCH] P4 to Git Change 1352835 by cpaquot@hog-ocl on 2016/12/13 19:59:07 SWDEV-108384 - Force map memory offset to 0 Copy what we do in ORCA and PAL backend: When mapping an image, default the offset to 0 instead of the map offset for the staging buffer. ReviewBoardURL = http://ocltc.amd.com/reviews/r/12010/diff/ Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocmemory.cpp#5 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.cpp#25 edit [ROCm/clr commit: 320d5de3a15e9732e9b24f4926a8c9f440b680f1] --- .../rocclr/runtime/device/rocm/rocmemory.cpp | 28 +++++++++++++++---- .../rocclr/runtime/device/rocm/rocvirtual.cpp | 8 ++---- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/projects/clr/rocclr/runtime/device/rocm/rocmemory.cpp b/projects/clr/rocclr/runtime/device/rocm/rocmemory.cpp index 588208ae47..bc614e85e4 100644 --- a/projects/clr/rocclr/runtime/device/rocm/rocmemory.cpp +++ b/projects/clr/rocclr/runtime/device/rocm/rocmemory.cpp @@ -710,6 +710,12 @@ Image::allocMapTarget( void* pHostMem = owner()->getHostMem(); + amd::Image* image = owner()->asImage(); + + size_t elementSize = image->getImageFormat().getElementSize(); + + size_t offset = origin[0] * elementSize; + if (pHostMem == NULL) { if (indirectMapCount_ == 1) { if (!allocateMapMemory(owner()->getSize())) { @@ -726,14 +732,24 @@ Image::allocMapTarget( } pHostMem = mapMemory_->getHostMem(); + + *rowPitch = region[0] * elementSize; + + size_t slicePitchTmp = 0; + + if (imageDescriptor_.geometry == HSA_EXT_IMAGE_GEOMETRY_1DA) { + slicePitchTmp = *rowPitch; + } + else { + slicePitchTmp = *rowPitch * region[1]; + } + if (slicePitch != NULL) { + *slicePitch = slicePitchTmp; + } + + return pHostMem; } - amd::Image* image = owner()->asImage(); - - size_t elementSize = image->getImageFormat().getElementSize(); - - size_t offset = origin[0] * elementSize; - // Adjust offset with Y dimension offset += image->getRowPitch() * origin[1]; diff --git a/projects/clr/rocclr/runtime/device/rocm/rocvirtual.cpp b/projects/clr/rocclr/runtime/device/rocm/rocvirtual.cpp index f55d2305d6..ca104d59f6 100644 --- a/projects/clr/rocclr/runtime/device/rocm/rocvirtual.cpp +++ b/projects/clr/rocclr/runtime/device/rocm/rocvirtual.cpp @@ -1182,8 +1182,7 @@ void VirtualGPU::submitMapMemory(amd::MapMemoryCommand &cmd) devMemory->mapMemory()->getDeviceMemory(dev(), false)); result = blitMgr().copyImageToBuffer( *hsaMemory, *mapMemory, cmd.origin(), - cmd.origin(), cmd.size(), cmd.isEntireMemory(), - image->getRowPitch(), image->getSlicePitch()); + amd::Coord3D(0,0,0), cmd.size(), cmd.isEntireMemory()); } else { result = blitMgr().readImage( @@ -1239,9 +1238,8 @@ void VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand &cmd) roc::Memory *mapMemory = static_cast( devMemory->mapMemory()->getDeviceMemory(dev(), false)); result = blitMgr().copyBufferToImage( - *mapMemory, *devMemory, mapInfo->origin_, - mapInfo->origin_, mapInfo->region_, mapInfo->isEntire(), - image->getRowPitch(), image->getSlicePitch()); + *mapMemory, *devMemory, amd::Coord3D(0,0,0), + mapInfo->origin_, mapInfo->region_, mapInfo->isEntire()); } else { result = blitMgr().writeImage(