aclrtMemMapSelectedLink

Applicable Products

Product

Supported

Ascend 950PR/Ascend 950DT

☓

Atlas A3 training products/Atlas A3 inference products

√

Atlas A2 training products/Atlas A2 inference products

☓

Atlas 200I/500 A2 inference products

☓

Atlas inference products

☓

Atlas training products

☓

Function

Maps the virtual address virPtrDst to the physical address corresponding to the virtual address virPtrSrc. You can select the HCCS or SIO link by setting linkIdx.

Prototype

1
aclError aclrtMemMapSelectedLink(void *virPtrDst, size_t size, void *virPtrSrc, uint32_t linkIdx)

Parameters

Parameter

Input/Output

Description

virPtrDst

Input

Virtual memory address to be mapped.

You need to reserve the virtual memory in advance by calling the aclrtReserveMemAddress API, and then pass the start address of the virtual memory as an input to this API. The start address of the virtual memory cannot be offset before being passed to this API.

size

Input

Virtual memory size, in bytes.

The virtual memory sizes for virPtrDst and virPtrSrc must be the same and equal to size.

virPtrSrc

Input

Virtual memory address that has been mapped to the physical memory.

The virtual memory must be mapped to the physical memory by calling the aclrtMapMem API in advance. The start address of the virtual memory is passed to this API as an input. The start address of the virtual memory cannot be offset before being passed to this API.

linkIdx

Input

Link index.

  • ACL_RT_MEM_LINK_IDX_0: Small Input Output (SIO), indicating the intra-chip connection mode. Two dies are connected in this mode.
  • ACL_RT_MEM_LINK_IDX_1: Huawei Cache Coherence System (HCCS). It is used for high-speed interconnection across CPUs and NPUs.

The macros are defined as follows:

#define ACL_RT_MEM_LINK_IDX_0 0U     // SIO
#define ACL_RT_MEM_LINK_IDX_1 1U     // HCCS

Returns

0 on success; otherwise, failure. For details, see aclError.

Restrictions

If the start address of the virPtrSrc virtual memory is mapped to multiple physical memory regions after an offset applied, virPtrDst will also be mapped to these different physical memory regions when the aclrtMemMapSelectedLink API is called to map virPtrDst to virPtrSrc. In addition, the address offset must be the same for virPtrDst and virPtrSrc. In this case, to cancel the mapping between virPtrDst and multiple physical addresses, you need to call the aclrtUnmapMem API multiple times.