Function: host_register

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas training product

Atlas inference product

x

Atlas 200I/500 A2 inference product

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
    1
    aclError aclrtHostRegister(void *ptr, uint64_t size, aclrtHostRegisterType type, void **devPtr)
    
  • Python Function
    1
    dev_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.