cudaError_t cudaHostRegister ( void *  ptr,
size_t  size,
unsigned int  flags 
)

Page-locks the memory range specified by ptr and size and maps it for the device(s) as specified by flags. This memory range also is added to the same tracking mechanism as cudaHostAlloc() to automatically accelerate calls to functions such as cudaMemcpy(). 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.

The flags parameter enables different options to be specified that affect the allocation, as follows.

  • cudaHostRegisterPortable: The memory returned by this call will be considered as pinned memory by all CUDA contexts, not just the one that performed the allocation.

  • cudaHostRegisterMapped: Maps the allocation into the CUDA address space. The device pointer to the memory may be obtained by calling cudaHostGetDevicePointer(). This feature is available only on GPUs with compute capability greater than or equal to 1.1.

All of these flags are orthogonal to one another: a developer may page-lock memory that is portable or mapped with no restrictions.

The CUDA context must have been created with the cudaMapHost flag in order for the cudaHostRegisterMapped flag to have any effect.

The cudaHostRegisterMapped flag may be specified on CUDA contexts for devices that do not support mapped pinned memory. The failure is deferred to cudaHostGetDevicePointer() because the memory may be mapped into other CUDA contexts via the cudaHostRegisterPortable flag.

The pointer ptr and size size must be aligned to the host page size (4 KB).

The memory page-locked by this function must be unregistered with cudaHostUnregister().

Parameters:
ptr - Host pointer to memory to page-lock
size - Size in bytes of the address range to page-lock in bytes
flags - Flags for allocation request
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorMemoryAllocation
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaHostUnregister, cudaHostGetFlags, cudaHostGetDevicePointer


Generated by Doxygen for NVIDIA CUDA Library  NVIDIA