Library/ManagedCuda/NPP/NPPImageBase.cs
/// <summary>
/// Copy from Host to device memory
/// </summary>
/// <param name="hostSrc">Source</param>
/// <param name="stride">Size of one image line in bytes with padding</param>
/// <param name="roi">ROI of source image</param>
///// <param name="height">Height in elements</param>
Copy from Host to device memory
Copy from Host to device memory
public void CopyToDeviceRoi(Array hostSrc, SizeT stride, NppiRect roi)
		{
			if (disposed) throw new ObjectDisposedException(this.ToString());
			GCHandle handle = GCHandle.Alloc(hostSrc, GCHandleType.Pinned);
			try
			{
				CUDAMemCpy2D copyParams = new CUDAMemCpy2D();
				copyParams.srcHost = handle.AddrOfPinnedObject();
				copyParams.srcPitch = stride;
				copyParams.srcXInBytes = roi.x * _typeSize * _channels;
				copyParams.srcY = roi.y;
				copyParams.srcMemoryType = CUMemoryType.Host;
				copyParams.dstDevice = _devPtr;
				copyParams.dstMemoryType = CUMemoryType.Device;
				copyParams.dstPitch = _pitch;
				copyParams.dstXInBytes = _pointRoi.x * _typeSize * _channels;
				copyParams.dstY = _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 CopyToDeviceRoi ( Array hostSrc , SizeT stride , NppiRect roi ) { if ( disposed ) throw new ObjectDisposedException ( this . ToString ( ) ) ; GCHandle handle = GCHandle . Alloc ( hostSrc , GCHandleType . Pinned ) ; try { CUDAMemCpy2D copyParams = new CUDAMemCpy2D ( ) ; copyParams . srcHost = handle . AddrOfPinnedObject ( ) ; copyParams . srcPitch = stride ; copyParams . srcXInBytes = roi . x * _typeSize * _channels ; copyParams . srcY = roi . y ; copyParams . srcMemoryType = CUMemoryType . Host ; copyParams . dstDevice = _devPtr ; copyParams . dstMemoryType = CUMemoryType . Device ; copyParams . dstPitch = _pitch ; copyParams . dstXInBytes = _pointRoi . x * _typeSize * _channels ; copyParams . dstY = _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 from Host to device memory
Copy from Host to device memory
hostSrc
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 source image
ROI of source image
height
Height in elements
Height in elements