mstxMemRegionsRegister

Supported Products

Product Supported
Ascend 910_95 AI Processors
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

Registers memory pool secondary allocation. The user must ensure that the memory registered by RegionsRegister is within the range registered by mstxMemHeapRegister; otherwise, the tool will report an out-of-bounds read/write.

Prototype

void mstxMemRegionsRegister(mstxDomainHandle_t domain, mstxMemRegionsRegisterBatch_t const *desc)

Parameter Description

Table 1 Parameter description

Parameter

Input/Output

Description

domain

Input

Either globalDomain or the handle returned by mstxDomainCreateA.

Data type: const char *.

desc

Input

Description information of the memory region to be sub-allocated from the memory pool. Cannot be null.

struct mstxMemRegion_st;
typedef struct mstxMemRegion_st mstxMemRegion_t;
typedef mstxMemRegion_t* mstxMemRegionHandle_t;

typedef struct mstxMemRegionsRegisterBatch_t {
    mstxMemHeapHandle_t heap;  // Handle of the memory pool for sub-allocation
    mstxMemType regionType;  // Memory type of the memory region
    size_t regionCount;  // Number of memory regions
    void const *regionDescArray;  // Memory region description data
    mstxMemRegionHandle_t* regionHandleArrayOut;  // Returned handle array obtained from registering sub-allocation
} mstxMemRegionsRegisterBatch_t;

Return Value Description

None

Example

mstxMemRegionsRegisterBatch_t regionsDesc{};
regionsDesc.heap = memPool;
regionsDesc.regionType = MSTX_MEM_TYPE_VIRTUAL_ADDRESS;
regionsDesc.regionCount = 1;
regionsDesc.regionDescArray = rangesDesc;
regionsDesc.regionHandleArrayOut = regionHandles;
mstxMemRegionsRegister(globalDomain, regionsDesc);              // Secondary allocation registrationry Allocation Registration