コード例 #1
0
        /// <summary>
        /// Creates a new buffer and allocates the specified ammount of memory.
        /// </summary>
        /// <param name="sizeInBytes">The number of bytes to allocate for the buffer</param>
        /// <returns>A pointer to the allocated buffer</returns>
        public static IntPtr Alloc(uint sizeInBytes)
        {
            IntPtr result = IntPtr.Zero;

            CudaUtil.Call(CudaMem.cuMemAllocHost(out result, (UInt32)sizeInBytes));
            return(result);
        }
コード例 #2
0
        public static HostBuffer1D <T> Alloc(int length)
        {
            HostBuffer1D <T> result   = new HostBuffer1D <T>();
            uint             elemSize = (uint)Marshal.SizeOf(typeof(T));

            CudaUtil.Call(CudaMem.cuMemAllocHost(out result.ptr, elemSize * (uint)length));
            result.length = length;
            return(result);
        }