From bb433385dbac49d4825b35c0f9ac598b2744f43b Mon Sep 17 00:00:00 2001 From: foreman Date: Wed, 3 Feb 2016 18:24:32 -0500 Subject: [PATCH] P4 to Git Change 1234162 by xcui@merged_opencl_jxcwin on 2016/02/03 18:17:16 SWDEV-84299 - added support for svmmemcpy to handle the situation that src/dst pointers may or may not in the SVM space code review: http://ocltc.amd.com/reviews/r/9645/ precheckin: http://ocltc.amd.com:8111/viewModification.html?modId=66292&personal=true&buildTypeId=&tab=vcsModificationBuilds&show_all_builds=true Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuvirtual.cpp#394 edit --- rocclr/runtime/device/gpu/gpuvirtual.cpp | 51 ++++++++++++++++-------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/rocclr/runtime/device/gpu/gpuvirtual.cpp b/rocclr/runtime/device/gpu/gpuvirtual.cpp index f79c80a576..ff284e6f3e 100644 --- a/rocclr/runtime/device/gpu/gpuvirtual.cpp +++ b/rocclr/runtime/device/gpu/gpuvirtual.cpp @@ -1016,32 +1016,51 @@ VirtualGPU::submitSvmCopyMemory(amd::SvmCopyMemoryCommand& vcmd) //no op for FGS supported device if (!dev().isFineGrainedSystem()) { - amd::Memory* srcMem = amd::SvmManager::FindSvmBuffer(vcmd.src()); - amd::Memory* dstMem = amd::SvmManager::FindSvmBuffer(vcmd.dst()); - if (NULL == srcMem || NULL == dstMem) { - vcmd.setStatus(CL_INVALID_OPERATION); - return; - } - amd::Coord3D srcOrigin(0, 0, 0); amd::Coord3D dstOrigin(0, 0, 0); amd::Coord3D size(vcmd.srcSize(), 1, 1); amd::BufferRect srcRect; amd::BufferRect dstRect; - srcOrigin.c[0] = static_cast(vcmd.src()) - static_cast
(srcMem->getSvmPtr()); - dstOrigin.c[0] = static_cast(vcmd.dst()) - static_cast
(dstMem->getSvmPtr()); - if (!(srcMem->validateRegion(srcOrigin, size)) || !(dstMem->validateRegion(dstOrigin, size))) { - vcmd.setStatus(CL_INVALID_OPERATION); - return; + bool result = false; + amd::Memory* srcMem = amd::SvmManager::FindSvmBuffer(vcmd.src()); + amd::Memory* dstMem = amd::SvmManager::FindSvmBuffer(vcmd.dst()); + if (NULL != srcMem) { + srcMem->commitSvmMemory(); + srcOrigin.c[0] = static_cast(vcmd.src()) - static_cast
(srcMem->getSvmPtr()); + if (!(srcMem->validateRegion(srcOrigin, size))) { + vcmd.setStatus(CL_INVALID_OPERATION); + return; + } + } + if (NULL != dstMem) { + dstMem->commitSvmMemory(); + dstOrigin.c[0] = static_cast(vcmd.dst()) - static_cast
(dstMem->getSvmPtr()); + if (!(dstMem->validateRegion(dstOrigin, size))) { + vcmd.setStatus(CL_INVALID_OPERATION); + return; + } } - bool entire = srcMem->isEntirelyCovered(srcOrigin, size) && - dstMem->isEntirelyCovered(dstOrigin, size); + if (NULL == srcMem && NULL != dstMem) { //src not in svm space + gpu::Memory* memory = dev().getGpuMemory(dstMem); + result = blitMgr().writeBuffer(vcmd.src(), *memory, + dstOrigin, size, dstMem->isEntirelyCovered(dstOrigin, size)); + } + else if (NULL != srcMem && NULL == dstMem) { //dst not in svm space + gpu::Memory* memory = dev().getGpuMemory(srcMem); + result = blitMgr().readBuffer(*memory, vcmd.dst(), + srcOrigin, size, srcMem->isEntirelyCovered(srcOrigin, size)); + } + else if (NULL != srcMem && NULL != dstMem) { //both not in svm space + bool entire = srcMem->isEntirelyCovered(srcOrigin, size) && + dstMem->isEntirelyCovered(dstOrigin, size); + result = copyMemory(type, *srcMem, *dstMem, entire, srcOrigin, dstOrigin, + size, srcRect, dstRect); + } - if (!copyMemory(type, *srcMem, *dstMem, entire, - srcOrigin, dstOrigin, size, srcRect, dstRect)) { + if (!result) { vcmd.setStatus(CL_INVALID_OPERATION); } }