已合并
修改c_api接口asc_set_store_atomic_config形式 #245
hw-zjy创建于 1月31日
修改c_api接口asc_set_store_atomic_config形式 #245
已合并
共 6 个文件变更+68-19
Rdocs/api/context/c_api/simd_atomic/asc_set_store_atomic_config.md→docs/api/context/c_api/simd_atomic/asc_set_store_atomic_config_v1.md+14-13
| @@ -1,4 +1,4 @@ | ||||||||||||
| 1 | -# asc_set_store_atomic_config | 1 | +# asc_set_store_atomic_config_v1 | |||||||||
| 2 | 2 | |||||||||||
| 3 | ## 产品支持情况 | 3 | ## 产品支持情况 | |||||||||
| 4 | 4 | |||||||||||
| @@ -13,18 +13,20 @@ | ||||||||||||
| 13 | 13 | |||||||||||
| 14 | ## 函数原型 | 14 | ## 函数原型 | |||||||||
| 15 | 15 | |||||||||||
| 16 | -```c++ | 16 | +```cpp | |||||||||
| 17 | -__aicore__ inline void asc_set_store_atomic_config(asc_store_atomic_config& config) | 17 | +__aicore__ inline void asc_set_store_atomic_config_v1(uint16_t type, uint16_t op) | |||||||||
| 18 | ``` | 18 | ``` | |||||||||
| 19 | 19 | |||||||||||
| 20 | ## 参数说明 | 20 | ## 参数说明 | |||||||||
| 21 | 21 | |||||||||||
M | ||||||||||||
| 22 | -| 参数名 | 输入/输出 | 描述 | | 22 | +| 参数名 | 输入/输出 | 描述 | | |||||||||
M 需要加上针对xxx,参数说明如下: 参考
![]() ![]() | ||||||||||||
| 23 | -| --------- | ----- | ---------------- | | 23 | +| :----- | :------- | :------- | | |||||||||
| 24 | -| asc_store_atomic_config | 输入 | 用于设置原子操作使能位和原子操作类型的值,详细说明请参考[asc_store_atomic_config](../struct/asc_store_atomic_config.md) 。| | 24 | +| type | 输入 | 原子操作使能位。<br>0:无原子操作。<br>1:使能原子操作,进行原子操作的数据类型为float。<br>2:使能原子操作,进行原子操作的数据类型为half。<br>3:使能原子操作,进行原子操作的数据类型为int16_t。<br>4:使能原子操作,进行原子操作的数据类型为int32_t。<br>5:使能原子操作,进行原子操作的数据类型为int8_t。<br>6:使能原子操作,进行原子操作的数据类型为bfloat16_t。<br>其余值无具体含义。 | | |||||||||
| 25 | +| op | 输入 | 原子操作类型。<br>0:求和操作。<br>其余值无具体含义。 | | |||||||||||
| 26 | + | |||||||||||
| 25 | ## 返回值说明 | 27 | ## 返回值说明 | |||||||||
| 26 | 28 | |||||||||||
| 27 | -无。 | 29 | +无 | |||||||||
| 28 | 30 | |||||||||||
| 29 | ## 流水类型 | 31 | ## 流水类型 | |||||||||
| 30 | 32 | |||||||||||
| @@ -36,9 +38,8 @@ PIPE_S | ||||||||||||
| 36 | 38 | |||||||||||
| 37 | ## 调用示例 | 39 | ## 调用示例 | |||||||||
| 38 | 40 | |||||||||||
| 39 | -```c++ | 41 | +```cpp | |||||||||
| 40 | -asc_store_atomic_config config; | 42 | +uint16_t type = 1; | |||||||||
| 41 | -config.atomic_type = 1; // 使能原子操作,进行原子操作的数据类型为float,值为1 | 43 | +uint16_t op = 0; | |||||||||
| 42 | -config.atomic_op = 0; // 求和操作,值为0 | 44 | +asc_set_store_atomic_config_v1(type, op); | |||||||||
| 43 | -asc_set_store_atomic_config(config); // 配置float类型原子求和操作 | 45 | +``` | |||||||||
| 44 | -``` | |||||||||||
| @@ -0,0 +1,44 @@ | |||
| 1 | +# asc_set_store_atomic_config_v2 | ||
| 2 | + | ||
| 3 | +## 产品支持情况 | ||
| 4 | + | ||
| 5 | +|产品 | 是否支持 | | ||
| 6 | +| ------------|:----:| | ||
| 7 | +| Ascend 950PR/Ascend 950DT | √ | | ||
| 8 | + | ||
| 9 | +## 功能说明 | ||
| 10 | + | ||
| 11 | +设置原子操作使能位与原子操作类型的值。 | ||
| 12 | + | ||
| 13 | +## 函数原型 | ||
| 14 | + | ||
| 15 | +```cpp | ||
| 16 | +__aicore__ inline void asc_set_store_atomic_config_v2(uint16_t type, uint16_t op) | ||
| 17 | +``` | ||
| 18 | + | ||
| 19 | +## 参数说明 | ||
| 20 | + | ||
| 21 | +| 参数名 | 输入/输出 | 描述 | | ||
| 22 | +| :----- | :------- | :------- | | ||
| 23 | +| type | 输入 | 原子操作使能位。<br>1:使能原子操作,进行原子操作的数据类型为int32_t。<br>4:使能原子操作,进行原子操作的数据类型为half。<br>5:使能原子操作,进行原子操作的数据类型为float。<br>7:使能原子操作,进行原子操作的数据类型为bfloat16_t。<br>9:使能原子操作,进行原子操作的数据类型为int16_t。<br>10:使能原子操作,进行原子操作的数据类型为int8_t。<br>其余值无具体含义。 | | ||
| 24 | +| op | 输入 | 原子操作类型。<br>2:求和操作。<br>其余值无具体含义。 | | ||
| 25 | + | ||
| 26 | +## 返回值说明 | ||
| 27 | + | ||
| 28 | +无 | ||
| 29 | + | ||
| 30 | +## 流水类型 | ||
| 31 | + | ||
| 32 | +PIPE_S | ||
| 33 | + | ||
| 34 | +## 约束说明 | ||
| 35 | + | ||
| 36 | +无 | ||
| 37 | + | ||
| 38 | +## 调用示例 | ||
| 39 | + | ||
| 40 | +```cpp | ||
| 41 | +uint16_t type = 1; | ||
| 42 | +uint16_t op = 2; | ||
| 43 | +asc_set_store_atomic_config_v2(type, op); | ||
| 44 | +``` | ||
| @@ -50,9 +50,9 @@ __aicore__ inline void asc_get_store_atomic_config(asc_store_atomic_config& conf | |||
| 50 | asc_get_store_atomic_config_impl(config); | 50 | asc_get_store_atomic_config_impl(config); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | -__aicore__ inline void asc_set_store_atomic_config(asc_store_atomic_config& config) | 53 | +__aicore__ inline void asc_set_store_atomic_config_v1(uint16_t type, uint16_t op) |
| 54 | { | 54 | { |
| 55 | - asc_set_store_atomic_config_impl(config); | 55 | + asc_set_store_atomic_config_v1_impl(type, op); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | __aicore__ inline void asc_set_atomic_add_bfloat() | 58 | __aicore__ inline void asc_set_atomic_add_bfloat() |
| @@ -24,9 +24,13 @@ | |||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | -__aicore__ inline void asc_set_store_atomic_config_impl(asc_store_atomic_config& config) | 27 | +__aicore__ inline void asc_set_store_atomic_config_v1_impl(uint16_t type, uint16_t op) |
| 28 | { | 28 | { |
| 29 | - set_st_atomic_cfg(config.config); | 29 | + constexpr uint64_t type_mask = 0x7; |
| 30 | + constexpr uint64_t op_mask = 0x3; | ||
| 31 | + constexpr uint64_t op_bit = 3; | ||
| 32 | + uint64_t config = (type & type_mask) | ((op & op_mask) << op_bit); | ||
| 33 | + set_st_atomic_cfg(config); | ||
| 30 | } | 34 | } |
| 31 | 35 | ||
| 32 | 36 | ||
| @@ -22,7 +22,7 @@ __aicore__ inline void asc_set_atomic_none(); | |||
| 22 | 22 | ||
| 23 | __aicore__ inline void asc_get_store_atomic_config(asc_store_atomic_config& config); | 23 | __aicore__ inline void asc_get_store_atomic_config(asc_store_atomic_config& config); |
| 24 | 24 | ||
| 25 | -__aicore__ inline void asc_set_store_atomic_config(asc_store_atomic_config& config); | 25 | +__aicore__ inline void asc_set_store_atomic_config_v1(uint16_t type, uint16_t op); |
| 26 | 26 | ||
| 27 | __aicore__ inline void asc_set_atomic_add_bfloat(); | 27 | __aicore__ inline void asc_set_atomic_add_bfloat(); |
| 28 | 28 | ||
| @@ -27,6 +27,6 @@ TEST_F(TestSimdAtomicGetStoreAtomicConfigCApi, get_st_atomic_cfg_Succ) | |||
| 27 | uint16_t atomic_op = config.atomic_op; | 27 | uint16_t atomic_op = config.atomic_op; |
| 28 | EXPECT_EQ(atomic_type, 0); | 28 | EXPECT_EQ(atomic_type, 0); |
| 29 | EXPECT_EQ(atomic_op, 0); | 29 | EXPECT_EQ(atomic_op, 0); |
| 30 | - asc_set_store_atomic_config(config); | 30 | + asc_set_store_atomic_config_v1(atomic_type, atomic_op); |
| 31 | GlobalMockObject::verify(); | 31 | GlobalMockObject::verify(); |
| 32 | } | 32 | } |


先要说明: 针对不同的AI处理器型号,入参的取值范围和各取值的含义不同。