已合并
fix releaseNote #4910
JC1126创建于 8月6日
fix releaseNote #4910
已合并
JC1126创建于 8月6日
6 个文件变更+325-465
@@ -3035,5 +3035,5 @@
3035 - [废弃接口](appendix/deprecated_interface.md)3035 - [废弃接口](appendix/deprecated_interface.md)
3036 - [接口变更说明](appendix/interface_change_description.md)3036 - [接口变更说明](appendix/interface_change_description.md)
3037 - [Release Notes](appendix/Release_Notes/release_notes.md)3037 - [Release Notes](appendix/Release_Notes/release_notes.md)
3038- - [CANN 9.0.0](appendix/Release_Notes/Cann_9_0_0.md)3038+ - [CANN 9.1.0](appendix/Release_Notes/CANN_9_1_0.md)
3039- - [CANN 9.1.0](appendix/Release_Notes/Cann_9_1_0.md)3039+ - [CANN 9.0.0](appendix/Release_Notes/CANN_9_0_0.md)
@@ -0,0 +1,176 @@
1+# C API
2+ 
3+CANN 9.0.0首次面向Ascend 950PR/Ascend 950DT(3510架构)提供试验性C语言扩展层单指令多数据(Single Instruction Multiple Data,SIMD)API。基于指针编程,提供C完备编程能力,通过声明静态数组管理本地内存,由开发者自主管理同步与内存,适配C语言开发习惯,开放全部底层硬件能力,支撑精细化调优与极致性能实现。接口覆盖数据结构、数据搬运、标量操作、矩阵计算、同步控制、系统变量、缓存控制、原子操作、其他操作、Reg数据搬运和Reg矢量计算等能力。
4+ 
5+## 特性
6+ 
7+### 数据结构
L
LLycheeeee8月7日

矢量寄存器那些应该也算数据结构

likedislike
8+ 
9+- `asc_set_l0c_copy_params_config`:用于设置L0C Buffer搬运过程中进行NZ格式转换为ND格式时所需的ND矩阵数量、源相邻NZ矩阵的起始地址偏移和目的相邻ND矩阵的起始地址偏移。
10+- `asc_load3d_v2_config`:用于设置asc_copy_l12l0a_3d,asc_copy_l12l0b_3d接口的repeat参数。
11+- `asc_ndim_pad_count_config`:用于`asc_set_ndim_pad_count`接口,设置`asc_ndim_copy_gm2ub`接口各个维度左右侧的填充元素个数。
12+- `asc_l13d_fmatrix_config`:用于设置`asc_copy_l12l0a``asc_copy_l12l0b`的3D格式搬运接口的特征图属性参数。
13+ 
14+### 数据搬运
15+ 
16+- `asc_copy_gm2ub_align``asc_copy_gm2ub_align_sync`:提供数据非对齐搬运功能,将数据从Global Memory搬运到Unified Buffer,支持8位、16位、32位数据类型搬运。
17+- `asc_copy_ub2gm_align``asc_copy_ub2gm_align_sync`:将数据从Unified Buffer搬运到Global Memory,支持8位、16位、32位分块搬运。
18+- `asc_ndim_copy_gm2ub`:多维数据搬运接口,将数据从Global Memory搬运到Unified Buffer,最多处理5个维度,每个维度可单独配置步长,并支持随路填充功能。
19+- `asc_set_gm2ub_loop_size`:将数据从Global Memory搬运到Unified Buffer时,设置数据搬运流程中的循环次数。
20+- `asc_set_gm2ub_loop1_stride``asc_set_gm2ub_loop2_stride`:将数据从Global Memory搬运到Unified Buffer时,分别设置内层循环、外层循环中相邻迭代数据块间的间隔。
21+- `asc_set_ub2gm_loop_size`:将数据从Unified Buffer搬运到Global Memory时,设置内层循环和外层循环的次数。
22+- `asc_set_ub2gm_loop1_stride``asc_set_ub2gm_loop2_stride`:将数据从Unified Buffer搬运到Global Memory时,分别设置内层循环、外层循环中相邻迭代数据块间的间隔。
23+- `asc_set_gm2ub_pad`:使用`asc_copy_gm2ub_align`将数据从Global Memory搬运到Unified Buffer且源操作数非对齐时,设置连续搬运数据块左右两侧需要填充的数据值。
24+- `asc_set_ndim_loop0_stride``asc_set_ndim_loop1_stride``asc_set_ndim_loop2_stride``asc_set_ndim_loop3_stride``asc_set_ndim_loop4_stride`:用于设置`asc_ndim_copy_gm2ub`接口每个维度内源操作数与目的操作数的元素间隔,最多设置5个维度。
25+- `asc_set_ndim_pad_count`:设置`asc_ndim_copy_gm2ub`接口各个维度左右侧的填充元素个数。
26+- `asc_set_ndim_pad_value`:当`asc_ndim_copy_gm2ub`接口的`padding_mode`参数为`true`时,设置填充固定值。
27+- `asc_set_l13d_rpt`:用于设置asc_copy_l12l0a_3d,asc_copy_l12l0b_3d接口的repeat参数。
28+- `asc_set_l13d_fmatrix`:设置特征图属性描述,用于`asc_copy_l12l0a``asc_copy_l12l0b`的3D格式搬运接口配置填充值。从左矩阵获取特征图属性时使用该接口。
29+- `asc_set_l0c_copy_prequant`:数据搬运过程中进行随路量化时,设置量化流程中的标量量化参数。
30+- `asc_set_l0c_copy_params`:从L0C Buffer搬运到Global Memory或L1 Buffer的过程中进行NZ格式转换为ND格式时,设置格式转换的相关配置。
31+- `asc_copy_l0c2l1`:将矩阵计算结果从L0C Buffer搬运至L1 Buffer,并可与其他接口组合配置多种随路能力。
32+- `asc_copy_l12l0a_mx`:将微缩放(Microscaling,MX)矩阵从L1 Buffer搬运到L0A Buffer。
33+- `asc_set_gm2l1_loop_size`:将数据从Global Memory搬运到L1 Buffer时,设置数据搬运流程中的循环次数。
34+- `asc_set_gm2l1_loop1_stride``asc_set_gm2l1_loop2_stride`:将数据从Global Memory搬运到L1 Buffer时,分别设置内层循环、外层循环中相邻迭代数据块间的间隔。
35+- `asc_set_gm2l1_pad`:将数据从Global Memory非对齐搬运到L1 Buffer时,设置连续搬运数据块左右两侧的填充值。
36+ 
37+### 标量操作
38+ 
39+- `asc_sflbits`:计算一个`int64_t`类型数字的二进制中,从最高数值位开始与符号位相同的连续比特位个数。
40+- `asc_ffz``asc_ffs`:分别获取一个`uint64_t`类型数字的二进制表示中,从最低有效位开始的第一个0、第一个1出现的位置,未找到时返回-1。
41+- `asc_popc`:获取一个`uint64_t`类型数字的二进制中1的个数。
42+- `asc_store_dev`:不经过数据缓存向Global Memory地址写数据。
43+ 
44+### 矩阵计算
45+ 
46+- `asc_set_l0c2gm_config`:数据搬运过程中进行随路量化时,设置量化流程中的矢量量化参数。
47+- `asc_set_l0c2gm_nz2nd`:数据搬运过程中进行NZ格式转换为ND格式时,设置格式转换的相关配置。
48+- `asc_mmad_mx``asc_mmad_mx_sync`:完成包含缩放功能的矩阵乘加操作,支持`fp4x2_e2m1_t``fp4x2_e1m2_t``fp8_e5m2_t``fp8_e4m3fn_t`输入组合。
49+ 
50+### 同步控制
51+ 
52+- `asc_sync``asc_sync_vec`:等待所有流水线操作完成。
53+- `asc_sync_mte2``asc_sync_mte3`:分别等待PIPE_MTE2流水、PIPE_MTE3流水完成。
54+- `asc_sync_notify``asc_sync_wait`:分别设置同步标志、等待同步标志。
55+- `asc_sync_pipe`:等待指定流水线操作完成。
56+ 
57+### 系统变量
58+ 
59+- `asc_get_ctrl``asc_set_ctrl`:分别读取、设置CTRL控制寄存器特定比特位上的值。
60+- `asc_get_block_num`:获取当前任务配置的核数,用于代码内部的多核逻辑控制等。
61+- `asc_get_system_cycle`:获取当前系统周期数。
62+- `asc_get_program_counter`:获取程序计数器的指针,程序计数器用于记录当前程序执行的位置。
63+- `asc_get_ar_spr`:读取指定特殊寄存器的值。
64+ 
65+### 缓存控制
66+ 
67+- `asc_icache_preload``asc_get_icache_preload_status`:分别从指令所在Global Memory地址预加载数据到对应的缓存行、获取指令缓存预加载状态。
68+- `asc_datacache_preload`:从源地址所在的特定Global Memory地址预加载数据到数据缓存。
69+- `asc_dcci_single``asc_ub_dcci_single`:分别刷新指定Global Memory地址或Unified Buffer地址所在的单个缓存行(Cache Line)。
70+- `asc_dcci_entire_all``asc_dcci_entire_out``asc_dcci_entire_atomic`:分别以ALL、OUT或ATOMIC模式刷新全部缓存行,以维护标量单元访问与Global Memory之间的缓存一致性。
71+ 
72+### 原子操作
73+ 
74+- `asc_set_atomic_add_float16``asc_set_atomic_add_float`:设置后续从Unified Buffer、L0C Buffer、L1 Buffer到Global Memory的数据搬运开启原子累加,累加的数据类型分别为`half``float`
75+- `asc_set_atomic_max_float16``asc_set_atomic_max_float`:设置计算结果以原子比较方式搬运到Global Memory,将待搬运的`half``float`数据与Global Memory中已有数据逐元素比较,并将最大值写入Global Memory。
76+- `asc_set_store_atomic_config_v2`:设置原子操作启用位与原子操作类型的值。
77+ 
78+### Reg数据搬运
M
Mmunanhw29 天前

Reg数据搬运和Reg矢量计算在其他下面,一般情况下其他是最后一个章节

