From 2c62ce5544e0a6afb56ad576da26d14890c9fe97 Mon Sep 17 00:00:00 2001 From: foreman Date: Wed, 13 Apr 2016 13:27:37 -0400 Subject: [PATCH] P4 to Git Change 1257532 by gandryey@gera-ocl on 2016/04/13 13:18:22 SWDEV-92049 - Forum [2712399]: clEnqueueMapBuffer in parallel - Handle multiple unmapInfo structures of multiple simultaneous maps of the same buffer - The change didn't affect images path, since it requires extra handling Affected files ... ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_memobj.cpp#79 edit ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_svm.cpp#16 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#194 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#271 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpumemory.cpp#126 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuvirtual.cpp#399 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsamemory.cpp#25 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsamemory.hpp#10 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsavirtual.cpp#64 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palmemory.cpp#2 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#4 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/command.hpp#82 edit [ROCm/clr commit: 8874f1f4d6030def61fef515c31291523326a974] --- .../opencl/api/opencl/amdocl/cl_memobj.cpp | 44 ++++++++++--------- .../clr/opencl/api/opencl/amdocl/cl_svm.cpp | 4 +- 2 files changed, 26 insertions(+), 22 deletions(-) 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; }