Skip to content

Store

产品支持情况​

  • Ascend 950PR&950DT系列产品:支持
  • Atlas A3系列产品:不支持
  • Atlas A2系列产品:不支持
  • Atlas 200I/500 A2推理产品:不支持
  • Atlas推理系列产品AI Core:不支持
  • Atlas推理系列产品Vector Core:不支持
  • Atlas训练系列产品:不支持
  • KirinX90处理器系列产品:支持
  • Kirin9020处理器系列产品:支持
  • Kirin9030处理器系列产品:支持
  • Kirin9050处理器系列产品:支持

功能说明​

头文件路径为:"basic_api/reg_compute/kernel_reg_compute_datacopy_intf.h"。

Reg矢量计算数据搬运接口,支持从RegTensor搬出至非32字节对齐的Unified Buffer(UB)地址dstAddr。连续搬运时,用户需手动更新dstAddr地址。

该接口封装了StoreUnalign和StoreUnalignPost。

函数原型​

  • 搬运srcReg中保存的全部数据

    C++
    template <typename T = DefaultType, typename U>
    __simd_callee__ inline void Store(__ubuf__ T* dstAddr, U& srcReg)
    
  • 搬运count个数据

    C++
    template <typename T = DefaultType, typename U>
    __simd_callee__ inline void Store(__ubuf__ T* dstAddr, U& srcReg, uint32_t count)
    

参数说明​

表1 模板参数说明

参数名描述
T操作数数据类型。支持的数据类型请参考数据类型。
U源操作数的RegTensor类型,例如RegTensor<half>,由编译器自动推导,用户不需要填写。

表2 参数说明

参数名输入/输出描述
dstAddr输出目的操作数,UB起始地址,不需要32字节对齐。
srcReg输入源操作数,类型为RegTensor。
count输入搬运数据量,仅带count的重载需要配置。连续搬运时需手动更新地址:dstAddr = dstAddr + count。

数据类型​

目的操作数与源操作数的数据类型需要保持一致。

  • 当RegTensor模板参数regTrait为RegTraitNumOne时支持的数据类型为:b8、b16、b32、b64。
  • 当RegTensor模板参数regTrait为RegTraitNumTwo时支持的数据类型为:complex32、b64。
  • Kirin9020处理器系列产品:仅支持RegTraitNumOne,不支持RegTraitNumTwo,支持的数据类型为:b8、b16、b32。
  • Kirin9050处理器系列产品:仅支持RegTraitNumOne,不支持RegTraitNumTwo,支持的数据类型为:b8、b16、b32。

返回值说明​

无

约束说明​

  • 不带count的重载搬运srcReg中保存的全部数据:RegTraitNumOne搬运256B,RegTraitNumTwo搬运512B。dstAddr起始位置需要保证至少有对应大小的可写空间。
  • 对于带count的重载,count不能大于srcReg能存储的数据个数,且dstAddr起始位置需要保证至少有count * sizeof(T)的可写空间:
    • 当RegTensor模板参数regTrait为RegTraitNumOne时,count <= 256B / sizeof(T)。
    • 当RegTensor模板参数regTrait为RegTraitNumTwo时,count <= 512B / sizeof(T)。
  • 接口内部定义了一个UnalignRegForStore,该寄存器数量上限为4,超出后编译器将报错。

调用示例​

  • 搬出srcReg中保存的全部数据

    C++
    template<typename T>
    __simd_vf__ inline void LoadStoreVF(__ubuf__ T* dstAddr, __ubuf__ T* srcAddr, uint16_t count, uint16_t repeatTimes)
    {
        AscendC::Reg::RegTensor<T> srcReg;
        for (uint16_t i = 0; i < repeatTimes; i++) {
            AscendC::Reg::Load(srcReg, srcAddr + i * count);
            AscendC::Reg::Store(dstAddr + i * count, srcReg);
        }
    }
    
  • 搬出count个数据

    C++
    template<typename T>
    __simd_vf__ inline void LoadStoreVF(__ubuf__ T* dstAddr, __ubuf__ T* srcAddr, uint16_t count, uint16_t repeatTimes)
    {
        AscendC::Reg::RegTensor<T> srcReg;
        for (uint16_t i = 0; i < repeatTimes; i++) {
            AscendC::Reg::Load(srcReg, srcAddr + i * count);
            AscendC::Reg::Store(dstAddr + i * count, srcReg, count);
        }
    }
    

免责声明:本站内容由 asc-devkit 仓 master 分支自动编译生成,属于持续开发版本,可能存在缺陷,仅供预览与参考。如需稳定及商用资料,请查阅官方 昇腾社区。