| @@ -1265,6 +1265,17 @@ | |||
| 1265 | - [asc_sflbits](SIMD-API/C-API/scalar_compute/asc_sflbits.md) | 1265 | - [asc_sflbits](SIMD-API/C-API/scalar_compute/asc_sflbits.md) |
| 1266 | - [asc_store_dev](SIMD-API/C-API/scalar_compute/asc_store_dev.md) | 1266 | - [asc_store_dev](SIMD-API/C-API/scalar_compute/asc_store_dev.md) |
| 1267 | - [asc_zero_bits_cnt](SIMD-API/C-API/scalar_compute/asc_zero_bits_cnt.md) | 1267 | - [asc_zero_bits_cnt](SIMD-API/C-API/scalar_compute/asc_zero_bits_cnt.md) |
| 1268 | + - [asc_atomic_add](SIMD-API/C-API/scalar_compute/asc_atomic_add.md) | ||
| 1269 | + - [asc_atomic_sub](SIMD-API/C-API/scalar_compute/asc_atomic_sub.md) | ||
| 1270 | + - [asc_atomic_or](SIMD-API/C-API/scalar_compute/asc_atomic_or.md) | ||
| 1271 | + - [asc_atomic_xor](SIMD-API/C-API/scalar_compute/asc_atomic_xor.md) | ||
| 1272 | + - [asc_atomic_and](SIMD-API/C-API/scalar_compute/asc_atomic_and.md) | ||
| 1273 | + - [asc_atomic_max](SIMD-API/C-API/scalar_compute/asc_atomic_max.md) | ||
| 1274 | + - [asc_atomic_min](SIMD-API/C-API/scalar_compute/asc_atomic_min.md) | ||
| 1275 | + - [asc_atomic_inc](SIMD-API/C-API/scalar_compute/asc_atomic_inc.md) | ||
| 1276 | + - [asc_atomic_dec](SIMD-API/C-API/scalar_compute/asc_atomic_dec.md) | ||
| 1277 | + - [asc_atomic_exch](SIMD-API/C-API/scalar_compute/asc_atomic_exch.md) | ||
| 1278 | + - [asc_atomic_cas](SIMD-API/C-API/scalar_compute/asc_atomic_cas.md) | ||
| 1268 | - [同步控制](SIMD-API/C-API/sync/同步控制.md) | 1279 | - [同步控制](SIMD-API/C-API/sync/同步控制.md) |
| 1269 | - [asc_lock](SIMD-API/C-API/sync/asc_lock.md) | 1280 | - [asc_lock](SIMD-API/C-API/sync/asc_lock.md) |
| 1270 | - [asc_sync](SIMD-API/C-API/sync/asc_sync.md) | 1281 | - [asc_sync](SIMD-API/C-API/sync/asc_sync.md) |
| @@ -1324,7 +1335,7 @@ | |||
| 1324 | - [asc_set_atomic_min](SIMD-API/C-API/simd_atomic/asc_set_atomic_min.md) | 1335 | - [asc_set_atomic_min](SIMD-API/C-API/simd_atomic/asc_set_atomic_min.md) |
| 1325 | - [asc_set_atomic_none](SIMD-API/C-API/simd_atomic/asc_set_atomic_none.md) | 1336 | - [asc_set_atomic_none](SIMD-API/C-API/simd_atomic/asc_set_atomic_none.md) |
| 1326 | - [asc_set_store_atomic_config_v1](SIMD-API/C-API/simd_atomic/asc_set_store_atomic_config_v1.md) | 1337 | - [asc_set_store_atomic_config_v1](SIMD-API/C-API/simd_atomic/asc_set_store_atomic_config_v1.md) |
| 1327 | - - [asc_set_store_atomic_config_v2](SIMD-API/C-API/simd_atomic/asc_set_store_atomic_config_v2.md) | 1338 | + - [asc_set_store_atomic_config_v2(废弃)](SIMD-API/C-API/simd_atomic/asc_set_store_atomic_config_v2_deprecated.md) |
| 1328 | - [其他操作](SIMD-API/C-API/misc/其他操作.md) | 1339 | - [其他操作](SIMD-API/C-API/misc/其他操作.md) |
| 1329 | - [asc_init](SIMD-API/C-API/misc/asc_init.md) | 1340 | - [asc_init](SIMD-API/C-API/misc/asc_init.md) |
| 1330 | 1341 | ||
| @@ -193,6 +193,17 @@ C API文档目录,整体使用时可以引入asc_simd.h,C API列表如下: | |||
| 193 | | [asc_zero_bits_cnt](scalar_compute/asc_zero_bits_cnt.md) | 获取一个uint64_t类型数字的二进制中0的个数。 | | 193 | | [asc_zero_bits_cnt](scalar_compute/asc_zero_bits_cnt.md) | 获取一个uint64_t类型数字的二进制中0的个数。 | |
| 194 | | [asc_store_dev](scalar_compute/asc_store_dev.md) | 不经过DCache向GM地址上写数据。 | | 194 | | [asc_store_dev](scalar_compute/asc_store_dev.md) | 不经过DCache向GM地址上写数据。 | |
| 195 | | [asc_float2int32](scalar_compute/asc_float2int32.md) | 将float类型转化为int32_t类型,并支持多种舍入模式。 | | 195 | | [asc_float2int32](scalar_compute/asc_float2int32.md) | 将float类型转化为int32_t类型,并支持多种舍入模式。 | |
| 196 | +| [asc_atomic_add](scalar_compute/asc_atomic_add.md) | 对Global Memory中的数据与指定数据执行原子加操作。 | | ||
| 197 | +| [asc_atomic_sub](scalar_compute/asc_atomic_sub.md) | 对Global Memory中的数据与指定数据执行原子减操作。 | | ||
| 198 | +| [asc_atomic_or](scalar_compute/asc_atomic_or.md) | 对Global Memory中的数据与指定数据执行原子或操作。 | | ||
| 199 | +| [asc_atomic_xor](scalar_compute/asc_atomic_xor.md) | 对Global Memory中的数据与指定数据执行原子异或操作。 | | ||
| 200 | +| [asc_atomic_and](scalar_compute/asc_atomic_and.md) | 对Global Memory中的数据与指定数据执行原子与操作。 | | ||
| 201 | +| [asc_atomic_max](scalar_compute/asc_atomic_max.md) | 对Global Memory中的数据与指定数据执行原子求最大值操作。 | | ||
| 202 | +| [asc_atomic_min](scalar_compute/asc_atomic_min.md) | 对Global Memory中的数据与指定数据执行原子求最小值操作。 | | ||
| 203 | +| [asc_atomic_inc](scalar_compute/asc_atomic_inc.md) | 对Global Memory中address指向的计数器执行原子递增操作,如果address上的数值大于等于指定数值val,则对address赋值为0,否则将address上数值加1。 | | ||
| 204 | +| [asc_atomic_dec](scalar_compute/asc_atomic_dec.md) | 对Global Memory中address指向的计数器执行原子递减操作,如果address上的数值等于0或大于指定数值val,则对address赋值为val,否则将address上数值减1。 | | ||
| 205 | +| [asc_atomic_exch](scalar_compute/asc_atomic_exch.md) | 对Global Memory中address指向的元素执行原子赋值操作。 | | ||
| 206 | +| [asc_atomic_cas](scalar_compute/asc_atomic_cas.md) | 对Global Memory中address指向的元素执行原子比较赋值操作,如果address上的数值等于指定数值compare,则对address赋值为指定数值val,否则address的数值不变。 | | ||
| 196 | 207 | ||
| 197 | ## 矩阵计算 | 208 | ## 矩阵计算 |
| 198 | 209 | ||
| @@ -310,7 +321,7 @@ C API文档目录,整体使用时可以引入asc_simd.h,C API列表如下: | |||
| 310 | | [asc_set_atomic_min_int8](simd_atomic/asc_set_atomic_min.md) | 设置计算结果以原子比较的方式传输到GM。在拷贝前,将待传输的int8_t数据与GM中已有数据进行逐元素比较,并将最小值写入GM。 | | 321 | | [asc_set_atomic_min_int8](simd_atomic/asc_set_atomic_min.md) | 设置计算结果以原子比较的方式传输到GM。在拷贝前,将待传输的int8_t数据与GM中已有数据进行逐元素比较,并将最小值写入GM。 | |
| 311 | | [asc_set_atomic_min_int16](simd_atomic/asc_set_atomic_min.md) | 设置计算结果以原子比较的方式传输到GM。在拷贝前,将待传输的int16_t数据与GM中已有数据进行逐元素比较,并将最小值写入GM。 | | 322 | | [asc_set_atomic_min_int16](simd_atomic/asc_set_atomic_min.md) | 设置计算结果以原子比较的方式传输到GM。在拷贝前,将待传输的int16_t数据与GM中已有数据进行逐元素比较,并将最小值写入GM。 | |
| 312 | | [asc_set_store_atomic_config_v1](simd_atomic/asc_set_store_atomic_config_v1.md)| 设置原子操作启用位与原子操作类型的值,适用于Atlas A3 训练系列产品/Atlas A3 推理系列产品和Atlas A2 训练系列产品/Atlas A2 推理系列产品。 | | 323 | | [asc_set_store_atomic_config_v1](simd_atomic/asc_set_store_atomic_config_v1.md)| 设置原子操作启用位与原子操作类型的值,适用于Atlas A3 训练系列产品/Atlas A3 推理系列产品和Atlas A2 训练系列产品/Atlas A2 推理系列产品。 | |
| 313 | -| <cann-filter npu_type = "950" > [asc_set_store_atomic_config_v2](simd_atomic/asc_set_store_atomic_config_v2.md)| 设置原子操作启用位与原子操作类型的值,适用于Ascend 950PR/Ascend 950DT。</cann-filter>| | 324 | +| <cann-filter npu_type = "950" > [asc_set_store_atomic_config_v2(废弃)](simd_atomic/asc_set_store_atomic_config_v2_deprecated.md)| 设置原子操作启用位与原子操作类型的值,适用于Ascend 950PR/Ascend 950DT。</cann-filter>| |
| 314 | | [asc_get_store_atomic_config](simd_atomic/asc_get_store_atomic_config.md)| 获取原子操作启用位与原子操作类型的值。 | | 325 | | [asc_get_store_atomic_config](simd_atomic/asc_get_store_atomic_config.md)| 获取原子操作启用位与原子操作类型的值。 | |
| 315 | | [asc_set_atomic_none](simd_atomic/asc_set_atomic_none.md) | 清空原子操作的状态。 | | 326 | | [asc_set_atomic_none](simd_atomic/asc_set_atomic_none.md) | 清空原子操作的状态。 | |
| 316 | 327 | ||
| @@ -0,0 +1,73 @@ | |||
| 1 | +# asc_atomic_add | ||
| 2 | + | ||
| 3 | +## 产品支持情况 | ||
| 4 | + | ||
| 5 | +<!-- npu="950" id1 --> | ||
| 6 | +- Ascend 950PR/Ascend 950DT:支持 | ||
| 7 | +<!-- end id1 --> | ||
| 8 | +<!-- npu="A3" id2 --> | ||
| 9 | +- Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持 | ||
| 10 | +<!-- end id2 --> | ||
| 11 | +<!-- npu="910b" id3 --> | ||
| 12 | +- Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持 | ||
| 13 | +<!-- end id3 --> | ||
| 14 | +<!-- npu="310b" id4 --> | ||
| 15 | +- Atlas 200I/500 A2 推理产品:不支持 | ||
| 16 | +<!-- end id4 --> | ||
| 17 | +<!-- npu="310p" id5 --> | ||
| 18 | +- Atlas 推理系列产品AI Core:不支持 | ||
| 19 | +<!-- end id5 --> | ||
| 20 | +<!-- npu="310p" id6 --> | ||
| 21 | +- Atlas 推理系列产品Vector Core:不支持 | ||
| 22 | +<!-- end id6 --> | ||
| 23 | +<!-- npu="910" id7 --> | ||
| 24 | +- Atlas 训练系列产品:不支持 | ||
| 25 | +<!-- end id7 --> | ||
| 26 | + | ||
| 27 | +## 功能说明 | ||
| 28 | + | ||
| 29 | +头文件路径:`"c_api/scalar_compute/scalar_compute.h"`。 | ||
| 30 | + | ||
| 31 | +对Global Memory中的数据与指定数据执行原子加操作,即将val累加到address指向的数据元素上。 | ||
| 32 | + | ||
| 33 | +## 函数原型 | ||
| 34 | + | ||
| 35 | +```cpp | ||
| 36 | +__aicore__ inline int32_t asc_atomic_add(__gm__ int32_t *address, int32_t val) | ||
| 37 | + | ||
| 38 | +__aicore__ inline uint32_t asc_atomic_add(__gm__ uint32_t *address, uint32_t val) | ||
| 39 | + | ||
| 40 | +__aicore__ inline float asc_atomic_add(__gm__ float *address, float val) | ||
| 41 | + | ||
| 42 | +__aicore__ inline int64_t asc_atomic_add(__gm__ int64_t *address, int64_t val) | ||
| 43 | + | ||
| 44 | +__aicore__ inline uint64_t asc_atomic_add(__gm__ uint64_t *address, uint64_t val) | ||
| 45 | +``` | ||
| 46 | + | ||
| 47 | +## 参数说明 | ||
Y | |||
| 48 | + | ||
| 49 | +| 参数名 | 输入/输出 | 描述 | | ||
| 50 | +| --- | --- | --- | | ||
| 51 | +| address | 输出 | Global Memory的地址。 | | ||
| 52 | +| val | 输入 | 源操作数。 | | ||
| 53 | + | ||
| 54 | +## 返回值说明 | ||
| 55 | + | ||
Y [V-2] P1 | 规则f(参数说明) | asc_atomic_add.md:37
此问题在所有12个atomic API页面的参数表中均存在。 此评论由AI生成,如有异议,请回复帮助我更快成长:) ![]() ![]() | |||
| 56 | +address地址中计算前的原始数据。 | ||
| 57 | + | ||
| 58 | +## 流水类型 | ||
| 59 | + | ||
| 60 | +PIPE_S | ||
| 61 | + | ||
| 62 | +## 约束说明 | ||
| 63 | + | ||
| 64 | +- 在开启编译器自动同步功能的前提下,编译器能够自动在PIPE_MTE2/PIPE_MTE3与PIPE_S之间插入同步。但是,asc_atomic_add为标量计算,在读写GM时如果与搬运单元(MTE2/MTE3)存在数据依赖,编译器却无法自动插入同步,开发者需要根据实际情况手动插入同步。 | ||
| 65 | +- Scalar原子操作会绕过DCache,需要调用[asc_dcci](../cache_ctrl/asc_dcci.md)接口确保GM与DCache的一致性。 | ||
| 66 | + | ||
| 67 | +## 调用示例 | ||
| 68 | + | ||
Y [V-1] P1 | 规则h(示例) | asc_atomic_add.md:49 调用示例中使用局部变量
同样的问题存在于其他11个atomic API页面(asc_atomic_sub/inc/dec/or/xor/and/max/min/exch/cas)。 此评论由AI生成,如有异议,请回复帮助我更快成长:) ![]() ![]() | |||
| 69 | +```cpp | ||
| 70 | +int32_t dst = 10; // 初始值 | ||
| 71 | +asc_dcci_entire_all(); // 手动同步 | ||
| 72 | +int32_t old = asc_atomic_add(&dst, 5); // dst = 15, old = 10 | ||
| 73 | +``` | ||
| @@ -0,0 +1,71 @@ | |||
| 1 | +# asc_atomic_and | ||
| 2 | + | ||
| 3 | +## 产品支持情况 | ||
| 4 | + | ||
| 5 | +<!-- npu="950" id1 --> | ||
| 6 | +- Ascend 950PR/Ascend 950DT:支持 | ||
| 7 | +<!-- end id1 --> | ||
| 8 | +<!-- npu="A3" id2 --> | ||
| 9 | +- Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持 | ||
| 10 | +<!-- end id2 --> | ||
| 11 | +<!-- npu="910b" id3 --> | ||
| 12 | +- Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持 | ||
| 13 | +<!-- end id3 --> | ||
| 14 | +<!-- npu="310b" id4 --> | ||
| 15 | +- Atlas 200I/500 A2 推理产品:不支持 | ||
| 16 | +<!-- end id4 --> | ||
| 17 | +<!-- npu="310p" id5 --> | ||
| 18 | +- Atlas 推理系列产品AI Core:不支持 | ||
| 19 | +<!-- end id5 --> | ||
| 20 | +<!-- npu="310p" id6 --> | ||
| 21 | +- Atlas 推理系列产品Vector Core:不支持 | ||
| 22 | +<!-- end id6 --> | ||
| 23 | +<!-- npu="910" id7 --> | ||
| 24 | +- Atlas 训练系列产品:不支持 | ||
| 25 | +<!-- end id7 --> | ||
| 26 | + | ||
| 27 | +## 功能说明 | ||
| 28 | + | ||
| 29 | +头文件路径:`"c_api/scalar_compute/scalar_compute.h"`。 | ||
| 30 | + | ||
| 31 | +对Global Memory中的数据与指定数据执行原子与操作,即将val按位与到address指向的数据元素上。 | ||
| 32 | + | ||
| 33 | +## 函数原型 | ||
| 34 | + | ||
| 35 | +```cpp | ||
| 36 | +__aicore__ inline int32_t asc_atomic_and(__gm__ int32_t *address, int32_t val) | ||
| 37 | + | ||
| 38 | +__aicore__ inline uint32_t asc_atomic_and(__gm__ uint32_t *address, uint32_t val) | ||
| 39 | + | ||
| 40 | +__aicore__ inline int64_t asc_atomic_and(__gm__ int64_t *address, int64_t val) | ||
| 41 | + | ||
| 42 | +__aicore__ inline uint64_t asc_atomic_and(__gm__ uint64_t *address, uint64_t val) | ||
| 43 | +``` | ||
| 44 | + | ||
| 45 | +## 参数说明 | ||
| 46 | + | ||
| 47 | +| 参数名 | 输入/输出 | 描述 | | ||
| 48 | +| --- | --- | --- | | ||
| 49 | +| address | 输出 | Global Memory的地址。 | | ||
| 50 | +| val | 输入 | 源操作数。 | | ||
| 51 | + | ||
| 52 | +## 返回值说明 | ||
| 53 | + | ||
| 54 | +address地址中计算前的原始数据。 | ||
| 55 | + | ||
| 56 | +## 流水类型 | ||
| 57 | + | ||
| 58 | +PIPE_S | ||
| 59 | + | ||
| 60 | +## 约束说明 | ||
| 61 | + | ||
| 62 | +- 在开启编译器自动同步功能的前提下,编译器能够自动在PIPE_MTE2/PIPE_MTE3与PIPE_S之间插入同步。但是,asc_atomic_and为标量计算,在读写GM时如果与搬运单元(MTE2/MTE3)存在数据依赖,编译器却无法自动插入同步,开发者需要根据实际情况手动插入同步。 | ||
| 63 | +- Scalar原子操作会绕过DCache,需要调用[asc_dcci](../cache_ctrl/asc_dcci.md)接口确保GM与DCache的一致性。 | ||
| 64 | + | ||
| 65 | +## 调用示例 | ||
| 66 | + | ||
| 67 | +```cpp | ||
| 68 | +uint32_t dst = 0xF; // 初始值 | ||
| 69 | +asc_dcci_entire_all(); // 手动同步 | ||
| 70 | +uint32_t old = asc_atomic_and(&dst, 0x6); // dst = 0x6, old = 0xF | ||
| 71 | +``` | ||
| @@ -0,0 +1,74 @@ | |||
| 1 | +# asc_atomic_cas | ||
| 2 | + | ||
| 3 | +## 产品支持情况 | ||
| 4 | + | ||
| 5 | +<!-- npu="950" id1 --> | ||
| 6 | +- Ascend 950PR/Ascend 950DT:支持 | ||
| 7 | +<!-- end id1 --> | ||
| 8 | +<!-- npu="A3" id2 --> | ||
| 9 | +- Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持 | ||
| 10 | +<!-- end id2 --> | ||
| 11 | +<!-- npu="910b" id3 --> | ||
| 12 | +- Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持 | ||
| 13 | +<!-- end id3 --> | ||
| 14 | +<!-- npu="310b" id4 --> | ||
| 15 | +- Atlas 200I/500 A2 推理产品:不支持 | ||
| 16 | +<!-- end id4 --> | ||
| 17 | +<!-- npu="310p" id5 --> | ||
| 18 | +- Atlas 推理系列产品AI Core:不支持 | ||
| 19 | +<!-- end id5 --> | ||
| 20 | +<!-- npu="310p" id6 --> | ||
| 21 | +- Atlas 推理系列产品Vector Core:不支持 | ||
| 22 | +<!-- end id6 --> | ||
| 23 | +<!-- npu="910" id7 --> | ||
| 24 | +- Atlas 训练系列产品:不支持 | ||
| 25 | +<!-- end id7 --> | ||
| 26 | + | ||
| 27 | +## 功能说明 | ||
| 28 | + | ||
| 29 | +头文件路径:`"c_api/scalar_compute/scalar_compute.h"`。 | ||
| 30 | + | ||
| 31 | +对Global Memory中address指向的元素执行原子比较赋值操作,如果address上的数值等于指定数值compare,则对address赋值为指定数值val,否则address的数值不变。 | ||
| 32 | + | ||
| 33 | +## 函数原型 | ||
| 34 | + | ||
| 35 | +```cpp | ||
| 36 | +__aicore__ inline float asc_atomic_cas(__gm__ float *address, float compare, float val) | ||
| 37 | + | ||
| 38 | +__aicore__ inline int32_t asc_atomic_cas(__gm__ int32_t *address, int32_t compare, int32_t val) | ||
| 39 | + | ||
| 40 | +__aicore__ inline uint32_t asc_atomic_cas(__gm__ uint32_t *address, uint32_t compare, uint32_t val) | ||
| 41 | + | ||
| 42 | +__aicore__ inline int64_t asc_atomic_cas(__gm__ int64_t *address, int64_t compare, int64_t val) | ||
| 43 | + | ||
| 44 | +__aicore__ inline uint64_t asc_atomic_cas(__gm__ uint64_t *address, uint64_t compare, uint64_t val) | ||
| 45 | +``` | ||
| 46 | + | ||
| 47 | +## 参数说明 | ||
| 48 | + | ||
| 49 | +| 参数名 | 输入/输出 | 描述 | | ||
| 50 | +| --- | --- | --- | | ||
| 51 | +| address | 输出 | Global Memory的地址。 | | ||
| 52 | +| compare | 输入 | 源操作数,做比较的值。 | | ||
| 53 | +| val | 输入 | 源操作数,用于赋值的值。 | | ||
| 54 | + | ||
| 55 | +## 返回值说明 | ||
| 56 | + | ||
| 57 | +address地址中计算前的原始数据。 | ||
| 58 | + | ||
| 59 | +## 流水类型 | ||
Y [V-2] P2 | api-rules(g) | asc_atomic_cas的float类型原子比较缺少精度约束说明 函数原型支持float类型的原子比较赋值(CAS),但约束说明中未提及浮点比较的精度限制。IEEE 754 float的精确相等比较在某些场景下可能不符合预期(如NaN!=NaN、-0==+0、微小浮点误差等)。建议在约束说明中补充float类型CAS的行为说明,或标注使用注意事项。 此评论由AI生成,如有异议,请回复帮助我更快成长:) ![]() ![]() | |||
| 60 | + | ||
| 61 | +PIPE_S | ||
| 62 | + | ||
| 63 | +## 约束说明 | ||
| 64 | + | ||
| 65 | +- 在开启编译器自动同步功能的前提下,编译器能够自动在PIPE_MTE2/PIPE_MTE3与PIPE_S之间插入同步。但是,asc_atomic_cas为标量计算,在读写GM时如果与搬运单元(MTE2/MTE3)存在数据依赖,编译器却无法自动插入同步,开发者需要根据实际情况手动插入同步。 | ||
| 66 | +- Scalar原子操作会绕过DCache,需要调用[asc_dcci](../cache_ctrl/asc_dcci.md)接口确保GM与DCache的一致性。 | ||
Y [V-3] P2 | 规则CR-11(排版格式) | asc_atomic_cas.md:48 代码块语言标记不一致: 此评论由AI生成,如有异议,请回复帮助我更快成长:) ![]() ![]() | |||
| 67 | + | ||
| 68 | +## 调用示例 | ||
| 69 | + | ||
| 70 | +```cpp | ||
| 71 | +int32_t dst = 10; // 初始值 | ||
| 72 | +asc_dcci_entire_all(); // 手动同步 | ||
| 73 | +int32_t old = asc_atomic_cas(&dst, 10, 20); // dst = 20, old = 10 | ||
| 74 | +``` | ||
| @@ -0,0 +1,67 @@ | |||
| 1 | +# asc_atomic_dec | ||
| 2 | + | ||
| 3 | +## 产品支持情况 | ||
| 4 | + | ||
| 5 | +<!-- npu="950" id1 --> | ||
| 6 | +- Ascend 950PR/Ascend 950DT:支持 | ||
| 7 | +<!-- end id1 --> | ||
| 8 | +<!-- npu="A3" id2 --> | ||
| 9 | +- Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持 | ||
| 10 | +<!-- end id2 --> | ||
| 11 | +<!-- npu="910b" id3 --> | ||
| 12 | +- Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持 | ||
| 13 | +<!-- end id3 --> | ||
| 14 | +<!-- npu="310b" id4 --> | ||
| 15 | +- Atlas 200I/500 A2 推理产品:不支持 | ||
| 16 | +<!-- end id4 --> | ||
| 17 | +<!-- npu="310p" id5 --> | ||
| 18 | +- Atlas 推理系列产品AI Core:不支持 | ||
| 19 | +<!-- end id5 --> | ||
| 20 | +<!-- npu="310p" id6 --> | ||
| 21 | +- Atlas 推理系列产品Vector Core:不支持 | ||
| 22 | +<!-- end id6 --> | ||
| 23 | +<!-- npu="910" id7 --> | ||
| 24 | +- Atlas 训练系列产品:不支持 | ||
| 25 | +<!-- end id7 --> | ||
| 26 | + | ||
| 27 | +## 功能说明 | ||
| 28 | + | ||
| 29 | +头文件路径:`"c_api/scalar_compute/scalar_compute.h"`。 | ||
| 30 | + | ||
| 31 | +对Global Memory中address指向的计数器执行原子递减操作,如果address上的数值等于0或大于指定数值val,则对address赋值为val,否则将address上数值减1。 | ||
| 32 | + | ||
| 33 | +## 函数原型 | ||
| 34 | + | ||
| 35 | +```cpp | ||
| 36 | +__aicore__ inline uint32_t asc_atomic_dec(__gm__ uint32_t *address, uint32_t val) | ||
| 37 | + | ||
| 38 | +__aicore__ inline uint64_t asc_atomic_dec(__gm__ uint64_t *address, uint64_t val) | ||
| 39 | +``` | ||
| 40 | + | ||
| 41 | +## 参数说明 | ||
| 42 | + | ||
| 43 | +| 参数名 | 输入/输出 | 描述 | | ||
| 44 | +| --- | --- | --- | | ||
| 45 | +| address | 输出 | Global Memory的地址。 | | ||
| 46 | +| val | 输入 | 源操作数。 | | ||
| 47 | + | ||
| 48 | +## 返回值说明 | ||
| 49 | + | ||
| 50 | +address地址中计算前的原始数据。 | ||
| 51 | + | ||
| 52 | +## 流水类型 | ||
| 53 | + | ||
| 54 | +PIPE_S | ||
| 55 | + | ||
| 56 | +## 约束说明 | ||
| 57 | + | ||
| 58 | +- 在开启编译器自动同步功能的前提下,编译器能够自动在PIPE_MTE2/PIPE_MTE3与PIPE_S之间插入同步。但是,asc_atomic_dec为标量计算,在读写GM时如果与搬运单元(MTE2/MTE3)存在数据依赖,编译器却无法自动插入同步,开发者需要根据实际情况手动插入同步。 | ||
| 59 | +- Scalar原子操作会绕过DCache,需要调用[asc_dcci](../cache_ctrl/asc_dcci.md)接口确保GM与DCache的一致性。 | ||
| 60 | + | ||
| 61 | +## 调用示例 | ||
| 62 | + | ||
| 63 | +```cpp | ||
| 64 | +uint32_t counter = 5; // 初始值 | ||
| 65 | +asc_dcci_entire_all(); // 手动同步 | ||
| 66 | +uint32_t old = asc_atomic_dec(&counter, 9); // counter = 4, old = 5 | ||
| 67 | +``` | ||
| @@ -0,0 +1,73 @@ | |||
| 1 | +# asc_atomic_exch | ||
| 2 | + | ||
| 3 | +## 产品支持情况 | ||
| 4 | + | ||
| 5 | +<!-- npu="950" id1 --> | ||
| 6 | +- Ascend 950PR/Ascend 950DT:支持 | ||
| 7 | +<!-- end id1 --> | ||
| 8 | +<!-- npu="A3" id2 --> | ||
| 9 | +- Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持 | ||
| 10 | +<!-- end id2 --> | ||
| 11 | +<!-- npu="910b" id3 --> | ||
| 12 | +- Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持 | ||
| 13 | +<!-- end id3 --> | ||
| 14 | +<!-- npu="310b" id4 --> | ||
| 15 | +- Atlas 200I/500 A2 推理产品:不支持 | ||
| 16 | +<!-- end id4 --> | ||
| 17 | +<!-- npu="310p" id5 --> | ||
| 18 | +- Atlas 推理系列产品AI Core:不支持 | ||
| 19 | +<!-- end id5 --> | ||
| 20 | +<!-- npu="310p" id6 --> | ||
| 21 | +- Atlas 推理系列产品Vector Core:不支持 | ||
| 22 | +<!-- end id6 --> | ||
| 23 | +<!-- npu="910" id7 --> | ||
| 24 | +- Atlas 训练系列产品:不支持 | ||
| 25 | +<!-- end id7 --> | ||
| 26 | + | ||
| 27 | +## 功能说明 | ||
| 28 | + | ||
| 29 | +头文件路径:`"c_api/scalar_compute/scalar_compute.h"`。 | ||
| 30 | + | ||
| 31 | +对Global Memory中address指向的元素执行原子赋值操作,即将该元素值设置为val。 | ||
| 32 | + | ||
| 33 | +## 函数原型 | ||
| 34 | + | ||
| 35 | +```cpp | ||
| 36 | +__aicore__ inline float asc_atomic_exch(__gm__ float *address, float val) | ||
| 37 | + | ||
| 38 | +__aicore__ inline int32_t asc_atomic_exch(__gm__ int32_t *address, int32_t val) | ||
| 39 | + | ||
| 40 | +__aicore__ inline uint32_t asc_atomic_exch(__gm__ uint32_t *address, uint32_t val) | ||
| 41 | + | ||
| 42 | +__aicore__ inline int64_t asc_atomic_exch(__gm__ int64_t *address, int64_t val) | ||
| 43 | + | ||
| 44 | +__aicore__ inline uint64_t asc_atomic_exch(__gm__ uint64_t *address, uint64_t val) | ||
| 45 | +``` | ||
| 46 | + | ||
| 47 | +## 参数说明 | ||
| 48 | + | ||
| 49 | +| 参数名 | 输入/输出 | 描述 | | ||
| 50 | +| --- | --- | --- | | ||
| 51 | +| address | 输出 | Global Memory的地址。 | | ||
| 52 | +| val | 输入 | 源操作数。 | | ||
| 53 | + | ||
| 54 | +## 返回值说明 | ||
| 55 | + | ||
| 56 | +address地址中计算前的原始数据。 | ||
| 57 | + | ||
| 58 | +## 流水类型 | ||
| 59 | + | ||
| 60 | +PIPE_S | ||
| 61 | + | ||
| 62 | +## 约束说明 | ||
| 63 | + | ||
| 64 | +- 在开启编译器自动同步功能的前提下,编译器能够自动在PIPE_MTE2/PIPE_MTE3与PIPE_S之间插入同步。但是,asc_atomic_exch为标量计算,在读写GM时如果与搬运单元(MTE2/MTE3)存在数据依赖,编译器却无法自动插入同步,开发者需要根据实际情况手动插入同步。 | ||
| 65 | +- Scalar原子操作会绕过DCache,需要调用[asc_dcci](../cache_ctrl/asc_dcci.md)接口确保GM与DCache的一致性。 | ||
| 66 | + | ||
| 67 | +## 调用示例 | ||
| 68 | + | ||
| 69 | +```cpp | ||
| 70 | +int32_t dst = 10; // 初始值 | ||
| 71 | +asc_dcci_entire_all(); // 手动同步 | ||
| 72 | +int32_t old = asc_atomic_exch(&dst, 20); // dst = 20, old = 10 | ||
| 73 | +``` | ||
| @@ -0,0 +1,67 @@ | |||
| 1 | +# asc_atomic_inc | ||
| 2 | + | ||
| 3 | +## 产品支持情况 | ||
| 4 | + | ||
| 5 | +<!-- npu="950" id1 --> | ||
| 6 | +- Ascend 950PR/Ascend 950DT:支持 | ||
| 7 | +<!-- end id1 --> | ||
| 8 | +<!-- npu="A3" id2 --> | ||
| 9 | +- Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持 | ||
| 10 | +<!-- end id2 --> | ||
| 11 | +<!-- npu="910b" id3 --> | ||
| 12 | +- Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持 | ||
| 13 | +<!-- end id3 --> | ||
| 14 | +<!-- npu="310b" id4 --> | ||
| 15 | +- Atlas 200I/500 A2 推理产品:不支持 | ||
| 16 | +<!-- end id4 --> | ||
| 17 | +<!-- npu="310p" id5 --> | ||
| 18 | +- Atlas 推理系列产品AI Core:不支持 | ||
| 19 | +<!-- end id5 --> | ||
| 20 | +<!-- npu="310p" id6 --> | ||
| 21 | +- Atlas 推理系列产品Vector Core:不支持 | ||
| 22 | +<!-- end id6 --> | ||
| 23 | +<!-- npu="910" id7 --> | ||
| 24 | +- Atlas 训练系列产品:不支持 | ||
| 25 | +<!-- end id7 --> | ||
| 26 | + | ||
| 27 | +## 功能说明 | ||
| 28 | + | ||
| 29 | +头文件路径:`"c_api/scalar_compute/scalar_compute.h"`。 | ||
| 30 | + | ||
| 31 | +对Global Memory中address指向的计数器执行原子递增操作,如果address上的数值大于等于指定数值val,则对address赋值为0,否则将address上数值加1。 | ||
| 32 | + | ||
| 33 | +## 函数原型 | ||
| 34 | + | ||
| 35 | +```cpp | ||
| 36 | +__aicore__ inline uint32_t asc_atomic_inc(__gm__ uint32_t *address, uint32_t val) | ||
| 37 | + | ||
| 38 | +__aicore__ inline uint64_t asc_atomic_inc(__gm__ uint64_t *address, uint64_t val) | ||
| 39 | +``` | ||
| 40 | + | ||
| 41 | +## 参数说明 | ||
| 42 | + | ||
| 43 | +| 参数名 | 输入/输出 | 描述 | | ||
| 44 | +| --- | --- | --- | | ||
| 45 | +| address | 输出 | Global Memory的地址。 | | ||
| 46 | +| val | 输入 | 源操作数。 | | ||
| 47 | + | ||
| 48 | +## 返回值说明 | ||
| 49 | + | ||
| 50 | +address地址中计算前的原始数据。 | ||
| 51 | + | ||
| 52 | +## 流水类型 | ||
| 53 | + | ||
| 54 | +PIPE_S | ||
| 55 | + | ||
| 56 | +## 约束说明 | ||
| 57 | + | ||
| 58 | +- 在开启编译器自动同步功能的前提下,编译器能够自动在PIPE_MTE2/PIPE_MTE3与PIPE_S之间插入同步。但是,asc_atomic_inc为标量计算,在读写GM时如果与搬运单元(MTE2/MTE3)存在数据依赖,编译器却无法自动插入同步,开发者需要根据实际情况手动插入同步。 | ||
| 59 | +- Scalar原子操作会绕过DCache,需要调用[asc_dcci](../cache_ctrl/asc_dcci.md)接口确保GM与DCache的一致性。 | ||
| 60 | + | ||
| 61 | +## 调用示例 | ||
| 62 | + | ||
| 63 | +```cpp | ||
| 64 | +uint32_t counter = 0; // 初始值 | ||
| 65 | +asc_dcci_entire_all(); // 手动同步 | ||
| 66 | +uint32_t old = asc_atomic_inc(&counter, 9); // counter = 1, old = 0 | ||
| 67 | +``` | ||
| @@ -0,0 +1,73 @@ | |||
| 1 | +# asc_atomic_max | ||
| 2 | + | ||
| 3 | +## 产品支持情况 | ||
| 4 | + | ||
| 5 | +<!-- npu="950" id1 --> | ||
| 6 | +- Ascend 950PR/Ascend 950DT:支持 | ||
| 7 | +<!-- end id1 --> | ||
| 8 | +<!-- npu="A3" id2 --> | ||
| 9 | +- Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持 | ||
| 10 | +<!-- end id2 --> | ||
| 11 | +<!-- npu="910b" id3 --> | ||
| 12 | +- Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持 | ||
| 13 | +<!-- end id3 --> | ||
| 14 | +<!-- npu="310b" id4 --> | ||
| 15 | +- Atlas 200I/500 A2 推理产品:不支持 | ||
| 16 | +<!-- end id4 --> | ||
| 17 | +<!-- npu="310p" id5 --> | ||
| 18 | +- Atlas 推理系列产品AI Core:不支持 | ||
| 19 | +<!-- end id5 --> | ||
| 20 | +<!-- npu="310p" id6 --> | ||
| 21 | +- Atlas 推理系列产品Vector Core:不支持 | ||
| 22 | +<!-- end id6 --> | ||
| 23 | +<!-- npu="910" id7 --> | ||
| 24 | +- Atlas 训练系列产品:不支持 | ||
| 25 | +<!-- end id7 --> | ||
| 26 | + | ||
| 27 | +## 功能说明 | ||
| 28 | + | ||
| 29 | +头文件路径:`"c_api/scalar_compute/scalar_compute.h"`。 | ||
| 30 | + | ||
| 31 | +对Global Memory中的数据与指定数据执行原子求最大值操作,即将address指向的数据元素与val中的最大值写回到该地址。 | ||
| 32 | + | ||
| 33 | +## 函数原型 | ||
| 34 | + | ||
| 35 | +```cpp | ||
| 36 | +__aicore__ inline int32_t asc_atomic_max(__gm__ int32_t *address, int32_t val) | ||
| 37 | + | ||
| 38 | +__aicore__ inline uint32_t asc_atomic_max(__gm__ uint32_t *address, uint32_t val) | ||
| 39 | + | ||
| 40 | +__aicore__ inline float asc_atomic_max(__gm__ float *address, float val) | ||
| 41 | + | ||
| 42 | +__aicore__ inline int64_t asc_atomic_max(__gm__ int64_t *address, int64_t val) | ||
| 43 | + | ||
| 44 | +__aicore__ inline uint64_t asc_atomic_max(__gm__ uint64_t *address, uint64_t val) | ||
| 45 | +``` | ||
| 46 | + | ||
| 47 | +## 参数说明 | ||
| 48 | + | ||
| 49 | +| 参数名 | 输入/输出 | 描述 | | ||
| 50 | +| --- | --- | --- | | ||
| 51 | +| address | 输出 | Global Memory的地址。 | | ||
| 52 | +| val | 输入 | 源操作数。 | | ||
| 53 | + | ||
| 54 | +## 返回值说明 | ||
| 55 | + | ||
| 56 | +address地址中计算前的原始数据。 | ||
| 57 | + | ||
| 58 | +## 流水类型 | ||
| 59 | + | ||
| 60 | +PIPE_S | ||
| 61 | + | ||
| 62 | +## 约束说明 | ||
| 63 | + | ||
| 64 | +- 在开启编译器自动同步功能的前提下,编译器能够自动在PIPE_MTE2/PIPE_MTE3与PIPE_S之间插入同步。但是,asc_atomic_max为标量计算,在读写GM时如果与搬运单元(MTE2/MTE3)存在数据依赖,编译器却无法自动插入同步,开发者需要根据实际情况手动插入同步。 | ||
| 65 | +- Scalar原子操作会绕过DCache,需要调用[asc_dcci](../cache_ctrl/asc_dcci.md)接口确保GM与DCache的一致性。 | ||
| 66 | + | ||
| 67 | +## 调用示例 | ||
| 68 | + | ||
| 69 | +```cpp | ||
| 70 | +int32_t dst = 10; // 初始值 | ||
| 71 | +asc_dcci_entire_all(); // 手动同步 | ||
| 72 | +int32_t old = asc_atomic_max(&dst, 20); // dst = 20, old = 10 | ||
| 73 | +``` | ||
| @@ -0,0 +1,73 @@ | |||
| 1 | +# asc_atomic_min | ||
| 2 | + | ||
| 3 | +## 产品支持情况 | ||
| 4 | + | ||
| 5 | +<!-- npu="950" id1 --> | ||
| 6 | +- Ascend 950PR/Ascend 950DT:支持 | ||
| 7 | +<!-- end id1 --> | ||
| 8 | +<!-- npu="A3" id2 --> | ||
| 9 | +- Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持 | ||
| 10 | +<!-- end id2 --> | ||
| 11 | +<!-- npu="910b" id3 --> | ||
| 12 | +- Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持 | ||
| 13 | +<!-- end id3 --> | ||
| 14 | +<!-- npu="310b" id4 --> | ||
| 15 | +- Atlas 200I/500 A2 推理产品:不支持 | ||
| 16 | +<!-- end id4 --> | ||
| 17 | +<!-- npu="310p" id5 --> | ||
| 18 | +- Atlas 推理系列产品AI Core:不支持 | ||
| 19 | +<!-- end id5 --> | ||
| 20 | +<!-- npu="310p" id6 --> | ||
| 21 | +- Atlas 推理系列产品Vector Core:不支持 | ||
| 22 | +<!-- end id6 --> | ||
| 23 | +<!-- npu="910" id7 --> | ||
| 24 | +- Atlas 训练系列产品:不支持 | ||
| 25 | +<!-- end id7 --> | ||
| 26 | + | ||
| 27 | +## 功能说明 | ||
| 28 | + | ||
| 29 | +头文件路径:`"c_api/scalar_compute/scalar_compute.h"`。 | ||
| 30 | + | ||
| 31 | +对Global Memory中的数据与指定数据执行原子求最小值操作,即将address指向的数据元素与val中的最小值写回到该地址。 | ||
| 32 | + | ||
| 33 | +## 函数原型 | ||
| 34 | + | ||
| 35 | +```cpp | ||
| 36 | +__aicore__ inline int32_t asc_atomic_min(__gm__ int32_t *address, int32_t val) | ||
| 37 | + | ||
| 38 | +__aicore__ inline uint32_t asc_atomic_min(__gm__ uint32_t *address, uint32_t val) | ||
| 39 | + | ||
| 40 | +__aicore__ inline float asc_atomic_min(__gm__ float *address, float val) | ||
| 41 | + | ||
| 42 | +__aicore__ inline int64_t asc_atomic_min(__gm__ int64_t *address, int64_t val) | ||
| 43 | + | ||
| 44 | +__aicore__ inline uint64_t asc_atomic_min(__gm__ uint64_t *address, uint64_t val) | ||
| 45 | +``` | ||
| 46 | + | ||
| 47 | +## 参数说明 | ||
| 48 | + | ||
| 49 | +| 参数名 | 输入/输出 | 描述 | | ||
| 50 | +| --- | --- | --- | | ||
| 51 | +| address | 输出 | Global Memory的地址。 | | ||
| 52 | +| val | 输入 | 源操作数。 | | ||
| 53 | + | ||
| 54 | +## 返回值说明 | ||
| 55 | + | ||
| 56 | +address地址中计算前的原始数据。 | ||
| 57 | + | ||
| 58 | +## 流水类型 | ||
| 59 | + | ||
| 60 | +PIPE_S | ||
| 61 | + | ||
| 62 | +## 约束说明 | ||
| 63 | + | ||
| 64 | +- 在开启编译器自动同步功能的前提下,编译器能够自动在PIPE_MTE2/PIPE_MTE3与PIPE_S之间插入同步。但是,asc_atomic_min为标量计算,在读写GM时如果与搬运单元(MTE2/MTE3)存在数据依赖,编译器却无法自动插入同步,开发者需要根据实际情况手动插入同步。 | ||
| 65 | +- Scalar原子操作会绕过DCache,需要调用[asc_dcci](../cache_ctrl/asc_dcci.md)接口确保GM与DCache的一致性。 | ||
| 66 | + | ||
| 67 | +## 调用示例 | ||
| 68 | + | ||
| 69 | +```cpp | ||
| 70 | +int32_t dst = 10; // 初始值 | ||
| 71 | +asc_dcci_entire_all(); // 手动同步 | ||
| 72 | +int32_t old = asc_atomic_min(&dst, 3); // dst = min(10, 3) = 3。 old = 10,即在进行asc_atomic_min操作前dst的值。 | ||
| 73 | +``` | ||
| @@ -0,0 +1,71 @@ | |||
| 1 | +# asc_atomic_or | ||
| 2 | + | ||
| 3 | +## 产品支持情况 | ||
| 4 | + | ||
| 5 | +<!-- npu="950" id1 --> | ||
| 6 | +- Ascend 950PR/Ascend 950DT:支持 | ||
| 7 | +<!-- end id1 --> | ||
| 8 | +<!-- npu="A3" id2 --> | ||
| 9 | +- Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持 | ||
| 10 | +<!-- end id2 --> | ||
| 11 | +<!-- npu="910b" id3 --> | ||
| 12 | +- Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持 | ||
| 13 | +<!-- end id3 --> | ||
| 14 | +<!-- npu="310b" id4 --> | ||
| 15 | +- Atlas 200I/500 A2 推理产品:不支持 | ||
| 16 | +<!-- end id4 --> | ||
| 17 | +<!-- npu="310p" id5 --> | ||
| 18 | +- Atlas 推理系列产品AI Core:不支持 | ||
| 19 | +<!-- end id5 --> | ||
| 20 | +<!-- npu="310p" id6 --> | ||
| 21 | +- Atlas 推理系列产品Vector Core:不支持 | ||
| 22 | +<!-- end id6 --> | ||
| 23 | +<!-- npu="910" id7 --> | ||
| 24 | +- Atlas 训练系列产品:不支持 | ||
| 25 | +<!-- end id7 --> | ||
| 26 | + | ||
| 27 | +## 功能说明 | ||
| 28 | + | ||
| 29 | +头文件路径:`"c_api/scalar_compute/scalar_compute.h"`。 | ||
| 30 | + | ||
| 31 | +对Global Memory中的数据与指定数据执行原子或操作,即将val按位或到address指向的数据元素上。 | ||
| 32 | + | ||
| 33 | +## 函数原型 | ||
| 34 | + | ||
| 35 | +```cpp | ||
| 36 | +__aicore__ inline int32_t asc_atomic_or(__gm__ int32_t *address, int32_t val) | ||
| 37 | + | ||
| 38 | +__aicore__ inline uint32_t asc_atomic_or(__gm__ uint32_t *address, uint32_t val) | ||
| 39 | + | ||
| 40 | +__aicore__ inline int64_t asc_atomic_or(__gm__ int64_t *address, int64_t val) | ||
| 41 | + | ||
| 42 | +__aicore__ inline uint64_t asc_atomic_or(__gm__ uint64_t *address, uint64_t val) | ||
| 43 | +``` | ||
| 44 | + | ||
| 45 | +## 参数说明 | ||
| 46 | + | ||
| 47 | +| 参数名 | 输入/输出 | 描述 | | ||
| 48 | +| --- | --- | --- | | ||
| 49 | +| address | 输出 | Global Memory的地址。 | | ||
| 50 | +| val | 输入 | 源操作数。 | | ||
| 51 | + | ||
| 52 | +## 返回值说明 | ||
| 53 | + | ||
| 54 | +address地址中计算前的原始数据。 | ||
| 55 | + | ||
| 56 | +## 流水类型 | ||
| 57 | + | ||
| 58 | +PIPE_S | ||
| 59 | + | ||
| 60 | +## 约束说明 | ||
| 61 | + | ||
| 62 | +- 在开启编译器自动同步功能的前提下,编译器能够自动在PIPE_MTE2/PIPE_MTE3与PIPE_S之间插入同步。但是,asc_atomic_or为标量计算,在读写GM时如果与搬运单元(MTE2/MTE3)存在数据依赖,编译器却无法自动插入同步,开发者需要根据实际情况手动插入同步。 | ||
| 63 | +- Scalar原子操作会绕过DCache,需要调用[asc_dcci](../cache_ctrl/asc_dcci.md)接口确保GM与DCache的一致性。 | ||
| 64 | + | ||
| 65 | +## 调用示例 | ||
| 66 | + | ||
| 67 | +```cpp | ||
| 68 | +uint32_t dst = 0x0; // 初始值 | ||
| 69 | +asc_dcci_entire_all(); // 手动同步 | ||
| 70 | +uint32_t old = asc_atomic_or(&dst, 0x5); // dst = 0x5, old = 0x0 | ||
| 71 | +``` | ||
| @@ -0,0 +1,73 @@ | |||
| 1 | +# asc_atomic_sub | ||
| 2 | + | ||
| 3 | +## 产品支持情况 | ||
| 4 | + | ||
| 5 | +<!-- npu="950" id1 --> | ||
| 6 | +- Ascend 950PR/Ascend 950DT:支持 | ||
| 7 | +<!-- end id1 --> | ||
| 8 | +<!-- npu="A3" id2 --> | ||
| 9 | +- Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持 | ||
| 10 | +<!-- end id2 --> | ||
| 11 | +<!-- npu="910b" id3 --> | ||
| 12 | +- Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持 | ||
| 13 | +<!-- end id3 --> | ||
| 14 | +<!-- npu="310b" id4 --> | ||
| 15 | +- Atlas 200I/500 A2 推理产品:不支持 | ||
| 16 | +<!-- end id4 --> | ||
| 17 | +<!-- npu="310p" id5 --> | ||
| 18 | +- Atlas 推理系列产品AI Core:不支持 | ||
| 19 | +<!-- end id5 --> | ||
| 20 | +<!-- npu="310p" id6 --> | ||
| 21 | +- Atlas 推理系列产品Vector Core:不支持 | ||
| 22 | +<!-- end id6 --> | ||
| 23 | +<!-- npu="910" id7 --> | ||
| 24 | +- Atlas 训练系列产品:不支持 | ||
| 25 | +<!-- end id7 --> | ||
| 26 | + | ||
| 27 | +## 功能说明 | ||
| 28 | + | ||
| 29 | +头文件路径:`"c_api/scalar_compute/scalar_compute.h"`。 | ||
| 30 | + | ||
| 31 | +对Global Memory中的数据与指定数据执行原子减操作,即将val从address指向的数据元素上减去。 | ||
| 32 | + | ||
| 33 | +## 函数原型 | ||
| 34 | + | ||
| 35 | +```cpp | ||
| 36 | +__aicore__ inline int32_t asc_atomic_sub(__gm__ int32_t *address, int32_t val) | ||
| 37 | + | ||
| 38 | +__aicore__ inline uint32_t asc_atomic_sub(__gm__ uint32_t *address, uint32_t val) | ||
| 39 | + | ||
| 40 | +__aicore__ inline float asc_atomic_sub(__gm__ float *address, float val) | ||
| 41 | + | ||
| 42 | +__aicore__ inline int64_t asc_atomic_sub(__gm__ int64_t *address, int64_t val) | ||
| 43 | + | ||
| 44 | +__aicore__ inline uint64_t asc_atomic_sub(__gm__ uint64_t *address, uint64_t val) | ||
| 45 | +``` | ||
| 46 | + | ||
| 47 | +## 参数说明 | ||
| 48 | + | ||
| 49 | +| 参数名 | 输入/输出 | 描述 | | ||
| 50 | +| --- | --- | --- | | ||
| 51 | +| address | 输出 | Global Memory的地址。 | | ||
| 52 | +| val | 输入 | 源操作数。 | | ||
| 53 | + | ||
| 54 | +## 返回值说明 | ||
| 55 | + | ||
| 56 | +address地址中计算前的原始数据。 | ||
| 57 | + | ||
| 58 | +## 流水类型 | ||
| 59 | + | ||
| 60 | +PIPE_S | ||
| 61 | + | ||
| 62 | +## 约束说明 | ||
| 63 | + | ||
| 64 | +- 在开启编译器自动同步功能的前提下,编译器能够自动在PIPE_MTE2/PIPE_MTE3与PIPE_S之间插入同步。但是,asc_atomic_sub为标量计算,在读写GM时如果与搬运单元(MTE2/MTE3)存在数据依赖,编译器却无法自动插入同步,开发者需要根据实际情况手动插入同步。 | ||
| 65 | +- Scalar原子操作会绕过DCache,需要调用[asc_dcci](../cache_ctrl/asc_dcci.md)接口确保GM与DCache的一致性。 | ||
| 66 | + | ||
| 67 | +## 调用示例 | ||
| 68 | + | ||
| 69 | +```cpp | ||
| 70 | +int32_t dst = 10; // 初始值 | ||
| 71 | +asc_dcci_entire_all(); // 手动同步 | ||
| 72 | +int32_t old = asc_atomic_sub(&dst, 3); // dst = 7, old = 10 | ||
| 73 | +``` | ||
| @@ -0,0 +1,71 @@ | |||
| 1 | +# asc_atomic_xor | ||
| 2 | + | ||
| 3 | +## 产品支持情况 | ||
| 4 | + | ||
| 5 | +<!-- npu="950" id1 --> | ||
| 6 | +- Ascend 950PR/Ascend 950DT:支持 | ||
| 7 | +<!-- end id1 --> | ||
| 8 | +<!-- npu="A3" id2 --> | ||
| 9 | +- Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持 | ||
| 10 | +<!-- end id2 --> | ||
| 11 | +<!-- npu="910b" id3 --> | ||
| 12 | +- Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持 | ||
| 13 | +<!-- end id3 --> | ||
| 14 | +<!-- npu="310b" id4 --> | ||
| 15 | +- Atlas 200I/500 A2 推理产品:不支持 | ||
| 16 | +<!-- end id4 --> | ||
| 17 | +<!-- npu="310p" id5 --> | ||
| 18 | +- Atlas 推理系列产品AI Core:不支持 | ||
| 19 | +<!-- end id5 --> | ||
| 20 | +<!-- npu="310p" id6 --> | ||
| 21 | +- Atlas 推理系列产品Vector Core:不支持 | ||
| 22 | +<!-- end id6 --> | ||
| 23 | +<!-- npu="910" id7 --> | ||
| 24 | +- Atlas 训练系列产品:不支持 | ||
| 25 | +<!-- end id7 --> | ||
| 26 | + | ||
| 27 | +## 功能说明 | ||
| 28 | + | ||
| 29 | +头文件路径:`"c_api/scalar_compute/scalar_compute.h"`。 | ||
| 30 | + | ||
| 31 | +对Global Memory中的数据与指定数据执行原子异或操作,即将val按位异或到address指向的数据元素上。 | ||
| 32 | + | ||
| 33 | +## 函数原型 | ||
| 34 | + | ||
| 35 | +```cpp | ||
| 36 | +__aicore__ inline int32_t asc_atomic_xor(__gm__ int32_t *address, int32_t val) | ||
| 37 | + | ||
| 38 | +__aicore__ inline uint32_t asc_atomic_xor(__gm__ uint32_t *address, uint32_t val) | ||
| 39 | + | ||
| 40 | +__aicore__ inline int64_t asc_atomic_xor(__gm__ int64_t *address, int64_t val) | ||
| 41 | + | ||
| 42 | +__aicore__ inline uint64_t asc_atomic_xor(__gm__ uint64_t *address, uint64_t val) | ||
| 43 | +``` | ||
| 44 | + | ||
| 45 | +## 参数说明 | ||
| 46 | + | ||
| 47 | +| 参数名 | 输入/输出 | 描述 | | ||
| 48 | +| --- | --- | --- | | ||
| 49 | +| address | 输出 | Global Memory的地址。 | | ||
| 50 | +| val | 输入 | 源操作数。 | | ||
| 51 | + | ||
| 52 | +## 返回值说明 | ||
| 53 | + | ||
| 54 | +address地址中计算前的原始数据。 | ||
| 55 | + | ||
| 56 | +## 流水类型 | ||
| 57 | + | ||
| 58 | +PIPE_S | ||
| 59 | + | ||
| 60 | +## 约束说明 | ||
| 61 | + | ||
| 62 | +- 在开启编译器自动同步功能的前提下,编译器能够自动在PIPE_MTE2/PIPE_MTE3与PIPE_S之间插入同步。但是,asc_atomic_xor为标量计算,在读写GM时如果与搬运单元(MTE2/MTE3)存在数据依赖,编译器却无法自动插入同步,开发者需要根据实际情况手动插入同步。 | ||
| 63 | +- Scalar原子操作会绕过DCache,需要调用[asc_dcci](../cache_ctrl/asc_dcci.md)接口确保GM与DCache的一致性。 | ||
| 64 | + | ||
| 65 | +## 调用示例 | ||
| 66 | + | ||
| 67 | +```cpp | ||
| 68 | +uint32_t dst = 0x0; // 初始值 | ||
| 69 | +asc_dcci_entire_all(); // 手动同步 | ||
| 70 | +uint32_t old = asc_atomic_xor(&dst, 0x1); // dst = 0x1, old = 0x0 | ||
| 71 | +``` | ||
| @@ -19,3 +19,25 @@ | |||
| 19 | - **[asc_store_dev](asc_store_dev.md)** | 19 | - **[asc_store_dev](asc_store_dev.md)** |
| 20 | 20 | ||
| 21 | - **[asc_zero_bits_cnt](asc_zero_bits_cnt.md)** | 21 | - **[asc_zero_bits_cnt](asc_zero_bits_cnt.md)** |
| 22 | + | ||
| 23 | +- **[asc_atomic_add](asc_atomic_add.md)** | ||
| 24 | + | ||
| 25 | +- **[asc_atomic_sub](asc_atomic_sub.md)** | ||
| 26 | + | ||
| 27 | +- **[asc_atomic_or](asc_atomic_or.md)** | ||
| 28 | + | ||
| 29 | +- **[asc_atomic_xor](asc_atomic_xor.md)** | ||
| 30 | + | ||
| 31 | +- **[asc_atomic_and](asc_atomic_and.md)** | ||
| 32 | + | ||
| 33 | +- **[asc_atomic_max](asc_atomic_max.md)** | ||
| 34 | + | ||
| 35 | +- **[asc_atomic_min](asc_atomic_min.md)** | ||
| 36 | + | ||
| 37 | +- **[asc_atomic_inc](asc_atomic_inc.md)** | ||
| 38 | + | ||
| 39 | +- **[asc_atomic_dec](asc_atomic_dec.md)** | ||
| 40 | + | ||
| 41 | +- **[asc_atomic_exch](asc_atomic_exch.md)** | ||
| 42 | + | ||
| 43 | +- **[asc_atomic_cas](asc_atomic_cas.md)** | ||
| @@ -12,11 +12,15 @@ | |||
| 12 | 12 | ||
| 13 | 头文件路径:`"c_api/atomic/atomic.h"`。 | 13 | 头文件路径:`"c_api/atomic/atomic.h"`。 |
| 14 | 14 | ||
| 15 | -获取原子操作启用位与原子操作类型的值。 | 15 | +获取原子操作启用位与原子操作类型的值,可用于校验[asc_set_store_atomic_config_v1](./asc_set_store_atomic_config_v1.md)和[asc_set_store_atomic_config_v2(废弃)](./asc_set_store_atomic_config_v2_deprecated.md)设置的原子操作启用位和原子操作类型的值是否符合预期。 |
| 16 | + | ||
| 17 | +<!-- npu="950" id1 --> | ||
| 18 | +**Ascend 950PR/Ascend 950DT产品上该接口已废弃。原子加操作可以直接使用[asc_atomic_add](../scalar_compute/asc_atomic_add.md)实现。无需再对原子操作启用位和原子操作类型的值进行配置和校验。** | ||
| 19 | +<!-- end id1 --> | ||
| 16 | 20 | ||
| 17 | ## 函数原型 | 21 | ## 函数原型 |
| 18 | 22 | ||
| 19 | -```c++ | 23 | +```cpp |
| 20 | __aicore__ inline void asc_get_store_atomic_config(asc_store_atomic_config& config) | 24 | __aicore__ inline void asc_get_store_atomic_config(asc_store_atomic_config& config) |
| 21 | ``` | 25 | ``` |
| 22 | 26 | ||
| @@ -36,11 +40,11 @@ PIPE_S | |||
| 36 | 40 | ||
| 37 | ## 约束说明 | 41 | ## 约束说明 |
| 38 | 42 | ||
| 39 | -- 需配合[asc_set_store_atomic_config_v1](./asc_set_store_atomic_config_v1.md)和[asc_set_store_atomic_config_v2](./asc_set_store_atomic_config_v2.md)接口使用,该接口用于设置原子操作启用位和原子操作类型的值。 | 43 | +- 需配合[asc_set_store_atomic_config_v1](./asc_set_store_atomic_config_v1.md)和[asc_set_store_atomic_config_v2(废弃)](./asc_set_store_atomic_config_v2_deprecated.md)接口使用,该接口用于设置原子操作启用位和原子操作类型的值。 |
| 40 | 44 | ||
| 41 | ## 调用示例 | 45 | ## 调用示例 |
| 42 | 46 | ||
| 43 | -```c++ | 47 | +```cpp |
| 44 | uint16_t atomic_type = 1; // 开启原子操作,进行原子操作的数据类型为float,值为1 | 48 | uint16_t atomic_type = 1; // 开启原子操作,进行原子操作的数据类型为float,值为1 |
| 45 | uint16_t atomic_op = 0; // 求和操作,值为0 | 49 | uint16_t atomic_op = 0; // 求和操作,值为0 |
| 46 | asc_set_store_atomic_config_v1(atomic_type, atomic_op); | 50 | asc_set_store_atomic_config_v1(atomic_type, atomic_op); |
| @@ -1,4 +1,4 @@ | |||
| 1 | -# asc_set_store_atomic_config_v2 | 1 | +# asc_set_store_atomic_config_v2(废弃) |
| 2 | 2 | ||
| 3 | ## 产品支持情况 | 3 | ## 产品支持情况 |
| 4 | 4 | ||
| @@ -8,6 +8,8 @@ | |||
| 8 | 8 | ||
| 9 | ## 功能说明 | 9 | ## 功能说明 |
| 10 | 10 | ||
| 11 | +**该接口已废弃。原子加操作请使用[asc_atomic_add](../scalar_compute/asc_atomic_add.md)实现。** | ||
| 12 | + | ||
| 11 | 头文件路径:`"c_api/atomic/atomic.h"`。 | 13 | 头文件路径:`"c_api/atomic/atomic.h"`。 |
| 12 | 14 | ||
| 13 | 设置原子操作启用位与原子操作类型的值。 | 15 | 设置原子操作启用位与原子操作类型的值。 |
| @@ -43,4 +45,4 @@ PIPE_S | |||
| 43 | uint16_t type = 1; | 45 | uint16_t type = 1; |
| 44 | uint16_t op = 2; | 46 | uint16_t op = 2; |
| 45 | asc_set_store_atomic_config_v2(type, op); | 47 | asc_set_store_atomic_config_v2(type, op); |
| 46 | -``` | 48 | +``` |
| @@ -12,4 +12,4 @@ | |||
| 12 | 12 | ||
| 13 | - **[asc_set_store_atomic_config_v1](asc_set_store_atomic_config_v1.md)** | 13 | - **[asc_set_store_atomic_config_v1](asc_set_store_atomic_config_v1.md)** |
| 14 | 14 | ||
| 15 | -- **[asc_set_store_atomic_config_v2](asc_set_store_atomic_config_v2.md)** | 15 | +- **[asc_set_store_atomic_config_v2(废弃)](asc_set_store_atomic_config_v2_deprecated.md)** |
| @@ -62,6 +62,8 @@ __aicore__ inline void asc_set_atomic_min_bfloat() | |||
| 62 | asc_set_atomic_min_bfloat_impl(); | 62 | asc_set_atomic_min_bfloat_impl(); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | +[[deprecated("NOTICE: asc_set_store_atomic_config_v2 is deprecated." | ||
| 66 | + "Please use asc_atomic_add instead for atomic add operation.")]] | ||
| 65 | __aicore__ inline void asc_set_store_atomic_config_v2(uint16_t type, uint16_t op) | 67 | __aicore__ inline void asc_set_store_atomic_config_v2(uint16_t type, uint16_t op) |
| 66 | { | 68 | { |
| 67 | asc_set_store_atomic_config_v2_impl(type, op); | 69 | asc_set_store_atomic_config_v2_impl(type, op); |
| @@ -83,6 +85,8 @@ __aicore__ inline void asc_set_atomic_none() | |||
| 83 | } | 85 | } |
| 84 | 86 | ||
| 85 | //===========asc_get_store_atomic_config=========== | 87 | //===========asc_get_store_atomic_config=========== |
| 88 | +[[deprecated("NOTICE: asc_get_store_atomic_config is deprecated on Ascend 950PR/Ascend 950DT." | ||
| 89 | + "Please use asc_atomic_add instead for atomic add operation.")]] | ||
| 86 | __aicore__ inline void asc_get_store_atomic_config(asc_store_atomic_config& config) | 90 | __aicore__ inline void asc_get_store_atomic_config(asc_store_atomic_config& config) |
| 87 | { | 91 | { |
| 88 | asc_get_store_atomic_config_impl(config); | 92 | asc_get_store_atomic_config_impl(config); |
| @@ -154,4 +158,4 @@ __aicore__ inline void asc_set_atomic_min_int16() | |||
| 154 | asc_set_atomic_min_int16_impl(); | 158 | asc_set_atomic_min_int16_impl(); |
| 155 | } | 159 | } |
| 156 | 160 | ||
| 157 | -#endif | 161 | +#endif |
| @@ -76,6 +76,12 @@ __aicore__ inline void asc_set_atomic_add_float16(); | |||
| 76 | 76 | ||
| 77 | __aicore__ inline void asc_set_atomic_max_float(); | 77 | __aicore__ inline void asc_set_atomic_max_float(); |
| 78 | 78 | ||
| 79 | +[[deprecated("NOTICE: asc_get_store_atomic_config is deprecated on Ascend 950PR/Ascend 950DT." | ||
| 80 | + "Please use asc_atomic_add instead for atomic add operation.")]] | ||
| 81 | +__aicore__ inline void asc_get_store_atomic_config(asc_store_atomic_config& config); | ||
| 82 | + | ||
| 83 | +[[deprecated("NOTICE: asc_set_store_atomic_config_v2 is deprecated." | ||
| 84 | + "Please use asc_atomic_add instead for atomic add operation.")]] | ||
| 79 | __aicore__ inline void asc_set_store_atomic_config_v2(uint16_t type, uint16_t op); | 85 | __aicore__ inline void asc_set_store_atomic_config_v2(uint16_t type, uint16_t op); |
| 80 | 86 | ||
| 81 | __aicore__ inline void asc_set_atomic_max_int(); | 87 | __aicore__ inline void asc_set_atomic_max_int(); |


[V-1] P1 | api-rules(e) | address参数标注为"输出"不准确
所有scalar atomic API的参数说明表中address均标注为"输出",但原子操作实际先读取address原值再写入新值,属于"输入/输出"属性。建议统一修正为"输入/输出",与实际语义一致。
此评论由AI生成,如有异议,请回复帮助我更快成长:)