likedislike
79+ 
80+提供使用`__simd_callee__`限定符的Reg数据搬运接口。
81+ 
82+**掩码读取:**
83+ 
84+- `asc_get_mask_spr_b16``asc_get_mask_spr_b32`:从特殊用途寄存器(Special Purpose Register,SPR)中读取掩码值,并按数据类型格式化后返回。
85+ 
86+**数据搬入:**
87+ 
88+- `asc_loadalign`:对齐数据搬运接口,从Unified Buffer连续对齐搬入目的操作数,实现NORM搬入模式,搬运一个矢量长度(Vector Length,VL)的数据。
89+- `asc_loadalign_brc`:对齐数据搬运接口,从Unified Buffer连续对齐搬入一个8位、16位或32位数据,并广播到目的操作数的所有元素位置。
90+- `asc_loadalign_brc_v2`:对齐数据搬运接口,从Unified Buffer连续对齐搬入一个32字节数据块(DataBlock),并广播到一个矢量长度。
91+- `asc_loadalign_brc_v3`:对齐数据搬运接口,从Unified Buffer连续对齐搬入数据,并将每个16位或32位元素广播到一个32字节数据块。
92+- `asc_loadalign_unpack`:对齐数据搬运接口,从Unified Buffer连续对齐搬入目的操作数,实现解压缩搬入模式:按8位、16位或32位无符号整数加载半个矢量长度的数据,扩展到一个矢量长度的16位、32位或64位数据,中间位置补0。
93+- `asc_loadalign_unpack_v2`:对齐数据搬运接口,从Unified Buffer连续对齐搬入目的操作数,实现解压缩搬入模式:按8位无符号整数加载四分之一个矢量长度的数据,扩展到一个矢量长度的32位数据,中间位置补0。
94+- `asc_loadalign_upsample`:对齐数据搬运接口,从Unified Buffer连续对齐搬入目的操作数,实现2倍上采样搬入模式:加载半个矢量长度的数据,每个输入元素重复两次。
95+- `asc_loadalign_downsample`:对齐数据搬运接口,从Unified Buffer连续对齐搬入目的操作数,实现2倍下采样搬入模式:加载2倍矢量长度的数据,数据每隔一个保留。
96+- `asc_loadalign_deintlv`:从Unified Buffer中读取以32字节对齐地址为起始位置的连续2倍矢量长度数据,在加载过程中完成解交织后,分别写入两个目的矢量数据寄存器。
97+- `asc_loadalign_postupdate``asc_loadalign_brc_postupdate``asc_loadalign_brc_postupdate_v2``asc_loadalign_brc_postupdate_v3`:实现相应的对齐搬入模式并启用Post Update,接口调用后自动更新源操作数地址。
98+- `asc_loadalign_unpack_postupdate``asc_loadalign_unpack_postupdate_v2``asc_loadalign_upsample_postupdate``asc_loadalign_downsample_postupdate``asc_loadalign_deintlv_postupdate`:实现相应的解压缩、2倍上采样、2倍下采样或解交织搬入模式并启用Post Update,接口调用后自动更新源操作数地址。
99+- `asc_loadunalign_pre`:用于非对齐数据搬入前的初始化,需配合`asc_loadunalign``asc_loadunalign_postupdate`使用。
100+- `asc_loadunalign``asc_loadunalign_postupdate`:适用于从Unified Buffer非32字节对齐地址连续搬入矢量数据寄存器的场景;后者支持自动更新源操作数地址。
101+- `asc_load`:支持从Unified Buffer非32字节对齐的源地址搬运至矢量数据寄存器,搬运量为一个矢量长度。
102+- `asc_gather`:根据索引位置将源操作数按元素收集到目的操作数中。
103+- `asc_gather_datablock`:给定源操作数在Unified Buffer中的基地址和索引,根据索引位置将源操作数按32字节数据块收集到目的操作数中。
104+ 
105+**数据搬出:**
106+ 
107+- `asc_storealign`:从矢量数据寄存器或掩码寄存器连续对齐搬出到Unified Buffer,实现NORM搬出模式,搬运一个矢量长度的数据。
108+- `asc_storealign_1st`:从矢量数据寄存器搬出第一个元素到Unified Buffer,忽略掩码。
109+- `asc_storealign_pack`:从矢量数据寄存器压缩搬出到Unified Buffer,根据掩码将源操作数中有效元素的低半部分比特位连续存储于目的操作数中。
110+- `asc_storealign_pack_v2`:从矢量数据寄存器压缩搬出到Unified Buffer,根据掩码将源操作数中有效元素的低8位连续存储于目的操作数中。
111+- `asc_storealign_intlv`:从矢量数据寄存器交错搬出到Unified Buffer,忽略掩码,将两个源操作数中的元素交错存储于目的操作数中。
112+- `asc_storealign_postupdate``asc_storealign_1st_postupdate`:实现NORM搬出模式或搬出第一个元素,并启用Post Update,接口调用后自动更新目的操作数地址。
113+- `asc_storealign_pack_postupdate``asc_storealign_pack_postupdate_v2`:实现低半部分比特位或低8位压缩搬出,并启用Post Update,接口调用后自动更新目的操作数地址。
114+- `asc_storeunalign``asc_storeunalign_postupdate`:适用于从矢量数据寄存器连续搬出到Unified Buffer非32字节对齐地址的场景;后者支持自动更新目的操作数地址。
115+- `asc_storeunalign_post``asc_storeunalign_post_postupdate`:适用于从矢量数据寄存器连续搬出到Unified Buffer非32字节对齐地址的尾块场景;后者支持自动更新目的操作数地址。
116+- `asc_scatter`:根据索引值将源操作数中的元素分散到目的操作数中。
117+- `asc_store`:适用于从矢量数据寄存器搬出到Unified Buffer的场景,不区分是否对齐;对齐场景推荐使用`asc_storealign`
118+ 
119+### Reg矢量计算
120+ 
121+提供使用`__simd_callee__`限定符的Reg矢量计算接口。根据接口能力,支持的数据类型包括`bool``int4b_t``int8_t``uint8_t``fp4x2_e2m1_t``fp4x2_e1m2_t``hifloat8_t``fp8_e8m0_t``fp8_e5m2_t``fp8_e4m3fn_t``int16_t``uint16_t``half``bfloat16_t``int32_t``uint32_t``float``int64_t``uint64_t`,具体支持组合以各接口说明为准。
122+ 
123+**寄存器与掩码:**
124+ 
125+- `asc_create_iter_reg_b8``asc_create_iter_reg_b16``asc_create_iter_reg_b32`:初始化地址寄存器,在循环中使用地址寄存器存储地址偏移量。
126+- `asc_create_mask_b8``asc_create_mask_b16``asc_create_mask_b32`:创建掩码寄存器,`pat_mode`参数指定哪些位置的元素参与计算。
127+- `asc_update_mask_b8``asc_update_mask_b16``asc_update_mask_b32`:根据元素个数生成掩码,并自动将元素个数减去当前矢量处理单元的元素个数。
128+- `asc_copy`:完成数据在寄存器间的搬运。
129+ 
130+**计算能力:**
131+ 
132+- 基础算术:`asc_add``asc_addc``asc_add_scalar``asc_sub``asc_subc``asc_mul``asc_mul_scalar``asc_madd``asc_mull``asc_max``asc_max_scalar``asc_min``asc_min_scalar``asc_abs``asc_neg``asc_abs_sub``asc_axpy``asc_relu``asc_leakyrelu``asc_prelu``asc_exp``asc_ln``asc_sqrt``asc_div`
133+- 逻辑与移位:`asc_and``asc_or``asc_xor``asc_not``asc_shiftleft``asc_shiftleft_scalar``asc_shiftright``asc_shiftright_scalar`
134+- 比较与选择:`asc_eq``asc_ne``asc_lt``asc_le``asc_gt``asc_ge``asc_eq_scalar``asc_ne_scalar``asc_lt_scalar``asc_le_scalar``asc_gt_scalar``asc_ge_scalar``asc_select``asc_squeeze``asc_squeeze_v2`
135+- 类型转换接口分组如下。同组函数根据能力提供向下、向上、向零、最近偶数或最近远离零舍入模式,以及饱和或非饱和模式。
136+ - `int4b_t``fp4x2_e2m1_t``fp4x2_e1m2_t`转换:
137+ - `half`转换为`int4b_t``asc_half2int4x2_rd``asc_half2int4x2_rd_sat``asc_half2int4x2_rd_v2``asc_half2int4x2_rd_sat_v2``asc_half2int4x2_rd_v3``asc_half2int4x2_rd_sat_v3``asc_half2int4x2_rd_v4``asc_half2int4x2_rd_sat_v4`。9.0.0公开头文件中其他舍入模式的接口错误复用了上述向下舍入函数名。
138+ - `int4b_t`转换为其他类型:`asc_int4x22half``asc_int4x22bfloat16``asc_int4x22int16`
139+ - `bfloat16_t`转换为`fp4x2_e2m1_t``asc_bfloat162e2m1x2_rd``asc_bfloat162e2m1x2_rd_v2``asc_bfloat162e2m1x2_rd_v3``asc_bfloat162e2m1x2_rd_v4``asc_bfloat162e2m1x2_rn``asc_bfloat162e2m1x2_rn_v2``asc_bfloat162e2m1x2_rn_v3``asc_bfloat162e2m1x2_rn_v4``asc_bfloat162e2m1x2_rna``asc_bfloat162e2m1x2_rna_v2``asc_bfloat162e2m1x2_rna_v3``asc_bfloat162e2m1x2_rna_v4``asc_bfloat162e2m1x2_ru``asc_bfloat162e2m1x2_ru_v2``asc_bfloat162e2m1x2_ru_v3``asc_bfloat162e2m1x2_ru_v4``asc_bfloat162e2m1x2_rz``asc_bfloat162e2m1x2_rz_v2``asc_bfloat162e2m1x2_rz_v3``asc_bfloat162e2m1x2_rz_v4`
140+ - `fp4x2_e2m1_t`转换为`bfloat16_t``asc_e2m1x22bfloat16`
141+ - `bfloat16_t`转换为`fp4x2_e1m2_t``asc_bfloat162e1m2x2_rd``asc_bfloat162e1m2x2_rd_v2``asc_bfloat162e1m2x2_rd_v3``asc_bfloat162e1m2x2_rd_v4``asc_bfloat162e1m2x2_rn``asc_bfloat162e1m2x2_rn_v2``asc_bfloat162e1m2x2_rn_v3``asc_bfloat162e1m2x2_rn_v4``asc_bfloat162e1m2x2_rna``asc_bfloat162e1m2x2_rna_v2``asc_bfloat162e1m2x2_rna_v3``asc_bfloat162e1m2x2_rna_v4``asc_bfloat162e1m2x2_ru``asc_bfloat162e1m2x2_ru_v2``asc_bfloat162e1m2x2_ru_v3``asc_bfloat162e1m2x2_ru_v4``asc_bfloat162e1m2x2_rz``asc_bfloat162e1m2x2_rz_v2``asc_bfloat162e1m2x2_rz_v3``asc_bfloat162e1m2x2_rz_v4`
142+ - `fp4x2_e1m2_t`转换为`bfloat16_t``asc_e1m2x22bfloat16`
143+ - `hifloat8_t``fp8_e5m2_t``fp8_e4m3fn_t`转换:
144+ - `hifloat8_t`转换:`asc_float2hif8_rh``asc_float2hif8_rh_sat``asc_float2hif8_rh_v2``asc_float2hif8_rh_sat_v2``asc_float2hif8_rh_v3``asc_float2hif8_rh_sat_v3``asc_float2hif8_rh_v4``asc_float2hif8_rh_sat_v4``asc_float2hif8_rna``asc_float2hif8_rna_sat``asc_float2hif8_rna_v2``asc_float2hif8_rna_sat_v2``asc_float2hif8_rna_v3``asc_float2hif8_rna_sat_v3``asc_float2hif8_rna_v4``asc_float2hif8_rna_sat_v4``asc_half2hif8_rh``asc_half2hif8_rh_sat``asc_half2hif8_rh_v2``asc_half2hif8_rh_sat_v2``asc_half2hif8_rna``asc_half2hif8_rna_sat``asc_half2hif8_rna_v2``asc_half2hif8_rna_sat_v2``asc_hif82half`
145+ - `fp8_e5m2_t`转换:`asc_float2e5m2_rn``asc_float2e5m2_rn_sat``asc_float2e5m2_rn_v2``asc_float2e5m2_rn_sat_v2``asc_float2e5m2_rn_v3``asc_float2e5m2_rn_sat_v3``asc_float2e5m2_rn_v4``asc_float2e5m2_rn_sat_v4``asc_e5m22float`
146+ - `fp8_e4m3fn_t`转换:`asc_float2e4m3_rn``asc_float2e4m3_rn_sat``asc_float2e4m3_rn_v2``asc_float2e4m3_rn_sat_v2``asc_float2e4m3_rn_v3``asc_float2e4m3_rn_sat_v3``asc_float2e4m3_rn_v4``asc_float2e4m3_rn_sat_v4``asc_e4m32float`
147+ - `half`转换为`bfloat16_t``asc_half2bfloat16_rd``asc_half2bfloat16_rn``asc_half2bfloat16_rna``asc_half2bfloat16_ru``asc_half2bfloat16_rz`
148+ - `float`转换为`bfloat16_t``asc_float2bfloat16_rd``asc_float2bfloat16_rd_sat``asc_float2bfloat16_rd_v2``asc_float2bfloat16_rd_sat_v2``asc_float2bfloat16_rd_sync``asc_float2bfloat16_rn``asc_float2bfloat16_rn_sat``asc_float2bfloat16_rn_v2``asc_float2bfloat16_rn_sat_v2``asc_float2bfloat16_rn_sync``asc_float2bfloat16_rna``asc_float2bfloat16_rna_sat``asc_float2bfloat16_rna_v2``asc_float2bfloat16_rna_sat_v2``asc_float2bfloat16_rna_sync``asc_float2bfloat16_ru``asc_float2bfloat16_ru_sat``asc_float2bfloat16_ru_v2``asc_float2bfloat16_ru_sat_v2``asc_float2bfloat16_ru_sync``asc_float2bfloat16_rz``asc_float2bfloat16_rz_sat``asc_float2bfloat16_rz_v2``asc_float2bfloat16_rz_sat_v2``asc_float2bfloat16_rz_sync`
149+ - `half``bfloat16_t``float`之间的其他转换:`asc_half2float``asc_bfloat162half``asc_bfloat162float``asc_float2half`
150+ - `int8_t`转换为`half``asc_int82half`
151+ - `uint8_t`转换为`half``asc_uint82half`
152+ - `int16_t`转换为浮点类型:`asc_int162half``asc_int162float`
153+ - `half`转换为8位整数:`asc_half2int8``asc_half2uint8`
154+ - `half`转换为`int16_t``asc_half2int16_rd``asc_half2int16_rd_sat``asc_half2int16_rd_sync``asc_half2int16_rn``asc_half2int16_rn_sat``asc_half2int16_rn_sync``asc_half2int16_rna``asc_half2int16_rna_sat``asc_half2int16_rna_sync``asc_half2int16_ru``asc_half2int16_ru_sat``asc_half2int16_ru_sync``asc_half2int16_rz``asc_half2int16_rz_sat``asc_half2int16_rz_sync`
155+ - `half`转换为`int32_t``asc_half2int32_rd``asc_half2int32_rd_v2``asc_half2int32_rd_sync``asc_half2int32_rn``asc_half2int32_rn_v2``asc_half2int32_rn_sync``asc_half2int32_rna``asc_half2int32_rna_v2``asc_half2int32_rna_sync``asc_half2int32_ru``asc_half2int32_ru_v2``asc_half2int32_ru_sync``asc_half2int32_rz``asc_half2int32_rz_v2``asc_half2int32_rz_sync`
156+ - `int32_t`转换为`float``asc_int322float`
157+ - `float`转换为`int16_t``asc_float2int16_rd``asc_float2int16_rd_sat``asc_float2int16_rd_v2``asc_float2int16_rd_sat_v2``asc_float2int16_rd_sync``asc_float2int16_rn``asc_float2int16_rn_sat``asc_float2int16_rn_v2``asc_float2int16_rn_sat_v2``asc_float2int16_rn_sync``asc_float2int16_rna``asc_float2int16_rna_sat``asc_float2int16_rna_v2``asc_float2int16_rna_sat_v2``asc_float2int16_rna_sync``asc_float2int16_ru``asc_float2int16_ru_sat``asc_float2int16_ru_v2``asc_float2int16_ru_sat_v2``asc_float2int16_ru_sync``asc_float2int16_rz``asc_float2int16_rz_sat``asc_float2int16_rz_v2``asc_float2int16_rz_sat_v2``asc_float2int16_rz_sync`
158+ - `float`转换为`int32_t``asc_float2int32_rd``asc_float2int32_rd_sat``asc_float2int32_rd_sync``asc_float2int32_rn``asc_float2int32_rn_sat``asc_float2int32_rn_sync``asc_float2int32_rna``asc_float2int32_rna_sat``asc_float2int32_rna_sync``asc_float2int32_ru``asc_float2int32_ru_sat``asc_float2int32_ru_sync``asc_float2int32_rz``asc_float2int32_rz_sat``asc_float2int32_rz_sync`
159+ - `float`转换为`int64_t``asc_float2int64_rd``asc_float2int64_rd_sat``asc_float2int64_rd_v2``asc_float2int64_rd_sat_v2``asc_float2int64_rd_sync``asc_float2int64_rn``asc_float2int64_rn_sat``asc_float2int64_rn_v2``asc_float2int64_rn_sat_v2``asc_float2int64_rn_sync``asc_float2int64_rna``asc_float2int64_rna_sat``asc_float2int64_rna_v2``asc_float2int64_rna_sat_v2``asc_float2int64_rna_sync``asc_float2int64_ru``asc_float2int64_ru_sat``asc_float2int64_ru_v2``asc_float2int64_ru_sat_v2``asc_float2int64_ru_sync``asc_float2int64_rz``asc_float2int64_rz_sat``asc_float2int64_rz_v2``asc_float2int64_rz_sat_v2``asc_float2int64_rz_sync`
160+ - `int64_t`转换为`float``asc_int642float_rd``asc_int642float_rd_v2``asc_int642float_rd_sync``asc_int642float_rn``asc_int642float_rn_v2``asc_int642float_rn_sync``asc_int642float_rna``asc_int642float_rna_v2``asc_int642float_rna_sync``asc_int642float_ru``asc_int642float_ru_v2``asc_int642float_ru_sync``asc_int642float_rz``asc_int642float_rz_v2``asc_int642float_rz_sync`
161+ - 整数位宽和符号转换:`asc_int82int16``asc_int82int32``asc_uint82uint16``asc_uint82uint32``asc_int162uint8``asc_int162int32``asc_int162uint32``asc_uint162uint8``asc_uint162uint32``asc_int322uint8``asc_int322int16``asc_int322uint16``asc_int322int64``asc_uint322uint8``asc_uint322int16``asc_uint322uint16``asc_int642int32`
162+ - 浮点取整:`asc_ceil``asc_floor``asc_rint``asc_round``asc_trunc`,结果仍保持源浮点数据类型。
163+- 归约:`asc_reduce_max``asc_reduce_min``asc_reduce_sum``asc_reduce_max_datablock``asc_reduce_min_datablock``asc_reduce_sum_datablock``asc_pair_reduce_sum`
164+- 数据压缩:`asc_pack``asc_pack_v2`将源操作数元素的低8位、低16位或低32位写入目的操作数的低半部分或高半部分。
165+- 位宽扩展:`asc_unpack_lower``asc_unpack_upper`分别选取源操作数低半部分、高半部分的元素并扩充位宽。无符号整数高位填0,有符号整数保持符号位扩充,`bool`类型将每个比特位展开为2个比特位且高位填0。
166+- 掩码解压缩:`asc_unsqueeze`将目的操作数的第0个元素置为0,第i个元素设置为掩码中从第0个到第i-1个元素中1的数量。
167+- 填充与重排:`asc_duplicate``asc_duplicate_scalar``asc_intlv``asc_deintlv`
168+- 累计直方图:`asc_cumulative_histogram_bin0``asc_cumulative_histogram_bin1`用于对直方图数据进行累计统计,分别统计源操作数中低位区间、高位区间的数据分布情况。
169+- 频率直方图:`asc_frequency_histogram_bin0``asc_frequency_histogram_bin1`对输入数据进行频率统计,分别统计低位区间、高位区间,统计结果在目的操作数原有数据基础上累加。
170+- 索引生成:`asc_arange``asc_arange_descend`以传入值为起始值,生成递增、递减的索引,并将生成的索引保存在目的操作数中。
171+- `asc_mem_bar`:Reg计算宏函数内不同流水线之间的同步指令,目的流水线等待源流水线上所有指令完成后执行。
172+- `asc_clear_ar_spr`:对AR特殊寄存器进行清零操作。
173+ 
174+### 其他操作
175+ 
176+- `asc_init`:初始化神经网络处理器(Neural-network Processing Unit,NPU)状态。
@@ -0,0 +1,145 @@
1+# C API
2+ 
3+CANN 9.1.0继续完善Ascend 950PR/Ascend 950DT(3510架构)C API,新增矢量计算、数据搬运、标量操作、矩阵计算、同步控制、系统变量和缓存控制接口,并修复9.0.0中的函数命名、类型声明和地址自更新签名问题。
4+ 
5+## 新增特性
6+ 
7+### 矢量计算
8+ 
9+- `asc_bitsort``asc_bitsort_sync`:分数(Score)和索引(Index)分别存储在两个源操作数中,按分数从大到小排序,将排序后的分数与对应索引组成数据结构存储在目的操作数中。
10+- `asc_mrgsort4``asc_mrgsort4_sync`:将已经排好序的最多4条队列合并排列成1条队列,结果按照分数域由大到小排序。
11+- `asc_transpose``asc_transpose_sync`:实现16×16的二维矩阵数据块转置。
12+- `asc_transto5hd_b8``asc_transto5hd_b8_sync``asc_transto5hd_b16``asc_transto5hd_b16_sync``asc_transto5hd_b32``asc_transto5hd_b32_sync`:执行数据格式转换,一般用于将NCHW格式转换成NC1HWC0格式,也可用于二维矩阵数据块转置。
13+- `asc_set_va_reg`:用于设置`asc_transto5hd_b8`的地址,将操作数地址序列与地址寄存器关联。
14+ 
15+### 数据搬运
16+ 
17+- `asc_copy_gm2ub``asc_copy_gm2ub_sync`:将数据从Global Memory搬运到Unified Buffer。
18+- `asc_copy_ub2gm``asc_copy_ub2gm_sync`:将数据从Unified Buffer搬运到Global Memory。
19+- `asc_copy_ub2ub``asc_copy_ub2ub_sync`:将数据从Unified Buffer搬运到Unified Buffer。
20+- `asc_copy_ub2l1``asc_copy_ub2l1_sync`:将数据从Unified Buffer搬运到L1 Buffer。
21+- `asc_set_copy_pad_val`:与`asc_copy_gm2ub_align`配合使用,设置连续搬运数据块左右两侧需要填充的数据值。Ascend 950PR/Ascend 950DT支持`int8_t``uint8_t``int16_t``uint16_t``half``bfloat16_t``int32_t``uint32_t``float``fp4x2_e2m1_t``fp4x2_e1m2_t``hifloat8_t``fp8_e8m0_t``fp8_e5m2_t``fp8_e4m3fn_t`数据需要先转换为`int8_t`再传入。
22+- `asc_ndim_copy_dci`:执行N维搬运场景所需的数据缓存失效(Data Cache Invalidate,DCI)操作。
23+- `asc_copy_gm2l1``asc_copy_gm2l1_sync`:将数据从Global Memory搬运到L1 Buffer。
24+- `asc_copy_gm2l1_align``asc_copy_gm2l1_align_sync`:将Global Memory中的数据填充后搬运到L1 Buffer。
25+- `asc_copy_gm2l1_nd2nz``asc_copy_gm2l1_nd2nz_sync`:在Global Memory到L1 Buffer搬运过程中完成ND到NZ格式转换。
L
LLycheeeee8月7日

