diff --git a/GPU/GPUTracking/Base/opencl/GPUReconstructionOCL.cxx b/GPU/GPUTracking/Base/opencl/GPUReconstructionOCL.cxx index 1be120db35bd8..ea14c2d1577c4 100644 --- a/GPU/GPUTracking/Base/opencl/GPUReconstructionOCL.cxx +++ b/GPU/GPUTracking/Base/opencl/GPUReconstructionOCL.cxx @@ -367,7 +367,7 @@ int32_t GPUReconstructionOCL::InitDevice_Runtime() GPUErrorReturn("Error allocating Page Locked Host Memory"); } - mDeviceMemoryBase = ((void**)mHostMemoryBase)[0]; + mDeviceMemoryBase = mInternals->mem_gpu_ptr = ((void**)mHostMemoryBase)[0]; mDeviceConstantMem = (GPUConstantMem*)((void**)mHostMemoryBase)[1]; if (GetProcessingSettings().debugLevel >= 1) { @@ -442,11 +442,11 @@ size_t GPUReconstructionOCL::GPUMemCpy(void* dst, const void* src, size_t size, GPUChkErr(clEnqueueMarkerWithWaitList(mInternals->command_queue[stream == -1 ? 0 : stream], nEvents, evList->getEventList(), ev->getEventList())); } } else if (toGPU == -2) { - GPUChkErr(clEnqueueCopyBuffer(mInternals->command_queue[stream == -1 ? 0 : stream], mInternals->mem_gpu, mInternals->mem_gpu, (char*)src - (char*)mDeviceMemoryBase, (char*)dst - (char*)mDeviceMemoryBase, size, nEvents, evList->getEventList(), ev->getEventList())); + GPUChkErr(clEnqueueCopyBuffer(mInternals->command_queue[stream == -1 ? 0 : stream], mInternals->mem_gpu, mInternals->mem_gpu, (char*)src - (char*)mInternals->mem_gpu_ptr, (char*)dst - (char*)mInternals->mem_gpu_ptr, size, nEvents, evList->getEventList(), ev->getEventList())); } else if (toGPU) { - GPUChkErr(clEnqueueWriteBuffer(mInternals->command_queue[stream == -1 ? 0 : stream], mInternals->mem_gpu, stream == -1, (char*)dst - (char*)mDeviceMemoryBase, size, src, nEvents, evList->getEventList(), ev->getEventList())); + GPUChkErr(clEnqueueWriteBuffer(mInternals->command_queue[stream == -1 ? 0 : stream], mInternals->mem_gpu, stream == -1, (char*)dst - (char*)mInternals->mem_gpu_ptr, size, src, nEvents, evList->getEventList(), ev->getEventList())); } else { - GPUChkErr(clEnqueueReadBuffer(mInternals->command_queue[stream == -1 ? 0 : stream], mInternals->mem_gpu, stream == -1, (char*)src - (char*)mDeviceMemoryBase, size, dst, nEvents, evList->getEventList(), ev->getEventList())); + GPUChkErr(clEnqueueReadBuffer(mInternals->command_queue[stream == -1 ? 0 : stream], mInternals->mem_gpu, stream == -1, (char*)src - (char*)mInternals->mem_gpu_ptr, size, dst, nEvents, evList->getEventList(), ev->getEventList())); } if (GetProcessingSettings().serializeGPU & 2) { GPUDebug(("GPUMemCpy " + std::to_string(toGPU)).c_str(), stream, true); diff --git a/GPU/GPUTracking/Base/opencl/GPUReconstructionOCLIncludesHost.h b/GPU/GPUTracking/Base/opencl/GPUReconstructionOCLIncludesHost.h index c79b021e80308..b6f71f9c451b1 100644 --- a/GPU/GPUTracking/Base/opencl/GPUReconstructionOCLIncludesHost.h +++ b/GPU/GPUTracking/Base/opencl/GPUReconstructionOCLIncludesHost.h @@ -46,6 +46,7 @@ struct GPUReconstructionOCLInternals { cl_context context; cl_command_queue command_queue[constants::GPU_MAX_STREAMS]; cl_mem mem_gpu; + void* mem_gpu_ptr; // Device address of mem_gpu, base of the offsets into it (a slave's mDeviceMemoryBase is offset into it) cl_mem mem_constant; cl_mem mem_host; cl_program program; diff --git a/GPU/GPUTracking/Base/opencl/GPUReconstructionOCLKernelsSpecialize.inc b/GPU/GPUTracking/Base/opencl/GPUReconstructionOCLKernelsSpecialize.inc index d5b0338aecbd9..279ab30fd1717 100644 --- a/GPU/GPUTracking/Base/opencl/GPUReconstructionOCLKernelsSpecialize.inc +++ b/GPU/GPUTracking/Base/opencl/GPUReconstructionOCLKernelsSpecialize.inc @@ -16,5 +16,5 @@ template <> inline void GPUReconstructionOCL::runKernelBackend(const krnlSetupTime& _xyz, void* const& ptr, uint64_t const& size) { cl_int4 val0 = {0, 0, 0, 0}; - GPUChkErr(clEnqueueFillBuffer(mInternals->command_queue[_xyz.x.stream], mInternals->mem_gpu, &val0, sizeof(val0), (char*)ptr - (char*)mDeviceMemoryBase, (size + sizeof(val0) - 1) & ~(sizeof(val0) - 1), _xyz.z.evList == nullptr ? 0 : _xyz.z.nEvents, _xyz.z.evList->getEventList(), _xyz.z.ev->getEventList())); + GPUChkErr(clEnqueueFillBuffer(mInternals->command_queue[_xyz.x.stream], mInternals->mem_gpu, &val0, sizeof(val0), (char*)ptr - (char*)mInternals->mem_gpu_ptr, (size + sizeof(val0) - 1) & ~(sizeof(val0) - 1), _xyz.z.evList == nullptr ? 0 : _xyz.z.nEvents, _xyz.z.evList->getEventList(), _xyz.z.ev->getEventList())); }