Library/ManagedCuda/CudaDeviceVariable.cs
/// <summary>
/// Copy from Host to device memory. Array elements can be of any (value)type, but total size in bytes must match to allocated device memory.
/// </summary>
/// <param name="hostSrc">Source</param>
Copy from Host to device memory. Array elements can be of any (value)type, but total size in bytes must match to allocated device memory.
Copy from Host to device memory . Array elements can be of any ( value ) type but total size in bytes must match to allocated device memory .
public void CopyToDevice(Array hostSrc)
		{
			if (disposed) throw new ObjectDisposedException(this.ToString());
			SizeT aSizeInBytes = _size * _typeSize;
			GCHandle handle = GCHandle.Alloc(hostSrc, GCHandleType.Pinned);
			try
			{
				IntPtr ptr = handle.AddrOfPinnedObject();
				res = DriverAPINativeMethods.SynchronousMemcpy_v2.cuMemcpyHtoD_v2(_devPtr, ptr, aSizeInBytes);
				Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuMemcpyHtoD", res));
			}
			finally
			{
				handle.Free();
			}
			if (res != CUResult.Success)
				throw new CudaException(res);
		}
public void CopyToDevice ( Array hostSrc ) { if ( disposed ) throw new ObjectDisposedException ( this . ToString ( ) ) ; SizeT aSizeInBytes = _size * _typeSize ; GCHandle handle = GCHandle . Alloc ( hostSrc , GCHandleType . Pinned ) ; try { IntPtr ptr = handle . AddrOfPinnedObject ( ) ; res = DriverAPINativeMethods . SynchronousMemcpy_v2 . cuMemcpyHtoD_v2 ( _devPtr , ptr , aSizeInBytes ) ; 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