CANN/asc-devkit地址寄存器创建

CANN/asc-devkit地址寄存器创建

asc_create_addr_reg

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

产品支持情况

产品是否支持
Ascend 950PR/Ascend 950DT

功能说明

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

地址寄存器通过该接口初始化,然后在循环之中使用地址寄存器存储地址偏移量,该重载接口同步支持1-4个offset参数,并支持初始化b8/b16/b32位宽的寄存器,适配1-4维Tensor。底层在多维循环中自动计算地址偏移,消除标量地址运算开销。

函数原型

__simd_callee__ inline addr_reg asc_create_addr_reg_b32(uint32_t offset) __simd_callee__ inline addr_reg asc_create_addr_reg_b16(uint32_t offset) __simd_callee__ inline addr_reg asc_create_addr_reg_b8(uint32_t offset) __simd_callee__ inline addr_reg asc_create_addr_reg_b32(uint32_t offset0, uint32_t offset1) __simd_callee__ inline addr_reg asc_create_addr_reg_b16(uint32_t offset0, uint32_t offset1) __simd_callee__ inline addr_reg asc_create_addr_reg_b8(uint32_t offset0, uint32_t offset1) __simd_callee__ inline addr_reg asc_create_addr_reg_b32(uint32_t offset0, uint32_t offset1, uint32_t offset2) __simd_callee__ inline addr_reg asc_create_addr_reg_b16(uint32_t offset0, uint32_t offset1, uint32_t offset2) __simd_callee__ inline addr_reg asc_create_addr_reg_b8(uint32_t offset0, uint32_t offset1, uint32_t offset2) __simd_callee__ inline addr_reg asc_create_addr_reg_b32(uint32_t offset0, uint32_t offset1, uint32_t offset2, uint32_t offset3) __simd_callee__ inline addr_reg asc_create_addr_reg_b16(uint32_t offset0, uint32_t offset1, uint32_t offset2, uint32_t offset3) __simd_callee__ inline addr_reg asc_create_addr_reg_b8(uint32_t offset0, uint32_t offset1, uint32_t offset2, uint32_t offset3)

参数说明

参数名输入/输出描述
offset输入地址偏移量。
offset0输入地址偏移量。
offset1输入地址偏移量。
offset2输入地址偏移量。
offset3输入地址偏移量。

返回值说明

地址寄存器。

流水类型

PIPE_V

约束说明

  • 请勿在循环内使用 if/else。
  • addr_reg必须在最内层循环体内赋值使用。
  • 不同步长的操作数,建议使用多个addr_reg,避免地址被覆盖。

调用示例

见地址寄存器调用示例。

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

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