aclrtHostRegister
Applicable Products
Product |
Supported |
|---|---|
√ |
|
☓ |
|
√ |
|
√ |
|
☓ |
|
☓ |
|
☓ |
Function
Maps and registers host memory as the memory address that can be accessed by devices, and obtains the mapped device memory address. This address can only be accessed on devices, for example, as a parameter of a kernel function for the device AI Core to access. If host memory processing is involved, use the original host memory address. To unregister host memory, call the aclrtHostUnregister API.
Prototype
1 | aclError aclrtHostRegister(void *ptr, uint64_t size, aclrtHostRegisterType type, void **devPtr) |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
ptr |
Input |
Host memory address. The host memory address must be 4 KB page-aligned. If the OS kernel version is 5.10 or earlier, using non-page-locked memory will cause exceptions. Therefore, you must call aclrtMallocHost to allocate page-locked host memory. If the OS kernel version is later than 5.10, non-page-locked host memory can be used. Therefore, you can either call aclrtMallocHost to allocate page-locked host memory, or call malloc to allocate non-page-locked host memory. |
size |
Input |
Memory size, in bytes. |
type |
Input |
Memory registration type. For details about the type definition, see aclrtHostRegisterType. |
devPtr |
Output |
Memory address mapped from the host memory. This address can be accessed by devices. |
Returns
0 on success; otherwise, failure. For details, see aclError.