From 458b50e5b89de1a71a952ee8647da68699b3e4df Mon Sep 17 00:00:00 2001
From: foreman
Date: Wed, 4 Jul 2018 15:50:23 -0400
Subject: [PATCH] P4 to Git Change 1576209 by vsytchen@vsytchen-win10 on
2018/07/04 15:37:58
SWDEV-79445 - OCL generic changes and code clean-up
1. Purge redundant AllocMapTarget function
ReviewBoardURL = http://ocltc.amd.com/reviews/r/15346/diff/
Affected files ...
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_memobj.cpp#84 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_svm.cpp#28 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#223 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#309 edit
[ROCm/clr commit: efc584a4b9c8ecb974c98233743ace6f43d8a0a5]
---
.../opencl/api/opencl/amdocl/cl_memobj.cpp | 20 ++++++++++++++++---
.../clr/opencl/api/opencl/amdocl/cl_svm.cpp | 4 ++--
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/projects/clr/opencl/api/opencl/amdocl/cl_memobj.cpp b/projects/clr/opencl/api/opencl/amdocl/cl_memobj.cpp
index 49e1852b94..b5df6490f9 100644
--- a/projects/clr/opencl/api/opencl/amdocl/cl_memobj.cpp
+++ b/projects/clr/opencl/api/opencl/amdocl/cl_memobj.cpp
@@ -3067,8 +3067,15 @@ RUNTIME_ENTRY_RET(void*, clEnqueueMapBuffer,
return (void*)0;
}
+ // Make sure we have memory for the command execution
+ device::Memory* mem = srcBuffer->getDeviceMemory(hostQueue.device());
+ if (NULL == mem) {
+ LogPrintfError("Can't allocate memory size - 0x%08X bytes!", srcBuffer->getSize());
+ *not_null(errcode_ret) = CL_MEM_OBJECT_ALLOCATION_FAILURE;
+ return NULL;
+ }
// Attempt to allocate the map target now (whether blocking or non-blocking)
- void* mapPtr = hostQueue.device().allocMapTarget(*srcBuffer, srcOffset, srcSize, map_flags);
+ void* mapPtr = mem->allocMapTarget(srcOffset, srcSize, map_flags);
if (NULL == mapPtr) {
*not_null(errcode_ret) = CL_MAP_FAILURE;
return NULL;
@@ -3332,9 +3339,16 @@ RUNTIME_ENTRY_RET(void*, clEnqueueMapImage,
return (void*)0;
}
+ // Make sure we have memory for the command execution
+ device::Memory* mem = srcImage->getDeviceMemory(hostQueue.device());
+ if (NULL == mem) {
+ LogPrintfError("Can't allocate memory size - 0x%08X bytes!", srcImage->getSize());
+ *not_null(errcode_ret) = CL_MEM_OBJECT_ALLOCATION_FAILURE;
+ return NULL;
+ }
// Attempt to allocate the map target now (whether blocking or non-blocking)
- void* mapPtr = hostQueue.device().allocMapTarget(*srcImage, srcOrigin, srcRegion, map_flags,
- image_row_pitch, image_slice_pitch);
+ void* mapPtr = mem->allocMapTarget(srcOrigin, srcRegion, map_flags,
+ image_row_pitch, image_slice_pitch);
if (NULL == mapPtr) {
*not_null(errcode_ret) = CL_MAP_FAILURE;
return NULL;
diff --git a/projects/clr/opencl/api/opencl/amdocl/cl_svm.cpp b/projects/clr/opencl/api/opencl/amdocl/cl_svm.cpp
index 3b00bf1c64..229452ee10 100644
--- a/projects/clr/opencl/api/opencl/amdocl/cl_svm.cpp
+++ b/projects/clr/opencl/api/opencl/amdocl/cl_svm.cpp
@@ -720,10 +720,10 @@ RUNTIME_ENTRY(cl_int, clEnqueueSVMMap,
device::Memory* mem = svmMem->getDeviceMemory(queue->device());
if (NULL == mem) {
LogPrintfError("Can't allocate memory size - 0x%08X bytes!", svmMem->getSize());
- return CL_OUT_OF_RESOURCES;
+ return CL_MEM_OBJECT_ALLOCATION_FAILURE;
}
// Attempt to allocate the map target now (whether blocking or non-blocking)
- void* mapPtr = (queue->device()).allocMapTarget(*svmMem, srcOffset, srcSize, map_flags);
+ void* mapPtr = mem->allocMapTarget(srcOffset, srcSize, map_flags);
if (NULL == mapPtr || mapPtr != svm_ptr) {
return CL_OUT_OF_RESOURCES;
}