Example #1
0
 /// <summary>
 /// Page-locks the memory range specified by <c>p</c> and <c>bytesize</c> and maps it
 /// for the device(s) as specified by <c>Flags</c>. This memory range also is added
 /// to the same tracking mechanism as ::cuMemHostAlloc to automatically accelerate
 /// calls to functions such as <see cref="DriverAPINativeMethods.SynchronousMemcpy_v2.cuMemcpyHtoD_v2(BasicTypes.CUdeviceptr, VectorTypes.dim3[], BasicTypes.SizeT)"/>. Since the memory can be accessed
 /// directly by the device, it can be read or written with much higher bandwidth
 /// than pageable memory that has not been registered.  Page-locking excessive
 /// amounts of memory may degrade system performance, since it reduces the amount
 /// of memory available to the system for paging. As a result, this function is
 /// best used sparingly to register staging areas for data exchange between
 /// host and device.<para/>
 /// The pointer <c>p</c> and size <c>bytesize</c> must be aligned to the host page size (4 KB).<para/>
 /// The memory page-locked by this function must be unregistered with <see cref="Unregister"/>
 /// </summary>
 /// <param name="flags"></param>
 public void Register(CUMemHostRegisterFlags flags)
 {
     if (disposed)
     {
         throw new ObjectDisposedException(this.ToString());
     }
     res = DriverAPINativeMethods.MemoryManagement.cuMemHostRegister(_intPtr, _size, flags);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuMemHostRegister", res));
     if (res != CUResult.Success)
     {
         throw new CudaException(res);
     }
     _registered = true;
 }
Example #2
0
 public static extern CUResult cuMemHostRegister(IntPtr p, SizeT byteSize, CUMemHostRegisterFlags Flags);
		/// <summary>
		/// Page-locks the memory range specified by <c>p</c> and <c>bytesize</c> and maps it
		/// for the device(s) as specified by <c>Flags</c>. This memory range also is added
		/// to the same tracking mechanism as ::cuMemHostAlloc to automatically accelerate
		/// calls to functions such as <see cref="DriverAPINativeMethods.SynchronousMemcpy_v2.cuMemcpyHtoD_v2(BasicTypes.CUdeviceptr, VectorTypes.dim3[], BasicTypes.SizeT)"/>. Since the memory can be accessed 
		/// directly by the device, it can be read or written with much higher bandwidth 
		/// than pageable memory that has not been registered.  Page-locking excessive
		/// amounts of memory may degrade system performance, since it reduces the amount
		/// of memory available to the system for paging. As a result, this function is
		/// best used sparingly to register staging areas for data exchange between
		/// host and device.<para/>
		/// The pointer <c>p</c> and size <c>bytesize</c> must be aligned to the host page size (4 KB).<para/>
		/// The memory page-locked by this function must be unregistered with <see cref="Unregister"/>
		/// </summary>
		/// <param name="flags"></param>
		public void Register(CUMemHostRegisterFlags flags)
		{
			if (disposed) throw new ObjectDisposedException(this.ToString());
			res = DriverAPINativeMethods.MemoryManagement.cuMemHostRegister(_intPtr, _size, flags);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuMemHostRegister", res));
			if (res != CUResult.Success) throw new CudaException(res);
			_registered = true;
		}