hiphostregister Interface Reference#
Register host memory so it can be accessed from the current device. More...
Public Member Functions | |
integer(kind(hipsuccess)) function | hiphostregister_orig (hostPtr, sizeBytes, flags) |
Detailed Description
Register host memory so it can be accessed from the current device.
- Parameters
-
[out] hostPtr Pointer to host memory to be registered. [in] sizeBytes size of the host memory [in] flags. See below.
Flags:
- #hipHostRegisterDefault Memory is Mapped and Portable
- #hipHostRegisterPortable Memory is considered registered by all contexts. HIP only supports one context so this is always assumed true.
- #hipHostRegisterMapped Map the allocation into the address space for the current device. The device pointer can be obtained with #hipHostGetDevicePointer.
After registering the memory, use #hipHostGetDevicePointer to obtain the mapped device pointer. On many systems, the mapped device pointer will have a different value than the mapped host pointer. Applications must use the device pointer in device code, and the host pointer in device code.
On some systems, registered memory is pinned. On some systems, registered memory may not be actually be pinned but uses OS or hardware facilities to all GPU access to the host memory.
Developers are strongly encouraged to register memory blocks which are aligned to the host cache-line size. (typically 64-bytes but can be obtains from the CPUID instruction).
If registering non-aligned pointers, the application must take care when register pointers from the same cache line on different devices. HIP's coarse-grained synchronization model does not guarantee correct results if different devices write to different parts of the same cache block - typically one of the writes will "win" and overwrite data from the other registered memory region.
- Returns
- #hipSuccess, #hipErrorOutOfMemory
- See also
- hipHostUnregister, hipHostGetFlags, hipHostGetDevicePointer
Member Function/Subroutine Documentation
◆ hiphostregister_orig()
integer(kind(hipsuccess)) function hipfort::hiphostregister::hiphostregister_orig | ( | type(c_ptr), value | hostPtr, |
integer(c_size_t), value | sizeBytes, | ||
integer(kind=4), value | flags | ||
) |
The documentation for this interface was generated from the following file: