コード例 #1
0
        /// <summary>
        /// Creates a new CudaPageLockedHostMemory and allocates the memory on host. Using cuMemHostAlloc
        /// </summary>
        /// <param name="size">In elements</param>
        /// <param name="allocFlags"></param>
        public CudaPageLockedHostMemory(SizeT size, CUMemHostAllocFlags allocFlags)
        {
            _intPtr   = new IntPtr();
            _size     = size;
            _typeSize = (SizeT)Marshal.SizeOf(typeof(T));

            res = DriverAPINativeMethods.MemoryManagement.cuMemHostAlloc(ref _intPtr, _typeSize * size, allocFlags);
            Debug.Write("");            //Line(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuMemHostAlloc", res));
            if (res != CUResult.Success)
            {
                throw new CudaException(res);
            }
            _isOwner = true;
        }
コード例 #2
0
        /// <summary>
        /// Passes back the flags that were specified when allocating the pinned host buffer
        /// </summary>
        /// <returns></returns>
        public CUMemHostAllocFlags GetAllocFlags()
        {
            if (disposed)
            {
                throw new ObjectDisposedException(this.ToString());
            }
            CUMemHostAllocFlags flags = new CUMemHostAllocFlags();

            res = DriverAPINativeMethods.MemoryManagement.cuMemHostGetFlags(ref flags, _intPtr);
            Debug.Write("");//Line(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuMemHostGetDevicePointer", res));
            if (res != CUResult.Success)
            {
                throw new CudaException(res);
            }
            return(flags);
        }
コード例 #3
0
ファイル: DriverAPI.cs プロジェクト: lvaleriu/managedCuda
 public static extern CUResult cuMemHostGetFlags(ref CUMemHostAllocFlags pFlags, IntPtr p);
コード例 #4
0
ファイル: DriverAPI.cs プロジェクト: lvaleriu/managedCuda
 public static extern CUResult cuMemHostAlloc(ref IntPtr pp, SizeT bytesize, CUMemHostAllocFlags Flags);
コード例 #5
0
        /// <summary>
        /// Creates a new CudaPageLockedHostMemory3D and allocates the memory on host. Using cuMemHostAlloc
        /// </summary>
        /// <param name="width">In elements</param>
        /// <param name="pitchInBytes">Width including alignment in bytes</param>
        /// <param name="height">In elements</param>
        /// <param name="depth">In elements</param>
        /// <param name="allocFlags"></param>
        public CudaPageLockedHostMemory3D(SizeT width, SizeT pitchInBytes, SizeT height, SizeT depth, CUMemHostAllocFlags allocFlags)
        {
            _intPtr       = new IntPtr();
            _width        = width;
            _pitchInBytes = pitchInBytes;
            _height       = height;
            _depth        = depth;
            _typeSize     = (SizeT)Marshal.SizeOf(typeof(T));
            _sizeInBytes  = _pitchInBytes * _height * _depth;

            if (_typeSize * width > _pitchInBytes)
            {
                throw new ArgumentException("pitchInBytes must be greater or equal to width * sizeof(T)", "pitchInBytes");
            }

            res = DriverAPINativeMethods.MemoryManagement.cuMemHostAlloc(ref _intPtr, _sizeInBytes, allocFlags);
            Debug.Write("");//Line(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuMemHostAlloc", res));
            if (res != CUResult.Success)
            {
                throw new CudaException(res);
            }
        }
コード例 #6
0
 /// <summary>
 /// Creates a new CudaPageLockedHostMemory3D and allocates the memory on host. Using cuMemHostAlloc without flags.<para/>
 /// Pitch is assumed to be width * sizeof(T). Using cuMemHostAlloc.
 /// </summary>
 /// <param name="width">In elements</param>
 /// <param name="height">In elements</param>
 /// <param name="depth">In elements</param>
 /// <param name="allocFlags"></param>
 public CudaPageLockedHostMemory3D(SizeT width, SizeT height, SizeT depth, CUMemHostAllocFlags allocFlags)
     : this(width, width *(SizeT)Marshal.SizeOf(typeof(T)), height, depth, allocFlags)
 {
 }