Closed
[Requirement|需求建议]: SIMT API 软仿实现上移至仓内及软软仿提示 #1942
ruoshuisixueAdd on 28 days agoClosed at 16 hours ago
28 days ago Added label: requirement
10 days ago Change title to "[Requirement|需求建议]: SIMT API 软仿实现上移至仓内及软软仿提示", originally titled "[Requirement|需求建议]: SIMT API 软仿实现上移至仓内".
10 days ago Change title to "[Requirement|需求建议]: SIMT API 软仿实现上移至仓内及软软仿提示", originally titled "[Requirement|需求建议]: SIMT API 软仿实现上移至仓内".
16 hours ago changed custom state from 待办的 to 已解决
16 hours ago Close issue
14 hours ago Added label: resolved
Background(背景信息)
SIMT API(
simt_api/asc_fp16.h、asc_bf16.h、device_functions.h)中部分接口(fp16/bf16 的比较、算术、NaN 类接口,以及__clz/__popc/__ffs/__mul24等整数/位操作接口)此前依赖毕昇编译器内置的软仿(soft implementation)实现。当用户关闭编译器软仿(定义
__BISHENG_DISABLE_SOFT_IMPL__)时,这些接口没有可用实现,导致编译失败;同时软仿语义由编译器维护,与仓内头文件演进不同步,不便于统一维护和问题修复。需要将上述软仿实现从编译器上移至 asc-devkit 仓内
impl/simt_api/目录,使其与公开头文件在同一仓内维护。Origin(信息来源)
NA
Benefit / Necessity (价值/作用)
__BISHENG_DISABLE_SOFT_IMPL__)的场景下,SIMT 头文件对外暴露的全部接口仍有仓内实现可用,编译不再失败;simt_stub.h),CPU debug 模式下同样可用。Design(设计方案)
公开头文件(
include/simt_api/asc_fp16.h、asc_bf16.h、device_functions.h)中以__BISHENG_DISABLE_SOFT_IMPL__宏区分两条路径:#ifndef __BISHENG_DISABLE_SOFT_IMPL__ // 原路径:static 声明,实现由编译器内置提供 static __SIMT_DEVICE_FUNCTIONS_DECL__ bool __heq(half x, half y); #else // 新路径:inline 声明,实现在仓内 impl 头中 __SIMT_DEVICE_FUNCTIONS_DECL__ inline bool __heq(half x, half y); #endif // 文件末尾统一引入实现: #include "impl/simt_api/asc_fp16_impl.h"新增实现文件:
impl/simt_api/asc_fp16_impl.h:fp16 软仿实现(比较类__heq/__hne/__hle/...及u后缀、x2向量化版本,算术类__hadd/__hsub/__hmul/__hdiv/__hfma_relu/__hcmadd等,NaN 相关__hmax_nan/__hisnan/__isnanx2等),约 60 个接口;impl/simt_api/asc_bf16_impl.h:bf16 同类软仿实现,约 58 个接口;impl/simt_api/device_functions_impl.h:整数/位操作软仿实现(__clz/__popc/__ffs/__saturatef/__mul24/__rhadd/__sad/__usad/__mul64hi/__umul64hi/__brev/__byte_perm及asc_nop/asc_dcci_single等),19 个实现。