/// <summary> /// Copies data from device memory to host memory asynchronously. /// </summary> /// <param name="src">The source pointer</param> /// <param name="dest">The destination buffer</param> /// <param name="stream">The stream in which to queue the copy operation</param> public static void CopyAsync <T>(DeviceBuffer src, HostBuffer1D <T> dest, Stream stream) where T : struct { if (src.ptr == DevicePtr.Zero || dest.IsNull()) { throw new NullPointerException(); } if (src.sizeInBytes != (uint)dest.SizeInBytes) { throw new ArgumentException("The source and destination sizes do not match."); } CudaUtil.Call(cuMemcpyDtoHAsync(dest.ptr, src.ptr.ptr, (uint)dest.SizeInBytes, stream.Handle)); }
/// <summary> /// Copies data from host memory to device memory. /// </summary> /// <param name="src">The source buffer</param> /// <param name="dest">The destination pointer</param> public static void Copy <T>(HostBuffer1D <T> src, DeviceBuffer dest) where T : struct { if (src.IsNull() || dest.ptr == DevicePtr.Zero) { throw new NullPointerException(); } if (src.SizeInBytes != dest.SizeInBytes) { throw new ArgumentException("The source and destination sizes do not match."); } CudaUtil.Call(cuMemcpyHtoD(dest.ptr.ptr, src.ptr, (uint)src.SizeInBytes)); }