CANN/asc-devkit:SIMD解交织加载后更新API

📅 2026/7/16 19:22:58 👁️ 阅读次数 📝 编程学习
CANN/asc-devkit:SIMD解交织加载后更新API

asc_loadalign_deintlv_postupdate

【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言,原生支持C和C++标准规范,主要由类库和语言扩展层构成,提供多层级API,满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit

产品支持情况

  • Ascend 950PR/Ascend 950DT:支持
  • Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持
  • Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持
  • Atlas 200I/500 A2 推理产品:不支持
  • Atlas 推理系列产品AI Core:不支持
  • Atlas 推理系列产品Vector Core:不支持
  • Atlas 训练系列产品:不支持

功能说明

头文件路径:"c_api/reg_compute/reg_load.h"

asc_loadalign_deintlv_postupdate用于从UB中读取以32B对齐地址src为起始位置的连续2 x VL长度数据。数据按元素类型宽度进行解释,在Load过程中完成解交织后,分别写入两个目的向量寄存器dst0dst1

asc_loadalign_deintlv不同,该接口在完成数据加载后,会对源地址参数src执行后更新操作:

src = src + offset

其中,offset的单位为元素个数,实际地址偏移字节数为:offset * sizeof(data_type)

float数据类型、Ascend 950PR/Ascend 950DT产品为例,若VL = 256Bsrc = 32offset = 128,调用asc_loadalign_deintlv_postupdate后,数据从UB到Reg的排布如下图所示,同时src会更新为544,可直接用于后续计算。

提示:

  1. 使用本接口需要包含头文件reg_load.h
  2. 本接口会修改输入的UB地址参数src。若需要保留原始地址,请使用asc_loadalign_deintlv

函数原型

支持的数据类型请参见数据类型章节。

__simd_callee__ inline void asc_loadalign_deintlv_postupdate(vector_int4x2_t& dst0, vector_int4x2_t& dst1, __ubuf__ int4b_t*& src, int32_t offset) __simd_callee__ inline void asc_loadalign_deintlv_postupdate(vector_fp4x2_e2m1_t& dst0, vector_fp4x2_e2m1_t& dst1, __ubuf__ fp4x2_e2m1_t*& src, int32_t offset) __simd_callee__ inline void asc_loadalign_deintlv_postupdate(vector_fp4x2_e1m2_t& dst0, vector_fp4x2_e1m2_t& dst1, __ubuf__ fp4x2_e1m2_t*& src, int32_t offset) __simd_callee__ inline void asc_loadalign_deintlv_postupdate(vector_int8_t& dst0, vector_int8_t& dst1, __ubuf__ int8_t*& src, int32_t offset) __simd_callee__ inline void asc_loadalign_deintlv_postupdate(vector_uint8_t& dst0, vector_uint8_t& dst1, __ubuf__ uint8_t*& src, int32_t offset) __simd_callee__ inline void asc_loadalign_deintlv_postupdate(vector_fp8_e8m0_t& dst0, vector_fp8_e8m0_t& dst1, __ubuf__ fp8_e8m0_t*& src, int32_t offset) __simd_callee__ inline void asc_loadalign_deintlv_postupdate(vector_fp8_e5m2_t& dst0, vector_fp8_e5m2_t& dst1, __ubuf__ fp8_e5m2_t*& src, int32_t offset) __simd_callee__ inline void asc_loadalign_deintlv_postupdate(vector_fp8_e4m3fn_t& dst0, vector_fp8_e4m3fn_t& dst1, __ubuf__ fp8_e4m3fn_t*& src, int32_t offset) __simd_callee__ inline void asc_loadalign_deintlv_postupdate(vector_hifloat8_t& dst0, vector_hifloat8_t& dst1, __ubuf__ hifloat8_t*& src, int32_t offset) __simd_callee__ inline void asc_loadalign_deintlv_postupdate(vector_int16_t& dst0, vector_int16_t& dst1, __ubuf__ int16_t*& src, int32_t offset) __simd_callee__ inline void asc_loadalign_deintlv_postupdate(vector_uint16_t& dst0, vector_uint16_t& dst1, __ubuf__ uint16_t*& src, int32_t offset) __simd_callee__ inline void asc_loadalign_deintlv_postupdate(vector_half& dst0, vector_half& dst1, __ubuf__ half*& src, int32_t offset) __simd_callee__ inline void asc_loadalign_deintlv_postupdate(vector_bfloat16_t& dst0, vector_bfloat16_t& dst1, __ubuf__ bfloat16_t*& src, int32_t offset) __simd_callee__ inline void asc_loadalign_deintlv_postupdate(vector_int32_t& dst0, vector_int32_t& dst1, __ubuf__ int32_t*& src, int32_t offset) __simd_callee__ inline void asc_loadalign_deintlv_postupdate(vector_uint32_t& dst0, vector_uint32_t& dst1, __ubuf__ uint32_t*& src, int32_t offset) __simd_callee__ inline void asc_loadalign_deintlv_postupdate(vector_float& dst0, vector_float& dst1, __ubuf__ float*& src, int32_t offset)

参数说明

参数名输入/输出说明
dst0输出第一个目的向量寄存器。
dst1输出第二个目的向量寄存器。
src输入/输出源数据在UB中的起始地址,要求32B对齐。接口执行完成后,src会更新为src + offset
offset输入地址偏移量,单位为元素个数。

向量寄存器类型的详细说明请参见data_type_definition.md。

数据类型

asc_loadalign_deintlv_postupdate支持的数据类型如下表所示。

源数据类型src目的寄存器类型dst0/dst1
int4b_tvector_int4x2_t
fp4x2_e1m2_tvector_fp4x2_e1m2_t
fp4x2_e2m1_tvector_fp4x2_e2m1_t
int8_tvector_int8_t
uint8_tvector_uint8_t
fp8_e4m3fn_tvector_fp8_e4m3fn_t
fp8_e5m2_tvector_fp8_e5m2_t
fp8_e8m0_tvector_fp8_e8m0_t
hifloat8_tvector_hifloat8_t
int16_tvector_int16_t
uint16_tvector_uint16_t
halfvector_half
bfloat16_tvector_bfloat16_t
int32_tvector_int32_t
uint32_tvector_uint32_t
floatvector_float

返回值说明

无。

流水类型

PIPE_V

约束说明

  • src必须为32B对齐地址,且访问范围不能超过UB有效地址上界减去2 x VL,否则可能导致UB越界访问。
  • 在循环中使用本接口时,offset的取值需要保证更新后的src仍满足32B对齐要求。
  • offset以元素为单位,实际地址步长需要结合源数据类型宽度进行换算。

调用示例

从UB中连续读取以32B对齐地址src为起始位置的float数据,并在每次调用后自动更新地址。

for (uint16_t i = 0; i < repeat_times; i++) { asc_loadalign_deintlv_postupdate(reg0, reg1, src, one_repeat_size); ... }

【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言,原生支持C和C++标准规范,主要由类库和语言扩展层构成,提供多层级API,满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考