---
title: 函数：mem_get_allocation_granularity
description: "| 产品 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/runtimeapi/aclpythondevg_01_0960.html
sourcePath: /source/zh/canncommercial/900/API/runtimeapi/aclpythondevg_01_0960.html
indexId: 2b345b41aa305ba09009a166c9c29c87b44c26ce184a4f38dbd733bad416e64071
---
# 函数：mem_get_allocation_granularity

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| Atlas 350 加速卡 | √ |
| Atlas A3 训练系列产品 / Atlas A3 推理系列产品 | √ |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | √ |
| Atlas 训练系列产品 | √ |
| Atlas 推理系列产品 | √ |
| Atlas 200I/500 A2 推理产品 | √ |


#### 功能说明

查询内存申请粒度。系统内部计算给定分配规范的最小粒度或建议粒度，并以granularity参数返回粒度。此粒度可用作对齐、地址大小或地址映射的倍数。


#### 函数原型

- C函数原型
  1 aclError aclrtMemGetAllocationGranularity(aclrtPhysicalMemProp *prop, aclrtMemGranularityOptions option, size_t *granularity)

- python函数
  1 granularity, ret = acl.rt.mem_get_allocation_granularity(prop, option)


#### 参数说明

| 参数名 | 说明 |
| --- | --- |
| prop | dict，物理内存属性信息，具体请参见aclrtPhysicalMemProp。 |
| option | int，最小粒度或推荐粒度，具体请参见aclrtMemGranularityOptions。 |


#### 返回值说明

| 返回值 | 说明 |
| --- | --- |
| granularity | int，内存申请粒度，单位为Byte，当前只支持2M。 |
| ret | int，错误码，返回0表示成功，返回其它值表示失败。 |


#### 约束说明

Ascend RC形态不支持调用本接口。