确定NZ还是Nz

likedislike
26+- `asc_copy_gm2l1_dn2nz``asc_copy_gm2l1_dn2nz_sync`:将矩阵数据从Global Memory搬运到L1 Buffer,并完成DN到NZ、NCHW到NC1HWC0或NCHW到C1HWNC0格式转换。D维未按C0大小对齐时,在L1 Buffer最内层维度填充0。
27+- `asc_copy_l12l0a``asc_copy_l12l0a_sync``asc_copy_l12l0b``asc_copy_l12l0b_sync`:将L1 Buffer中的512字节矩阵搬运到L0A Buffer或L0B Buffer,支持2D格式搬运、2D格式转置搬运、3D格式搬运。
28+- `asc_copy_l12l0b_trans``asc_copy_l12l0b_trans_sync`:将矩阵从L1 Buffer转置搬运到L0B Buffer。
29+- `asc_copy_l12l0b_mx``asc_copy_l12l0b_mx_sync`:将微缩放(Microscaling,MX)矩阵从L1 Buffer搬运到L0B Buffer。
30+- `asc_copy_l0c2gm``asc_copy_l0c2gm_sync`:将L0C Buffer中的数据搬运到Global Memory,支持量化、ReLU、Leaky ReLU、通道拆分和NZ2ND随路控制。
31+- `asc_copy_l0c2ub``asc_copy_l0c2ub_sync`:将L0C Buffer中的数据搬运到Unified Buffer,支持量化、ReLU、Leaky ReLU和通道拆分随路控制。
32+- `asc_copy_l12fb``asc_copy_l12fb_sync`:将量化参数从L1 Buffer搬运到Fixpipe Buffer。
33+- `asc_copy_l12bt``asc_copy_l12bt_sync`:将矩阵乘使用的偏置(Bias)数据从L1 Buffer搬运到BiasTable Buffer。
34+- `asc_copy_l12ub``asc_copy_l12ub_sync`:将数据从L1 Buffer搬运到Unified Buffer。
35+- `asc_fill_l1``asc_fill_l1_sync`:将`value`的二进制值赋值给目的操作数,对L1 Buffer的Local Memory进行初始化。
36+- `asc_set_l13d_fmatrix_b`:设置特征图属性描述,用于`asc_copy_l12l0a``asc_copy_l12l0b`的3D格式搬运接口配置填充值。从右矩阵获取特征图属性时使用该接口。
37+- `asc_set_l0c2gm_lrelu_alpha`:用于设置`asc_copy_l0c2l1``asc_copy_l0c2gm`计算过程中使用的Leaky ReLU alpha值,该值只支持`half``float`两种数据类型。
38+- `asc_set_l13d_padding`:设置填充属性描述,用于调用`asc_copy_l12l0a`时配置填充值。
39+ 
40+### 标量操作
41+ 
42+- `asc_clear_nthbit``asc_set_nthbit`:清除或设置`uint64_t`值中的指定比特位。
43+- `asc_atomic_add``asc_atomic_sub``asc_atomic_max``asc_atomic_min``asc_atomic_exch``asc_atomic_cas`:对Global Memory中的`int32_t``uint32_t``float``int64_t``uint64_t`数据执行标量原子操作,并返回操作前的值。
44+- `asc_atomic_and``asc_atomic_or``asc_atomic_xor`:对Global Memory中的`int32_t``uint32_t``int64_t``uint64_t`数据执行原子按位运算。
45+- `asc_atomic_inc`:对Global Memory中的`uint32_t``uint64_t`计数器执行原子递增操作;计数器数值大于等于`val`时赋值为0,否则加1。
46+- `asc_atomic_dec`:对Global Memory中的`uint32_t``uint64_t`计数器执行原子递减操作;计数器数值等于0或大于`val`时赋值为`val`,否则减1。
47+ 
48+### 矩阵计算
49+ 
50+- `asc_mmad``asc_mmad_sync`:完成矩阵乘加操作,支持`int8_t``hifloat8_t``fp8_e5m2_t``fp8_e4m3fn_t``half``bfloat16_t``float`同精度和混合精度输入组合。
51+- `asc_enable_fp8`:设置矩阵乘加计算开启FP8模式并关闭HiF8模式,L0A Buffer、L0B Buffer中的FP8数据在参与矩阵乘加计算之前不会转换为`hifloat8_t`数据。
52+- `asc_enable_hif8`:设置矩阵乘加计算开启HiF8模式,L0A Buffer、L0B Buffer中的8位数据在参与矩阵乘法运算前转换为`hifloat8_t`数据。
53+- `asc_enable_hf32_trans`:设置HF32模式舍入方式,使用该接口前需要先使用`asc_enable_hf32`开启HF32模式。
54+- `asc_enable_hf32`:设置矩阵乘加计算开启HF32模式,提升FP32数据的计算性能,但会带来一定的精度损失。
55+- `asc_set_fp32_mode`:设置矩阵乘加计算开启FP32模式,L0A Buffer、L0B Buffer中的FP32数据在参与矩阵乘加计算之前不做舍入处理。
56+- `asc_set_mmad_direction_m``asc_set_mmad_direction_n`:分别设置矩阵乘加计算优先通过M方向、N方向生成结果。
57+ 
58+### 同步控制
59+ 
60+- `asc_lock``asc_unlock`:用于AI Core内部异步流水线同步。
61+- `asc_sync_intra_arrive``asc_sync_intra_wait`:用于核间信号同步。
62+- `asc_sync_subblock_arrive``asc_sync_subblock_wait`:用于组内子块(Subblock)间的信号同步。
63+- `asc_sync_inter_arrive``asc_sync_inter_wait`:用于组间计算块(Block)的信号同步。
64+- `asc_sync_data_barrier`:等待指定范围内先前发起的内存访问完成。
65+ 
66+### 系统变量
67+ 
68+- `asc_get_smmu_tag_version``asc_get_phy_stack_base``asc_get_status``asc_get_sys_virtual_base`:分别获取系统内存管理单元(System Memory Management Unit,SMMU)版本信息、物理堆栈基地址、状态信息和系统虚拟基地址。
69+- `asc_get_block_idx`:获取当前运行核的索引。
70+- `asc_get_sub_block_num`:在分离模式下获取一个AI Core上的Cube Core或Vector Core数量。
71+- `asc_get_sub_block_id`:获取AI Core上的Vector Core ID。
72+- `asc_get_phy_buf_addr`:根据偏移量获取片上实际物理地址。
73+- `asc_get_core_id``asc_get_arch_ver`:分别获取核ID和架构版本。
74+- `asc_get_vf_len`:获取Tensor位宽VL(Vector Length)的大小。
75+- `asc_set_gm2l1_nz_para`:设置MTE2_NZ_PARA寄存器的值。
76+- `asc_set_l0c2gm_channel_para`:设置通道步长参数专用寄存器的比特位。
77+- `asc_set_l0c2gm_quant_post`:设置QUANT_POST寄存器的值。试验接口。
78+- `asc_set_l0c2gm_relu_alpha`:设置RELU_ALPHA寄存器的值。
79+- `asc_set_l12l0_padding_val`:设置PADDING_B寄存器的值。
80+- `asc_set_l3d_rpt_b`:用于设置`asc_copy_l12l0a``asc_copy_l12l0b`的2D格式搬运repeat参数。
81+ 
82+### 缓存控制
83+ 
84+- `asc_dci`:使整个数据缓存失效,不回写缓存行,未同步到主存的修改会被丢弃。调用前必须先执行`asc_sync_data_barrier(mem_dsb_t::DSB_ALL)`,等待此前的内存访问完成。
85+ 
86+## Bug修复
87+ 
88+- `asc_sync_block_arrive`由9.0.0的`asc_sync_block_arrive(pipe, mode, flagID)`调整为`asc_sync_block_arrive(pipe, flag_id)`,删除`mode`参数并统一事件标号命名。
89+- `asc_sync_block_wait`由9.0.0的`asc_sync_block_wait(flagID)`调整为`asc_sync_block_wait(pipe, flag_id)`,新增流水线参数并统一事件标号命名。
90+- `asc_get_arch_ver`参数名由`coreVersion`统一为`core_version`
91+- 修复`cache_ctrl.h`复用原子操作头文件保护宏的问题,避免包含顺序导致缓存控制声明被跳过。
92+- 统一`asc_simd.h``misc.h``cache_ctrl.h``sync.h``sys_var.h``utils_intf.h`中的头文件引用路径,避免安装目录变化导致包含失败。
93+-`asc_loadalign_postupdate``asc_loadalign_brc_postupdate``asc_loadalign_brc_postupdate_v2``asc_loadalign_brc_postupdate_v3``asc_loadalign_upsample_postupdate``asc_loadalign_downsample_postupdate``asc_loadalign_unpack_postupdate``asc_loadalign_unpack_postupdate_v2``asc_loadalign_deintlv_postupdate`中需要自动更新的Unified Buffer源指针参数修正为指针引用,确保调用后地址变化对调用方可见。
94+-`asc_storealign_postupdate``asc_storealign_1st_postupdate``asc_storealign_pack_postupdate``asc_storealign_pack_postupdate_v2`中需要自动更新的Unified Buffer目的指针参数修正为指针引用,确保调用后地址变化对调用方可见。
95+- 将不更新地址的`asc_storeunalign`目的参数由指针引用修正为普通指针,并补齐`asc_storeunalign_postupdate`的地址更新重载。
96+- 修复`half`转换为`int4b_t`接口的舍入模式命名。9.0.0将以下四种舍入模式的接口声明为向下舍入函数名,9.1.0修复为与实际舍入模式一致的函数名:
97+ - 向上舍入:`asc_half2int4x2_ru``asc_half2int4x2_ru_sat``asc_half2int4x2_ru_v2``asc_half2int4x2_ru_sat_v2``asc_half2int4x2_ru_v3``asc_half2int4x2_ru_sat_v3``asc_half2int4x2_ru_v4``asc_half2int4x2_ru_sat_v4`
98+ - 向零舍入:`asc_half2int4x2_rz``asc_half2int4x2_rz_sat``asc_half2int4x2_rz_v2``asc_half2int4x2_rz_sat_v2``asc_half2int4x2_rz_v3``asc_half2int4x2_rz_sat_v3``asc_half2int4x2_rz_v4``asc_half2int4x2_rz_sat_v4`
99+ - 最近偶数舍入:`asc_half2int4x2_rn``asc_half2int4x2_rn_sat``asc_half2int4x2_rn_v2``asc_half2int4x2_rn_sat_v2``asc_half2int4x2_rn_v3``asc_half2int4x2_rn_sat_v3``asc_half2int4x2_rn_v4``asc_half2int4x2_rn_sat_v4`
100+ - 最近远离零舍入:`asc_half2int4x2_rna``asc_half2int4x2_rna_sat``asc_half2int4x2_rna_v2``asc_half2int4x2_rna_sat_v2``asc_half2int4x2_rna_v3``asc_half2int4x2_rna_sat_v3``asc_half2int4x2_rna_v4``asc_half2int4x2_rna_sat_v4`
101+-`asc_int162half_rc`修正为`asc_int162half_rz`
102+-`asc_reduce_min_datablock_`修正为`asc_reduce_min_datablock`,去除多余的尾部下划线。
103+-`asc_half2uint8_rd_sat_v2_impl``asc_half2uint8_rn_sat_v2_impl``asc_half2uint8_rna_sat_v2_impl``asc_half2uint8_ru_sat_v2_impl``asc_half2uint8_rz_sat_v2_impl`分别修正为`asc_half2uint8_rd_sat_v2``asc_half2uint8_rn_sat_v2``asc_half2uint8_rna_sat_v2``asc_half2uint8_ru_sat_v2``asc_half2uint8_rz_sat_v2`
104+- 将以下`bfloat16_t`转换为`fp4x2_e1m2_t`接口的目的类型从`vector_f4e1m2x2`修正为`vector_fp4x2_e1m2_t`
105+ - 向下舍入:`asc_bfloat162e1m2x2_rd``asc_bfloat162e1m2x2_rd_v2``asc_bfloat162e1m2x2_rd_v3``asc_bfloat162e1m2x2_rd_v4`
106+ - 最近偶数舍入:`asc_bfloat162e1m2x2_rn``asc_bfloat162e1m2x2_rn_v2``asc_bfloat162e1m2x2_rn_v3``asc_bfloat162e1m2x2_rn_v4`
107+ - 最近远离零舍入:`asc_bfloat162e1m2x2_rna``asc_bfloat162e1m2x2_rna_v2``asc_bfloat162e1m2x2_rna_v3``asc_bfloat162e1m2x2_rna_v4`
108+ - 向上舍入:`asc_bfloat162e1m2x2_ru``asc_bfloat162e1m2x2_ru_v2``asc_bfloat162e1m2x2_ru_v3``asc_bfloat162e1m2x2_ru_v4`
109+ - 向零舍入:`asc_bfloat162e1m2x2_rz``asc_bfloat162e1m2x2_rz_v2``asc_bfloat162e1m2x2_rz_v3``asc_bfloat162e1m2x2_rz_v4`
110+-`asc_half2uint8``asc_min_scalar`的非标准类型别名`vector_u8``vector_f16`修正为`vector_uint8_t``vector_half`
111+- `asc_arange``asc_arange_descend`参数名由`index`统一为`value`
112+- `asc_update_mask_b8``asc_update_mask_b16``asc_update_mask_b32`参数名由`scalar`统一为`value`
113+ 
114+## 增强
115+ 
116+- `asc_copy_gm2ub_align``asc_copy_gm2ub_align_sync``asc_copy_ub2gm_align``asc_copy_ub2gm_align_sync`新增仅传入`dst``src``size`的简化重载。
117+- `asc_copy_l0c2l1`新增`asc_copy_l0c2l1_sync`,并新增`int16_t`目的数据与`int32_t`源数据、`bfloat16_t`目的数据与`float`源数据的组合,以及目的参数为`__cbuf__ void*`、源参数分别为`__cc__ int32_t*``__cc__ float*`的通用重载。
118+- `asc_copy_l12l0a_mx`新增`asc_copy_l12l0a_mx_sync`
119+- `asc_set_atomic_add_int8``asc_set_atomic_add_int16``asc_set_atomic_add_int`:设置后续从Unified Buffer、L0C Buffer到Global Memory的数据搬运开启原子累加,累加的数据类型分别为`int8_t``int16_t``int32_t`
120+- `asc_gather``int16_t``uint16_t``half``bfloat16_t`数据新增使用`vector_uint32_t`索引的重载。
121+- `asc_gather_datablock`新增`int4b_t`重载和无需传入掩码参数的`uint64_t`重载。
122+- `asc_loadalign``asc_loadalign_brc``asc_loadalign_brc_v2``asc_loadalign_upsample``asc_loadalign_downsample``asc_loadalign_unpack``asc_loadalign_unpack_v2``asc_loadalign_deintlv`新增`int4b_t``vector_int4x2_t`重载。
123+- `asc_loadalign``asc_loadalign_upsample``asc_loadalign_downsample``asc_loadalign_postupdate`新增`vector_bool`重载。
124+- `asc_storealign``asc_storealign_1st``asc_storealign_intlv``asc_storeunalign``asc_storeunalign_postupdate``asc_storeunalign_post``asc_storeunalign_post_postupdate``asc_store`新增`int4b_t``vector_int4x2_t`数据重载。
125+- `asc_storealign``asc_storealign_pack``asc_storealign_postupdate``asc_storealign_pack_postupdate``asc_storeunalign_postupdate`新增`vector_bool`输出重载。
126+- `asc_scatter`新增9组目的Unified Buffer地址在前、源矢量寄存器在后的重载,根据索引将源矢量寄存器元素分散写入Unified Buffer。支持的数据类型为`int8_t``uint8_t``int16_t``uint16_t``half``bfloat16_t``int32_t``uint32_t``float`
127+- `asc_create_iter_reg_b8``asc_create_iter_reg_b16``asc_create_iter_reg_b32`从单个偏移扩展为支持1至4个偏移。
128+- `asc_copy`新增将`vector_uint16_t``vector_uint32_t`矢量数据寄存器复制到`vector_bool`掩码寄存器的重载。
129+- `asc_duplicate_scalar`新增无需传入掩码参数的重载。
130+ 
131+## 接口废弃
132+ 
133+本版本标记以下接口或特定重载为`deprecated`
134+ 
135+### 数据搬运
136+ 
137+| 废弃接口或重载 | 替代接口 | 说明 |
B
Bbianque8月7日

