diff --git a/projects/clr/opencl/api/opencl/amdocl/cl_memobj.cpp b/projects/clr/opencl/api/opencl/amdocl/cl_memobj.cpp index 222a0a3df0..c927447a13 100644 --- a/projects/clr/opencl/api/opencl/amdocl/cl_memobj.cpp +++ b/projects/clr/opencl/api/opencl/amdocl/cl_memobj.cpp @@ -3314,6 +3314,14 @@ RUNTIME_ENTRY_RET(void *, clEnqueueMapBuffer, ( return (void*) 0; } + // Attempt to allocate the map target now (whether blocking or non-blocking) + void* mapPtr = hostQueue.device().allocMapTarget( + *srcBuffer, srcOffset, srcSize, map_flags); + if (NULL == mapPtr) { + *not_null(errcode_ret) = CL_MAP_FAILURE; + return NULL; + } + // Allocate a map command for the queue thread amd::MapMemoryCommand *command = new amd::MapMemoryCommand( hostQueue, @@ -3323,7 +3331,10 @@ RUNTIME_ENTRY_RET(void *, clEnqueueMapBuffer, ( map_flags, blocking_map ? true : false, srcOffset, - srcSize); + srcSize, + nullptr, + nullptr, + mapPtr); if (command == NULL) { *not_null(errcode_ret) = CL_OUT_OF_HOST_MEMORY; return NULL; @@ -3343,15 +3354,6 @@ RUNTIME_ENTRY_RET(void *, clEnqueueMapBuffer, ( hostQueue.finish(); } - // Attempt to allocate the map target now (whether blocking or non-blocking) - void* mapPtr = hostQueue.device().allocMapTarget( - *srcBuffer, srcOffset, srcSize, map_flags); - if (NULL == mapPtr) { - delete command; - *not_null(errcode_ret) = CL_MAP_FAILURE; - return NULL; - } - // Send the map command for processing command->enqueue(); @@ -3598,6 +3600,14 @@ RUNTIME_ENTRY_RET(void *, clEnqueueMapImage, ( return (void*) 0; } + // 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); + if (NULL == mapPtr) { + *not_null(errcode_ret) = CL_MAP_FAILURE; + return NULL; + } + // Allocate a map command for the queue thread amd::MapMemoryCommand *command = new amd::MapMemoryCommand( hostQueue, @@ -3607,7 +3617,10 @@ RUNTIME_ENTRY_RET(void *, clEnqueueMapImage, ( map_flags, blocking_map ? true : false, srcOrigin, - srcRegion); + srcRegion, + nullptr, + nullptr, + mapPtr); if (command == NULL) { *not_null(errcode_ret) = CL_OUT_OF_HOST_MEMORY; return NULL; @@ -3627,15 +3640,6 @@ RUNTIME_ENTRY_RET(void *, clEnqueueMapImage, ( hostQueue.finish(); } - // 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); - if (NULL == mapPtr) { - delete command; - *not_null(errcode_ret) = CL_MAP_FAILURE; - return NULL; - } - // Send the map command for processing command->enqueue(); diff --git a/projects/clr/opencl/api/opencl/amdocl/cl_svm.cpp b/projects/clr/opencl/api/opencl/amdocl/cl_svm.cpp index acc1a346be..241c6e2239 100644 --- a/projects/clr/opencl/api/opencl/amdocl/cl_svm.cpp +++ b/projects/clr/opencl/api/opencl/amdocl/cl_svm.cpp @@ -797,7 +797,7 @@ RUNTIME_ENTRY(cl_int, clEnqueueSVMMap, ( } amd::Command* command = new amd::SvmMapMemoryCommand( - hostQueue, eventWaitList, svmMem, size, offset, map_flags); + hostQueue, eventWaitList, svmMem, size, offset, map_flags, svm_ptr); if (command == NULL) { return CL_OUT_OF_HOST_MEMORY; } @@ -910,7 +910,7 @@ RUNTIME_ENTRY(cl_int, clEnqueueSVMUnmap, ( } amd::Command* command = new amd::SvmUnmapMemoryCommand( - hostQueue, eventWaitList, svmMem); + hostQueue, eventWaitList, svmMem, svm_ptr); if (command == NULL) { return CL_OUT_OF_HOST_MEMORY; }