aclrtGetMemInfo

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

Obtains the free and total memory sizes on the device based on a specified attribute, excluding the memory size reserved for the system.

Prototype

1
aclError aclrtGetMemInfo(aclrtMemAttr attr, size_t *free, size_t *total)

Parameters

Parameter

Input/Output

Description

attr

Input

Memory attribute to query. For details about the type definition, see aclrtMemAttr.

free

Output

Pointer to the free memory of a specified attribute, in bytes.

total

Output

Pointer to the total memory of a specified attribute, in bytes.

Returns

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

Restrictions

  • Before calling this API, you must specify the compute device (for example, by calling aclrtSetDevice). Therefore, no device ID is involved in this API.
  • Select the memory attribute based on the actual hardware support. Otherwise, the free memory size and total memory size output by this API call are both 0. If the hardware does not support HBM, the API automatically queries DDR memory information when you query HBM memory information. For example, when you query ACL_HBM_MEM, the API actually queries ACL_DDR_MEM.