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; }