Library/ManagedCuda/NPP/NPPImageBase.cs
/// <summary>
/// Copy data from this device to host memory
/// </summary>
/// <param name="hostDest">Destination</param>
/// <param name="stride">Size of one image line in bytes with padding</param>
/// <param name="roi">ROI of destination image</param>
Copy data from this device to host memory
Copy data from this device to host memory
public void CopyToHostRoi(Array hostDest, SizeT stride, NppiRect roi)
		{
			if (disposed) throw new ObjectDisposedException(this.ToString());
			GCHandle handle = GCHandle.Alloc(hostDest, GCHandleType.Pinned);
			try
			{
				CUDAMemCpy2D copyParams = new CUDAMemCpy2D();
				copyParams.dstHost = handle.AddrOfPinnedObject();
				copyParams.dstPitch = stride;
				copyParams.dstXInBytes = roi.x * _typeSize * _channels;
				copyParams.dstY = roi.y;
				copyParams.dstMemoryType = CUMemoryType.Host;
				copyParams.srcDevice = _devPtr;
				copyParams.srcMemoryType = CUMemoryType.Device;
				copyParams.srcPitch = _pitch;
				copyParams.srcXInBytes = _pointRoi.x * _typeSize * _channels;
				copyParams.srcY = _pointRoi.y;
				copyParams.Height = _sizeRoi.height;
				copyParams.WidthInBytes = _sizeRoi.width * _typeSize * _channels;
				res = DriverAPINativeMethods.SynchronousMemcpy_v2.cuMemcpy2D_v2(ref copyParams);
				Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuMemcpy2D", res));
			}
			finally
			{
				handle.Free();
			}
			if (res != CUResult.Success)
				throw new CudaException(res);
		}
public void CopyToHostRoi ( Array hostDest , SizeT stride , NppiRect roi ) { if ( disposed ) throw new ObjectDisposedException ( this . ToString ( ) ) ; GCHandle handle = GCHandle . Alloc ( hostDest , GCHandleType . Pinned ) ; try { CUDAMemCpy2D copyParams = new CUDAMemCpy2D ( ) ; copyParams . dstHost = handle . AddrOfPinnedObject ( ) ; copyParams . dstPitch = stride ; copyParams . dstXInBytes = roi . x * _typeSize * _channels ; copyParams . dstY = roi . y ; copyParams . dstMemoryType = CUMemoryType . Host ; copyParams . srcDevice = _devPtr ; copyParams . srcMemoryType = CUMemoryType . Device ; copyParams . srcPitch = _pitch ; copyParams . srcXInBytes = _pointRoi . x * _typeSize * _channels ; copyParams . srcY = _pointRoi . y ; copyParams . Height = _sizeRoi . height ; copyParams . WidthInBytes = _sizeRoi . width * _typeSize * _channels ; res = DriverAPINativeMethods . SynchronousMemcpy_v2 . cuMemcpy2D_v2 ( ref copyParams ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; } finally { handle . Free ( ) ; } if ( res != CUResult . Success ) throw new CudaException ( res ) ; }
Copy data from this device to host memory
Copy data from this device to host memory
hostDest
Array
None
stride
SizeT
Size of one image line in bytes with padding
Size of one image line in bytes with padding
roi
NppiRect
ROI of destination image
ROI of destination image