已合并
【C API】feat: 新增asc_ld_dev并支持duplicate highest模式 #5039
guojianyang创建于 16 天前
【C API】feat: 新增asc_ld_dev并支持duplicate highest模式 #5039
已合并
共 18 个文件变更+942-97
| @@ -1156,6 +1156,8 @@ | |||
| 1156 | - [asc_pack(废弃)](SIMD-API/c_api/reg/data_compress/asc_pack_deprecated.md) | 1156 | - [asc_pack(废弃)](SIMD-API/c_api/reg/data_compress/asc_pack_deprecated.md) |
| 1157 | - [数据填充](SIMD-API/c_api/reg/data_fill/data_fill.md) | 1157 | - [数据填充](SIMD-API/c_api/reg/data_fill/data_fill.md) |
| 1158 | - [asc_duplicate](SIMD-API/c_api/reg/data_fill/asc_duplicate.md) | 1158 | - [asc_duplicate](SIMD-API/c_api/reg/data_fill/asc_duplicate.md) |
| 1159 | + - [asc_duplicate_highest](SIMD-API/c_api/reg/data_fill/asc_duplicate_highest.md) | ||
| 1160 | + - [asc_duplicate_highest_merge](SIMD-API/c_api/reg/data_fill/asc_duplicate_highest_merge.md) | ||
| 1159 | - [asc_duplicate_merge](SIMD-API/c_api/reg/data_fill/asc_duplicate_merge.md) | 1161 | - [asc_duplicate_merge](SIMD-API/c_api/reg/data_fill/asc_duplicate_merge.md) |
| 1160 | - [asc_duplicate_scalar](SIMD-API/c_api/reg/data_fill/asc_duplicate_scalar.md) | 1162 | - [asc_duplicate_scalar](SIMD-API/c_api/reg/data_fill/asc_duplicate_scalar.md) |
| 1161 | - [asc_duplicate_scalar_merge](SIMD-API/c_api/reg/data_fill/asc_duplicate_scalar_merge.md) | 1163 | - [asc_duplicate_scalar_merge](SIMD-API/c_api/reg/data_fill/asc_duplicate_scalar_merge.md) |
| @@ -1250,6 +1252,7 @@ | |||
| 1250 | - [asc_ffs](SIMD-API/c_api/scalar_compute/asc_ffs.md) | 1252 | - [asc_ffs](SIMD-API/c_api/scalar_compute/asc_ffs.md) |
| 1251 | - [asc_ffz](SIMD-API/c_api/scalar_compute/asc_ffz.md) | 1253 | - [asc_ffz](SIMD-API/c_api/scalar_compute/asc_ffz.md) |
| 1252 | - [asc_float2int32](SIMD-API/c_api/scalar_compute/asc_float2int32.md) | 1254 | - [asc_float2int32](SIMD-API/c_api/scalar_compute/asc_float2int32.md) |
| 1255 | + - [asc_load_dev](SIMD-API/c_api/scalar_compute/asc_load_dev.md) | ||
| 1253 | - [asc_popc](SIMD-API/c_api/scalar_compute/asc_popc.md) | 1256 | - [asc_popc](SIMD-API/c_api/scalar_compute/asc_popc.md) |
| 1254 | - [asc_set_nthbit](SIMD-API/c_api/scalar_compute/asc_set_nthbit.md) | 1257 | - [asc_set_nthbit](SIMD-API/c_api/scalar_compute/asc_set_nthbit.md) |
| 1255 | - [asc_sflbits](SIMD-API/c_api/scalar_compute/asc_sflbits.md) | 1258 | - [asc_sflbits](SIMD-API/c_api/scalar_compute/asc_sflbits.md) |
| @@ -201,6 +201,7 @@ C API文档目录,整体使用时可以引入asc_simd.h,C API列表如下: | |||
| 201 | | [asc_ffs](scalar_compute/asc_ffs.md) | FindFirstSet接口,输入数据的二进制表示中从最低位向最高位查找第一个值为1的位,并返回其位置,如果没找到则返回-1。 | | 201 | | [asc_ffs](scalar_compute/asc_ffs.md) | FindFirstSet接口,输入数据的二进制表示中从最低位向最高位查找第一个值为1的位,并返回其位置,如果没找到则返回-1。 | |
| 202 | | [asc_ffz](scalar_compute/asc_ffz.md) | 获取一个uint64_t类型数字的二进制表示中从最低有效位开始的第一个0出现的位置,如果没找到则返回-1。 | | 202 | | [asc_ffz](scalar_compute/asc_ffz.md) | 获取一个uint64_t类型数字的二进制表示中从最低有效位开始的第一个0出现的位置,如果没找到则返回-1。 | |
| 203 | | [asc_float2int32](scalar_compute/asc_float2int32.md) | 将float类型转化为int32_t类型,并支持多种舍入模式。 | | 203 | | [asc_float2int32](scalar_compute/asc_float2int32.md) | 将float类型转化为int32_t类型,并支持多种舍入模式。 | |
| 204 | +| [asc_load_dev](scalar_compute/asc_load_dev.md) | 不经过DCache直接从GM地址读取整型数据。 | | ||
| 204 | | [asc_popc](scalar_compute/asc_popc.md) | 获取一个uint64_t类型数字的二进制中1的个数。 | | 205 | | [asc_popc](scalar_compute/asc_popc.md) | 获取一个uint64_t类型数字的二进制中1的个数。 | |
| 205 | | [asc_set_nthbit](scalar_compute/asc_set_nthbit.md) | 计算一个uint64_t类型数字的指定二进制位置为1,其余位保持不变。 | | 206 | | [asc_set_nthbit](scalar_compute/asc_set_nthbit.md) | 计算一个uint64_t类型数字的指定二进制位置为1,其余位保持不变。 | |
| 206 | | [asc_sflbits](scalar_compute/asc_sflbits.md) | 计算一个int64_t类型数字的二进制中,从最高数值位开始与符号位相同的连续比特位的个数。 | | 207 | | [asc_sflbits](scalar_compute/asc_sflbits.md) | 计算一个int64_t类型数字的二进制中,从最高数值位开始与符号位相同的连续比特位的个数。 | |
| @@ -533,6 +534,8 @@ Reg矢量计算类API,单独使用时可以引入reg_vector.h,此类API列 | |||
| 533 | | [asc_unpack](reg/data_compress/asc_unpack.md) | 矢量解包操作。 | | 534 | | [asc_unpack](reg/data_compress/asc_unpack.md) | 矢量解包操作。 | |
| 534 | | [asc_unsqueeze](reg/data_compress/asc_unsqueeze.md) | 根据mask进行解压缩,将生成的数据输出到dst。 | | 535 | | [asc_unsqueeze](reg/data_compress/asc_unsqueeze.md) | 根据mask进行解压缩,将生成的数据输出到dst。 | |
| 535 | | [asc_duplicate](reg/data_fill/asc_duplicate.md) | 根据mask将源操作数src的最低位元素填充到目的操作数dst。 | | 536 | | [asc_duplicate](reg/data_fill/asc_duplicate.md) | 根据mask将源操作数src的最低位元素填充到目的操作数dst。 | |
| 537 | +| [asc_duplicate_highest](reg/data_fill/asc_duplicate_highest.md) | 根据mask将源操作数src的最高位元素填充到目的操作数dst,dst中未被mask筛选的元素置为0。 | | ||
| 538 | +| [asc_duplicate_highest_merge](reg/data_fill/asc_duplicate_highest_merge.md) | 根据mask将源操作数src的最高位元素填充到目的操作数dst,dst中未被mask筛选的元素保留原值。 | | ||
| 536 | | [asc_duplicate_merge](reg/data_fill/asc_duplicate_merge.md) | 根据mask将源操作数src的最低位元素填充到目的操作数dst,dst中未被mask筛选的元素保留原值。 | | 539 | | [asc_duplicate_merge](reg/data_fill/asc_duplicate_merge.md) | 根据mask将源操作数src的最低位元素填充到目的操作数dst,dst中未被mask筛选的元素保留原值。 | |
| 537 | | [asc_duplicate_scalar](reg/data_fill/asc_duplicate_scalar.md) | 根据mask将value填充到目的操作数dst。 | | 540 | | [asc_duplicate_scalar](reg/data_fill/asc_duplicate_scalar.md) | 根据mask将value填充到目的操作数dst。 | |
| 538 | | [asc_duplicate_scalar_merge](reg/data_fill/asc_duplicate_scalar_merge.md) | 根据mask将value填充到目的操作数dst,dst中未被mask筛选的元素保留原值。 | | 541 | | [asc_duplicate_scalar_merge](reg/data_fill/asc_duplicate_scalar_merge.md) | 根据mask将value填充到目的操作数dst,dst中未被mask筛选的元素保留原值。 | |
| @@ -0,0 +1,84 @@ | |||
| 1 | +# asc_duplicate_highest | ||
M | |||
| 2 | + | ||
| 3 | +## 产品支持情况 | ||
| 4 | + | ||
| 5 | +<!-- npu="950" id1 --> | ||
| 6 | +- Ascend 950PR/Ascend 950DT:支持 | ||
| 7 | +<!-- end id1 --> | ||
| 8 | +<!-- npu="A3" id2 --> | ||
| 9 | +- Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持 | ||
| 10 | +<!-- end id2 --> | ||
| 11 | +<!-- npu="910b" id3 --> | ||
| 12 | +- Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持 | ||
| 13 | +<!-- end id3 --> | ||
| 14 | +<!-- npu="910" id4 --> | ||
| 15 | +- Atlas 训练系列产品:不支持 | ||
| 16 | +<!-- end id4 --> | ||
| 17 | +<!-- npu="310p" id5 --> | ||
| 18 | +- Atlas 推理系列产品AI Core:不支持 | ||
| 19 | +<!-- end id5 --> | ||
| 20 | +<!-- npu="310p" id6 --> | ||
| 21 | +- Atlas 推理系列产品Vector Core:不支持 | ||
| 22 | +<!-- end id6 --> | ||
| 23 | +<!-- npu="310b" id7 --> | ||
| 24 | +- Atlas 200I/500 A2 推理产品:不支持 | ||
| 25 | +<!-- end id7 --> | ||
| 26 | + | ||
| 27 | +## 功能说明 | ||
| 28 | + | ||
| 29 | +将src的最高位元素广播到dst中被mask筛选的位置,dst中未被mask筛选的位置被置为0。 | ||
| 30 | + | ||
| 31 | +## 函数原型 | ||
| 32 | + | ||
| 33 | +```cpp | ||
| 34 | +__simd_callee__ inline void asc_duplicate_highest(vector_int8_t& dst, vector_int8_t src, vector_bool mask) | ||
| 35 | +__simd_callee__ inline void asc_duplicate_highest(vector_uint8_t& dst, vector_uint8_t src, vector_bool mask) | ||
| 36 | +__simd_callee__ inline void asc_duplicate_highest(vector_fp8_e8m0_t& dst, vector_fp8_e8m0_t src, vector_bool mask) | ||
| 37 | +__simd_callee__ inline void asc_duplicate_highest(vector_fp8_e5m2_t& dst, vector_fp8_e5m2_t src, vector_bool mask) | ||
| 38 | +__simd_callee__ inline void asc_duplicate_highest(vector_fp8_e4m3fn_t& dst, vector_fp8_e4m3fn_t src, vector_bool mask) | ||
| 39 | +__simd_callee__ inline void asc_duplicate_highest(vector_int16_t& dst, vector_int16_t src, vector_bool mask) | ||
| 40 | +__simd_callee__ inline void asc_duplicate_highest(vector_uint16_t& dst, vector_uint16_t src, vector_bool mask) | ||
| 41 | +__simd_callee__ inline void asc_duplicate_highest(vector_half& dst, vector_half src, vector_bool mask) | ||
| 42 | +__simd_callee__ inline void asc_duplicate_highest(vector_bfloat16_t& dst, vector_bfloat16_t src, vector_bool mask) | ||
| 43 | +__simd_callee__ inline void asc_duplicate_highest(vector_int32_t& dst, vector_int32_t src, vector_bool mask) | ||
| 44 | +__simd_callee__ inline void asc_duplicate_highest(vector_uint32_t& dst, vector_uint32_t src, vector_bool mask) | ||
| 45 | +__simd_callee__ inline void asc_duplicate_highest(vector_float& dst, vector_float src, vector_bool mask) | ||
| 46 | +``` | ||
| 47 | + | ||
| 48 | +## 参数说明 | ||
| 49 | + | ||
| 50 | +**表1** 参数说明 | ||
| 51 | + | ||
| 52 | +| 参数名 | 输入/输出 | 描述 | | ||
| 53 | +| --- | --- | --- | | ||
| 54 | +| dst | 输出 | 目的操作数(矢量数据寄存器)。 | | ||
| 55 | +| src | 输入 | 源操作数(矢量数据寄存器)。 | | ||
| 56 | +| mask | 输入 | 源操作数掩码(掩码寄存器),用于指示在计算过程中哪些元素参与计算。对应位置为1时参与计算,为0时不参与计算。mask未筛选的元素在输出中置零。 | | ||
| 57 | + | ||
| 58 | +矢量数据寄存器和掩码寄存器的详细说明请参见[reg数据类型定义](../reg_data_types/data_type_definition.md)。 | ||
| 59 | + | ||
| 60 | +## 返回值说明 | ||
| 61 | + | ||
| 62 | +无 | ||
| 63 | + | ||
| 64 | +## 约束说明 | ||
| 65 | + | ||
| 66 | +无 | ||
| 67 | + | ||
| 68 | +## 调用示例 | ||
| 69 | + | ||
| 70 | +```cpp | ||
| 71 | +__simd_vf__ inline void duplicate_highest_vf(__ubuf__ half* dst_addr, __ubuf__ half* src_addr, | ||
| 72 | + uint32_t count, uint16_t one_repeat_size, uint16_t repeat_time) | ||
| 73 | +{ | ||
| 74 | + vector_half dst; | ||
| 75 | + vector_half src; | ||
| 76 | + vector_bool mask; | ||
| 77 | + for (uint16_t i = 0; i < repeat_time; ++i) { | ||
| 78 | + mask = asc_update_mask_b16(count); | ||
| 79 | + asc_loadalign(src, src_addr + i * one_repeat_size); | ||
| 80 | + asc_duplicate_highest(dst, src, mask); | ||
| 81 | + asc_storealign(dst_addr + i * one_repeat_size, dst, mask); | ||
| 82 | + } | ||
| 83 | +} | ||
| 84 | +``` | ||
| @@ -0,0 +1,85 @@ | |||
| 1 | +# asc_duplicate_highest_merge | ||
| 2 | + | ||
| 3 | +## 产品支持情况 | ||
| 4 | + | ||
| 5 | +<!-- npu="950" id1 --> | ||
| 6 | +- Ascend 950PR/Ascend 950DT:支持 | ||
| 7 | +<!-- end id1 --> | ||
| 8 | +<!-- npu="A3" id2 --> | ||
| 9 | +- Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持 | ||
| 10 | +<!-- end id2 --> | ||
| 11 | +<!-- npu="910b" id3 --> | ||
| 12 | +- Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持 | ||
| 13 | +<!-- end id3 --> | ||
| 14 | +<!-- npu="910" id4 --> | ||
| 15 | +- Atlas 训练系列产品:不支持 | ||
| 16 | +<!-- end id4 --> | ||
| 17 | +<!-- npu="310p" id5 --> | ||
| 18 | +- Atlas 推理系列产品AI Core:不支持 | ||
| 19 | +<!-- end id5 --> | ||
| 20 | +<!-- npu="310p" id6 --> | ||
| 21 | +- Atlas 推理系列产品Vector Core:不支持 | ||
| 22 | +<!-- end id6 --> | ||
| 23 | +<!-- npu="310b" id7 --> | ||
| 24 | +- Atlas 200I/500 A2 推理产品:不支持 | ||
| 25 | +<!-- end id7 --> | ||
| 26 | + | ||
| 27 | +## 功能说明 | ||
| 28 | + | ||
| 29 | +merge模式下,将src的最高位元素广播到dst中被mask筛选的位置,dst中未被mask筛选的元素保留原值。 | ||
| 30 | + | ||
| 31 | +## 函数原型 | ||
| 32 | + | ||
| 33 | +```cpp | ||
| 34 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_int8_t& dst, vector_int8_t src, vector_bool mask) | ||
| 35 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_uint8_t& dst, vector_uint8_t src, vector_bool mask) | ||
| 36 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_fp8_e8m0_t& dst, vector_fp8_e8m0_t src, vector_bool mask) | ||
| 37 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_fp8_e5m2_t& dst, vector_fp8_e5m2_t src, vector_bool mask) | ||
| 38 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_fp8_e4m3fn_t& dst, vector_fp8_e4m3fn_t src, vector_bool mask) | ||
| 39 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_int16_t& dst, vector_int16_t src, vector_bool mask) | ||
| 40 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_uint16_t& dst, vector_uint16_t src, vector_bool mask) | ||
| 41 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_half& dst, vector_half src, vector_bool mask) | ||
| 42 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_bfloat16_t& dst, vector_bfloat16_t src, vector_bool mask) | ||
| 43 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_int32_t& dst, vector_int32_t src, vector_bool mask) | ||
| 44 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_uint32_t& dst, vector_uint32_t src, vector_bool mask) | ||
| 45 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_float& dst, vector_float src, vector_bool mask) | ||
| 46 | +``` | ||
| 47 | + | ||
| 48 | +## 参数说明 | ||
| 49 | + | ||
| 50 | +**表1** 参数说明 | ||
| 51 | + | ||
| 52 | +| 参数名 | 输入/输出 | 描述 | | ||
| 53 | +| --- | --- | --- | | ||
| 54 | +| dst | 输入/输出 | 目的操作数(矢量数据寄存器)。未被mask筛选的元素保留原值。 | | ||
| 55 | +| src | 输入 | 源操作数(矢量数据寄存器)。 | | ||
| 56 | +| mask | 输入 | 源操作数掩码(掩码寄存器),用于指示在计算过程中哪些元素参与计算。对应位置为1时参与计算,为0时不参与计算。 | | ||
| 57 | + | ||
| 58 | +矢量数据寄存器和掩码寄存器的详细说明请参见[reg数据类型定义](../reg_data_types/data_type_definition.md)。 | ||
| 59 | + | ||
| 60 | +## 返回值说明 | ||
| 61 | + | ||
| 62 | +无 | ||
| 63 | + | ||
| 64 | +## 约束说明 | ||
| 65 | + | ||
| 66 | +无 | ||
| 67 | + | ||
| 68 | +## 调用示例 | ||
| 69 | + | ||
| 70 | +```cpp | ||
| 71 | +__simd_vf__ inline void duplicate_highest_merge_vf(__ubuf__ half* dst_addr, __ubuf__ half* src_addr, | ||
| 72 | + uint32_t count, uint16_t one_repeat_size, uint16_t repeat_time) | ||
| 73 | +{ | ||
| 74 | + vector_half dst; | ||
| 75 | + vector_half src; | ||
| 76 | + vector_bool mask; | ||
| 77 | + for (uint16_t i = 0; i < repeat_time; ++i) { | ||
| 78 | + mask = asc_update_mask_b16(count); | ||
| 79 | + asc_loadalign(dst, dst_addr + i * one_repeat_size); | ||
| 80 | + asc_loadalign(src, src_addr + i * one_repeat_size); | ||
| 81 | + asc_duplicate_highest_merge(dst, src, mask); | ||
| 82 | + asc_storealign(dst_addr + i * one_repeat_size, dst, mask); | ||
| 83 | + } | ||
| 84 | +} | ||
| 85 | +``` | ||
| @@ -2,6 +2,10 @@ | |||
| 2 | 2 | ||
| 3 | - **[asc_duplicate](asc_duplicate.md)** | 3 | - **[asc_duplicate](asc_duplicate.md)** |
| 4 | 4 | ||
| 5 | +- **[asc_duplicate_highest](asc_duplicate_highest.md)** | ||
| 6 | + | ||
| 7 | +- **[asc_duplicate_highest_merge](asc_duplicate_highest_merge.md)** | ||
| 8 | + | ||
| 5 | - **[asc_duplicate_merge](asc_duplicate_merge.md)** | 9 | - **[asc_duplicate_merge](asc_duplicate_merge.md)** |
| 6 | 10 | ||
| 7 | - **[asc_duplicate_scalar](asc_duplicate_scalar.md)** | 11 | - **[asc_duplicate_scalar](asc_duplicate_scalar.md)** |
| @@ -0,0 +1,77 @@ | |||
| 1 | +# asc_load_dev | ||
| 2 | + | ||
| 3 | +## 产品支持情况 | ||
| 4 | + | ||
| 5 | +<!-- npu="950" id1 --> | ||
| 6 | +- Ascend 950PR/Ascend 950DT:支持 | ||
| 7 | +<!-- end id1 --> | ||
| 8 | +<!-- npu="A3" id2 --> | ||
| 9 | +- Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持 | ||
| 10 | +<!-- end id2 --> | ||
| 11 | +<!-- npu="910b" id3 --> | ||
| 12 | +- Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持 | ||
| 13 | +<!-- end id3 --> | ||
| 14 | +<!-- npu="910" id4 --> | ||
| 15 | +- Atlas 训练系列产品:不支持 | ||
| 16 | +<!-- end id4 --> | ||
| 17 | +<!-- npu="310p" id5 --> | ||
| 18 | +- Atlas 推理系列产品AI Core:不支持 | ||
| 19 | +<!-- end id5 --> | ||
| 20 | +<!-- npu="310p" id6 --> | ||
| 21 | +- Atlas 推理系列产品Vector Core:不支持 | ||
| 22 | +<!-- end id6 --> | ||
| 23 | +<!-- npu="310b" id7 --> | ||
| 24 | +- Atlas 200I/500 A2 推理产品:不支持 | ||
| 25 | +<!-- end id7 --> | ||
| 26 | + | ||
| 27 | +## 功能说明 | ||
| 28 | + | ||
| 29 | +不经过DCache直接从GM地址读取整型数据。 | ||
| 30 | +当多核操作GM地址且数据无法对齐到Cache Line时,经过DCache读写可能引入Cache Line粒度的数据覆盖。此时,可使用本接口绕过DCache读取GM数据。 | ||
| 31 | + | ||
| 32 | +## 函数原型 | ||
| 33 | + | ||
| 34 | +```cpp | ||
| 35 | +__aicore__ inline int8_t asc_load_dev(__gm__ int8_t* addr) | ||
| 36 | + | ||
| 37 | +__aicore__ inline uint8_t asc_load_dev(__gm__ uint8_t* addr) | ||
| 38 | + | ||
| 39 | +__aicore__ inline int16_t asc_load_dev(__gm__ int16_t* addr) | ||
| 40 | + | ||
| 41 | +__aicore__ inline uint16_t asc_load_dev(__gm__ uint16_t* addr) | ||
| 42 | + | ||
| 43 | +__aicore__ inline int32_t asc_load_dev(__gm__ int32_t* addr) | ||
| 44 | + | ||
| 45 | +__aicore__ inline uint32_t asc_load_dev(__gm__ uint32_t* addr) | ||
| 46 | + | ||
| 47 | +__aicore__ inline int64_t asc_load_dev(__gm__ int64_t* addr) | ||
| 48 | + | ||
| 49 | +__aicore__ inline uint64_t asc_load_dev(__gm__ uint64_t* addr) | ||
| 50 | +``` | ||
| 51 | + | ||
| 52 | +## 参数说明 | ||
| 53 | + | ||
| 54 | +**表1** 参数说明 | ||
| 55 | + | ||
| 56 | +| 参数名 | 输入/输出 | 描述 | | ||
| 57 | +| --- | --- | --- | | ||
| 58 | +| addr | 输入 | 源GM地址。支持的数据类型为`int8_t`、`uint8_t`、`int16_t`、`uint16_t`、`int32_t`、`uint32_t`、`int64_t`、`uint64_t`。 | | ||
| 59 | + | ||
| 60 | +## 返回值说明 | ||
| 61 | + | ||
| 62 | +从GM读取的数据,返回值的数据类型与`addr`指向的数据类型一致。 | ||
| 63 | + | ||
| 64 | +## 流水类型 | ||
| 65 | + | ||
| 66 | +PIPE_S | ||
| 67 | + | ||
| 68 | +## 约束说明 | ||
| 69 | + | ||
| 70 | +仅支持整型数据,不支持浮点类型。 | ||
| 71 | + | ||
| 72 | +## 调用示例 | ||
| 73 | + | ||
| 74 | +```cpp | ||
| 75 | +// addr是外部输入的GM地址,类型为__gm__ int32_t*。 | ||
| 76 | +int32_t value = asc_load_dev(addr); | ||
| 77 | +``` | ||
| @@ -10,6 +10,8 @@ | |||
| 10 | 10 | ||
| 11 | - **[asc_float2int32](asc_float2int32.md)** | 11 | - **[asc_float2int32](asc_float2int32.md)** |
| 12 | 12 | ||
| 13 | +- **[asc_load_dev](asc_load_dev.md)** | ||
| 14 | + | ||
| 13 | - **[asc_popc](asc_popc.md)** | 15 | - **[asc_popc](asc_popc.md)** |
| 14 | 16 | ||
| 15 | - **[asc_set_nthbit](asc_set_nthbit.md)** | 17 | - **[asc_set_nthbit](asc_set_nthbit.md)** |
| @@ -23,6 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | + | ||
| 26 | 27 | ||
| 27 | 28 | ||
| 28 | 29 | ||
| @@ -65,6 +66,22 @@ __aicore__ inline void asc_store_dev(__gm__ int64_t* addr, int64_t value) { asc_ | |||
| 65 | 66 | ||
| 66 | __aicore__ inline void asc_store_dev(__gm__ uint64_t* addr, uint64_t value) { asc_store_dev_impl(addr, value); } | 67 | __aicore__ inline void asc_store_dev(__gm__ uint64_t* addr, uint64_t value) { asc_store_dev_impl(addr, value); } |
| 67 | 68 | ||
| 69 | +__aicore__ inline int8_t asc_load_dev(__gm__ int8_t* addr) { return asc_load_dev_impl(addr); } | ||
| 70 | + | ||
| 71 | +__aicore__ inline uint8_t asc_load_dev(__gm__ uint8_t* addr) { return asc_load_dev_impl(addr); } | ||
| 72 | + | ||
| 73 | +__aicore__ inline int16_t asc_load_dev(__gm__ int16_t* addr) { return asc_load_dev_impl(addr); } | ||
| 74 | + | ||
| 75 | +__aicore__ inline uint16_t asc_load_dev(__gm__ uint16_t* addr) { return asc_load_dev_impl(addr); } | ||
| 76 | + | ||
| 77 | +__aicore__ inline int32_t asc_load_dev(__gm__ int32_t* addr) { return asc_load_dev_impl(addr); } | ||
| 78 | + | ||
| 79 | +__aicore__ inline uint32_t asc_load_dev(__gm__ uint32_t* addr) { return asc_load_dev_impl(addr); } | ||
| 80 | + | ||
| 81 | +__aicore__ inline int64_t asc_load_dev(__gm__ int64_t* addr) { return asc_load_dev_impl(addr); } | ||
| 82 | + | ||
| 83 | +__aicore__ inline uint64_t asc_load_dev(__gm__ uint64_t* addr) { return asc_load_dev_impl(addr); } | ||
| 84 | + | ||
| 68 | // ==========asc_float2int32 (rd/ru/rn/rna)========== | 85 | // ==========asc_float2int32 (rd/ru/rn/rna)========== |
| 69 | __aicore__ inline int32_t asc_float2int32_rd(float value) { return asc_float2int32_rd_impl(value); } | 86 | __aicore__ inline int32_t asc_float2int32_rd(float value) { return asc_float2int32_rd_impl(value); } |
| 70 | 87 | ||
| @@ -0,0 +1,69 @@ | |||
| 1 | +/** | ||
| 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | + * See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | + */ | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + "impl/c_api/instr_impl/npu_arch_3510/scalar_compute_impl/asc_load_dev_impl.h is an internal header file and must not be used directly. Functions or variables defined in this file may be removed in the future. Please use " | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +constexpr int16_t ASC_C_API_LOAD_DEV_DEFAULT_OFFSET = 0; | ||
| 24 | + | ||
| 25 | +__aicore__ inline int8_t asc_load_dev_impl(__gm__ int8_t* addr) | ||
| 26 | +{ | ||
| 27 | + return ld_dev(reinterpret_cast<__gm__ uint8_t*>(addr), ASC_C_API_LOAD_DEV_DEFAULT_OFFSET); | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +__aicore__ inline uint8_t asc_load_dev_impl(__gm__ uint8_t* addr) | ||
| 31 | +{ | ||
| 32 | + return ld_dev(addr, ASC_C_API_LOAD_DEV_DEFAULT_OFFSET); | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +__aicore__ inline int16_t asc_load_dev_impl(__gm__ int16_t* addr) | ||
| 36 | +{ | ||
| 37 | + return ld_dev(reinterpret_cast<__gm__ uint16_t*>(addr), ASC_C_API_LOAD_DEV_DEFAULT_OFFSET); | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +__aicore__ inline uint16_t asc_load_dev_impl(__gm__ uint16_t* addr) | ||
| 41 | +{ | ||
| 42 | + return ld_dev(addr, ASC_C_API_LOAD_DEV_DEFAULT_OFFSET); | ||
| 43 | +} | ||
| 44 | + | ||
| 45 | +__aicore__ inline int32_t asc_load_dev_impl(__gm__ int32_t* addr) | ||
| 46 | +{ | ||
| 47 | + return ld_dev(reinterpret_cast<__gm__ uint32_t*>(addr), ASC_C_API_LOAD_DEV_DEFAULT_OFFSET); | ||
| 48 | +} | ||
| 49 | + | ||
| 50 | +__aicore__ inline uint32_t asc_load_dev_impl(__gm__ uint32_t* addr) | ||
| 51 | +{ | ||
| 52 | + return ld_dev(addr, ASC_C_API_LOAD_DEV_DEFAULT_OFFSET); | ||
| 53 | +} | ||
| 54 | + | ||
| 55 | +__aicore__ inline int64_t asc_load_dev_impl(__gm__ int64_t* addr) | ||
| 56 | +{ | ||
| 57 | + return ld_dev(addr, ASC_C_API_LOAD_DEV_DEFAULT_OFFSET); | ||
| 58 | +} | ||
| 59 | + | ||
| 60 | +__aicore__ inline uint64_t asc_load_dev_impl(__gm__ uint64_t* addr) | ||
| 61 | +{ | ||
| 62 | + return ld_dev(addr, ASC_C_API_LOAD_DEV_DEFAULT_OFFSET); | ||
| 63 | +} | ||
| 64 | + | ||
| 65 | + | ||
| 66 | + | ||
| 67 | + | ||
| 68 | + | ||
| 69 | + | ||
| @@ -1584,6 +1584,67 @@ __simd_callee__ inline void asc_duplicate(vector_float& dst, vector_float src, v | |||
| 1584 | asc_duplicate_impl(dst, src, mask); | 1584 | asc_duplicate_impl(dst, src, mask); |
| 1585 | } | 1585 | } |
| 1586 | 1586 | ||
| 1587 | +// ==========asc_duplicate_highest(uint8_t/int8_t/fp8_e4m3fn_t/fp8_e5m2_t/fp8_e8m0_t/uint16_t/int16_t/half/bfloat16_t/uint32_t/int32_t/float)========== | ||
| 1588 | +__simd_callee__ inline void asc_duplicate_highest(vector_uint8_t& dst, vector_uint8_t src, vector_bool mask) | ||
| 1589 | +{ | ||
| 1590 | + asc_duplicate_highest_impl(dst, src, mask); | ||
| 1591 | +} | ||
| 1592 | + | ||
| 1593 | +__simd_callee__ inline void asc_duplicate_highest(vector_int8_t& dst, vector_int8_t src, vector_bool mask) | ||
| 1594 | +{ | ||
| 1595 | + asc_duplicate_highest_impl(dst, src, mask); | ||
| 1596 | +} | ||
| 1597 | + | ||
| 1598 | +__simd_callee__ inline void asc_duplicate_highest(vector_fp8_e4m3fn_t& dst, vector_fp8_e4m3fn_t src, vector_bool mask) | ||
| 1599 | +{ | ||
| 1600 | + asc_duplicate_highest_impl(dst, src, mask); | ||
| 1601 | +} | ||
| 1602 | + | ||
| 1603 | +__simd_callee__ inline void asc_duplicate_highest(vector_fp8_e5m2_t& dst, vector_fp8_e5m2_t src, vector_bool mask) | ||
| 1604 | +{ | ||
| 1605 | + asc_duplicate_highest_impl(dst, src, mask); | ||
| 1606 | +} | ||
| 1607 | + | ||
| 1608 | +__simd_callee__ inline void asc_duplicate_highest(vector_fp8_e8m0_t& dst, vector_fp8_e8m0_t src, vector_bool mask) | ||
| 1609 | +{ | ||
| 1610 | + asc_duplicate_highest_impl(dst, src, mask); | ||
| 1611 | +} | ||
| 1612 | + | ||
| 1613 | +__simd_callee__ inline void asc_duplicate_highest(vector_uint16_t& dst, vector_uint16_t src, vector_bool mask) | ||
| 1614 | +{ | ||
| 1615 | + asc_duplicate_highest_impl(dst, src, mask); | ||
| 1616 | +} | ||
| 1617 | + | ||
| 1618 | +__simd_callee__ inline void asc_duplicate_highest(vector_int16_t& dst, vector_int16_t src, vector_bool mask) | ||
| 1619 | +{ | ||
| 1620 | + asc_duplicate_highest_impl(dst, src, mask); | ||
| 1621 | +} | ||
| 1622 | + | ||
| 1623 | +__simd_callee__ inline void asc_duplicate_highest(vector_half& dst, vector_half src, vector_bool mask) | ||
| 1624 | +{ | ||
| 1625 | + asc_duplicate_highest_impl(dst, src, mask); | ||
| 1626 | +} | ||
| 1627 | + | ||
| 1628 | +__simd_callee__ inline void asc_duplicate_highest(vector_bfloat16_t& dst, vector_bfloat16_t src, vector_bool mask) | ||
| 1629 | +{ | ||
| 1630 | + asc_duplicate_highest_impl(dst, src, mask); | ||
| 1631 | +} | ||
| 1632 | + | ||
| 1633 | +__simd_callee__ inline void asc_duplicate_highest(vector_uint32_t& dst, vector_uint32_t src, vector_bool mask) | ||
| 1634 | +{ | ||
| 1635 | + asc_duplicate_highest_impl(dst, src, mask); | ||
| 1636 | +} | ||
| 1637 | + | ||
| 1638 | +__simd_callee__ inline void asc_duplicate_highest(vector_int32_t& dst, vector_int32_t src, vector_bool mask) | ||
| 1639 | +{ | ||
| 1640 | + asc_duplicate_highest_impl(dst, src, mask); | ||
| 1641 | +} | ||
| 1642 | + | ||
| 1643 | +__simd_callee__ inline void asc_duplicate_highest(vector_float& dst, vector_float src, vector_bool mask) | ||
| 1644 | +{ | ||
| 1645 | + asc_duplicate_highest_impl(dst, src, mask); | ||
| 1646 | +} | ||
| 1647 | + | ||
| 1587 | // ==========asc_duplicate_merge(uint8_t/int8_t/fp8_e4m3fn_t/fp8_e5m2_t/fp8_e8m0_t/uint16_t/int16_t/half/bfloat16_t/uint32_t/int32_t/float)========== | 1648 | // ==========asc_duplicate_merge(uint8_t/int8_t/fp8_e4m3fn_t/fp8_e5m2_t/fp8_e8m0_t/uint16_t/int16_t/half/bfloat16_t/uint32_t/int32_t/float)========== |
| 1588 | __simd_callee__ inline void asc_duplicate_merge(vector_uint8_t& dst, vector_uint8_t src, vector_bool mask) | 1649 | __simd_callee__ inline void asc_duplicate_merge(vector_uint8_t& dst, vector_uint8_t src, vector_bool mask) |
| 1589 | { | 1650 | { |
| @@ -1645,6 +1706,68 @@ __simd_callee__ inline void asc_duplicate_merge(vector_float& dst, vector_float | |||
| 1645 | asc_duplicate_merge_impl(dst, src, mask); | 1706 | asc_duplicate_merge_impl(dst, src, mask); |
| 1646 | } | 1707 | } |
| 1647 | 1708 | ||
| 1709 | +// ==========asc_duplicate_highest_merge(uint8_t/int8_t/fp8_e4m3fn_t/fp8_e5m2_t/fp8_e8m0_t/uint16_t/int16_t/half/bfloat16_t/uint32_t/int32_t/float)========== | ||
| 1710 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_uint8_t& dst, vector_uint8_t src, vector_bool mask) | ||
| 1711 | +{ | ||
| 1712 | + asc_duplicate_highest_merge_impl(dst, src, mask); | ||
| 1713 | +} | ||
| 1714 | + | ||
| 1715 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_int8_t& dst, vector_int8_t src, vector_bool mask) | ||
| 1716 | +{ | ||
| 1717 | + asc_duplicate_highest_merge_impl(dst, src, mask); | ||
| 1718 | +} | ||
| 1719 | + | ||
| 1720 | +__simd_callee__ inline void asc_duplicate_highest_merge( | ||
| 1721 | + vector_fp8_e4m3fn_t& dst, vector_fp8_e4m3fn_t src, vector_bool mask) | ||
| 1722 | +{ | ||
| 1723 | + asc_duplicate_highest_merge_impl(dst, src, mask); | ||
| 1724 | +} | ||
| 1725 | + | ||
| 1726 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_fp8_e5m2_t& dst, vector_fp8_e5m2_t src, vector_bool mask) | ||
| 1727 | +{ | ||
| 1728 | + asc_duplicate_highest_merge_impl(dst, src, mask); | ||
| 1729 | +} | ||
| 1730 | + | ||
| 1731 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_fp8_e8m0_t& dst, vector_fp8_e8m0_t src, vector_bool mask) | ||
| 1732 | +{ | ||
| 1733 | + asc_duplicate_highest_merge_impl(dst, src, mask); | ||
| 1734 | +} | ||
| 1735 | + | ||
| 1736 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_uint16_t& dst, vector_uint16_t src, vector_bool mask) | ||
| 1737 | +{ | ||
| 1738 | + asc_duplicate_highest_merge_impl(dst, src, mask); | ||
| 1739 | +} | ||
| 1740 | + | ||
| 1741 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_int16_t& dst, vector_int16_t src, vector_bool mask) | ||
| 1742 | +{ | ||
| 1743 | + asc_duplicate_highest_merge_impl(dst, src, mask); | ||
| 1744 | +} | ||
| 1745 | + | ||
| 1746 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_half& dst, vector_half src, vector_bool mask) | ||
| 1747 | +{ | ||
| 1748 | + asc_duplicate_highest_merge_impl(dst, src, mask); | ||
| 1749 | +} | ||
| 1750 | + | ||
| 1751 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_bfloat16_t& dst, vector_bfloat16_t src, vector_bool mask) | ||
| 1752 | +{ | ||
| 1753 | + asc_duplicate_highest_merge_impl(dst, src, mask); | ||
| 1754 | +} | ||
| 1755 | + | ||
| 1756 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_uint32_t& dst, vector_uint32_t src, vector_bool mask) | ||
| 1757 | +{ | ||
| 1758 | + asc_duplicate_highest_merge_impl(dst, src, mask); | ||
| 1759 | +} | ||
| 1760 | + | ||
| 1761 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_int32_t& dst, vector_int32_t src, vector_bool mask) | ||
| 1762 | +{ | ||
| 1763 | + asc_duplicate_highest_merge_impl(dst, src, mask); | ||
| 1764 | +} | ||
| 1765 | + | ||
| 1766 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_float& dst, vector_float src, vector_bool mask) | ||
| 1767 | +{ | ||
| 1768 | + asc_duplicate_highest_merge_impl(dst, src, mask); | ||
| 1769 | +} | ||
| 1770 | + | ||
| 1648 | // ==========asc_abs_sub(half/float)========== | 1771 | // ==========asc_abs_sub(half/float)========== |
| 1649 | __simd_callee__ inline void asc_abs_sub(vector_half& dst, vector_half src0, vector_half src1, vector_bool mask) | 1772 | __simd_callee__ inline void asc_abs_sub(vector_half& dst, vector_half src0, vector_half src1, vector_bool mask) |
| 1650 | { | 1773 | { |
| @@ -102,6 +102,91 @@ __simd_callee__ inline void asc_duplicate_impl(vector_float& dst, vector_float s | |||
| 102 | } | 102 | } |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | +__simd_callee__ inline void asc_duplicate_highest_impl(vector_uint8_t& dst, vector_uint8_t src, vector_bool mask) | ||
| 106 | +{ | ||
| 107 | + if ASC_IS_AIV { | ||
| 108 | + vdup(dst, src, mask, POS_HIGHEST, MODE_ZEROING); | ||
| 109 | + } | ||
| 110 | +} | ||
| 111 | + | ||
| 112 | +__simd_callee__ inline void asc_duplicate_highest_impl(vector_int8_t& dst, vector_int8_t src, vector_bool mask) | ||
| 113 | +{ | ||
| 114 | + if ASC_IS_AIV { | ||
| 115 | + vdup(dst, src, mask, POS_HIGHEST, MODE_ZEROING); | ||
| 116 | + } | ||
| 117 | +} | ||
| 118 | + | ||
| 119 | +__simd_callee__ inline void asc_duplicate_highest_impl( | ||
| 120 | + vector_fp8_e4m3fn_t& dst, vector_fp8_e4m3fn_t src, vector_bool mask) | ||
| 121 | +{ | ||
| 122 | + if ASC_IS_AIV { | ||
| 123 | + vdup(dst, src, mask, POS_HIGHEST, MODE_ZEROING); | ||
| 124 | + } | ||
| 125 | +} | ||
| 126 | + | ||
| 127 | +__simd_callee__ inline void asc_duplicate_highest_impl(vector_fp8_e5m2_t& dst, vector_fp8_e5m2_t src, vector_bool mask) | ||
| 128 | +{ | ||
| 129 | + if ASC_IS_AIV { | ||
| 130 | + vdup(dst, src, mask, POS_HIGHEST, MODE_ZEROING); | ||
| 131 | + } | ||
| 132 | +} | ||
| 133 | + | ||
| 134 | +__simd_callee__ inline void asc_duplicate_highest_impl(vector_fp8_e8m0_t& dst, vector_fp8_e8m0_t src, vector_bool mask) | ||
| 135 | +{ | ||
| 136 | + if ASC_IS_AIV { | ||
| 137 | + vdup(dst, src, mask, POS_HIGHEST, MODE_ZEROING); | ||
| 138 | + } | ||
| 139 | +} | ||
| 140 | + | ||
| 141 | +__simd_callee__ inline void asc_duplicate_highest_impl(vector_uint16_t& dst, vector_uint16_t src, vector_bool mask) | ||
| 142 | +{ | ||
| 143 | + if ASC_IS_AIV { | ||
| 144 | + vdup(dst, src, mask, POS_HIGHEST, MODE_ZEROING); | ||
| 145 | + } | ||
| 146 | +} | ||
| 147 | + | ||
| 148 | +__simd_callee__ inline void asc_duplicate_highest_impl(vector_int16_t& dst, vector_int16_t src, vector_bool mask) | ||
| 149 | +{ | ||
| 150 | + if ASC_IS_AIV { | ||
| 151 | + vdup(dst, src, mask, POS_HIGHEST, MODE_ZEROING); | ||
| 152 | + } | ||
| 153 | +} | ||
| 154 | + | ||
| 155 | +__simd_callee__ inline void asc_duplicate_highest_impl(vector_half& dst, vector_half src, vector_bool mask) | ||
| 156 | +{ | ||
| 157 | + if ASC_IS_AIV { | ||
| 158 | + vdup(dst, src, mask, POS_HIGHEST, MODE_ZEROING); | ||
| 159 | + } | ||
| 160 | +} | ||
| 161 | + | ||
| 162 | +__simd_callee__ inline void asc_duplicate_highest_impl(vector_bfloat16_t& dst, vector_bfloat16_t src, vector_bool mask) | ||
| 163 | +{ | ||
| 164 | + if ASC_IS_AIV { | ||
| 165 | + vdup(dst, src, mask, POS_HIGHEST, MODE_ZEROING); | ||
| 166 | + } | ||
| 167 | +} | ||
| 168 | + | ||
| 169 | +__simd_callee__ inline void asc_duplicate_highest_impl(vector_uint32_t& dst, vector_uint32_t src, vector_bool mask) | ||
| 170 | +{ | ||
| 171 | + if ASC_IS_AIV { | ||
| 172 | + vdup(dst, src, mask, POS_HIGHEST, MODE_ZEROING); | ||
| 173 | + } | ||
| 174 | +} | ||
| 175 | + | ||
| 176 | +__simd_callee__ inline void asc_duplicate_highest_impl(vector_int32_t& dst, vector_int32_t src, vector_bool mask) | ||
| 177 | +{ | ||
| 178 | + if ASC_IS_AIV { | ||
| 179 | + vdup(dst, src, mask, POS_HIGHEST, MODE_ZEROING); | ||
| 180 | + } | ||
| 181 | +} | ||
| 182 | + | ||
| 183 | +__simd_callee__ inline void asc_duplicate_highest_impl(vector_float& dst, vector_float src, vector_bool mask) | ||
| 184 | +{ | ||
| 185 | + if ASC_IS_AIV { | ||
| 186 | + vdup(dst, src, mask, POS_HIGHEST, MODE_ZEROING); | ||
| 187 | + } | ||
| 188 | +} | ||
| 189 | + | ||
| 105 | // vdup with merging mode | 190 | // vdup with merging mode |
| 106 | __simd_callee__ inline void asc_duplicate_merge_impl(vector_uint8_t& dst, vector_uint8_t src, vector_bool mask) | 191 | __simd_callee__ inline void asc_duplicate_merge_impl(vector_uint8_t& dst, vector_uint8_t src, vector_bool mask) |
| 107 | { | 192 | { |
| @@ -187,4 +272,94 @@ __simd_callee__ inline void asc_duplicate_merge_impl(vector_float& dst, vector_f | |||
| 187 | vdup(dst, src, mask, POS_LOWEST, MODE_MERGING); | 272 | vdup(dst, src, mask, POS_LOWEST, MODE_MERGING); |
| 188 | } | 273 | } |
| 189 | } | 274 | } |
| 275 | + | ||
| 276 | +__simd_callee__ inline void asc_duplicate_highest_merge_impl(vector_uint8_t& dst, vector_uint8_t src, vector_bool mask) | ||
| 277 | +{ | ||
| 278 | + if ASC_IS_AIV { | ||
| 279 | + vdup(dst, src, mask, POS_HIGHEST, MODE_MERGING); | ||
| 280 | + } | ||
| 281 | +} | ||
| 282 | + | ||
| 283 | +__simd_callee__ inline void asc_duplicate_highest_merge_impl(vector_int8_t& dst, vector_int8_t src, vector_bool mask) | ||
| 284 | +{ | ||
| 285 | + if ASC_IS_AIV { | ||
| 286 | + vdup(dst, src, mask, POS_HIGHEST, MODE_MERGING); | ||
| 287 | + } | ||
| 288 | +} | ||
| 289 | + | ||
| 290 | +__simd_callee__ inline void asc_duplicate_highest_merge_impl( | ||
| 291 | + vector_fp8_e4m3fn_t& dst, vector_fp8_e4m3fn_t src, vector_bool mask) | ||
| 292 | +{ | ||
| 293 | + if ASC_IS_AIV { | ||
| 294 | + vdup(dst, src, mask, POS_HIGHEST, MODE_MERGING); | ||
| 295 | + } | ||
| 296 | +} | ||
| 297 | + | ||
| 298 | +__simd_callee__ inline void asc_duplicate_highest_merge_impl( | ||
| 299 | + vector_fp8_e5m2_t& dst, vector_fp8_e5m2_t src, vector_bool mask) | ||
| 300 | +{ | ||
| 301 | + if ASC_IS_AIV { | ||
| 302 | + vdup(dst, src, mask, POS_HIGHEST, MODE_MERGING); | ||
| 303 | + } | ||
| 304 | +} | ||
| 305 | + | ||
| 306 | +__simd_callee__ inline void asc_duplicate_highest_merge_impl( | ||
| 307 | + vector_fp8_e8m0_t& dst, vector_fp8_e8m0_t src, vector_bool mask) | ||
| 308 | +{ | ||
| 309 | + if ASC_IS_AIV { | ||
| 310 | + vdup(dst, src, mask, POS_HIGHEST, MODE_MERGING); | ||
| 311 | + } | ||
| 312 | +} | ||
| 313 | + | ||
| 314 | +__simd_callee__ inline void asc_duplicate_highest_merge_impl( | ||
| 315 | + vector_uint16_t& dst, vector_uint16_t src, vector_bool mask) | ||
| 316 | +{ | ||
| 317 | + if ASC_IS_AIV { | ||
| 318 | + vdup(dst, src, mask, POS_HIGHEST, MODE_MERGING); | ||
| 319 | + } | ||
| 320 | +} | ||
| 321 | + | ||
| 322 | +__simd_callee__ inline void asc_duplicate_highest_merge_impl(vector_int16_t& dst, vector_int16_t src, vector_bool mask) | ||
| 323 | +{ | ||
| 324 | + if ASC_IS_AIV { | ||
| 325 | + vdup(dst, src, mask, POS_HIGHEST, MODE_MERGING); | ||
| 326 | + } | ||
| 327 | +} | ||
| 328 | + | ||
| 329 | +__simd_callee__ inline void asc_duplicate_highest_merge_impl(vector_half& dst, vector_half src, vector_bool mask) | ||
| 330 | +{ | ||
| 331 | + if ASC_IS_AIV { | ||
| 332 | + vdup(dst, src, mask, POS_HIGHEST, MODE_MERGING); | ||
| 333 | + } | ||
| 334 | +} | ||
| 335 | + | ||
| 336 | +__simd_callee__ inline void asc_duplicate_highest_merge_impl( | ||
| 337 | + vector_bfloat16_t& dst, vector_bfloat16_t src, vector_bool mask) | ||
| 338 | +{ | ||
| 339 | + if ASC_IS_AIV { | ||
| 340 | + vdup(dst, src, mask, POS_HIGHEST, MODE_MERGING); | ||
| 341 | + } | ||
| 342 | +} | ||
| 343 | + | ||
| 344 | +__simd_callee__ inline void asc_duplicate_highest_merge_impl( | ||
| 345 | + vector_uint32_t& dst, vector_uint32_t src, vector_bool mask) | ||
| 346 | +{ | ||
| 347 | + if ASC_IS_AIV { | ||
| 348 | + vdup(dst, src, mask, POS_HIGHEST, MODE_MERGING); | ||
| 349 | + } | ||
| 350 | +} | ||
| 351 | + | ||
| 352 | +__simd_callee__ inline void asc_duplicate_highest_merge_impl(vector_int32_t& dst, vector_int32_t src, vector_bool mask) | ||
| 353 | +{ | ||
| 354 | + if ASC_IS_AIV { | ||
| 355 | + vdup(dst, src, mask, POS_HIGHEST, MODE_MERGING); | ||
| 356 | + } | ||
| 357 | +} | ||
| 358 | + | ||
| 359 | +__simd_callee__ inline void asc_duplicate_highest_merge_impl(vector_float& dst, vector_float src, vector_bool mask) | ||
| 360 | +{ | ||
| 361 | + if ASC_IS_AIV { | ||
| 362 | + vdup(dst, src, mask, POS_HIGHEST, MODE_MERGING); | ||
| 363 | + } | ||
| 364 | +} | ||
| 190 | 365 | ||
| @@ -389,6 +389,31 @@ __simd_callee__ inline void asc_duplicate(vector_int32_t& dst, vector_int32_t sr | |||
| 389 | 389 | ||
| 390 | __simd_callee__ inline void asc_duplicate(vector_float& dst, vector_float src, vector_bool mask); | 390 | __simd_callee__ inline void asc_duplicate(vector_float& dst, vector_float src, vector_bool mask); |
| 391 | 391 | ||
| 392 | +// ==========asc_duplicate_highest(uint8_t/int8_t/fp8_e4m3fn_t/fp8_e5m2_t/fp8_e8m0_t/uint16_t/int16_t/half/bfloat16_t/uint32_t/int32_t/float)========== | ||
| 393 | +__simd_callee__ inline void asc_duplicate_highest(vector_uint8_t& dst, vector_uint8_t src, vector_bool mask); | ||
| 394 | + | ||
| 395 | +__simd_callee__ inline void asc_duplicate_highest(vector_int8_t& dst, vector_int8_t src, vector_bool mask); | ||
| 396 | + | ||
| 397 | +__simd_callee__ inline void asc_duplicate_highest(vector_fp8_e4m3fn_t& dst, vector_fp8_e4m3fn_t src, vector_bool mask); | ||
| 398 | + | ||
| 399 | +__simd_callee__ inline void asc_duplicate_highest(vector_fp8_e5m2_t& dst, vector_fp8_e5m2_t src, vector_bool mask); | ||
| 400 | + | ||
| 401 | +__simd_callee__ inline void asc_duplicate_highest(vector_fp8_e8m0_t& dst, vector_fp8_e8m0_t src, vector_bool mask); | ||
| 402 | + | ||
| 403 | +__simd_callee__ inline void asc_duplicate_highest(vector_uint16_t& dst, vector_uint16_t src, vector_bool mask); | ||
| 404 | + | ||
| 405 | +__simd_callee__ inline void asc_duplicate_highest(vector_int16_t& dst, vector_int16_t src, vector_bool mask); | ||
| 406 | + | ||
| 407 | +__simd_callee__ inline void asc_duplicate_highest(vector_half& dst, vector_half src, vector_bool mask); | ||
| 408 | + | ||
| 409 | +__simd_callee__ inline void asc_duplicate_highest(vector_bfloat16_t& dst, vector_bfloat16_t src, vector_bool mask); | ||
| 410 | + | ||
| 411 | +__simd_callee__ inline void asc_duplicate_highest(vector_uint32_t& dst, vector_uint32_t src, vector_bool mask); | ||
| 412 | + | ||
| 413 | +__simd_callee__ inline void asc_duplicate_highest(vector_int32_t& dst, vector_int32_t src, vector_bool mask); | ||
| 414 | + | ||
| 415 | +__simd_callee__ inline void asc_duplicate_highest(vector_float& dst, vector_float src, vector_bool mask); | ||
| 416 | + | ||
| 392 | // ==========asc_duplicate_merge(uint8_t/int8_t/fp8_e4m3fn_t/fp8_e5m2_t/fp8_e8m0_t/uint16_t/int16_t/half/bfloat16_t/uint32_t/int32_t/float)========== | 417 | // ==========asc_duplicate_merge(uint8_t/int8_t/fp8_e4m3fn_t/fp8_e5m2_t/fp8_e8m0_t/uint16_t/int16_t/half/bfloat16_t/uint32_t/int32_t/float)========== |
| 393 | __simd_callee__ inline void asc_duplicate_merge(vector_uint8_t& dst, vector_uint8_t src, vector_bool mask); | 418 | __simd_callee__ inline void asc_duplicate_merge(vector_uint8_t& dst, vector_uint8_t src, vector_bool mask); |
| 394 | 419 | ||
| @@ -414,6 +439,35 @@ __simd_callee__ inline void asc_duplicate_merge(vector_int32_t& dst, vector_int3 | |||
| 414 | 439 | ||
| 415 | __simd_callee__ inline void asc_duplicate_merge(vector_float& dst, vector_float src, vector_bool mask); | 440 | __simd_callee__ inline void asc_duplicate_merge(vector_float& dst, vector_float src, vector_bool mask); |
| 416 | 441 | ||
| 442 | +// ==========asc_duplicate_highest_merge(uint8_t/int8_t/fp8_e4m3fn_t/fp8_e5m2_t/fp8_e8m0_t/uint16_t/int16_t/half/bfloat16_t/uint32_t/int32_t/float)========== | ||
| 443 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_uint8_t& dst, vector_uint8_t src, vector_bool mask); | ||
| 444 | + | ||
| 445 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_int8_t& dst, vector_int8_t src, vector_bool mask); | ||
| 446 | + | ||
| 447 | +__simd_callee__ inline void asc_duplicate_highest_merge( | ||
| 448 | + vector_fp8_e4m3fn_t& dst, vector_fp8_e4m3fn_t src, vector_bool mask); | ||
| 449 | + | ||
| 450 | +__simd_callee__ inline void asc_duplicate_highest_merge( | ||
| 451 | + vector_fp8_e5m2_t& dst, vector_fp8_e5m2_t src, vector_bool mask); | ||
| 452 | + | ||
| 453 | +__simd_callee__ inline void asc_duplicate_highest_merge( | ||
| 454 | + vector_fp8_e8m0_t& dst, vector_fp8_e8m0_t src, vector_bool mask); | ||
| 455 | + | ||
| 456 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_uint16_t& dst, vector_uint16_t src, vector_bool mask); | ||
| 457 | + | ||
| 458 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_int16_t& dst, vector_int16_t src, vector_bool mask); | ||
| 459 | + | ||
| 460 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_half& dst, vector_half src, vector_bool mask); | ||
| 461 | + | ||
| 462 | +__simd_callee__ inline void asc_duplicate_highest_merge( | ||
| 463 | + vector_bfloat16_t& dst, vector_bfloat16_t src, vector_bool mask); | ||
| 464 | + | ||
| 465 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_uint32_t& dst, vector_uint32_t src, vector_bool mask); | ||
| 466 | + | ||
| 467 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_int32_t& dst, vector_int32_t src, vector_bool mask); | ||
| 468 | + | ||
| 469 | +__simd_callee__ inline void asc_duplicate_highest_merge(vector_float& dst, vector_float src, vector_bool mask); | ||
| 470 | + | ||
| 417 | // ==========asc_abs_sub(half/float)========== | 471 | // ==========asc_abs_sub(half/float)========== |
| 418 | __simd_callee__ inline void asc_abs_sub(vector_half& dst, vector_half src0, vector_half src1, vector_bool mask); | 472 | __simd_callee__ inline void asc_abs_sub(vector_half& dst, vector_half src0, vector_half src1, vector_bool mask); |
| 419 | 473 | ||
| @@ -51,6 +51,14 @@ __aicore__ inline void asc_store_dev(__gm__ int32_t* addr, int32_t value); | |||
| 51 | __aicore__ inline void asc_store_dev(__gm__ uint32_t* addr, uint32_t value); | 51 | __aicore__ inline void asc_store_dev(__gm__ uint32_t* addr, uint32_t value); |
| 52 | __aicore__ inline void asc_store_dev(__gm__ int64_t* addr, int64_t value); | 52 | __aicore__ inline void asc_store_dev(__gm__ int64_t* addr, int64_t value); |
| 53 | __aicore__ inline void asc_store_dev(__gm__ uint64_t* addr, uint64_t value); | 53 | __aicore__ inline void asc_store_dev(__gm__ uint64_t* addr, uint64_t value); |
| 54 | +__aicore__ inline int8_t asc_load_dev(__gm__ int8_t* addr); | ||
| 55 | +__aicore__ inline uint8_t asc_load_dev(__gm__ uint8_t* addr); | ||
| 56 | +__aicore__ inline int16_t asc_load_dev(__gm__ int16_t* addr); | ||
| 57 | +__aicore__ inline uint16_t asc_load_dev(__gm__ uint16_t* addr); | ||
| 58 | +__aicore__ inline int32_t asc_load_dev(__gm__ int32_t* addr); | ||
| 59 | +__aicore__ inline uint32_t asc_load_dev(__gm__ uint32_t* addr); | ||
| 60 | +__aicore__ inline int64_t asc_load_dev(__gm__ int64_t* addr); | ||
| 61 | +__aicore__ inline uint64_t asc_load_dev(__gm__ uint64_t* addr); | ||
| 54 | namespace __asc_aicore { | 62 | namespace __asc_aicore { |
| 55 | __aicore__ inline int32_t asc_atomic_add(__gm__ int32_t* address, int32_t val); | 63 | __aicore__ inline int32_t asc_atomic_add(__gm__ int32_t* address, int32_t val); |
| 56 | __aicore__ inline uint32_t asc_atomic_add(__gm__ uint32_t* address, uint32_t val); | 64 | __aicore__ inline uint32_t asc_atomic_add(__gm__ uint32_t* address, uint32_t val); |
| @@ -122,6 +122,8 @@ static void test_host_c_api_reg_compute_3() | |||
| 122 | using ::asc_deintlv_b8; | 122 | using ::asc_deintlv_b8; |
| 123 | using ::asc_div; | 123 | using ::asc_div; |
| 124 | using ::asc_duplicate; | 124 | using ::asc_duplicate; |
| 125 | + using ::asc_duplicate_highest; | ||
| 126 | + using ::asc_duplicate_highest_merge; | ||
| 125 | using ::asc_duplicate_merge; | 127 | using ::asc_duplicate_merge; |
| 126 | using ::asc_duplicate_scalar; | 128 | using ::asc_duplicate_scalar; |
| 127 | using ::asc_duplicate_scalar_merge; | 129 | using ::asc_duplicate_scalar_merge; |
| @@ -20,6 +20,7 @@ static void test_host_c_api_scalar_compute_0() | |||
| 20 | using ::asc_float2int32_rn; | 20 | using ::asc_float2int32_rn; |
| 21 | using ::asc_float2int32_rna; | 21 | using ::asc_float2int32_rna; |
| 22 | using ::asc_float2int32_ru; | 22 | using ::asc_float2int32_ru; |
| 23 | + using ::asc_load_dev; | ||
| 23 | using ::asc_popc; | 24 | using ::asc_popc; |
| 24 | using ::asc_set_nthbit; | 25 | using ::asc_set_nthbit; |
| 25 | using ::asc_sflbits; | 26 | using ::asc_sflbits; |
| @@ -0,0 +1,62 @@ | |||
| 1 | +/** | ||
| 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | + * See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | + */ | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + | ||
| 17 | +int64_t ld_dev(__gm__ int64_t*, int16_t) { return 0; } | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + namespace { \ | ||
| 21 | + uint64_t ld_dev_##data_type##_stub(__gm__ cce_type* addr, int16_t offset) \ | ||
| 22 | + { \ | ||
| 23 | + EXPECT_EQ(offset, 0); \ | ||
| 24 | + return static_cast<uint64_t>(raw_value); \ | ||
| 25 | + } \ | ||
| 26 | + } \ | ||
| 27 | + \ | ||
| 28 | + TEST(AscLoadDev, data_type) \ | ||
| 29 | + { \ | ||
| 30 | + __gm__ data_type* addr = nullptr; \ | ||
| 31 | + static_assert(std::is_same_v<decltype(asc_load_dev(addr)), data_type>); \ | ||
| 32 | + MOCKER_CPP(ld_dev, uint64_t(__gm__ cce_type*, int16_t)).times(1).will(invoke(ld_dev_##data_type##_stub)); \ | ||
| 33 | + EXPECT_EQ(asc_load_dev(addr), static_cast<data_type>(expected_value)); \ | ||
| 34 | + GlobalMockObject::verify(); \ | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | +TEST_ASC_LOAD_DEV(int8_t, uint8_t, UINT8_MAX, -1) | ||
| 38 | +TEST_ASC_LOAD_DEV(uint8_t, uint8_t, 1, 1) | ||
| 39 | +TEST_ASC_LOAD_DEV(int16_t, uint16_t, UINT16_MAX, -1) | ||
| 40 | +TEST_ASC_LOAD_DEV(uint16_t, uint16_t, 2, 2) | ||
| 41 | +TEST_ASC_LOAD_DEV(int32_t, uint32_t, UINT32_MAX, -1) | ||
| 42 | +TEST_ASC_LOAD_DEV(uint32_t, uint32_t, 3, 3) | ||
| 43 | +TEST_ASC_LOAD_DEV(uint64_t, uint64_t, 4, 4) | ||
| 44 | + | ||
| 45 | +namespace { | ||
| 46 | +int64_t ld_dev_int64_t_stub(__gm__ int64_t* addr, int16_t offset) | ||
| 47 | +{ | ||
| 48 | + EXPECT_EQ(offset, 0); | ||
| 49 | + return -1; | ||
| 50 | +} | ||
| 51 | +} // namespace | ||
| 52 | + | ||
| 53 | +TEST(AscLoadDev, int64_t) | ||
| 54 | +{ | ||
| 55 | + __gm__ int64_t* addr = nullptr; | ||
| 56 | + static_assert(std::is_same_v<decltype(asc_load_dev(addr)), int64_t>); | ||
| 57 | + MOCKER_CPP(ld_dev, int64_t(__gm__ int64_t*, int16_t)).times(1).will(invoke(ld_dev_int64_t_stub)); | ||
| 58 | + EXPECT_EQ(asc_load_dev(addr), -1); | ||
| 59 | + GlobalMockObject::verify(); | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | + | ||
| @@ -1,97 +1,170 @@ | |||
| 1 | -/** | 1 | +/** |
| 2 | - * Copyright (c) 2025 Huawei Technologies Co., Ltd. | 2 | + * Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | - */ | 9 | + */ |
| 10 | - | 10 | + |
| 11 | -#include <gtest/gtest.h> | 11 | +#include <gtest/gtest.h> |
| 12 | -#include <mockcpp/mockcpp.hpp> | 12 | +#include <mockcpp/mockcpp.hpp> |
| 13 | -#include "tests/api/c_api/stub/cce_stub.h" | 13 | +#include "tests/api/c_api/stub/cce_stub.h" |
| 14 | -#include "include/c_api/asc_simd.h" | 14 | +#include "include/c_api/asc_simd.h" |
| 15 | - | 15 | + |
| 16 | -#define TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(class_name, c_api_name, cce_name, data_type) \ | 16 | +#define TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(class_name, c_api_name, cce_name, data_type) \ |
| 17 | - \ | 17 | + \ |
| 18 | - class TestVectorCompute##class_name####data_type##CApi : public testing::Test { \ | 18 | + class TestVectorCompute##class_name####data_type##CApi : public testing::Test { \ |
| 19 | - protected: \ | 19 | + protected: \ |
| 20 | - void SetUp() {} \ | 20 | + void SetUp() {} \ |
| 21 | - void TearDown() {} \ | 21 | + void TearDown() {} \ |
| 22 | - }; \ | 22 | + }; \ |
| 23 | - \ | 23 | + \ |
| 24 | - namespace { \ | 24 | + namespace { \ |
| 25 | - void cce_name##_##data_type##_Stub(data_type& dst, data_type src0, vector_bool mask, int32_t pos, Literal mode) {} \ | 25 | + void cce_name##_##data_type##_Stub(data_type& dst, data_type src0, vector_bool mask, int32_t pos, Literal mode) {} \ |
| 26 | - } \ | 26 | + } \ |
| 27 | - \ | 27 | + \ |
| 28 | - TEST_F(TestVectorCompute##class_name####data_type##CApi, c_api_name##_##data_type##_Succ) \ | 28 | + TEST_F(TestVectorCompute##class_name####data_type##CApi, c_api_name##_##data_type##_Succ) \ |
| 29 | - { \ | 29 | + { \ |
| 30 | - data_type dst; \ | 30 | + data_type dst; \ |
| 31 | - data_type src0; \ | 31 | + data_type src0; \ |
| 32 | - vector_bool mask; \ | 32 | + vector_bool mask; \ |
| 33 | - \ | 33 | + \ |
| 34 | - MOCKER_CPP(cce_name, void(data_type&, data_type, vector_bool, int32_t, Literal)) \ | 34 | + MOCKER_CPP(cce_name, void(data_type&, data_type, vector_bool, int32_t, Literal)) \ |
| 35 | - .times(1) \ | 35 | + .times(1) \ |
| 36 | - .will(invoke(cce_name##_##data_type##_Stub)); \ | 36 | + .will(invoke(cce_name##_##data_type##_Stub)); \ |
| 37 | - \ | 37 | + \ |
| 38 | - c_api_name(dst, src0, mask); \ | 38 | + c_api_name(dst, src0, mask); \ |
| 39 | - GlobalMockObject::verify(); \ | 39 | + GlobalMockObject::verify(); \ |
| 40 | - } | 40 | + } |
| 41 | - | 41 | + |
| 42 | -TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_uint8_t); | 42 | +TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_uint8_t); |
| 43 | -TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_int8_t); | 43 | +TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_int8_t); |
| 44 | -TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_fp8_e4m3fn_t); | 44 | +TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_fp8_e4m3fn_t); |
| 45 | -TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_fp8_e5m2_t); | 45 | +TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_fp8_e5m2_t); |
| 46 | -TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_fp8_e8m0_t); | 46 | +TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_fp8_e8m0_t); |
| 47 | -TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_uint16_t); | 47 | +TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_uint16_t); |
| 48 | -TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_int16_t); | 48 | +TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_int16_t); |
| 49 | -TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_half); | 49 | +TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_half); |
| 50 | -TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_bfloat16_t); | 50 | +TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_bfloat16_t); |
| 51 | -TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_uint32_t); | 51 | +TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_uint32_t); |
| 52 | -TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_int32_t); | 52 | +TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_int32_t); |
| 53 | -TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_float); | 53 | +TEST_VECTOR_COMPUTE_DUPLICATE_INSTR(Vdup, asc_duplicate, vdup, vector_float); |
| 54 | - | 54 | + |
| 55 | -#define TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(class_name, c_api_name, cce_name, data_type) \ | 55 | +#define TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_INSTR(data_type) \ |
| 56 | - \ | 56 | + namespace { \ |
| 57 | - class TestVectorCompute##class_name####data_type##MergeCApi : public testing::Test { \ | 57 | + void vdup_highest_##data_type##_Stub(data_type& dst, data_type src0, vector_bool mask, int32_t pos, Literal mode) \ |
| 58 | - protected: \ | 58 | + { \ |
| 59 | - void SetUp() {} \ | 59 | + EXPECT_EQ(pos, static_cast<int32_t>(POS_HIGHEST.value)); \ |
| 60 | - void TearDown() {} \ | 60 | + EXPECT_EQ(mode, MODE_ZEROING); \ |
| 61 | - }; \ | 61 | + } \ |
| 62 | - \ | 62 | + } \ |
| 63 | - namespace { \ | 63 | + \ |
| 64 | - void cce_name##_merging_##data_type##_Stub( \ | 64 | + TEST(TestVectorComputeVdupHighest, data_type) \ |
| 65 | - data_type& dst, data_type src0, vector_bool mask, int32_t pos, Literal mode) \ | 65 | + { \ |
| 66 | - { \ | 66 | + data_type dst; \ |
| 67 | - EXPECT_EQ(pos, static_cast<int32_t>(POS_LOWEST.value)); \ | 67 | + data_type src0; \ |
| 68 | - EXPECT_EQ(mode, MODE_MERGING); \ | 68 | + vector_bool mask; \ |
| 69 | - } \ | 69 | + MOCKER_CPP(vdup, void(data_type&, data_type, vector_bool, int32_t, Literal)) \ |
| 70 | - } \ | 70 | + .times(1) \ |
| 71 | - \ | 71 | + .will(invoke(vdup_highest_##data_type##_Stub)); \ |
| 72 | - TEST_F(TestVectorCompute##class_name####data_type##MergeCApi, c_api_name##_##data_type##_MergeSucc) \ | 72 | + asc_duplicate_highest(dst, src0, mask); \ |
| 73 | - { \ | 73 | + GlobalMockObject::verify(); \ |
| 74 | - data_type dst; \ | 74 | + } |
| 75 | - data_type src0; \ | 75 | + |
| 76 | - vector_bool mask; \ | 76 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_INSTR(vector_uint8_t) |
| 77 | - \ | 77 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_INSTR(vector_int8_t) |
| 78 | - MOCKER_CPP(cce_name, void(data_type&, data_type, vector_bool, int32_t, Literal)) \ | 78 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_INSTR(vector_fp8_e4m3fn_t) |
| 79 | - .times(1) \ | 79 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_INSTR(vector_fp8_e5m2_t) |
| 80 | - .will(invoke(cce_name##_merging_##data_type##_Stub)); \ | 80 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_INSTR(vector_fp8_e8m0_t) |
| 81 | - \ | 81 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_INSTR(vector_uint16_t) |
| 82 | - c_api_name(dst, src0, mask); \ | 82 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_INSTR(vector_int16_t) |
| 83 | - GlobalMockObject::verify(); \ | 83 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_INSTR(vector_half) |
| 84 | - } | 84 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_INSTR(vector_bfloat16_t) |
| 85 | - | 85 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_INSTR(vector_uint32_t) |
| 86 | -TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_uint8_t); | 86 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_INSTR(vector_int32_t) |
| 87 | -TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_int8_t); | 87 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_INSTR(vector_float) |
| 88 | -TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_fp8_e4m3fn_t); | 88 | + |
| 89 | -TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_fp8_e5m2_t); | 89 | +#undef TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_INSTR |
| 90 | -TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_fp8_e8m0_t); | 90 | + |
| 91 | -TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_uint16_t); | 91 | +#define TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(class_name, c_api_name, cce_name, data_type) \ |
| 92 | -TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_int16_t); | 92 | + \ |
| 93 | -TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_half); | 93 | + class TestVectorCompute##class_name####data_type##MergeCApi : public testing::Test { \ |
| 94 | -TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_bfloat16_t); | 94 | + protected: \ |
| 95 | -TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_uint32_t); | 95 | + void SetUp() {} \ |
| 96 | -TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_int32_t); | 96 | + void TearDown() {} \ |
| 97 | -TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_float); | 97 | + }; \ |
| 98 | + \ | ||
| 99 | + namespace { \ | ||
| 100 | + void cce_name##_merging_##data_type##_Stub( \ | ||
| 101 | + data_type& dst, data_type src0, vector_bool mask, int32_t pos, Literal mode) \ | ||
| 102 | + { \ | ||
| 103 | + EXPECT_EQ(pos, static_cast<int32_t>(POS_LOWEST.value)); \ | ||
| 104 | + EXPECT_EQ(mode, MODE_MERGING); \ | ||
| 105 | + } \ | ||
| 106 | + } \ | ||
| 107 | + \ | ||
| 108 | + TEST_F(TestVectorCompute##class_name####data_type##MergeCApi, c_api_name##_##data_type##_MergeSucc) \ | ||
| 109 | + { \ | ||
| 110 | + data_type dst; \ | ||
| 111 | + data_type src0; \ | ||
| 112 | + vector_bool mask; \ | ||
| 113 | + \ | ||
| 114 | + MOCKER_CPP(cce_name, void(data_type&, data_type, vector_bool, int32_t, Literal)) \ | ||
| 115 | + .times(1) \ | ||
| 116 | + .will(invoke(cce_name##_merging_##data_type##_Stub)); \ | ||
| 117 | + \ | ||
| 118 | + c_api_name(dst, src0, mask); \ | ||
| 119 | + GlobalMockObject::verify(); \ | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | +TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_uint8_t); | ||
| 123 | +TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_int8_t); | ||
| 124 | +TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_fp8_e4m3fn_t); | ||
| 125 | +TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_fp8_e5m2_t); | ||
| 126 | +TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_fp8_e8m0_t); | ||
| 127 | +TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_uint16_t); | ||
| 128 | +TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_int16_t); | ||
| 129 | +TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_half); | ||
| 130 | +TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_bfloat16_t); | ||
| 131 | +TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_uint32_t); | ||
| 132 | +TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_int32_t); | ||
| 133 | +TEST_VECTOR_COMPUTE_DUPLICATE_MERGE_INSTR(Vdup, asc_duplicate_merge, vdup, vector_float); | ||
| 134 | + | ||
| 135 | + | ||
| 136 | + namespace { \ | ||
| 137 | + void vdup_highest_merge_##data_type##_Stub( \ | ||
| 138 | + data_type& dst, data_type src0, vector_bool mask, int32_t pos, Literal mode) \ | ||
| 139 | + { \ | ||
| 140 | + EXPECT_EQ(pos, static_cast<int32_t>(POS_HIGHEST.value)); \ | ||
| 141 | + EXPECT_EQ(mode, MODE_MERGING); \ | ||
| 142 | + } \ | ||
| 143 | + } \ | ||
| 144 | + \ | ||
| 145 | + TEST(TestVectorComputeVdupHighestMerge, data_type) \ | ||
| 146 | + { \ | ||
| 147 | + data_type dst; \ | ||
| 148 | + data_type src0; \ | ||
| 149 | + vector_bool mask; \ | ||
| 150 | + MOCKER_CPP(vdup, void(data_type&, data_type, vector_bool, int32_t, Literal)) \ | ||
| 151 | + .times(1) \ | ||
| 152 | + .will(invoke(vdup_highest_merge_##data_type##_Stub)); \ | ||
| 153 | + asc_duplicate_highest_merge(dst, src0, mask); \ | ||
| 154 | + GlobalMockObject::verify(); \ | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_MERGE_INSTR(vector_uint8_t) | ||
| 158 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_MERGE_INSTR(vector_int8_t) | ||
| 159 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_MERGE_INSTR(vector_fp8_e4m3fn_t) | ||
| 160 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_MERGE_INSTR(vector_fp8_e5m2_t) | ||
| 161 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_MERGE_INSTR(vector_fp8_e8m0_t) | ||
| 162 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_MERGE_INSTR(vector_uint16_t) | ||
| 163 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_MERGE_INSTR(vector_int16_t) | ||
| 164 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_MERGE_INSTR(vector_half) | ||
| 165 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_MERGE_INSTR(vector_bfloat16_t) | ||
| 166 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_MERGE_INSTR(vector_uint32_t) | ||
| 167 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_MERGE_INSTR(vector_int32_t) | ||
| 168 | +TEST_VECTOR_COMPUTE_DUPLICATE_HIGHEST_MERGE_INSTR(vector_float) | ||
| 169 | + | ||
| 170 | + | ||
| @@ -12,6 +12,9 @@ | |||
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | +// The compiler supports this overload, but it is missing from the CPU debug stub header. | ||
| 16 | +int64_t ld_dev(__gm__ int64_t* src, int16_t offset); | ||
| 17 | + | ||
| 15 | 18 | ||
| 16 | 19 | ||
| 17 | 20 | ||


新增文件要同步修改api目录下的README.md文件和C API列表