Library/ManagedCuda/CudaPitchedDeviceVariable.cs
/// <summary>
/// Copy from host to device memory
/// </summary>
/// <param name="hostSrc">Source</param>
/// <param name="SrcXInBytes">Source X in bytes</param>
/// <param name="SrcY">Source Y</param>
/// <param name="DestXInBytes">Destination X in bytes</param>
/// <param name="DestY">Destination Y</param>
/// <param name="widthInBytes">Width in bytes</param>
/// <param name="height">Height in elements</param>
/// <param name="SrcPitch">Source pitch</param>
/// <param name="DestPitch">Destination pitch</param>
Copy from host to device memory
Copy from host to device memory
public void CopyToDevice(T[] hostSrc, SizeT SrcXInBytes, SizeT SrcY, SizeT DestXInBytes, SizeT DestY, SizeT widthInBytes, SizeT height, SizeT SrcPitch, SizeT DestPitch)
		{
			if (disposed) throw new ObjectDisposedException(this.ToString());
			GCHandle handle = GCHandle.Alloc(hostSrc, GCHandleType.Pinned);
			try
			{
				CUDAMemCpy2D copyParams = new CUDAMemCpy2D();
				copyParams.srcHost = handle.AddrOfPinnedObject();
				copyParams.srcMemoryType = CUMemoryType.Host;
				copyParams.srcPitch = SrcPitch;
				copyParams.srcXInBytes = SrcXInBytes;
				copyParams.srcY = SrcY;
				copyParams.dstDevice = _devPtr;
				copyParams.dstMemoryType = CUMemoryType.Device;
				copyParams.dstPitch = DestPitch;
				copyParams.dstXInBytes = DestXInBytes;
				copyParams.dstY = DestY;
				copyParams.Height = height;
				copyParams.WidthInBytes = widthInBytes;
				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 CopyToDevice ( T [ ] hostSrc , SizeT SrcXInBytes , SizeT SrcY , SizeT DestXInBytes , SizeT DestY , SizeT widthInBytes , SizeT height , SizeT SrcPitch , SizeT DestPitch ) { if ( disposed ) throw new ObjectDisposedException ( this . ToString ( ) ) ; GCHandle handle = GCHandle . Alloc ( hostSrc , GCHandleType . Pinned ) ; try { CUDAMemCpy2D copyParams = new CUDAMemCpy2D ( ) ; copyParams . srcHost = handle . AddrOfPinnedObject ( ) ; copyParams . srcMemoryType = CUMemoryType . Host ; copyParams . srcPitch = SrcPitch ; copyParams . srcXInBytes = SrcXInBytes ; copyParams . srcY = SrcY ; copyParams . dstDevice = _devPtr ; copyParams . dstMemoryType = CUMemoryType . Device ; copyParams . dstPitch = DestPitch ; copyParams . dstXInBytes = DestXInBytes ; copyParams . dstY = DestY ; copyParams . Height = height ; copyParams . WidthInBytes = widthInBytes ; 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
T[]
None
SrcXInBytes
SizeT
Source X in bytes
Source X in bytes
SrcY
SizeT
None
DestXInBytes
SizeT
Destination X in bytes
Destination X in bytes
DestY
SizeT
None
widthInBytes
SizeT
Width in bytes
Width in bytes
height
SizeT
Height in elements
Height in elements
SrcPitch
SizeT
None
DestPitch
SizeT
None