Function: host_register
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
√ |
|
x |
|
x |
Description
Registers the host memory mapping as an address accessible to the device for the NIC on the device side 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)
Parameters
Parameter |
Description |
|---|---|
ptr |
Int, host memory address. The host memory address must be 4 KB page-aligned. If the OS kernel version is 5.10 or earlier, an exception occurs when the non-lock page memory is used. Therefore, the acl.rt.malloc_host API must be called to apply for the host memory. When the OS kernel version is later than 5.10, the host memory of non-lock pages can be used. Therefore, the acl.rt.malloc_host API can be called to allocate 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 accessible to the device. |
Return Value
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. |