mstxMemHeapRegister
| 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 | √ |
Registers a memory pool. When calling this API to register a memory pool, the user must ensure that the memory has been allocated in advance.
mstxMemHeapHandle_t mstxMemHeapRegister(mstxDomainHandle_t domain, mstxMemHeapDesc_t const *desc)
Table 1 Parameter description
Either globalDomain or the handle returned by mstxDomainCreateA. |
||
typedef enum mstxMemHeapUsageType { /* @brief This heap memory is used as a memory pool * Heap memory registered using this usage type must be accessed after secondary allocation registration */ MSTX_MEM_HEAP_USAGE_TYPE_SUB_ALLOCATOR = 0, } mstxMemHeapUsageType; /** @brief Heap memory type * The "type" here refers to the method used to describe the heap memory pointer. Currently, only linearly arranged memory is supported. * memory, but the capability to support more memory types in the future is reserved here. For example, some APIs return * multiple handles to describe a memory range, or some high-dimensional memory requires stride, tiling, or * interlace for description. */ typedef enum mstxMemType { /** @brief Standard linearly laid out virtual memory * In this case, mstxMemHeapRegister receives a description of the mstxMemVirtualRangeDesc_t type. */ MSTX_MEM_TYPE_VIRTUAL_ADDRESS = 0, } mstxMemType; typedef struct mstxMemVirtualRangeDesc_t { uint32_t deviceId; // Device ID corresponding to the memory region void const *ptr; // Start address of the memory region uint64_t size; // Length of the memory region } mstxMemVirtualRangeDesc_t; typedef struct mstxMemHeapDesc_t { mstxMemHeapUsageType usage; // Usage mode of the heap memory mstxMemType type; // Type of the heap memory void const *typeSpecificDesc; // Description information of the heap memory under the specified memory type } mstxMemHeapDesc_t; |
Handle corresponding to the memory pool.
mstxMemVirtualRangeDesc_t rangeDesc = {};
rangeDesc.deviceId = deviceId; // Device ID
rangeDesc.ptr = gm; // Start address of the registered memory pool gm
rangeDesc.size = 1024; // Memory pool size
heapDesc.typeSpecificDesc = &rangeDesc;
mstxMemHeapDesc_t heapDesc{};
mstxMemHeapHandle_t memPool = mstxMemHeapRegister(globalDomain, &heapDesc); // Register memory pool