aclrtMapMem
Applicable Products
|
Product |
Supported |
|---|---|
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
Function
Maps virtual memory to physical memory.
- Call aclrtReserveMemAddress to allocate virtual memory.
- Call aclrtMallocPhysical to allocate physical memory.
- Call aclrtMapMem to map virtual memory to physical memory.
- Call specific task APIs to execute tasks.
- Call aclrtUnmapMem to cancel the mapping between virtual memory and physical memory.
- Call aclrtFreePhysical to free physical memory.
- Call aclrtReleaseMemAddress to free virtual memory.
Prototype
1
|
aclError aclrtMapMem(void *virPtr, size_t size, size_t offset, aclrtDrvMemHandle handle, uint64_t flags) |
Parameters
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
virPtr |
Input |
Pointer to the virtual memory address to be mapped. The address may not be the start address. You can also offset the address based on the start address and then map the address. |
|
size |
Input |
Size of the memory to be mapped, in bytes. This size must be the same as that of the size parameter of aclrtMallocPhysical. It must also be aligned with ACL_RT_MEM_ALLOC_GRANULARITY_MINIMUM obtained by aclrtMemGetAllocationGranularity. |
|
offset |
Input |
Offset of the physical memory. This parameter can only be set to 0. |
|
handle |
Input |
Handle for storing physical memory information. For details about the type definition, see aclrtDrvMemHandle. A virtual address segment reserved by using the aclrtReserveMemAddress API is managed and divided by users. It cannot be bound to the physical addresses allocated on two devices at the same time. A virtual address segment reserved by using the aclrtReserveMemAddress API is managed and divided by users. It cannot be bound at the same time to the handles returned by the aclrtMallocPhysical and aclrtMemImportFromShareableHandle APIs. |
|
flags |
Input |
Reserved. The value is fixed at 0. |
Returns
0 on success; otherwise, failure. For details, see aclError.