aclrtGetMemInfo

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

Description

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 be queried. For details about the type definition, see aclrtMemAttr.

free

Output

Pointer to the free memory size of the corresponding attribute, in bytes.

total

Output

Pointer to the total memory size of the corresponding attribute, in bytes.

Returns

0 on success; else, 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.