Library/ManagedCuda/CudaArray2D.cs
/// <summary>
/// Copy data from this array to host
/// </summary>
/// <typeparam name="T">Host array base type</typeparam>
/// <param name="aHostDest">Destination</param>
Copy data from this array to host
Copy data from this array to host
public void CopyFromThisToHost<T>(T[] aHostDest) where T : struct
        {
            GCHandle handle = GCHandle.Alloc(aHostDest, GCHandleType.Pinned);
            try
            {
                CUDAMemCpy2D copyParams = new CUDAMemCpy2D();
                copyParams.dstHost = handle.AddrOfPinnedObject();
                copyParams.dstMemoryType = CUMemoryType.Host;
                copyParams.srcArray = _cuArray;
                copyParams.srcMemoryType = CUMemoryType.Array;
                copyParams.Height = _arrayDescriptor.Height;
                copyParams.WidthInBytes = _arrayDescriptor.Width * Marshal.SizeOf(typeof(T));
                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 CopyFromThisToHost < T > ( T [ ] aHostDest ) where T : struct { GCHandle handle = GCHandle . Alloc ( aHostDest , GCHandleType . Pinned ) ; try { CUDAMemCpy2D copyParams = new CUDAMemCpy2D ( ) ; copyParams . dstHost = handle . AddrOfPinnedObject ( ) ; copyParams . dstMemoryType = CUMemoryType . Host ; copyParams . srcArray = _cuArray ; copyParams . srcMemoryType = CUMemoryType . Array ; copyParams . Height = _arrayDescriptor . Height ; copyParams . WidthInBytes = _arrayDescriptor . Width * Marshal . SizeOf ( typeof ( T ) ) ; 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 data from this array to host
Copy data from this array to host
aHostDest
T[]
None
typeparam
Host array base type
Host array base type