Library/ManagedCuda/CudaDeviceVariable.cs
/// <summary>
/// Copy data from device to host memory
/// </summary>
/// <param name="dest">Destination pointer to host memory</param>
Copy data from device to host memory
Copy data from device to host memory
public void CopyToHost(T[] dest)
		{
			if (disposed) throw new ObjectDisposedException(this.ToString());
			SizeT aSizeInBytes = MinSize(dest.LongLength) * _typeSize;
			GCHandle handle = GCHandle.Alloc(dest, GCHandleType.Pinned);
			CUResult res;
			try
			{
				IntPtr ptr = handle.AddrOfPinnedObject();
				res = DriverAPINativeMethods.SynchronousMemcpy_v2.cuMemcpyDtoH_v2(ptr, _devPtr, aSizeInBytes);
				Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuMemcpyDtoH", res));
			}
			finally
			{
				handle.Free();
			}
			if (res != CUResult.Success)
				throw new CudaException(res);
		}
public void CopyToHost ( T [ ] dest ) { if ( disposed ) throw new ObjectDisposedException ( this . ToString ( ) ) ; SizeT aSizeInBytes = MinSize ( dest . LongLength ) * _typeSize ; GCHandle handle = GCHandle . Alloc ( dest , GCHandleType . Pinned ) ; CUResult res ; try { IntPtr ptr = handle . AddrOfPinnedObject ( ) ; res = DriverAPINativeMethods . SynchronousMemcpy_v2 . cuMemcpyDtoH_v2 ( ptr , _devPtr , aSizeInBytes ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; } finally { handle . Free ( ) ; } if ( res != CUResult . Success ) throw new CudaException ( res ) ; }
Copy data from device to host memory
Copy data from device to host memory
dest
T[]
Destination pointer to host memory
Destination pointer to host memory