CUresult cuMemHostRegister ( void *  p,
size_t  bytesize,
unsigned int  Flags 
)

Page-locks the memory range specified by p and bytesize and maps it for the device(s) as specified by Flags. This memory range also is added to the same tracking mechanism as cuMemHostAlloc to automatically accelerate calls to functions such as cuMemcpyHtoD(). 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.

This function is not yet supported on Mac OS X.

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

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

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 CU_CTX_MAP_HOST flag in order for the CU_MEMHOSTREGISTER_DEVICEMAP flag to have any effect.

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

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

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

Parameters:
p - Host pointer to memory to page-lock
bytesize - Size in bytes of the address range to page-lock
Flags - Flags for allocation request
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_OUT_OF_MEMORY
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuMemHostUnregister, cuMemHostGetFlags, cuMemHostGetDevicePointer


Generated by Doxygen for NVIDIA CUDA Library  NVIDIA