コード例 #1
0
ファイル: CudaMem.cs プロジェクト: rpmiller4/FractalsInNet
        /// <summary>
        /// Copies data from host memory to a cuda array asynchronously. No size checks are performed, it is
        /// up to the programmer to ensure the destination is large enough to hold the data.
        /// </summary>
        /// <param name="src">The source buffer</param>
        /// <param name="dest">The destination pointer</param>
        /// <param name="stream">The stream in which to queue the copy operation</param>
        public static void CopyAsync <T>(HostBuffer2D <T> src, CudaArray dest, Stream stream) where T : struct
        {
            if (src.IsNull() || dest.IsNull())
            {
                throw new NullPointerException();
            }

            CudaUtil.Call(CudaMem.memcpy2DAsyncHelper(
                              MemoryType.Host, 0, 0, src.ptr, (uint)src.RowSizeBytes,
                              MemoryType.Array, 0, 0, dest.handle, 0,
                              (uint)src.RowSizeBytes, (uint)src.height, stream.Handle
                              ));
        }
コード例 #2
0
ファイル: CudaMem.cs プロジェクト: rpmiller4/FractalsInNet
        /// <summary>
        /// Copies data from host memory to device memory asynchronously. No size checks are performed, it is
        /// up to the programmer to ensure the destination is large enough to hold the data.
        /// </summary>
        /// <param name="src">The source pointer, must be to page locked memory</param>
        /// <param name="dest">The destination pointer</param>
        /// <param name="widthInBytes">The size of each row in bytes</param>
        /// <param name="height">The number of rows</param>
        /// <param name="stream">The stream in which to queue the copy operation</param>
        public static void CopyRaw2DAsync(IntPtr srcPtr, DevicePtr2D dest, IntPtr widthInBytes, IntPtr height, Stream stream)
        {
            if (srcPtr == IntPtr.Zero || dest == DevicePtr2D.Zero)
            {
                throw new NullPointerException();
            }

            CudaUtil.Call(CudaMem.memcpy2DAsyncHelper(
                              MemoryType.Host, 0, 0, srcPtr, (uint)widthInBytes,
                              MemoryType.Device, 0, 0, (IntPtr)dest.ptr, (uint)dest.Pitch,
                              (uint)widthInBytes, (uint)height, stream.Handle
                              ));
        }
コード例 #3
0
ファイル: CudaMem.cs プロジェクト: rpmiller4/FractalsInNet
        /// <summary>
        /// Copies data from host memory to device memory asynchronously.
        /// </summary>
        /// <param name="src">The source buffer</param>
        /// <param name="dest">The destination buffer</param>
        /// <param name="stream">The stream in which to queue the copy operation</param>
        public static void Copy <T>(HostBuffer2D <T> src, DeviceBuffer2D dest, Stream stream) where T : struct
        {
            if (src.IsNull() || dest.ptr == DevicePtr2D.Zero)
            {
                throw new NullPointerException();
            }
            if ((uint)src.RowSizeBytes != dest.WidthInBytes || (uint)src.Height != dest.Height)
            {
                throw new ArgumentException("The source and destination sizes do not match.");
            }

            CudaUtil.Call(CudaMem.memcpy2DAsyncHelper(
                              MemoryType.Host, 0, 0, src.ptr, (uint)src.RowSizeBytes,
                              MemoryType.Device, 0, 0, (IntPtr)dest.ptr.ptr, dest.ptr.pitch,
                              (uint)src.RowSizeBytes, (uint)src.height, stream.Handle
                              ));
        }