这里是说废弃接口的示例?还是什么?和上面的函数重命名有什么区别

likedislike
138+| :--- | :--- | :--- |
139+| `asc_set_gm2ub_pad` | `asc_set_copy_pad_val` | 使用通用搬运填充值配置接口。 |
140+| `asc_get_store_atomic_config`(Ascend 950PR/Ascend 950DT) | `asc_atomic_add` | 标量原子加无需预先配置和查询数据搬运原子状态。 |
141+| `asc_set_store_atomic_config_v2` | `asc_atomic_add` | 标量原子加改为直接调用原子接口。 |
142+| 源矢量寄存器在前、目的Unified Buffer地址在后的`asc_scatter`重载 | 目的Unified Buffer地址在前、源矢量寄存器在后的`asc_scatter`重载 | 支持的数据类型不变,仅调整参数顺序。 |
143+| `asc_exp_sub_v2(vector_float&, vector_float, vector_float, vector_bool)` | `asc_exp_sub` | `half`输入的`asc_exp_sub_v2`仍保留,用于读取源操作数的奇数索引元素;仅`float`输入的该重载废弃。 |
144+ 
145+**注:** 详情可参考[废弃接口](../deprecated_interface.md)。
@@ -1,282 +0,0 @@
1-# C API
2- 
3-新增实验性C API 3510系列,开放底层完备能力,提供直接操作NPU硬件资源的接口,覆盖数据搬运、矢量计算、矩阵计算、同步控制、标量计算、缓存控制等全场景。支持以数组形式分配内存,一般基于指针编程。提供与业界一致的C语言编程体验。
4- 
5-## 特性
6- 
7-### 数据结构
8- 
9-提供配置类联合体定义,用于矩阵填充、原子操作、L0C Buffer搬运、3D加载、N维填充等场景的参数封装。
10- 
11-- `asc_fill_value_config`:fill_value的初始化参数结构体,包含 `asc_fill_l0a` / `asc_fill_l0b` / `asc_fill_l1` 接口需要配置的各种初始化参数。
12-- `asc_store_atomic_config`:原子操作使能位与原子操作类型的值。
13-- `asc_set_l0c_copy_params_config`:DataCopy(L0C Buffer->GM、L0C Buffer->L1 Buffer)过程中进行随路格式转换(NZ格式转换为ND格式)时,通过调用该接口设置格式转换的相关配置。
14-- `asc_load3d_v2_config`:Load3Dv2接口的repeat参数。
15-- `asc_ndim_pad_count_config`:N维搬运时各层循环的左右填充计数配置。
16-- `asc_l13d_fmatrix_config`:L1 3D fmatrix配置,用于设置 `asc_copy_l12l0a` / `asc_copy_l12l0b` 的3D格式搬运的fmatrix参数。
17- 
18-### 矢量数据搬运
19- 
20-- `asc_copy_gm2ub_align` / `asc_copy_gm2ub_align_sync`:提供数据非对齐搬运的功能,将数据从Global Memory搬运到Unified Buffer,扩展支持 `fp8_e5m2_t` / `fp8_e4m3fn_t` / `hifloat8_t`,增加 `enable_constant_pad` / `l2_cache_mode` 参数。
21-- `asc_copy_ub2gm_align` / `asc_copy_ub2gm_align_sync`:将数据从Unified Buffer搬运到Global Memory,增加 `l2_cache_mode` 参数。
22-- `asc_copy_ub2l1` / `asc_copy_ub2l1_sync`:将数据从Unified Buffer搬运到L1 Buffer。
23-- `asc_ndim_copy_gm2ub`:N维GM到UB搬运,支持 `int8_t` / `uint8_t` / `fp4x2_e2m1_t` / `fp4x2_e1m2_t` / `fp8_e8m0_t` / `fp8_e5m2_t` / `fp8_e4m3fn_t` / `int16_t` / `uint16_t` / `half` / `bfloat16_t` / `int32_t` / `uint32_t` / `float`
24-- `asc_set_gm2ub_loop_size` / `asc_set_gm2ub_loop1_stride` / `asc_set_gm2ub_loop2_stride`:GM到UB循环搬运参数配置。
25-- `asc_set_ub2gm_loop_size` / `asc_set_ub2gm_loop1_stride` / `asc_set_ub2gm_loop2_stride`:UB到GM循环搬运参数配置。
26-- `asc_set_gm2ub_pad`:GM到UB填充值配置。
27-- `asc_set_ndim_loop0_stride` ~ `asc_set_ndim_loop4_stride`:N维循环步长配置。
28-- `asc_set_ndim_pad_count` / `asc_set_ndim_pad_value`:N维填充配置。
29- 
30-### Reg矢量计算
31- 
32-提供基于矢量寄存器的计算接口,使用 `__simd_callee__` 限定符,支持 `int8_t` / `uint8_t` / `int16_t` / `uint16_t` / `int32_t` / `uint32_t` / `half` / `float` / `bfloat16_t` / `fp8_e4m3fn_t` / `fp8_e5m2_t` / `hifloat8_t` / `fp8_e8m0_t` / `fp4x2_e2m1_t` / `fp4x2_e1m2_t` 等数据类型。
33- 
34-**寄存器数据类型:**
35- 
36-- `asc_create_iter_reg_b8` / `asc_create_iter_reg_b16` / `asc_create_iter_reg_b32`:地址寄存器通过该接口初始化,然后在循环之中使用地址寄存器存储地址偏移量。
37-- `asc_create_mask_b8` / `asc_create_mask_b16` / `asc_create_mask_b32`(宏):根据入参生成相应的掩码寄存器。
38-- `asc_get_mask_spr_b16` / `asc_get_mask_spr_b32`:从特殊寄存器SPR{MASK1, MASK0} 读取mask值并根据数据类型格式返回对应的mask数据,MASK0、MASK1均为64bit的寄存器。
39-- `asc_update_mask_b8` / `asc_update_mask_b16` / `asc_update_mask_b32`:根据value大小生成对应的掩码寄存器中的值。
40- 
41-**reg数据搬入:**
42- 
43-- `asc_loadalign`:对齐数据搬运接口,从UB连续对齐搬入目的操作数,支持多种搬入模式。
44-- `asc_loadalign_brc` / `asc_loadalign_brc_v2` / `asc_loadalign_brc_v3`:广播加载对齐数据。
45-- `asc_loadalign_unpack` / `asc_loadalign_unpack_v2`:解包加载对齐数据。
46-- `asc_loadalign_upsample` / `asc_loadalign_downsample`:上采样/下采样加载对齐数据。
47-- `asc_loadalign_deintlv`:解交织加载对齐数据。
48-- `asc_loadalign_postupdate` 及各变体的 `_postupdate` 版本:地址自更新加载。
49-- `asc_loadunalign`:reg计算数据搬运接口,适用于从UB非32B对齐的起始地址连续搬入矢量数据寄存器的场景。
50-- `asc_loadunalign_pre`:用于在进行非对齐数据搬入前的初始化,需配合 `asc_loadunalign` 接口使用。
51-- `asc_loadunalign_postupdate`:非对齐搬入的地址自更新版本。
52-- `asc_load`:reg计算数据搬运接口,支持从UB非32字节对齐的源地址src搬运至矢量数据寄存器,搬运量为VL。
53-- `asc_gather`:根据索引位置index将源操作数src按元素收集到目的操作数dst中。
54-- `asc_gather_datablock`:给定源操作数在UB中的基地址和索引,根据索引位置将源操作数按DataBlock收集到目的操作数中。
55-- `asc_copy`:完成数据在寄存器内的搬运。
56- 
57-**reg数据搬出:**
58- 
59-- `asc_storealign`:reg计算数据搬运接口,适用于从矢量数据寄存器连续对齐搬出到UB的场景,并支持多种搬出模式。
60-- `asc_storealign_1st`:首次对齐搬出。
61-- `asc_storealign_pack` / `asc_storealign_pack_v2`:打包搬出。
62-- `asc_storealign_intlv`:交织搬出。
63-- `asc_storeunalign`:reg计算数据搬运接口,适用于从矢量数据寄存器连续非32B对齐的起始地址连续搬出到UB的场景。
64-- `asc_storeunalign_post` / `asc_storeunalign_postupdate` / `asc_storeunalign_post_postupdate`:非对齐搬出的地址自更新变体。
65-- `asc_storealign_postupdate` 及各变体的 `_postupdate` 版本:地址自更新搬出。
66-- `asc_scatter`:数据分散存储。
67-- `asc_store`:reg计算数据搬运接口,适用于从矢量数据寄存器搬出到UB的场景,不区分是否对齐,在追求极致性能时,应尽量避免使用该接口。
68- 
69-**基础算术:**
70- 
71-- `asc_add`:按元素执行加法运算。
72-- `asc_addc`:按元素执行带进位的加法运算。
73-- `asc_add_scalar`:按元素执行矢量和标量的加法运算。
74-- `asc_sub`:按元素执行减法运算。
75-- `asc_subc`:按元素执行带借位的减法运算。
76-- `asc_mul`:对源操作数src0和src1进行乘法运算,将结果写入目的操作数dst。
77-- `asc_mul_scalar`:对源操作数src、value进行按元素乘法操作,将结果写入目的操作数dst。
78-- `asc_madd`:madd(multiply-add),对源操作数执行逐元素乘法和加法。
79-- `asc_mull`:根据mask对输入数据src0、src1按元素相乘,将结果写入dst0,溢出部分写入dst1。
80-- `asc_max`:按元素求最大值。
81-- `asc_max_scalar`:按元素求矢量和标量的最大值。
82-- `asc_min`:根据mask对源操作数src0、src1进行按元素求最小值操作,将结果写入目的操作数dst。
83-- `asc_min_scalar`:源操作数矢量内每个元素与标量比较,取较小值。
84-- `asc_abs`:逐元素计算绝对值。
85-- `asc_neg`:根据mask对源操作数src进行取相反数操作,将结果写入目的操作数dst。
86-- `asc_abs_sub`:逐元素计算差的绝对值。
87-- `asc_axpy`:根据mask对源操作数src、value进行按元素做乘加操作,将结果写入目的操作数dst。
88-- `asc_relu`:逐元素执行ReLU运算。
89-- `asc_leakyrelu`:按元素执行Leaky ReLU(Leaky Rectified Linear Unit)操作。
90-- `asc_prelu`:源操作数src0大于0的情况下直接将src0写入目的操作数dst,否则将src0 * src1的结果写入dst。
91-- `asc_exp`:对源操作数逐元素计算指数。
92-- `asc_ln`:对源操作数逐元素计算自然对数。
93-- `asc_sqrt`:逐元素计算平方根。
94-- `asc_div`:按元素执行除法运算。
95- 
96-**逻辑计算:**
97- 
98-- `asc_and`:对掩码寄存器操作:根据mask对源操作数src0、src1的有效bit进行逻辑与运算,得到新的掩码寄存器。
99-- `asc_or`:对源操作数src0和src1进行或(|)运算,将结果写入目的操作数dst。
100-- `asc_xor`:根据mask对输入的src0、src1按元素异或(^)进行操作,将结果写入dst。
101-- `asc_not`:执行矢量非运算。
102-- `asc_shiftleft`:根据掩码mask对输入数据src0,按照src1对应元素进行左移操作,完成后将结果写入dst中。
103-- `asc_shiftleft_scalar`:根据mask对源操作数src执行左移,左移的位数由输入参数value决定,将结果写入目的操作数dst。
104-- `asc_shiftright`:根据掩码mask对输入数据src0,按照src1对应元素进行右移操作,完成后将结果写入dst中。
105-- `asc_shiftright_scalar`:根据mask对源操作数src执行右移,右移的位数由输入参数value决定,将结果写入目的操作数dst。
106- 
107-**比较与选择:**
108- 
109-- `asc_eq`:对源操作数逐元素比较是否相等。
110-- `asc_eq_scalar`:对源操作数逐元素比较是否与标量相等。
111-- `asc_ne`:ne(not equal),对源操作数执行逐元素比较。
112-- `asc_ne_scalar`:src中的每个元素逐个与标量value比较大小,如果src_i != value,则输出结果dst对应比特位为1,否则为0。
113-- `asc_lt`:lt(less than),对源操作数执行逐元素比较。
114-- `asc_lt_scalar`:lt(less than),对源操作数与标量执行逐元素比较。
115-- `asc_le`:le(less than or equal to),对源操作数执行逐元素比较。
116-- `asc_le_scalar`:le(less than or equal to),对源操作数与标量执行逐元素比较。
117-- `asc_gt`:gt(greater than),对源操作数执行逐元素比较。
118-- `asc_gt_scalar`:gt(greater than),对源操作数与标量执行逐元素比较。
119-- `asc_ge`:ge(greater than or equal to),对源操作数执行逐元素比较。
120-- `asc_ge_scalar`:ge(greater than or equal to),对源操作数与标量执行逐元素比较。
121-- `asc_select`:根据mask的比特位值,从源操作数src0、src1中选择元素,得到目的操作数dst。
122-- `asc_squeeze` / `asc_squeeze_v2`:将src中被mask选择的有效元素依次复制到dst,有效元素在dst上连续排列。
123- 
124-**类型转换:**
125- 
126-- `asc_float2half`:将float类型转换为half类型,并支持多种舍入模式。
127-- `asc_half2float`:将half类型数据转换为float类型。
128-- `asc_float2bfloat16`:将float类型转换为bfloat16_t类型,并支持多种舍入模式。
129-- `asc_bfloat162float`:将bfloat16_t类型转换为float类型,无舍入模式。
130-- `asc_float2e4m3`:将float类型转换为fp8_e4m3fn_t类型,支持RINT舍入模式。
131-- `asc_float2e5m2`:将float类型数据转换为fp8_e5m2类型。
132-- `asc_float2hif8`:将float类型转换为hifloat8_t类型,并支持多种舍入模式。
133-- `asc_e4m32float`:将fp8_e4m3fn_t类型转换为float类型。
134-- `asc_e5m22float`:将vector_fp8_e5m2_t类型的源操作数以256B为单位分为四部分,读取其中一部分元素,将其转换成vector_float类型并写入目的操作数。
135-- `asc_hif82half`:将hifloat8_t类型数据转换为half类型。
136-- `asc_half2hif8`:将half类型转换为hifloat8_t类型,并支持多种舍入模式。
137-- `asc_bfloat162e1m2x2`:将bfloat16_t类型转换为fp4x2_e1m2_t类型,并支持多种舍入模式。
138-- `asc_bfloat162e2m1x2`:将bfloat16_t类型转换为fp4x2_e2m1_t类型,并支持多种舍入模式。
139-- `asc_e1m2x22bfloat16`:将fp4x2_e1m2_t类型转换为bfloat16_t类型。
140-- `asc_e2m1x22bfloat16`:将fp4x2_e2m1_t类型转换为bfloat16_t类型。
141-- `asc_bfloat162half`:将bfloat16_t类型转换为half类型,并支持多种舍入模式和饱和/非饱和模式。
142-- `asc_half2bf16`:将half类型数据转换为bfloat16_t类型,并支持多种舍入模式。
143-- `asc_int4x22half`:将int4x2_t类型数据转换为half类型。
144-- `asc_int4x22int16`:将int4x2_t类型转换为int16_t类型。
145-- `asc_int4x22bfloat16`:将int4x2_t类型转换为bfloat16_t类型,无舍入模式。
146-- `asc_half2int4x2`:将half类型数据转换为int4x2_t类型,并支持多种舍入模式。
147-- `asc_half2int8`:将half类型转换为int8_t类型,并支持多种舍入模式。
148-- `asc_half2int16`:将half类型数据转换为int16_t类型,并支持多种舍入模式。
149-- `asc_half2int32`:将half类型数据转换为int32_t类型,并支持多种舍入模式。
150-- `asc_half2uint8`:将half类型转换为uint8_t类型,并支持多种舍入模式。
151-- `asc_float2int16`:将float类型转换为int16_t类型,并支持多种舍入模式。
152-- `asc_float2int32`:将float类型转换为int32_t类型,并支持多种舍入模式。
153-- `asc_float2int64`:将float类型转换为int64_t类型,并支持多种舍入模式。
154-- `asc_int162float`:将int16_t类型转换为float类型。
155-- `asc_int322float`:将int32_t类型转换为float类型,并支持多种舍入模式。
156-- `asc_int642float`:将int64_t类型数据转换为float类型,并支持多种舍入模式。
157-- `asc_int162half`:将int16_t类型转换为half类型。
158-- `asc_int162int32`:将int16_t类型转换为int32_t类型。
159-- `asc_int162uint32`:将int16_t类型转换为uint32_t类型。
160-- `asc_int162uint8`:将int16_t类型转换为uint8_t类型。
161-- `asc_int322int16`:将int32_t类型转换为int16_t类型。
162-- `asc_int322int64`:将int32_t类型转换为int64_t类型。
163-- `asc_int322uint16`:将int32_t类型转换为uint16_t类型。
164-- `asc_int322uint8`:将int32_t类型转换为uint8_t类型。
165-- `asc_int642int32`:将int64_t类型转换为int32_t类型。
166-- `asc_int82half`:将int8_t类型转换为half类型。
167-- `asc_int82int16`:将int8_t类型转换为int16_t类型。
168-- `asc_int82int32`:将int8_t类型转换为int32_t类型。
169-- `asc_uint82half`:将uint8_t类型转换为half类型。
170-- `asc_uint82uint16`:将uint8_t类型转换为uint16_t类型。
171-- `asc_uint82uint32`:将uint8_t类型转换为uint32_t类型。
172-- `asc_uint162uint32`:将uint16_t类型转换为uint32_t类型。
173-- `asc_uint162uint8`:将uint16_t类型转换为uint8_t类型。
174-- `asc_uint322int16`:将uint32_t类型转换为int16_t类型。
175-- `asc_uint322uint16`:将uint32_t类型转换为uint16_t类型。
176-- `asc_uint322uint8`:将uint32_t类型转换为uint8_t类型。
177-- `asc_ceil` / `asc_floor` / `asc_rint` / `asc_round` / `asc_trunc`:将源操作数的浮点数元素截断到整数位,同时源操作数的数据类型保持不变,并支持多种舍入模式。
178- 
179-**归约计算:**
180- 
181-- `asc_reduce_max`:根据mask对源操作数src进行归约最大值操作,将结果写入目的操作数dst。
182-- `asc_reduce_min`:根据mask对源操作数src进行归约最小值操作,将结果写入目的操作数dst。
183-- `asc_reduce_sum`:归约求和功能,用于将src中的所有参与计算的元素求和,得到的结果保存在dst中。
184-- `asc_reduce_max_datablock`:找出DataBlock中的最大值,并将最终的计算结果依次保存在dst中的最低位。
185-- `asc_reduce_min_datablock`:根据mask将每个DataBlock(32B)中的最小值,依次保存在dst中的最低位。
186-- `asc_reduce_sum_datablock`:归约求和功能,用于将src每个DataBlock(32B)中参与计算的元素求和,得到的结果依次保存在dst中。
187-- `asc_pair_reduce_sum`:PairReduceSum,相邻两个(奇偶)元素求和,结果写入dst。
188- 
189-**数据压缩:**
190- 
191-- `asc_pack` / `asc_pack_v2`:将源操作数中的元素选取低8位(b16)、低16位(b32)、低32位(b64)写入目的操作数的低半部分或高半部分。
192-- `asc_unpack`:矢量解包操作。
193-- `asc_unsqueeze`:根据mask进行解压缩,将生成的数据输出到dst。
194- 
195-**数据填充:**
196- 
197-- `asc_duplicate`:根据mask将源操作数src的最低位元素填充到目的操作数dst。
198-- `asc_duplicate_scalar`:根据mask将value填充到目的操作数dst。
199- 
200-**数据重排:**
201- 
202-- `asc_intlv`:将源操作数src0和src1中的元素交织存入目的操作数dst0和dst1中。
203-- `asc_deintlv`:给定源操作数src0和src1,将src0和src1中的元素解交织存入结果操作数dst0和dst1中。
204- 
205-**直方图计算:**
206- 
207-- `asc_cumulative_histogram`:对直方图数据进行累计统计。
208-- `asc_frequency_histogram`:对直方图数据进行频率统计。
209- 
210-**索引操作:**
211- 
212-- `asc_arange` / `asc_arange_descend`:以传入的value为起始值,生成递增/递减的索引,并将生成的索引保存在dst中。
213- 
214-**同步控制:**
215- 
216-- `asc_mem_bar`(宏):Reg计算宏函数内不同流水线之间的同步指令。
217- 
218-**系统变量访问:**
219- 
220-- `asc_clear_ar_spr`:对AR寄存器进行清理,AR寄存器通常由 `asc_squeeze` 接口使用。
221- 
222-### 矩阵数据搬运
223- 
224-- `asc_set_l13d_size`:设置 `asc_copy_l12l0a` / `asc_copy_l12l0b` 的3D格式搬运接口在L1 Buffer的边界值。
225-- `asc_set_l13d_rpt`:用于设置Load3Dv2接口的repeat参数。
226-- `asc_set_l13d_padding`:设置Pad属性描述,用于在调用 `asc_copy_l12l0a` 接口时配置填充数值。
227-- `asc_set_l13d_fmatrix`:3D fmatrix配置。
228-- `asc_set_l0c_copy_prequant`:数据搬运过程中进行随路量化时,通过调用该接口设置量化流程中的标量量化参数。
229-- `asc_set_l0c_copy_params`:DataCopy(L0C Buffer->GM、L0C Buffer->L1 Buffer)过程中进行随路格式转换(NZ格式转换为ND格式)时,通过调用该接口设置格式转换的相关配置。
230-- `asc_copy_l0c2l1` / `asc_copy_l0c2l1_sync`:L0C Buffer到L1 Buffer搬运,扩展量化、ReLU、裁剪等随路操作参数。
231-- `asc_copy_l12l0a_mx` / `asc_copy_l12l0a_mx_sync`:L1 Buffer到L0A Buffer微缩格式搬运。
232-- `asc_set_gm2l1_loop_size` / `asc_set_gm2l1_loop1_stride` / `asc_set_gm2l1_loop2_stride` / `asc_set_gm2l1_pad`:GM到L1 Buffer循环搬运参数配置。
233- 
234-### 矩阵计算
235- 
236-- `asc_mmad_mx` / `asc_mmad_mx_sync`:微缩格式矩阵乘法,支持 `fp4x2_e1m2_t` / `fp4x2_e2m1_t` / `fp8_e4m3fn_t` / `fp8_e5m2_t`
237-- `asc_set_l0c2gm_config`:数据搬运过程中进行随路量化时,通过调用该接口设置量化流程中的矢量量化参数。
238-- `asc_set_l0c2gm_nz2nd`:NZ到ND格式转换配置。
239- 
240-### 标量计算
241- 
242-- `asc_sflbits`:计算一个int64_t类型数字的二进制中,从最高数值位开始与符号位相同的连续比特位的个数。
243-- `asc_ffz`:获取一个uint64_t类型数字的二进制表示中从最低有效位开始的第一个0出现的位置,如果没找到则返回 -1。
244-- `asc_ffs`:FindFirstSet接口,输入数据的二进制表示中从最低位向最高位查找第一个值为1的位,并返回其位置,如果没找到则返回 -1。
245-- `asc_popc`:获取一个uint64_t类型数字的二进制中1的个数。
246-- `asc_store_dev`:标量数据存储到Global Memory,支持 `int8_t` / `uint8_t` / `int16_t` / `uint16_t` / `int32_t` / `uint32_t` / `int64_t` / `uint64_t`等数据类型。
247- 
248-### 同步控制
249- 
250-- `asc_sync`:等待所有流水线操作完成。
251-- `asc_sync_vec`:同步所有流水线。
252-- `asc_sync_mte2`:等待PIPE_MTE2流水完成。
253-- `asc_sync_mte3`:等待PIPE_MTE3流水完成。
254-- `asc_sync_notify`:设置同步标志(宏定义)。
255-- `asc_sync_wait`:等待同步标志(宏定义)。
256-- `asc_sync_pipe`:等待指定流水线操作完成(宏定义)。
257-- `asc_sync_data_barrier`:用于阻塞后续的指令执行,直到所有之前的内存访问指令(需要等待的内存位置可以通过参数控制)执行结束。
258- 
259-### 系统变量
260- 
261-- `asc_get_ctrl`:读取CTRL寄存器(控制寄存器)的值。
262-- `asc_set_ctrl`:设置CTRL寄存器(控制寄存器)的值。
263-- `asc_get_block_num`:获取AI核数。
264-- `asc_get_system_cycle`:获取当前系统cycle数。
265- 
266-### 缓存控制
267- 
268-- `asc_icache_preload`:从指令所在DDR地址预加载数据到对应的cacheline中。
269-- `asc_get_icache_preload_status`:获取ICache的Preload的状态。
270-- `asc_datacache_preload`:从源地址所在的特定GM地址预加载数据到Data Cache中。
271-- `asc_dcci_single` / `asc_dcci_entire_out` / `asc_dcci_entire_all` / `asc_dcci_entire_atomic`:用于刷新Cache,保证Cache的一致性。
272-- `asc_ub_dcci_single`:Unified Buffer数据缓存失效。
273- 
274-### 原子操作
275- 
276-- `asc_set_atomic_add_float`:设置对后续的从Unified Buffer/L0C Buffer/L1 Buffer到Global Memory的数据传输开启原子累加。累加的数据类型为float。
277-- `asc_set_atomic_max_float16`:设置计算结果以原子比较的方式传输到GM。在拷贝前,将待传输的half数据与GM中已有数据进行逐元素比较,并将最大值写入GM。
278-- `asc_set_store_atomic_config_v2`:设置原子操作使能位与原子操作类型的值。
279- 
280-### 其他操作
281- 
282-- `asc_init`:初始化NPU状态。
@@ -1,179 +0,0 @@
1-# C API
2- 
3-C API 3510系列新增标量原子操作、Cube数据搬运全链路、同步控制、系统变量等领域接口,同时对已有接口进行了数据类型扩展、参数增强和Bug修复。
4- 
5-## 特性
6- 
7-### 矢量数据搬运
8- 
9-**新增接口:**
10- 
11-- `asc_copy_gm2ub`/`asc_copy_gm2ub_sync`:将数据从Global Memory搬运到Unified Buffer。
12-- `asc_copy_ub2gm`/`asc_copy_ub2gm_sync`:将数据从Unified Buffer搬运到Global Memory。
13-- `asc_copy_ub2ub`/`asc_copy_ub2ub_sync`:将数据从Unified Buffer搬运到Unified Buffer。
14-- `asc_copy_ub2l1`/`asc_copy_ub2l1_sync`:将数据从Unified Buffer搬运到L1 Buffer。
15-- `asc_ndim_copy_dci`:带DCI的N维搬运。
16-- `asc_set_copy_pad_val`:通用填充配置,支持`int8_t`/`uint8_t`/`int16_t`/`uint16_t`/`half`/`bfloat16_t`/`int32_t`/`uint32_t`/`float`共9种数据类型。
17- 
18-**数据类型扩展:**
19- 
20-- `asc_copy_gm2ub_align`/`asc_copy_ub2gm_align`:数据类型从9种扩展到12种,新增`fp8_e5m2_t`/`fp8_e4m3fn_t`/`hifloat8_t`
21-- `asc_ndim_copy_gm2ub`:新增`fp4x2_e2m1_t`/`fp4x2_e1m2_t`/`fp8_e8m0_t`类型支持。
22- 
23-### Reg矢量计算
24- 
25-**接口重载:**
26- 
27-- `asc_gather`:根据索引位置index将源操作数src按元素收集到目的操作数dst中,新增`vector_uint32_t index`重载。
28-- `asc_scatter`:根据mask对输入的src0、src1按元素进行分散存储,新增9个重载。
29-- `asc_loadalign`及各种特性场景(`_brc`/`_unpack`/`_upsample`/`_downsample`/`_deintlv`):新增`int4x2_t`类型支持,新增`_postupdate`地址自更新版本。
30-- `asc_storealign`及各种特性场景(`_1st`/`_pack`/`_intlv`):新增`iter_reg offset`参数重载,新增`_postupdate`地址自更新版本。
31-- `asc_storeunalign`/`asc_storeunalign_post`/`asc_storeunalign_postupdate`/`asc_storeunalign_post_postupdate`:新增16种数据类型的非对齐搬出重载。
32-- `asc_add_scalar`:按元素执行矢量和标量的加法运算,新增9种数据类型重载。
33-- `asc_exp`:对源操作数逐元素计算指数,新增`half`/`float`重载。
34-- `asc_min_scalar`:源操作数矢量内每个元素与标量比较,取较小值,新增`uint16_t`/`int8_t`/`uint8_t`/`float`/`half`重载。
35-- `asc_reduce_max_datablock`:找出DataBlock中的最大值,新增6种数据类型重载(无尾部下划线版本)。
36-- `asc_pack`:将源操作数中的元素选取低8位写入目的操作数,新增`uint16_t`->`uint8_t`重载。
37-- `asc_copy`:完成数据在寄存器内的搬运,新增`vector_bool`<-`vector_uint16_t`/`vector_uint32_t`重载。
38-- `asc_set_va_reg`:用于设置transpose的地址,将操作数地址序列与地址寄存器关联,新增8种数据类型重载。
39-- `asc_duplicate_scalar`:根据mask将value填充到目的操作数dst,新增不带mask的重载版本(12种数据类型)。
40- 
41-**数据类型扩展:**
42- 
43-- `asc_gather_datablock`:新增`int4x2_t`/`int64_t`/`uint64_t`类型支持。
44-- `asc_store`:新增`int4b_t`类型支持。
45-- `asc_loadalign`/`asc_storealign`:新增`int4x2_t`类型支持。
46- 
47-### 矩阵数据搬运
48- 
49-**新增接口:**
50- 
51-- `asc_copy_gm2l1`/`asc_copy_gm2l1_sync`:将数据从Global Memory搬运到L1 Buffer,支持`bfloat16_t`/`half`/`float`/`int32_t`/`int8_t`/`uint32_t`/`uint8_t`类型。
52-- `asc_copy_gm2l1_align`/`asc_copy_gm2l1_align_sync`:对齐GM到L1 Buffer搬运。
53-- `asc_copy_gm2l1_nd2nz`/`asc_copy_gm2l1_nd2nz_sync`:GM到L1 Buffer ND2NZ格式转换搬运。
54-- `asc_copy_gm2l1_dn2nz`/`asc_copy_gm2l1_dn2nz_sync`:GM到L1 Buffer DN2NZ格式转换搬运。
55-- `asc_copy_l12l0a`/`asc_copy_l12l0a_sync`:用于搬运存放在L1 Buffer里的512B大小的矩阵到L0A Buffer里,支持`bfloat16_t`/`fp8_e4m3fn_t`/`fp8_e5m2_t`/`half`/`float`/`hifloat8_t`/`int16_t`/`int32_t`/`int8_t`/`uint16_t`/`uint32_t`/`uint8_t`/`int4b_t`/`fp4x2_e2m1_t`/`fp4x2_e1m2_t`共14种数据类型,集成img2col功能。
56-- `asc_copy_l12l0b`/`asc_copy_l12l0b_sync`:用于搬运存放在L1 Buffer里的512B大小的矩阵到L0B Buffer里,同上14种数据类型。
57-- `asc_copy_l12l0a_trans`/`asc_copy_l12l0b_trans`/`asc_copy_l12l0a_trans_sync`/`asc_copy_l12l0b_trans_sync`:带转置的L1 Buffer到L0A Buffer/L0B Buffer搬运。
58-- `asc_copy_l12l0b_mx`/`asc_copy_l12l0b_mx_sync`:L1 Buffer到L0B Buffer搬运。
59-- `asc_copy_l0c2gm`/`asc_copy_l0c2gm_sync`:将L0C Buffer中的数据搬运到GM中,支持量化、ReLU、裁剪、广播、NZ2ND等随路操作。
60-- `asc_copy_l0c2ub`/`asc_copy_l0c2ub_sync`:将L0C Buffer中的数据搬运到UB中,支持量化、ReLU、裁剪、广播等随路操作。
61-- `asc_copy_gm2l0a`/`asc_copy_gm2l0b`/`asc_copy_gm2l0a_sync`/`asc_copy_gm2l0b_sync`:将数据从GM搬运到L0A Buffer/L0B Buffer。
62-- `asc_copy_l12fb`/`asc_copy_l12fb_sync`:将数据从L1 Buffer搬运到Fixpipe Buffer中。
63-- `asc_copy_l12bt`/`asc_copy_l12bt_sync`:将数据从L1 Buffer搬运到BiasTable Buffer中。
64-- `asc_copy_l12ub`/`asc_copy_l12ub_sync`:将数据从L1 Buffer搬运到UB中。
65-- `asc_fill_l0a`/`asc_fill_l0b`/`asc_fill_l1`/`asc_fill_l0a_sync`/`asc_fill_l0b_sync`/`asc_fill_l1_sync`:将L0A Buffer/L0B Buffer/L1 Buffer的Local Memory初始化为某一具体数值。
66-- `asc_load_image_to_cbuf`/`asc_load_image_to_cbuf_sync`:将图像数据从Global Memory搬运到L1 Buffer。
67-- `asc_copy_l12l0b_sparse`/`asc_copy_l12l0b_sparse_sync`:用于搬运存放在L1 Buffer里的512B大小的稠密权重矩阵到L0B Buffer里,同时读取128B大小的索引矩阵用于稠密矩阵的稀疏化。
68-- `asc_set_l13d_fmatrix_b`:3D fmatrix B参数配置。
69-- `asc_set_l0c2gm_lrelu_alpha`:L0C Buffer到GM LeakyReLU alpha参数配置。
70- 
71-### 矩阵计算
72- 
73-**新增接口:**
74- 
75-- `asc_mmad`/`asc_mmad_sync`:新增标准矩阵乘法,支持`bfloat16_t`/`fp8_e4m3fn_t`/`fp8_e5m2_t`/`half`/`float`/`int8_t`/`hifloat8_t`输入类型组合,共16个重载。使用`disable_gemv`参数替代9.0.0中`asc_mmad_mx``k_direction_align`参数。
76-- `asc_enable_fp8`:启用FP8计算模式。
77-- `asc_enable_hif8`:启用HiFloat8计算模式。
78- 
79-**数据类型扩展:**
80- 
81-- `asc_mmad_mx`:新增`fp8_e4m3fn_t``fp8_e5m2_t``fp8_e5m2_t``fp8_e4m3fn_t`等混合精度组合。
82- 
83-### 标量计算
84- 
85-**新增接口:**
86- 
87-新增完整的标量原子操作接口集,支持对Global Memory数据执行原子读写操作,覆盖`int32_t`/`uint32_t`/`float`/`int64_t`/`uint64_t`数据类型。
88- 
89-- `asc_atomic_add`:原子加,返回计算前的原始数据(5个重载)。
90-- `asc_atomic_sub`:原子减,返回计算前的原始数据(5个重载)。
91-- `asc_atomic_max`:原子最大值,返回计算前的原始数据(5个重载)。
92-- `asc_atomic_min`:原子最小值,返回计算前的原始数据(5个重载)。
93-- `asc_atomic_exch`:原子交换,返回计算前的原始数据(5个重载)。
94-- `asc_atomic_cas`:原子比较并交换,返回计算前的原始数据(5个重载)。
95-- `asc_atomic_and`:原子按位与(4个重载,不支持float)。
96-- `asc_atomic_or`:原子按位或(4个重载,不支持float)。
97-- `asc_atomic_xor`:原子按位异或(4个重载,不支持float)。
98-- `asc_atomic_inc`:原子自增(2个重载,仅`uint32_t`/`uint64_t`)。
99-- `asc_atomic_dec`:原子自减(2个重载,仅`uint32_t`/`uint64_t`)。
100- 
101-### 同步控制
102- 
103-**新增接口:**
104- 
105-- `asc_lock`/`asc_unlock`:异步流水线之间的同步(宏定义),支持阻塞和非阻塞模式(`ASC_LOCK_BLOCK`/`ASC_LOCK_NON_BLOCK`)。
106-- `asc_sync_intra_arrive`/`asc_sync_intra_wait`:核内到达/等待同步(宏定义)。
107-- `asc_sync_subblock_arrive`/`asc_sync_subblock_wait`:子Block级到达/等待同步(宏定义)。
108-- `asc_sync_inter_arrive`/`asc_sync_inter_wait`:核间到达/等待同步(宏定义)。
109- 
110-**接口签名变更:**
111- 
112-- `asc_sync_block_arrive`:9.0.0为函数声明`asc_sync_block_arrive(pipe_t pipe, uint8_t mode, int64_t flagID)`(3个参数),9.1.0改为宏定义`asc_sync_block_arrive(pipe, flag_id)`(2个参数,移除`mode`参数)。
113-- `asc_sync_block_wait`:9.0.0为函数声明`asc_sync_block_wait(int64_t flagID)`(1个参数),9.1.0改为宏定义`asc_sync_block_wait(pipe, flag_id)`(2个参数,新增`pipe`参数)。
114-- `asc_sync_data_barrier`:9.0.0为函数声明`asc_sync_data_barrier(mem_dsb_t arg)`,9.1.0改为宏定义`asc_sync_data_barrier(arg)`
115- 
116-### 系统变量
117- 
118-**新增接口:**
119- 
120-- `asc_get_smmu_tag_version`:获取SMMU标签版本。
121-- `asc_get_phy_stack_base`:获取物理栈基地址。
122-- `asc_get_status`:获取系统状态。
123-- `asc_get_sys_virtual_base`:获取系统虚拟基地址。
124-- `asc_get_vf_len`:获取矢量长度(`constexpr`,编译期求值)。
125-- `asc_set_l0c2gm_channel_para`:L0C Buffer到GM通道参数配置。
126-- `asc_set_l3d_rpt_b`:L1 3D重复B配置。
127-- `asc_set_gm2l1_nz_para`:GM到L1 Buffer NZ参数配置。
128-- `asc_set_l13d_padding`:L1 3D填充配置(4个重载:`uint64_t`/`half`/`int16_t`/`uint16_t`)。
129-- `asc_set_l12l0_padding_val`:L1 Buffer到L0填充值配置。
130-- `asc_set_l0c2gm_quant_post`:L0C Buffer到GM后量化配置。
131-- `asc_set_l0c2gm_relu_alpha`:L0C Buffer到GM ReLU alpha配置。
132- 
133-### 缓存控制
134- 
135-**新增接口:**
136- 
137-- `asc_dci`:数据缓存失效(Data Cache Invalidate)指令。
138- 
139-## Bug修复
140- 
141-### 函数命名错误修复
142- 
143-- `asc_half2int4x2`:9.0.0中`ru`/`rz`/`rn`/`rna`四种舍入模式的函数声明均错误命名为`asc_half2int4x2_rd`,9.1.0已修正为各自的正确名称(`_ru`/`_rz`/`_rn`/`_rna`)。
144-- `asc_int162half`:9.0.0中存在`asc_int162half_rc`(舍入模式`rc`不存在),9.1.0修正为`asc_int162half_rz`
145-- `asc_reduce_min_datablock_`:9.0.0中函数名带尾部下划线`asc_reduce_min_datablock_`,9.1.0修正为`asc_reduce_min_datablock`(去除尾部下划线,与`asc_reduce_max_datablock`命名风格统一)。
146- 
147-### 类型名称修复
148- 
149-- `asc_bfloat162e1m2x2`:9.0.0中目的操作数类型为`vector_f4e1m2x2`,9.1.0修正为`vector_fp4x2_e1m2_t`
150-- `asc_half2uint8`:9.0.0中使用`vector_u8`/`vector_f16`类型别名,9.1.0修正为标准类型名`vector_uint8_t`/`vector_half`
151-- `asc_min_scalar`(half重载):9.0.0中源操作数类型错误写为`vector_f16`,9.1.0修正为`vector_half`
152- 
153-### 参数命名统一
154- 
155-- `asc_get_arch_ver`:9.0.0中参数名为`coreVersion`(驼峰命名),9.1.0修正为`core_version`(蛇形命名)。
156-- `asc_arange`/`asc_arange_descend`:9.0.0中参数名为`index`,9.1.0修正为`value`
157-- `asc_update_mask_b8`/`asc_update_mask_b16`/`asc_update_mask_b32`:9.0.0中参数名为`scalar`,9.1.0修正为`value`
158- 
159-## 增强
160- 
161-**参数增强:**
162- 
163-- `asc_copy_gm2ub_align`/`asc_copy_ub2gm_align`:新增`enable_constant_pad`/`l2_cache_mode`参数,支持常量填充模式和L2缓存控制。
164-- `asc_copy_gm2ub_align`/`asc_copy_ub2gm_align`:新增size-only简化重载(12种数据类型),仅需`dst`/`src`/`size`三个参数。
165-- `asc_create_iter_reg_b8`/`asc_create_iter_reg_b16`/`asc_create_iter_reg_b32`:地址寄存器初始化,从单维偏移扩展到支持1~4维偏移参数。
166-- `asc_create_iter_reg_b8`/`asc_create_iter_reg_b16`/`asc_create_iter_reg_b32`:地址寄存器初始化,从单维偏移扩展到支持1~4维偏移参数。
167- 
168-## 接口废弃
169- 
170-本版本标记以下接口为**deprecated**,建议使用替代接口:
171- 
172-| 废弃接口 | 替代接口 | 说明 |
173-| :--- | :--- | :--- |
174-| `asc_get_store_atomic_config` | `asc_atomic_add`等 | 原子操作查询接口废弃,改用标量原子操作接口 |
175-| `asc_set_store_atomic_config_v2` | `asc_atomic_add`等 | 原子操作配置接口废弃,改用标量原子操作接口 |
176-| `asc_exp_sub_v2` | `asc_exp_sub` | 指数减法V2版本废弃 |
177-| `asc_set_gm2ub_pad` | `asc_set_copy_pad_val` | GM到UB填充配置废弃,改用通用填充值配置接口 |
178- 
179-**注:** 详情可参考[废弃接口](../deprecated_interface.md)。
@@ -1,5 +1,5 @@
1# Release Notes1# Release Notes
2 2 
3-- **[CANN 9.0.0](Cann_9_0_0.md)**3+- **[CANN 9.1.0](CANN_9_1_0.md)**
4 4 
5-- **[CANN 9.1.0](Cann_9_1_0.md)**5+- **[CANN 9.0.0](CANN_9_0_0.md)**