Function: host_register
Applicability
Product |
Supported (√/x) |
|---|---|
√ |
|
√ |
|
√ |
|
x |
|
x |
Function Usage
Maps and registers the host memory as an address accessible to the device for the NIC on the device to access. The mapped device address cannot be used for memory copy.
This API is used in pairs with acl.rt.host_unregister.
Prototype
- C Prototype
1aclError aclrtHostRegister(void *ptr, uint64_t size, aclrtHostRegisterType type, void **devPtr)
- Python Function
1dev_ptr, ret = acl.rt.host_register(ptr, size, type)
Parameter Description
Parameter |
Description |
|---|---|
ptr |
Int, host memory address. The host memory address must be 4K-page-aligned. If the OS kernel version is 5.10 or earlier, using non-lock page memory will cause exceptions. In this case, you must call acl.rt.malloc_host to allocate the host memory. If the OS kernel version is later than 5.10, non-lock page memory can be used, so acl.rt.malloc_host is not required for allocating the host memory. |
size |
Int, memory size, in bytes. |
type |
Int, memory registration type. Currently, only ACL_HOST_REGISTER_MAPPED is supported, indicating that the host memory is mapped and registered as an address accessible to the device. |
Return Value Description
Return Value |
Description |
|---|---|
dev_ptr |
Int, memory address mapped from the host and accessible to the device. |
ret |
Int, error code: 0 on success; else, failure. |