Function: reserve_mem_address
Applicability
Product |
Supported (√/x) |
|---|---|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
Function Usage
Reserves virtual memory.
- Call acl.rt.reserve_mem_address to allocate virtual memory.
- Call acl.rt.malloc_physical to allocate physical memory.
- Call acl.rt.map_mem to map the virtual memory to the physical memory.
- Call specific task APIs to execute tasks.
- Call acl.rt.unmap_mem to unmap the virtual memory from the physical memory.
- Call acl.rt.free_physical to free the physical memory.
- Call acl.rt.release_mem_address to free the virtual memory.
Prototype
- C Prototype
1aclError aclrtReserveMemAddress(void **virPtr, size_t size, size_t alignment, void *expectPtr, uint64_t flags)
- Python Function
1vir_ptr, ret = acl.rt.reserve_mem_address(size, alignment, expect_ptr, flags)
Parameter Description
Parameter |
Description |
|---|---|
size |
Int, size of the virtual address space, in bytes. Must not be 0. |
alignment |
Int, alignment value of the virtual address. This parameter is reserved and can only be set to 0. |
expectPtr |
Int, start address of the virtual address space to be returned. This parameter is reserved and can only be set to 0. |
flags |
Int, huge page or common page flag. The flag must be the same as the memory type of acl.rt.malloc_physical. Value range:
|
Return Value Description
Return Value |
Description |
|---|---|
virPtr |
Int, pointing to the address of the allocated virtual address space. |
ret |
Int, error code: 0 on success; else, failure. |
Restrictions
- This API is not supported in the Ascend RC form.
Currently, the following models support the Ascend RC form:
Atlas 200I/500 A2 inference products
- To use the virtual memory reserved by this API, only memcpy_async can be called to copy data between two devices in the single-process scenario.