Merged
capi资料刷新 #3
pangfdAdd on Nov 29, 2025
capi资料刷新 #3
Merged
pangfdAdd on Nov 29, 2025
Total: 49 files changed+235-231
@@ -1,6 +1,6 @@
1# C API1# C API
2 2 
3-C API开放芯片完备编程能力,支持以数组形式分配内存,一般基于指针编程。提供与业界一致的C语言编程体验。3+C API开放芯片完备编程能力,支持[以数组形式分配内存](general_instruction.md#以数组方式申请内存),一般基于指针编程。提供与业界一致的C语言编程体验。
4 4 
5## 需要包含的头文件5## 需要包含的头文件
6 6 
@@ -20,7 +20,7 @@ C API开放芯片完备编程能力,支持以数组形式分配内存,一般
20 20 
21## 关键字21## 关键字
22 22 
23-|结构名|描述|23+|名称|描述|
24|-----------------------|-----------------------|24|-----------------------|-----------------------|
25|\_\_gm\_\_|存储空间定义修饰符,表示被修饰的变量位于Global Memory地址空间。|25|\_\_gm\_\_|存储空间定义修饰符,表示被修饰的变量位于Global Memory地址空间。|
26|\_\_ubuf\_\_|存储空间定义修饰符,表示被修饰的变量位于Unified Buffer地址空间。|26|\_\_ubuf\_\_|存储空间定义修饰符,表示被修饰的变量位于Unified Buffer地址空间。|
@@ -49,3 +49,4 @@ NPU内部有不同的计算单元,在计算时往往需要把计算数据搬
49| [同步控制](c_api_list.md#同步控制) |49| [同步控制](c_api_list.md#同步控制) |
50| [系统变量](c_api_list.md#系统变量) |50| [系统变量](c_api_list.md#系统变量) |
51| [原子操作](c_api_list.md#原子操作) |51| [原子操作](c_api_list.md#原子操作) |
52+| [其他操作](c_api_list.md#其他操作) |
@@ -73,12 +73,14 @@
73 73 
74| API名称 | 说明 |74| API名称 | 说明 |
75|----------|-----------|75|----------|-----------|
76+| [asc_get_block_num](sys_var/asc_get_block_num.md) | 获取AI核数。 |
77+| [asc_get_block_idx](sys_var/asc_get_block_idx.md) | 获取当前运行核的索引。 |
78+| [asc_get_core_id](sys_var/asc_get_core_id.md) | 获取当前核的编号。 |
79+| [asc_get_sub_block_id](sys_var/asc_get_sub_block_id.md) | 获取AI Core上Vector核的ID。 |
80+| [asc_get_sub_block_dim](sys_var/asc_get_sub_block_dim.md) | 分离模式下,获取一个AI Core上Cube Core(AIC)或者Vector Core(AIV)的数量。 |
76| [asc_set_ctrl](sys_var/asc_set_ctrl.md) | 设置CTRL寄存器(控制寄存器)的值。 |81| [asc_set_ctrl](sys_var/asc_set_ctrl.md) | 设置CTRL寄存器(控制寄存器)的值。 |
77| [asc_get_ctrl](sys_var/asc_get_ctrl.md) | 读取CTRL寄存器(控制寄存器)的值。 |82| [asc_get_ctrl](sys_var/asc_get_ctrl.md) | 读取CTRL寄存器(控制寄存器)的值。 |
78-| [asc_get_core_id](sys_var/asc_get_core_id.md) | 获取当前核的编号。 |
79| [asc_get_phy_buf_addr](sys_var/asc_get_phy_buf_addr.md) | 基于偏移量获取片上实际物理地址。 |83| [asc_get_phy_buf_addr](sys_var/asc_get_phy_buf_addr.md) | 基于偏移量获取片上实际物理地址。 |
80-| [asc_get_sub_block_dim](sys_var/asc_get_sub_block_dim.md) | 分离模式下,获取一个AI Core上Cube Core(AIC)或者Vector Core(AIV)的数量。 |
81-| [asc_get_sub_block_id](sys_var/asc_get_sub_block_id.md) | 获取AI Core上Vector核的ID。 |
82| [asc_get_system_cycle](sys_var/asc_get_system_cycle.md) | 获取当前系统cycle数。 |84| [asc_get_system_cycle](sys_var/asc_get_system_cycle.md) | 获取当前系统cycle数。 |
83 85 
84## 原子操作86## 原子操作
@@ -87,3 +89,8 @@
87|----------|-----------|89|----------|-----------|
88| [asc_data_cache_clean_and_invalid](simd_atomic/asc_data_cache_clean_and_invalid.md)| 用于刷新Cache, 保证Cache的一致性。 |90| [asc_data_cache_clean_and_invalid](simd_atomic/asc_data_cache_clean_and_invalid.md)| 用于刷新Cache, 保证Cache的一致性。 |
89 91 
92+## 其他操作
93+ 
94+| API名称 | 说明 |
95+|----------|-----------|
96+| [asc_init](misc/asc_init.md)| 初始化NPU状态。 |
@@ -59,10 +59,8 @@ PIPE_TYPE_MTE2
59## 调用示例59## 调用示例
60 60 
61```cpp61```cpp
62-//total_length指参与搬运的数据总长度62+//total_length指参与搬运的数据总长度。src是外部输入的half类型的GM内存。
63uint64_t offset = 0;63uint64_t offset = 0;
64-src_gm = (__gm__ half*)asc_get_phy_buf_addr(0);64+dst = (__ubuf__ half*)asc_get_phy_buf_addr(offset);
65-offset += total_length * sizeof(half);65+asc_copy_gm2ub(dst, src, total_length * sizeof(half));
66-dst_ub = (__ubuf__ half*)asc_get_phy_buf_addr(offset);
67-asc_copy_gm2ub(dst_ub, src_gm, total_length);
68```66```
@@ -59,10 +59,8 @@ PIPE_TYPE_MTE2
59## 调用示例59## 调用示例
60 60 
61```cpp61```cpp
62-//total_length指参与搬运的数据总长度62+//total_length指参与搬运的数据总长度。dst是外部输入的half类型的GM内存。
63uint64_t offset = 0;63uint64_t offset = 0;
64-src_ub_ = (__ubuf__ half*)asc_get_phy_buf_addr(0);64+src = (__ubuf__ half*)asc_get_phy_buf_addr(offset);
65-offset += total_length * sizeof(half);65+asc_copy_ub2gm(dst, src, total_length * sizeof(half));
66-dst_gm = (__gm__ half*)asc_get_phy_buf_addr(offset);
67-asc_copy_ub2gm(dst_gm, src_ub, total_length);
68```66```
@@ -157,4 +157,43 @@ asc_add(dst, src0, src1, config);
157 157 
158mask过程如下:<br>158mask过程如下:<br>
159mask={6148914691236517205, 0}(注:6148914691236517205表示64位二进制数0b010101....01)159mask={6148914691236517205, 0}(注:6148914691236517205表示64位二进制数0b010101....01)
160-![ ](figures/mask_proc2.png)160+![ ](figures/mask_proc2.png)
161+ 
162+## 以数组方式申请内存
163+ 
164+编译器支持以数组方式申请内存。但需注意以下约束:
165+ 
166+- 当前仅支持Ascend 910C和Ascend 910B产品。
167+- 数组方式的申请方式,和asc_get_phy_buf_addr API接口不能混用。否则可能导致地址重叠。
168+- 不支持多维数组和嵌套的数组。
169+- 封装到数据结构中时,不支持隐式构造。
170+- 不支持动态数组。
171+ 
172+基本使用方式如下:
173+ 
174+~~~cpp
175+// 数组长度必须为编译期常量。
176+constexpr uint32_t src_len = 1024;
177+constexpr uint32_t dst_len = 128;
178+ 
179+// 方式1:直接使用。
180+__ubuf__ float src[src_len];
181+__ubuf__ float dst[dst_len];
182+ 
183+// 方式2:封装到结构体中使用。
184+struct UbBuff {
185+ float src[src_len];
186+ float dst[dst_len];
187+}
188+__ubuf__ UbBuff buff{}; // 必须加{},不支持隐式构造。
189+ 
190+// 不支持的场景举例:
191+__ubuf__ UbBuff buff[32]; // 不支持数组嵌套,UbBuff中也存在数组。
192+__ubuf__ float buff[src_len][dst_len]; // 不支持多维数组。
193+__ubuf__ float buff[result_len]; // 不支持动态数组。result_len为前置操作的计算结果。
194+ 
195+// 不支持两种地址申请方式混用。下面的写法获取的src0和src1的起始位置相同:
196+__ubuf__ float* src0 = asc_get_phy_buf_addr(0);
197+__ubuf__ float src1[src_len];
198+ 
199+~~~
Rdocs/api/context/c_api/sync/asc_sync_mte1.md→docs/api/context/c_api/misc/asc_init.md+9-13
@@ -1,27 +1,25 @@
1-# asc_sync_mte11+# asc_init
2 2 
3## AI处理器支持情况3## AI处理器支持情况
4 4 
5-| AI处理器类型 | 是否支持 |5+| AI处理器类型 | 是否支持 |
6| :-----------| :------: |6| :-----------| :------: |
7-| Ascend 910C | √ |7+| Ascend 910C | √ |
8-| Ascend 910B | √ |8+| Ascend 910B | √ |
9 9 
10## 功能说明10## 功能说明
11 11 
12-针对MTE1流水线执行同步操作。12+初始化NPU状态。
13 13 
14## 函数原型14## 函数原型
15 15 
16```cpp16```cpp
17-__aicore__ inline void asc_sync_mte1(int id)17+__aicore__ inline void asc_init()
18```18```
19 19 
20## 参数说明20## 参数说明
21 21 
22-| 参数名 | 输入/输出 | 描述 |22+无
23-| :--- | :--- | :--- |
24-| id | 输入 | 同步ID |
25 23 
26## 返回值说明24## 返回值说明
27 25 
@@ -29,7 +27,7 @@ __aicore__ inline void asc_sync_mte1(int id)
29 27 
30## 流水类型28## 流水类型
31 29 
32-PIPE_S30+PIPE_TYPE_S
33 31 
34## 约束说明32## 约束说明
35 33 
@@ -37,6 +35,4 @@ PIPE_S
37 35 
38## 调用示例36## 调用示例
39 37 
40-```cpp38+无
41-asc_sync_mte1(0);
42-```
@@ -43,5 +43,6 @@ PIPE_TYPE_S
43## 调用示例43## 调用示例
44 44 
45```c++45```c++
46+//dst为外部输入的待刷新的目标地址。
46asc_data_cache_clean_and_invalid(dst, 0);47asc_data_cache_clean_and_invalid(dst, 0);
47```48```
@@ -9,14 +9,14 @@ constexpr uint64_t CAPI_DEFAULT_BINARY_CONFIG_VALUE = 0x0100080808010101;
9union asc_binary_config {9union asc_binary_config {
10 uint64_t config = CAPI_DEFAULT_BINARY_CONFIG_VALUE;10 uint64_t config = CAPI_DEFAULT_BINARY_CONFIG_VALUE;
11 struct {11 struct {
12- uint64_t dst_block_stride: 8;12+ uint64_t dst_block_stride : 8;
13- uint64_t src0_block_stride: 8;13+ uint64_t src0_block_stride : 8;
14- uint64_t src1_block_stride: 8;14+ uint64_t src1_block_stride : 8;
15- uint64_t dst_repeat_stride: 8;15+ uint64_t dst_repeat_stride : 8;
16- uint64_t src0_repeat_stride: 8;16+ uint64_t src0_repeat_stride : 8;
17- uint64_t src1_repeat_stride: 8;17+ uint64_t src1_repeat_stride : 8;
18- uint64_t reserved: 8;18+ uint64_t reserved : 8;
19- uint64_t repeat: 8;19+ uint64_t repeat : 8;
20 };20 };
21};21};
22```22```
@@ -9,10 +9,10 @@ constexpr uint64_t CAPI_DEFAULT_REDUCE_CONFIG_VALUE = 0x0100000800010001;
9union asc_block_reduce_config {9union asc_block_reduce_config {
10 uint64_t config = CAPI_DEFAULT_REDUCE_CONFIG_VALUE;10 uint64_t config = CAPI_DEFAULT_REDUCE_CONFIG_VALUE;
11 struct {11 struct {
12- uint64_t dst_repeat_stride: 16;12+ uint64_t dst_repeat_stride : 16;
13- uint64_t src_block_stride: 16;13+ uint64_t src_block_stride : 16;
14- uint64_t src_repeat_stride: 16;14+ uint64_t src_repeat_stride : 16;
15- uint64_t reserved: 8;15+ uint64_t reserved : 8;
16 uint64_t repeat : 8;16 uint64_t repeat : 8;
17 };17 };
18};18};
@@ -8,11 +8,11 @@ asc_brcb_config为控制操作数地址步长的数据结构。具体使用方
8union asc_brcb_config {8union asc_brcb_config {
9 uint64_t config;9 uint64_t config;
10 struct {10 struct {
11- uint64_t dst_block_stride: 16;11+ uint64_t dst_block_stride : 16;
12- uint64_t reserved1: 16;12+ uint64_t reserved1 : 16;
13- uint64_t dst_repeat_stride: 12;13+ uint64_t dst_repeat_stride : 12;
14- uint64_t reserved2: 12;14+ uint64_t reserved2 : 12;
15- uint64_t repeat: 8;15+ uint64_t repeat : 8;
16 };16 };
17};17};
18```18```
@@ -8,11 +8,11 @@ asc_copy_config为数据搬运操作的控制参数。
8union asc_copy_config {8union asc_copy_config {
9 uint64_t config;9 uint64_t config;
10 struct {10 struct {
11- uint64_t sid: 4;11+ uint64_t sid : 4;
12- uint64_t n_burst: 12;12+ uint64_t n_burst : 12;
13- uint64_t burst_len: 16;13+ uint64_t burst_len : 16;
14- uint64_t src_gap: 16;14+ uint64_t src_gap : 16;
15- uint64_t dst_gap: 16;15+ uint64_t dst_gap : 16;
16 };16 };
17};17};
18```18```
@@ -24,5 +24,5 @@ union asc_copy_config {
24| sid | 保留,未使用。填0即可。 |24| sid | 保留,未使用。填0即可。 |
25| n_burst | 待搬运的连续传输数据块个数。取值范围:[1, 4095]。 |25| n_burst | 待搬运的连续传输数据块个数。取值范围:[1, 4095]。 |
26| burst_len | 待搬运的每个连续传输数据块的长度,单位为DataBlock(32字节)。取值范围:[1, 65535]。 |26| burst_len | 待搬运的每个连续传输数据块的长度,单位为DataBlock(32字节)。取值范围:[1, 65535]。 |
27-| src_gap | 源操作数相邻连续数据块的间隔(前面一个数据块的尾鱼后面一个数据块的头的间隔)。<br>单位为DataBlock(32字节)。取值范围:[1, 65535]。 |27+| src_gap | 源操作数相邻连续数据块的间隔(前面一个数据块的尾与后面一个数据块的头的间隔)。<br>单位为DataBlock(32字节)。 |
28-| dst_gap | 目的操作数相邻连续数据块的间隔(前面一个数据块的尾鱼后面一个数据块的头的间隔)。<br>单位为DataBlock(32字节)。取值范围:[1, 65535]。 |28+| dst_gap | 目的操作数相邻连续数据块的间隔(前面一个数据块的尾与后面一个数据块的头的间隔)。<br>单位为DataBlock(32字节)。 |
@@ -9,11 +9,11 @@ constexpr uint64_t CAPI_DEFAULT_DUPLICATE_CONFIG_VALUE = 0x0100800800010001;
9union asc_duplicate_config {9union asc_duplicate_config {
10 uint64_t config = CAPI_DEFAULT_DUPLICATE_CONFIG_VALUE;10 uint64_t config = CAPI_DEFAULT_DUPLICATE_CONFIG_VALUE;
11 struct {11 struct {
12- uint64_t dst_block_stride: 16;12+ uint64_t dst_block_stride : 16;
13- uint64_t src_block_stride: 16;13+ uint64_t src_block_stride : 16;
14- uint64_t dst_repeat_stride: 12;14+ uint64_t dst_repeat_stride : 12;
15- uint64_t src_repeat_stride: 12;15+ uint64_t src_repeat_stride : 12;
16- uint64_t repeat: 8;16+ uint64_t repeat : 8;
17 };17 };
18};18};
19```19```
@@ -9,11 +9,11 @@ constexpr uint64_t CAPI_DEFAULT_REDUCE_CONFIG_VALUE = 0x0100000800010001;
9union asc_repeat_reduce_config {9union asc_repeat_reduce_config {
10 uint64_t config = CAPI_DEFAULT_REDUCE_CONFIG_VALUE;10 uint64_t config = CAPI_DEFAULT_REDUCE_CONFIG_VALUE;
11 struct {11 struct {
12- uint64_t dst_repeat_stride: 16;12+ uint64_t dst_repeat_stride : 16;
13- uint64_t src_block_stride: 16;13+ uint64_t src_block_stride : 16;
14- uint64_t src_repeat_stride: 16;14+ uint64_t src_repeat_stride : 16;
15- uint64_t reserved: 8;15+ uint64_t reserved : 8;
16- uint64_t repeat: 8;16+ uint64_t repeat : 8;
17 };17 };
18};18};
19```19```
@@ -9,10 +9,10 @@ constexpr uint64_t CAPI_DEFAULT_UNARY_CONFIG_VALUE = 0x0100800800010001;
9union asc_unary_config {9union asc_unary_config {
10 uint64_t config = CAPI_DEFAULT_UNARY_CONFIG_VALUE;10 uint64_t config = CAPI_DEFAULT_UNARY_CONFIG_VALUE;
11 struct {11 struct {
12- uint64_t dst_block_stride: 16;12+ uint64_t dst_block_stride : 16;
13- uint64_t src_block_stride: 16;13+ uint64_t src_block_stride : 16;
14- uint64_t dst_repeat_stride: 12;14+ uint64_t dst_repeat_stride : 12;
15- uint64_t src_repeat_stride: 12;15+ uint64_t src_repeat_stride : 12;
16 uint64_t repeat : 8;16 uint64_t repeat : 8;
17 };17 };
18};18};
@@ -9,12 +9,13 @@
9 9 
10## 功能说明10## 功能说明
11 11 
12-流水线同步屏障,等待指定流水线或所有流水线操作完成。12+等待指定流水线或所有流水线操作完成。
13 13 
14## 函数原型14## 函数原型
15 15 
16```cpp16```cpp
17-__aicore__ inline void asc_sync(pipe_t pipe)17+template<typename Pipe>
18+__aicore__ inline void asc_sync(Pipe pipe);
18__aicore__ inline void asc_sync()19__aicore__ inline void asc_sync()
19```20```
20 21 
@@ -30,7 +31,7 @@ __aicore__ inline void asc_sync()
30 31 
31## 流水类型32## 流水类型
32 33 
33-PIPE_S34+PIPE_TYPE_S
34 35 
35## 约束说明36## 约束说明
36 37 
@@ -39,5 +40,5 @@ PIPE_S
39## 调用示例40## 调用示例
40 41 
41```cpp42```cpp
42-asc_sync_vec();43+asc_sync();
43```44```
@@ -9,7 +9,7 @@
9 9 
10## 功能说明10## 功能说明
11 11 
12-针对MTE2流水线执行特定的同步操作序列(设置并等待标志,然后执行屏障)。12+针对PIPE_TYPE_MTE2流水线执行同步操作。
13 13 
14## 函数原型14## 函数原型
15 15 
@@ -29,7 +29,7 @@ __aicore__ inline void asc_sync_mte2(int id)
29 29 
30## 流水类型30## 流水类型
31 31 
32-PIPE_S32+PIPE_TYPE_S
33 33 
34## 约束说明34## 约束说明
35 35 
@@ -9,7 +9,7 @@
9 9 
10## 功能说明10## 功能说明
11 11 
12-针对MTE3流水线执行特定的同步操作序列(设置并等待标志,然后执行屏障)。12+针对PIPE_TYPE_MTE3流水线执行同步操作。
13 13 
14## 函数原型14## 函数原型
15 15 
@@ -29,7 +29,7 @@ __aicore__ inline void asc_sync_mte3(int id)
29 29 
30## 流水类型30## 流水类型
31 31 
32-PIPE_S32+PIPE_TYPE_S
33 33 
34## 约束说明34## 约束说明
35 35 
@@ -32,7 +32,7 @@ __aicore__ inline void asc_sync_notify(Pipe pipe, TPipe tpipe, int id)
32 32 
33## 流水类型33## 流水类型
34 34 
35-PIPE_S35+PIPE_TYPE_S
36 36 
37## 约束说明37## 约束说明
38 38 
@@ -9,7 +9,7 @@
9 9 
10## 功能说明10## 功能说明
11 11 
12-同步所有流水线,等同于全屏障。12+针对所有流水线执行同步操作。
13 13 
14## 函数原型14## 函数原型
15 15 
@@ -27,7 +27,7 @@ __aicore__ inline void asc_sync_vec()
27 27 
28## 流水类型28## 流水类型
29 29 
30-PIPE_S30+PIPE_TYPE_S
31 31 
32## 约束说明32## 约束说明
33 33 
@@ -32,7 +32,7 @@ __aicore__ inline void asc_sync_wait(Pipe pipe, TPipe tpipe, int id)
32 32 
33## 流水类型33## 流水类型
34 34 
35-PIPE_S35+PIPE_TYPE_S
36 36 
37## 约束说明37## 约束说明
38 38 
Rdocs/api/context/c_api/sync/asc_sync_fixpipe.md→docs/api/context/c_api/sys_var/asc_get_block_idx.md+9-13
@@ -1,27 +1,25 @@
1-# asc_sync_fixpipe1+# asc_get_block_idx
2 2 
3## AI处理器支持情况3## AI处理器支持情况
4 4 
5-| AI处理器类型 | 是否支持 |5+| AI处理器类型 | 是否支持 |
6| :-----------| :------: |6| :-----------| :------: |
7-| Ascend 910C | √ |7+| Ascend 910C | √ |
8-| Ascend 910B | √ |8+| Ascend 910B | √ |
9 9 
10## 功能说明10## 功能说明
11 11 
12-针对Fixpipe流水线执行同步操作。12+获取当前运行核的索引。
13 13 
14## 函数原型14## 函数原型
15 15 
16```cpp16```cpp
17-__aicore__ inline void asc_sync_fixpipe(int id)17+__aicore__ inline int64_t asc_get_block_idx()
18```18```
19 19 
20## 参数说明20## 参数说明
21 21 
22-| 参数名 | 输入/输出 | 描述 |22+无
23-| :--- | :--- | :--- |
24-| id | 输入 | 同步ID |
25 23 
26## 返回值说明24## 返回值说明
27 25 
@@ -29,7 +27,7 @@ __aicore__ inline void asc_sync_fixpipe(int id)
29 27 
30## 流水类型28## 流水类型
31 29 
32-PIPE_S30+PIPE_TYPE_S
33 31 
34## 约束说明32## 约束说明
35 33 
@@ -37,6 +35,4 @@ PIPE_S
37 35 
38## 调用示例36## 调用示例
39 37 
40-```cpp38+无
41-asc_sync_fixpipe(0);
42-```
Rdocs/api/context/c_api/sync/asc_sync_matrix.md→docs/api/context/c_api/sys_var/asc_get_block_num.md+9-13
@@ -1,27 +1,25 @@
1-# asc_sync_matrix1+# asc_get_block_num
2 2 
3## AI处理器支持情况3## AI处理器支持情况
4 4 
5-| AI处理器类型 | 是否支持 |5+| AI处理器类型 | 是否支持 |
6| :-----------| :------: |6| :-----------| :------: |
7-| Ascend 910C | √ |7+| Ascend 910C | √ |
8-| Ascend 910B | √ |8+| Ascend 910B | √ |
9 9 
10## 功能说明10## 功能说明
11 11 
12-针对矩阵计算流水线执行同步操作。12+获取AI核数。
13 13 
14## 函数原型14## 函数原型
15 15 
16```cpp16```cpp
17-__aicore__ inline void asc_sync_matrix(int id)17+__aicore__ inline int64_t asc_get_block_num()
18```18```
19 19 
20## 参数说明20## 参数说明
21 21 
22-| 参数名 | 输入/输出 | 描述 |22+无
23-| :--- | :--- | :--- |
24-| id | 输入 | 同步ID |
25 23 
26## 返回值说明24## 返回值说明
27 25 
@@ -29,7 +27,7 @@ __aicore__ inline void asc_sync_matrix(int id)
29 27 
30## 流水类型28## 流水类型
31 29 
32-PIPE_S30+PIPE_TYPE_S
33 31 
34## 约束说明32## 约束说明
35 33 
@@ -37,6 +35,4 @@ PIPE_S
37 35 
38## 调用示例36## 调用示例
39 37 
40-```cpp38+无
41-asc_sync_matrix(0);
42-```
@@ -35,7 +35,7 @@ PIPE_TYPE_S
35 35 
36## 约束说明36## 约束说明
37 37 
38-无38+不能和[以数组方式申请内存的方法](../general_instruction.md#以数组方式申请内存)混用。
39 39 
40## 调用示例40## 调用示例
41 41 
@@ -12,7 +12,7 @@
12执行矢量加法运算。计算公式如下:12执行矢量加法运算。计算公式如下:
13 13 
14$$14$$
15-dst_i = src0_i + scalar15+dst_i = src0_i + a
16$$16$$
17 17 
18## 函数原型18## 函数原型
@@ -30,10 +30,10 @@ __aicore__ inline void asc_add_scalar(_ubuf__ float* dst, _ubuf__ float* src, fl
30- 高维切分计算30- 高维切分计算
31 31 
32```cpp32```cpp
33-_aicore__ inline void asc_add_scalar_(ubuf__ int16_t* dst, _ubuf__ int16_t* src, int16_t a, const asc_binary_config& config)33+_aicore__ inline void asc_add_scalar(ubuf__ int16_t* dst, _ubuf__ int16_t* src, int16_t a, const asc_unary_config& config)
34-__aicore__ inline void asc_add_scalar(_ubuf__ half* dst, _ubuf__ half* src0, half a, const asc_binary_config& config)34+__aicore__ inline void asc_add_scalar(_ubuf__ half* dst, _ubuf__ half* src, half a, const asc_unary_config& config)
35-__aicore__ inline void asc_add_scalar(_ubuf__ int32_t* dst, _ubuf__ int32_t* src0, int32_t a, const asc_binary_config& config)35+__aicore__ inline void asc_add_scalar(_ubuf__ int32_t* dst, _ubuf__ int32_t* src, int32_t a, const asc_unary_config& config)
36-__aicore__ inline void asc_add_scalar(_ubuf__ float* dst, _ubuf__ float* src0, float a, const asc_binary_config& config)36+__aicore__ inline void asc_add_scalar(_ubuf__ float* dst, _ubuf__ float* src, float a, const asc_unary_config& config)
37```37```
38 38 
39- 同步计算39- 同步计算
@@ -52,9 +52,10 @@ __aicore__ inline void asc_add_scalar_sync(_ubuf__ float* dst, _ubuf__ float* sr
52| 参数名 | 输入/输出 | 描述 |52| 参数名 | 输入/输出 | 描述 |
53| --------- | ----- | ---------------- |53| --------- | ----- | ---------------- |
54| dst | 输出 | 目的操作数。 |54| dst | 输出 | 目的操作数。 |
55-| src0、src1 | 输入 | 源操作数。 |55+| src | 输入 | 源操作数。 |
56+| a | 输入 | 标量源操作数。 |
56| count | 输入 | 参与连续计算的元素个数。 |57| count | 输入 | 参与连续计算的元素个数。 |
57-| config | 输入 | 在高维切分计算场景下使用的计算配置参数。<br/>详细说明请参考[asc_binary_config](../struct/asc_binary_config.md)。 |58+| config | 输入 | 在高维切分计算场景下使用的计算配置参数。<br/>详细说明请参考[asc_unary_config](../struct/asc_unary_config.md)。 |
58 59 
59 60 
60## 返回值说明61## 返回值说明
@@ -30,10 +30,10 @@ __aicore__ inline void asc_bf162float_sync(__ubuf__ float* dst, __ubuf__ bfloat1
30 30 
31|参数名|输入/输出|描述|31|参数名|输入/输出|描述|
32| ------------ | ------------ | ------------ |32| ------------ | ------------ | ------------ |
33-|dst|输出|目的操作数|33+|dst|输出|目的操作数。|
34-|src|输入|源操作数|34+|src|输入|源操作数。|
35-|count|输入|参与计算的元素个数|35+|count|输入|参与计算的元素个数。|
36-|config|输入|在非连续场景下使用的计算配置参数|36+|config|输入|在非连续场景下使用的计算配置参数。<br/>详细说明请参考[asc_unary_config](../struct/asc_unary_config.md)。|
37 37 
38## 返回值说明38## 返回值说明
39 39 
@@ -56,5 +56,5 @@ uint64_t offset = 0;
56__ubuf__ bfloat16_t* src = (__ubuf__ bfloat16_t*)asc_get_phy_buf_addr(offset);56__ubuf__ bfloat16_t* src = (__ubuf__ bfloat16_t*)asc_get_phy_buf_addr(offset);
57offset += total_length * sizeof(bfloat16_t);57offset += total_length * sizeof(bfloat16_t);
58__ubuf__ float* dst = (__ubuf__ float*)asc_get_phy_buf_addr(offset);58__ubuf__ float* dst = (__ubuf__ float*)asc_get_phy_buf_addr(offset);
59-asc_asc_bf162float(dst, src, total_length);59+asc_bf162float(dst, src, total_length);
60```60```
@@ -38,10 +38,10 @@ __aicore__ inline void asc_exp_sync(__ubuf__ float* dst, __ubuf__ float* src, ui
38 38 
39|参数名|输入/输出|描述|39|参数名|输入/输出|描述|
40| ------------ | ------------ | ------------ |40| ------------ | ------------ | ------------ |
41-|dst|输出|目的操作数|41+|dst|输出|目的操作数。|
42-|src|输入|源操作数|42+|src|输入|源操作数。|
43-|count|输入|参与计算的元素个数|43+|count|输入|参与计算的元素个数。|
44-|config|输入|在非连续场景下使用的计算配置参数|44+|config|输入|在非连续场景下使用的计算配置参数。<br/>详细说明请参考[asc_unary_config](../struct/asc_unary_config.md)。|
45 45 
46## 返回值说明46## 返回值说明
47 47 
@@ -123,7 +123,7 @@
123| dst | 输出 | 目的操作数。 |123| dst | 输出 | 目的操作数。 |
124| src | 输入 | 源操作数。|124| src | 输入 | 源操作数。|
125| count | 输入 | 参与计算的元素个数。 |125| count | 输入 | 参与计算的元素个数。 |
126-| config | 输入 | 在非连续场景下使用的计算配置参数。|126+| config | 输入 | 在非连续场景下使用的计算配置参数。<br/>详细说明请参考[asc_unary_config](../struct/asc_unary_config.md)。|
127 127 
128## 返回值说明128## 返回值说明
129 129 
@@ -106,10 +106,10 @@
106 106 
107|参数名|输入/输出|描述|107|参数名|输入/输出|描述|
108| ------------ | ------------ | ------------ |108| ------------ | ------------ | ------------ |
109-|dst|输出|目的操作数|109+|dst|输出|目的操作数。|
110-|src|输入|源操作数|110+|src|输入|源操作数。|
111-|count|输入|参与计算的元素个数|111+|count|输入|参与计算的元素个数。|
112-|config|输入|在非连续场景下使用的计算配置参数|112+|config|输入|在非连续场景下使用的计算配置参数。<br/>详细说明请参考[asc_unary_config](../struct/asc_unary_config.md)。|
113 113 
114## 返回值说明114## 返回值说明
115 115 
@@ -44,10 +44,10 @@ __aicore__ inline void asc_min(__ubuf__ float* dst, __ubuf__ float* src0, __ubuf
44 44 
45|参数名|输入/输出|描述|45|参数名|输入/输出|描述|
46| ------------ | ------------ | ------------ |46| ------------ | ------------ | ------------ |
47-|dst|输出|目的操作数|47+|dst|输出|目的操作数。|
48-|src|输入|源操作数|48+|src|输入|源操作数。|
49-|count|输入|参与计算的元素个数|49+|count|输入|参与计算的元素个数。|
50-|config|输入|在非连续场景下使用的计算配置参数|50+|config|输入|在非连续场景下使用的计算配置参数。<br/>详细说明请参考[asc_binary_config](../struct/asc_binary_config.md)。|
51 51 
52## 返回值说明52## 返回值说明
53 53 
@@ -51,7 +51,7 @@ $$
51| dst | 输出 | 目的操作数地址。 |51| dst | 输出 | 目的操作数地址。 |
52| src0、src1 | 输入 | 源操作数地址。 |52| src0、src1 | 输入 | 源操作数地址。 |
53| count | 输入 | 参与计算的元素个数。 |53| count | 输入 | 参与计算的元素个数。 |
54-| config | 输入 | 在高维切分计算场景下使用的计算配置参数, 详细说明请参考[asc_unary_config](../struct/asc_unary_config.md)。 |54+| config | 输入 | 在高维切分计算场景下使用的计算配置参数, 详细说明请参考[asc_binary_config](../struct/asc_binary_config.md)。 |
55 55 
56### 返回值说明56### 返回值说明
57 57 
@@ -13,7 +13,7 @@
13执行矢量与标量的乘法运算。计算公式如下13执行矢量与标量的乘法运算。计算公式如下
14 14 
15$$15$$
16-dst_i = src_i * scalar16+dst_i = src_i * a
17$$17$$
18 18 
19### 函数原型19### 函数原型
@@ -51,7 +51,7 @@ $$
51| :----- | :------- | :------- |51| :----- | :------- | :------- |
52| dst | 输出 | 目的操作数地址。 |52| dst | 输出 | 目的操作数地址。 |
53| src | 输入 | 源操作数地址。 |53| src | 输入 | 源操作数地址。 |
54-| a | 输入 | 源操作数。 |54+| a | 输入 | 标量源操作数。 |
55| count | 输入 | 参与计算的元素个数。 |55| count | 输入 | 参与计算的元素个数。 |
56| config | 输入 | 在高维切分计算场景下使用的计算配置参数, 详细说明请参考[asc_unary_config](../struct/asc_unary_config.md)。 |56| config | 输入 | 在高维切分计算场景下使用的计算配置参数, 详细说明请参考[asc_unary_config](../struct/asc_unary_config.md)。 |
57 57 
@@ -46,7 +46,7 @@ __aicore__ inline void asc_repeat_reduce_max_sync(__ubuf__ float* dst, __ubuf__
46| dst | 输出 | 目的操作数。 |46| dst | 输出 | 目的操作数。 |
47| src | 输入 | 源操作数。|47| src | 输入 | 源操作数。|
48| count | 输入 | 参与计算的元素个数。 |48| count | 输入 | 参与计算的元素个数。 |
49-| config | 输入 | 在高维切分计算场景下使用的计算配置参数。详细说明请参考[asc_repeat_reduce_config](../struct/asc_repeat_reduce_config.md)|49+| config | 输入 | 在高维切分计算场景下使用的计算配置参数。详细说明请参考[asc_repeat_reduce_config](../struct/asc_repeat_reduce_config.md)。|
50| order | 输入 | 使用order参数指定dst中index与value的相对位置以及返回结果行为,取值范围如下:<br>VALUE_INDEX:表示value位于低半部,返回结果存储顺序为[value, index]。<br>INDEX_VALUE:表示index位于低半部,返回结果存储顺序为[index, value]。<br>ONLY_VALUE:表示只返回最值,返回结果存储顺序为[value]。<br>ONLY_INDEX:表示只返回最值索引,返回结果存储顺序为[index]。 |50| order | 输入 | 使用order参数指定dst中index与value的相对位置以及返回结果行为,取值范围如下:<br>VALUE_INDEX:表示value位于低半部,返回结果存储顺序为[value, index]。<br>INDEX_VALUE:表示index位于低半部,返回结果存储顺序为[index, value]。<br>ONLY_VALUE:表示只返回最值,返回结果存储顺序为[value]。<br>ONLY_INDEX:表示只返回最值索引,返回结果存储顺序为[index]。 |
51 51 
52## 返回值说明52## 返回值说明
@@ -46,7 +46,7 @@ __aicore__ inline void asc_repeat_reduce_min_sync(__ubuf__ float* dst, __ubuf__
46| dst | 输出 | 目的操作数。 |46| dst | 输出 | 目的操作数。 |
47| src | 输入 | 源操作数。|47| src | 输入 | 源操作数。|
48| count | 输入 | 参与计算的元素个数。 |48| count | 输入 | 参与计算的元素个数。 |
49-| config | 输入 | 在高维切分计算场景下使用的计算配置参数。详细说明请参考[asc_repeat_reduce_config](../struct/asc_repeat_reduce_config.md)|49+| config | 输入 | 在高维切分计算场景下使用的计算配置参数。详细说明请参考[asc_repeat_reduce_config](../struct/asc_repeat_reduce_config.md)。|
50| order | 输入 | 使用order参数指定dst中index与value的相对位置以及返回结果行为,取值范围如下:<br>VALUE_INDEX:表示value位于低半部,返回结果存储顺序为[value, index]。<br>INDEX_VALUE:表示index位于低半部,返回结果存储顺序为[index, value]。<br>ONLY_VALUE:表示只返回最值,返回结果存储顺序为[value]。<br>ONLY_INDEX:表示只返回最值索引,返回结果存储顺序为[index]。 |50| order | 输入 | 使用order参数指定dst中index与value的相对位置以及返回结果行为,取值范围如下:<br>VALUE_INDEX:表示value位于低半部,返回结果存储顺序为[value, index]。<br>INDEX_VALUE:表示index位于低半部,返回结果存储顺序为[index, value]。<br>ONLY_VALUE:表示只返回最值,返回结果存储顺序为[value]。<br>ONLY_INDEX:表示只返回最值索引,返回结果存储顺序为[index]。 |
51 51 
52## 返回值说明52## 返回值说明
@@ -72,6 +72,6 @@ __ubuf__ half* src = asc_get_phy_buf_addr(offset); // 获取src的地址,
72offset += 128 * sizeof(half); // 通过offset将dst的起始地址设置在src之后。72offset += 128 * sizeof(half); // 通过offset将dst的起始地址设置在src之后。
73__ubuf__ half* dst = asc_get_phy_buf_addr(offset); // 获取dst的地址,通过__ubuf__关键字指定该地址指向UB内存。73__ubuf__ half* dst = asc_get_phy_buf_addr(offset); // 获取dst的地址,通过__ubuf__关键字指定该地址指向UB内存。
74...... // 将源操作数搬运到src。74...... // 将源操作数搬运到src。
75-asc_repeat_reduce_mmin(dst, src, 128, ONLY_VALUE);75+asc_repeat_reduce_min(dst, src, 128, ONLY_VALUE);
76...... // 使用dst中的数据进行后续计算或数据搬运操作。76...... // 使用dst中的数据进行后续计算或数据搬运操作。
77```77```
@@ -46,7 +46,7 @@ __aicore__ inline void asc_repeat_reduce_sum_sync(__ubuf__ float* dst, __ubuf__
46| dst | 输出 | 目的操作数。 |46| dst | 输出 | 目的操作数。 |
47| src | 输入 | 源操作数。|47| src | 输入 | 源操作数。|
48| count | 输入 | 参与计算的元素个数。 |48| count | 输入 | 参与计算的元素个数。 |
49-| config | 输入 | 在高维切分计算场景下使用的计算配置参数。详细说明请参考[asc_repeat_reduce_config](../struct/asc_repeat_reduce_config.md)|49+| config | 输入 | 在高维切分计算场景下使用的计算配置参数。详细说明请参考[asc_repeat_reduce_config](../struct/asc_repeat_reduce_config.md)。|
50 50 
51## 返回值说明51## 返回值说明
52 52 
@@ -9,7 +9,7 @@
9 9 
10## 功能说明10## 功能说明
11 11 
12-设置mask模式为Counter模式。该模式下,不需要开发者去感知迭代次数、处理非对齐的尾块等操作,可直接传入数据计算数据量,实际迭代次数由Vector计算单元自动推断。12+设置mask模式为Counter模式。该模式下,不需要开发者去感知迭代次数、处理非对齐的尾块等操作,可直接传入数据计算数据量,实际迭代次数由Vector计算单元自动推断。在前n个数据计算类的接口内部会自动设置该模式。
13 13 
14## 函数原型14## 函数原型
15 15 
@@ -12,7 +12,7 @@
12执行矢量和标量的减法运算。12执行矢量和标量的减法运算。
13 13 
14$$14$$
15-dst_i = src_i - scalar15+dst_i = src_i - a
16$$16$$
17 17 
18## 函数原型18## 函数原型
@@ -54,7 +54,7 @@ __aicore__ inline void asc_sub_scalar_sync(__ubuf__ float* dst, __ubuf__ float*
54| src | 输入 | 矢量源操作数。|54| src | 输入 | 矢量源操作数。|
55| a | 输入 | 标量源操作数。|55| a | 输入 | 标量源操作数。|
56| count | 输入 | 参与连续计算的元素个数。|56| count | 输入 | 参与连续计算的元素个数。|
57-| config | 输入 | 在非连续场景下使用的计算配置参数。|57+| config | 输入 | 在非连续场景下使用的计算配置参数。<br/>详细说明请参考[asc_unary_config](../struct/asc_unary_config.md)。|
58 58 
59## 返回值说明59## 返回值说明
60 60 
@@ -74,6 +74,7 @@ PIPE_TYPE_V
74```c++74```c++
75// total_length指参与计算的数据总长度75// total_length指参与计算的数据总长度
76uint64_t offset = 0;76uint64_t offset = 0;
77+half scalar = 0.0f;
77__ubuf__ half* src = (__ubuf__ half*)asc_get_phy_buf_addr(0);78__ubuf__ half* src = (__ubuf__ half*)asc_get_phy_buf_addr(0);
78offset += total_length * sizeof(half);79offset += total_length * sizeof(half);
79__ubuf__ half* dst = (__ubuf__ half*)asc_get_phy_buf_addr(offset);80__ubuf__ half* dst = (__ubuf__ half*)asc_get_phy_buf_addr(offset);
@@ -12,22 +12,10 @@
12#define IMPL_C_API_INSTR_MISC_H12#define IMPL_C_API_INSTR_MISC_H
13 13
14#include "init_soc_state_impl.h"14#include "init_soc_state_impl.h"
15-#include "get_block_idx_impl.h"
16-#include "get_block_num_impl.h"
17 15 
18__aicore__ inline void asc_init()16__aicore__ inline void asc_init()
19{17{
20 CApiInternal::init_soc_state_impl();18 CApiInternal::init_soc_state_impl();
21}19}
22 20 
23-__aicore__ inline int64_t asc_get_block_idx()
24-{
25- CApiInternal::get_block_idx_impl();
26-}
27- 
28-__aicore__ inline int64_t asc_get_block_num()
29-{
30- CApiInternal::get_block_num_impl();
31-}
32- 
33#endif21#endif
@@ -28,8 +28,6 @@ __aicore__ inline void sync_vec_impl()
28 pipe_barrier(pipe_t::PIPE_ALL);28 pipe_barrier(pipe_t::PIPE_ALL);
29}29}
30 30 
31-__aicore__ inline void sync_mte1_impl(int id) { }
32- 
33__aicore__ inline void sync_mte2_impl(int id)31__aicore__ inline void sync_mte2_impl(int id)
34{32{
35 set_flag(pipe_t::PIPE_MTE2, pipe_t::PIPE_MTE3, id);33 set_flag(pipe_t::PIPE_MTE2, pipe_t::PIPE_MTE3, id);
@@ -48,10 +46,6 @@ __aicore__ inline void sync_mte3_impl(int id)
48 pipe_barrier(pipe_t::PIPE_MTE3);46 pipe_barrier(pipe_t::PIPE_MTE3);
49}47}
50 48 
51-__aicore__ inline void sync_matrix_impl(int id) { }
52- 
53-__aicore__ inline void sync_fixpipe_impl(int id) { }
54- 
55__aicore__ inline void sync_impl()49__aicore__ inline void sync_impl()
56{50{
57 pipe_barrier(pipe_t::PIPE_ALL);51 pipe_barrier(pipe_t::PIPE_ALL);
@@ -50,21 +50,6 @@ __aicore__ inline void asc_sync_mte2(int id)
50 CApiInternal::sync_mte2_impl(id);50 CApiInternal::sync_mte2_impl(id);
51}51}
52 52 
53-__aicore__ inline void asc_sync_mte1(int id)
54-{
55- CApiInternal::sync_mte1_impl(id);
56-}
57- 
58-__aicore__ inline void asc_sync_matrix(int id)
59-{
60- CApiInternal::sync_matrix_impl(id);
61-}
62- 
63-__aicore__ inline void asc_sync_fixpipe(int id)
64-{
65- CApiInternal::sync_fixpipe_impl(id);
66-}
67- 
68__aicore__ inline void asc_sync()53__aicore__ inline void asc_sync()
69{54{
70 CApiInternal::sync_impl();55 CApiInternal::sync_impl();
Rimpl/c_api/c_api_instr_impl/misc/get_block_idx_impl.h→impl/c_api/c_api_instr_impl/sys_var/get_block_idx/asc_2201/get_block_idx_impl.h+2-2
@@ -7,8 +7,8 @@
7* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.7* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8* See LICENSE in the root of the software repository for the full text of the License.8* See LICENSE in the root of the software repository for the full text of the License.
9*/9*/
10-#ifndef IMPL_C_API_INSTR_MISC_GET_BLOCK_IDX_IMPL_H10+#ifndef IMPL_C_API_INSTR_SYS_VAR_GET_BLOCK_IDX_ASC_2201_GET_BLOCK_IDX_IMPL_H
11-#define IMPL_C_API_INSTR_MISC_GET_BLOCK_IDX_IMPL_H11+#define IMPL_C_API_INSTR_SYS_VAR_GET_BLOCK_IDX_ASC_2201_GET_BLOCK_IDX_IMPL_H
12 12 
13namespace CApiInternal {13namespace CApiInternal {
14 14 
Rimpl/c_api/c_api_instr_impl/misc/get_block_num_impl.h→impl/c_api/c_api_instr_impl/sys_var/get_block_num/asc_2201/get_block_num_impl.h+2-2
@@ -7,8 +7,8 @@
7* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.7* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8* See LICENSE in the root of the software repository for the full text of the License.8* See LICENSE in the root of the software repository for the full text of the License.
9*/9*/
10-#ifndef IMPL_C_API_INSTR_MISC_GET_BLOCK_NUM_IMPL_H10+#ifndef IMPL_C_API_INSTR_SYS_VAR_GET_BLOCK_NUM_ASC_2201_GET_BLOCK_NUM_IMPL_H
11-#define IMPL_C_API_INSTR_MISC_GET_BLOCK_NUM_IMPL_H11+#define IMPL_C_API_INSTR_SYS_VAR_GET_BLOCK_NUM_ASC_2201_GET_BLOCK_NUM_IMPL_H
12 12 
13namespace CApiInternal {13namespace CApiInternal {
14 14 
@@ -19,12 +19,24 @@
19#include "get_sub_block_id/asc_2201/get_sub_block_id_impl.h"19#include "get_sub_block_id/asc_2201/get_sub_block_id_impl.h"
20#include "get_sys_cnt/asc_2201/get_sys_cnt_impl.h"20#include "get_sys_cnt/asc_2201/get_sys_cnt_impl.h"
21#include "set_ctrl/asc_2201/set_ctrl_impl.h"21#include "set_ctrl/asc_2201/set_ctrl_impl.h"
22+#include "get_block_idx/asc_2201/get_block_idx_impl.h"
23+#include "get_block_num/asc_2201/get_block_num_impl.h"
22 24 
23__aicore__ inline int64_t asc_get_core_id()25__aicore__ inline int64_t asc_get_core_id()
24{26{
25 return CApiInternal::get_core_id_impl();27 return CApiInternal::get_core_id_impl();
26}28}
27 29 
30+__aicore__ inline int64_t asc_get_block_idx()
31+{
32+ return CApiInternal::get_block_idx_impl();
33+}
34+ 
35+__aicore__ inline int64_t asc_get_block_num()
36+{
37+ return CApiInternal::get_block_num_impl();
38+}
39+ 
28__aicore__ inline int64_t asc_get_ctrl()40__aicore__ inline int64_t asc_get_ctrl()
29{41{
30 return CApiInternal::get_ctrl_impl();42 return CApiInternal::get_ctrl_impl();
@@ -13,7 +13,7 @@
13 13 
14namespace CApiInternal {14namespace CApiInternal {
15 15 
16-__aicore__ inline void set_cmp_mask_impl(__ubuf__ void *sel_mask)16+__aicore__ inline void set_cmp_mask_impl(__ubuf__ void* sel_mask)
17{17{
18 set_cmpmask(sel_mask);18 set_cmpmask(sel_mask);
19}19}
@@ -79,7 +79,7 @@ __aicore__ inline void asc_get_vms4_sr(uint16_t sorted_num[4])
79 CApiInternal::get_vms4_sr_impl(sorted_num);79 CApiInternal::get_vms4_sr_impl(sorted_num);
80}80}
81 81 
82-__aicore__ inline void asc_set_cmp_mask(__ubuf__ void *sel_mask)82+__aicore__ inline void asc_set_cmp_mask(__ubuf__ void* sel_mask)
83{83{
84 CApiInternal::set_cmp_mask_impl(sel_mask);84 CApiInternal::set_cmp_mask_impl(sel_mask);
85}85}
@@ -15,8 +15,4 @@
15 15
16__aicore__ inline void asc_init();16__aicore__ inline void asc_init();
17 17 
18-__aicore__ inline int64_t asc_get_block_idx();
19- 
20-__aicore__ inline int64_t asc_get_block_num();
21- 
22#endif18#endif
@@ -29,12 +29,6 @@ __aicore__ inline void asc_sync_mte3(int id);
29 29 
30__aicore__ inline void asc_sync_mte2(int id);30__aicore__ inline void asc_sync_mte2(int id);
31 31 
32-__aicore__ inline void asc_sync_mte1(int id);
33- 
34-__aicore__ inline void asc_sync_matrix(int id);
35- 
36-__aicore__ inline void asc_sync_fixpipe(int id);
37- 
38__aicore__ inline void asc_sync();32__aicore__ inline void asc_sync();
39 33 
40#endif34#endif
@@ -17,6 +17,10 @@ __aicore__ inline void asc_set_ctrl(uint64_t config);
17 17 
18__aicore__ inline int64_t asc_get_core_id();18__aicore__ inline int64_t asc_get_core_id();
19 19 
20+__aicore__ inline int64_t asc_get_block_idx();
21+ 
22+__aicore__ inline int64_t asc_get_block_num();
23+ 
20__aicore__ inline int64_t asc_get_ctrl();24__aicore__ inline int64_t asc_get_ctrl();
21 25 
22__aicore__ inline uint64_t asc_get_overflow_status();26__aicore__ inline uint64_t asc_get_overflow_status();
@@ -11,43 +11,41 @@
11#ifndef INCLUDE_C_API_UTILS_C_API_UNION_H11#ifndef INCLUDE_C_API_UTILS_C_API_UNION_H
12#define INCLUDE_C_API_UTILS_C_API_UNION_H12#define INCLUDE_C_API_UTILS_C_API_UNION_H
13 13 
14-#include "c_api_constants.h"
15#include <cstdint>14#include <cstdint>
15+#include "c_api_constants.h"
16 16 
17union asc_copy_config {17union asc_copy_config {
18 uint64_t config;18 uint64_t config;
19 struct {19 struct {
20- uint64_t sid: 4;20+ uint64_t sid : 4;
21- uint64_t n_burst: 12;21+ uint64_t n_burst : 12;
22- uint64_t burst_len: 16;22+ uint64_t burst_len : 16;
23- uint64_t src_gap: 16;23+ uint64_t src_gap : 16;
24- uint64_t dst_gap: 16;24+ uint64_t dst_gap : 16;
25 };25 };
26};26};
27 27 
28-union asc_copy_align_config { };
29- 
30union asc_binary_config {28union asc_binary_config {
31 uint64_t config = CAPI_DEFAULT_BINARY_CONFIG_VALUE;29 uint64_t config = CAPI_DEFAULT_BINARY_CONFIG_VALUE;
32 struct {30 struct {
33- uint64_t dst_block_stride: 8;31+ uint64_t dst_block_stride : 8;
34- uint64_t src0_block_stride: 8;32+ uint64_t src0_block_stride : 8;
35- uint64_t src1_block_stride: 8;33+ uint64_t src1_block_stride : 8;
36- uint64_t dst_repeat_stride: 8;34+ uint64_t dst_repeat_stride : 8;
37- uint64_t src0_repeat_stride: 8;35+ uint64_t src0_repeat_stride : 8;
38- uint64_t src1_repeat_stride: 8;36+ uint64_t src1_repeat_stride : 8;
39- uint64_t reserved: 8;37+ uint64_t reserved : 8;
40- uint64_t repeat: 8;38+ uint64_t repeat : 8;
41 };39 };
42};40};
43 41 
44union asc_unary_config {42union asc_unary_config {
45 uint64_t config = CAPI_DEFAULT_UNARY_CONFIG_VALUE;43 uint64_t config = CAPI_DEFAULT_UNARY_CONFIG_VALUE;
46 struct {44 struct {
47- uint64_t dst_block_stride: 16;45+ uint64_t dst_block_stride : 16;
48- uint64_t src_block_stride: 16;46+ uint64_t src_block_stride : 16;
49- uint64_t dst_repeat_stride: 12;47+ uint64_t dst_repeat_stride : 12;
50- uint64_t src_repeat_stride: 12;48+ uint64_t src_repeat_stride : 12;
51 uint64_t repeat : 8;49 uint64_t repeat : 8;
52 };50 };
53};51};
@@ -55,10 +53,10 @@ union asc_unary_config {
55union asc_block_reduce_config {53union asc_block_reduce_config {
56 uint64_t config = CAPI_DEFAULT_REDUCE_CONFIG_VALUE;54 uint64_t config = CAPI_DEFAULT_REDUCE_CONFIG_VALUE;
57 struct {55 struct {
58- uint64_t dst_repeat_stride: 16;56+ uint64_t dst_repeat_stride : 16;
59- uint64_t src_block_stride: 16;57+ uint64_t src_block_stride : 16;
60- uint64_t src_repeat_stride: 16;58+ uint64_t src_repeat_stride : 16;
61- uint64_t reserved: 8;59+ uint64_t reserved : 8;
62 uint64_t repeat : 8;60 uint64_t repeat : 8;
63 };61 };
64};62};
@@ -66,10 +64,10 @@ union asc_block_reduce_config {
66union asc_repeat_reduce_config {64union asc_repeat_reduce_config {
67 uint64_t config = CAPI_DEFAULT_REDUCE_CONFIG_VALUE;65 uint64_t config = CAPI_DEFAULT_REDUCE_CONFIG_VALUE;
68 struct {66 struct {
69- uint64_t dst_repeat_stride: 16;67+ uint64_t dst_repeat_stride : 16;
70- uint64_t src_block_stride: 16;68+ uint64_t src_block_stride : 16;
71- uint64_t src_repeat_stride: 16;69+ uint64_t src_repeat_stride : 16;
72- uint64_t reserved: 8;70+ uint64_t reserved : 8;
73 uint64_t repeat : 8;71 uint64_t repeat : 8;
74 };72 };
75};73};
@@ -77,25 +75,23 @@ union asc_repeat_reduce_config {
77union asc_duplicate_config {75union asc_duplicate_config {
78 uint64_t config = CAPI_DEFAULT_DUPLICATE_CONFIG_VALUE;76 uint64_t config = CAPI_DEFAULT_DUPLICATE_CONFIG_VALUE;
79 struct {77 struct {
80- uint64_t dst_block_stride: 16;78+ uint64_t dst_block_stride : 16;
81- uint64_t src_block_stride: 16;79+ uint64_t src_block_stride : 16;
82- uint64_t dst_repeat_stride: 12;80+ uint64_t dst_repeat_stride : 12;
83- uint64_t src_repeat_stride: 12;81+ uint64_t src_repeat_stride : 12;
84- uint64_t repeat: 8;82+ uint64_t repeat : 8;
85 };83 };
86};84};
87 85 
88union asc_brcb_config {86union asc_brcb_config {
89 uint64_t config;87 uint64_t config;
90 struct {88 struct {
91- uint64_t dst_block_stride: 16;89+ uint64_t dst_block_stride : 16;
92- uint64_t reserved1: 16;90+ uint64_t reserved1 : 16;
93- uint64_t dst_repeat_stride: 12;91+ uint64_t dst_repeat_stride : 12;
94- uint64_t reserved2: 12;92+ uint64_t reserved2 : 12;
95- uint64_t repeat: 8;93+ uint64_t repeat : 8;
96 };94 };
97};95};
98 96 
99-union asc_mrgsort_config { };
100- 
101#endif97#endif
@@ -24,7 +24,7 @@ __aicore__ inline int64_t asc_get_rsvd_count();
24 24 
25__aicore__ inline void asc_get_vms4_sr(uint16_t sorted_num[4]);25__aicore__ inline void asc_get_vms4_sr(uint16_t sorted_num[4]);
26 26 
27-__aicore__ inline void asc_set_cmp_mask(__ubuf__ void *sel_mask);27+__aicore__ inline void asc_set_cmp_mask(__ubuf__ void* sel_mask);
28 28 
29__aicore__ inline void asc_set_mask_count();29__aicore__ inline void asc_set_mask_count();
30 30