已合并
新增capi接口,提供数据归约求和,发送/等待同步点,设置/获取核间同步寄存器基地址能力 #431
zhangyike创建于 2月9日
新增capi接口,提供数据归约求和,发送/等待同步点,设置/获取核间同步寄存器基地址能力 #431
已合并
共 16 个文件变更+569-0
| @@ -33,6 +33,8 @@ | |||
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | 35 | ||
| 36 | + | ||
| 37 | + | ||
| 36 | 38 | ||
| 37 | __aicore__ inline void asc_sync_vec() | 39 | __aicore__ inline void asc_sync_vec() |
| 38 | { | 40 | { |
| @@ -54,6 +56,16 @@ __aicore__ inline void asc_sync() | |||
| 54 | asc_sync_impl(); | 56 | asc_sync_impl(); |
| 55 | } | 57 | } |
| 56 | 58 | ||
| 59 | +__aicore__ inline void asc_sync_block_arrive(pipe_t pipe, uint8_t mode, int64_t flagID) | ||
| 60 | +{ | ||
| 61 | + asc_sync_block_arrive_impl(pipe, mode, flagID); | ||
| 62 | +} | ||
| 63 | + | ||
| 64 | +__aicore__ inline void asc_sync_block_wait(int64_t flagID) | ||
| 65 | +{ | ||
| 66 | + asc_sync_block_wait_impl(flagID); | ||
| 67 | +} | ||
| 68 | + | ||
| 57 | 69 | ||
| 58 | 70 | ||
| 59 | 71 | ||
| @@ -0,0 +1,35 @@ | |||
| 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 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +__aicore__ inline void asc_sync_block_arrive_impl(pipe_t pipe, uint8_t mode, int64_t flagID) | ||
| 24 | +{ | ||
| 25 | + uint64_t config = 0x1ULL | (static_cast<uint64_t>(mode) << 4) | (static_cast<uint64_t>(flagID) << 8); | ||
| 26 | + ffts_cross_core_sync(pipe, config); | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + | ||
| 33 | + | ||
| 34 | + | ||
| 35 | + | ||
| @@ -0,0 +1,34 @@ | |||
| 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 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +__aicore__ inline void asc_sync_block_wait_impl(int64_t flagID) | ||
| 24 | +{ | ||
| 25 | + wait_flag_dev(flagID); | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + | ||
| 33 | + | ||
| 34 | + | ||
| @@ -30,6 +30,8 @@ | |||
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | + | ||
| 34 | + | ||
| 33 | 35 | ||
| 34 | __aicore__ inline int64_t asc_get_core_id() | 36 | __aicore__ inline int64_t asc_get_core_id() |
| 35 | { | 37 | { |
| @@ -91,6 +93,16 @@ __aicore__ inline int64_t asc_get_program_counter() | |||
| 91 | return asc_get_program_counter_impl(); | 93 | return asc_get_program_counter_impl(); |
| 92 | } | 94 | } |
| 93 | 95 | ||
| 96 | +__aicore__ inline int64_t asc_get_ffts_base_addr() | ||
| 97 | +{ | ||
| 98 | + return asc_get_ffts_base_addr_impl(); | ||
| 99 | +} | ||
| 100 | + | ||
| 101 | +__aicore__ inline void asc_set_ffts_base_addr(uint64_t config) | ||
| 102 | +{ | ||
| 103 | + asc_set_ffts_base_addr_impl(config); | ||
| 104 | +} | ||
| 105 | + | ||
| 94 | 106 | ||
| 95 | 107 | ||
| 96 | 108 | ||
| @@ -0,0 +1,34 @@ | |||
| 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 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +__aicore__ inline int64_t asc_get_ffts_base_addr_impl() | ||
| 24 | +{ | ||
| 25 | + return get_ffts_base_addr(); | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + | ||
| 33 | + | ||
| 34 | + | ||
| @@ -0,0 +1,34 @@ | |||
| 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 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +__aicore__ inline void asc_set_ffts_base_addr_impl(uint64_t config) | ||
| 24 | +{ | ||
| 25 | + set_ffts_base_addr(config); | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + | ||
| 33 | + | ||
| 34 | + | ||
| @@ -153,6 +153,7 @@ | |||
| 153 | 153 | ||
| 154 | 154 | ||
| 155 | 155 | ||
| 156 | + | ||
| 156 | 157 | ||
| 157 | // ==========asc_add(half/float/int16_t/int32_t)========== | 158 | // ==========asc_add(half/float/int16_t/int32_t)========== |
| 158 | __aicore__ inline void asc_add(__ubuf__ half* dst, __ubuf__ half* src0, __ubuf__ half* src1, uint32_t count) | 159 | __aicore__ inline void asc_add(__ubuf__ half* dst, __ubuf__ half* src0, __ubuf__ half* src1, uint32_t count) |
| @@ -5066,6 +5067,39 @@ __aicore__ inline int64_t asc_get_rsvd_count() | |||
| 5066 | return asc_get_rsvd_count_impl(); | 5067 | return asc_get_rsvd_count_impl(); |
| 5067 | } | 5068 | } |
| 5068 | 5069 | ||
| 5070 | +//==========asc_pair_reduce_sum(half/float)============ | ||
| 5071 | +__aicore__ inline void asc_pair_reduce_sum(__ubuf__ half* dst, __ubuf__ half* src, uint8_t repeat, uint16_t dst_repeat_stride, | ||
| 5072 | + uint16_t src_block_stride, uint16_t src_repeat_stride) | ||
| 5073 | +{ | ||
| 5074 | + asc_pair_reduce_sum_impl(dst, src, repeat, dst_repeat_stride, src_block_stride, src_repeat_stride); | ||
| 5075 | +} | ||
| 5076 | + | ||
| 5077 | +__aicore__ inline void asc_pair_reduce_sum(__ubuf__ half* dst, __ubuf__ half* src, uint32_t count) | ||
| 5078 | +{ | ||
| 5079 | + asc_pair_reduce_sum_impl(dst, src, count); | ||
| 5080 | +} | ||
| 5081 | + | ||
| 5082 | +__aicore__ inline void asc_pair_reduce_sum_sync(__ubuf__ half* dst, __ubuf__ half* src, uint32_t count) | ||
| 5083 | +{ | ||
| 5084 | + asc_pair_reduce_sum_sync_impl(dst, src, count); | ||
| 5085 | +} | ||
| 5086 | + | ||
| 5087 | +__aicore__ inline void asc_pair_reduce_sum(__ubuf__ float* dst, __ubuf__ float* src, uint8_t repeat, uint16_t dst_repeat_stride, | ||
| 5088 | + uint16_t src_block_stride, uint16_t src_repeat_stride) | ||
| 5089 | +{ | ||
| 5090 | + asc_pair_reduce_sum_impl(dst, src, repeat, dst_repeat_stride, src_block_stride, src_repeat_stride); | ||
| 5091 | +} | ||
| 5092 | + | ||
| 5093 | +__aicore__ inline void asc_pair_reduce_sum(__ubuf__ float* dst, __ubuf__ float* src, uint32_t count) | ||
| 5094 | +{ | ||
| 5095 | + asc_pair_reduce_sum_impl(dst, src, count); | ||
| 5096 | +} | ||
| 5097 | + | ||
| 5098 | +__aicore__ inline void asc_pair_reduce_sum_sync(__ubuf__ float* dst, __ubuf__ float* src, uint32_t count) | ||
| 5099 | +{ | ||
| 5100 | + asc_pair_reduce_sum_sync_impl(dst, src, count); | ||
| 5101 | +} | ||
| 5102 | + | ||
| 5069 | 5103 | ||
| 5070 | 5104 | ||
| 5071 | 5105 | ||
| @@ -0,0 +1,79 @@ | |||
| 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 | + * \file asc_pair_reduce_sum_impl.h | ||
| 13 | + * \brief | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + "impl/c_api/instr_impl/npu_arch_2201/vector_compute_impl/asc_pair_reduce_sum_impl.h is an internal header file and must not be used directly. Functions or variables defined in this file maybe removed in the future. Please use " | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + | ||
| 28 | +__aicore__ inline void asc_pair_reduce_sum_impl(__ubuf__ half* dst, __ubuf__ half* src, uint8_t repeat, uint16_t dst_repeat_stride, | ||
| 29 | + uint16_t src_block_stride, uint16_t src_repeat_stride) | ||
| 30 | +{ | ||
| 31 | + if ASC_IS_AIV { | ||
| 32 | + vcpadd(dst, src, repeat, dst_repeat_stride, src_block_stride, src_repeat_stride); | ||
| 33 | + } | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | + | ||
| 37 | +__aicore__ inline void asc_pair_reduce_sum_impl(__ubuf__ half* dst, __ubuf__ half* src, uint32_t count) | ||
| 38 | +{ | ||
| 39 | + asc_set_mask_count_begin(count); | ||
| 40 | + asc_pair_reduce_sum_impl(dst, src, ASC_C_API_DEFAULT_REPEAT.U8, ASC_C_API_DEFAULT_BLOCK_STRIDE.U16, ASC_C_API_DEFAULT_BLOCK_STRIDE.U16, | ||
| 41 | + ASC_C_API_DEFAULT_REPEAT_STRIDE.U16); | ||
| 42 | + asc_set_mask_count_end(); | ||
| 43 | +} | ||
| 44 | + | ||
| 45 | +__aicore__ inline void asc_pair_reduce_sum_sync_impl(__ubuf__ half* dst, __ubuf__ half* src, uint32_t count) | ||
| 46 | +{ | ||
| 47 | + asc_pair_reduce_sum_impl(dst, src, count); | ||
| 48 | + asc_sync_post_process(); | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | + | ||
| 52 | +__aicore__ inline void asc_pair_reduce_sum_impl(__ubuf__ float* dst, __ubuf__ float* src, uint8_t repeat, uint16_t dst_repeat_stride, | ||
| 53 | + uint16_t src_block_stride, uint16_t src_repeat_stride) | ||
| 54 | +{ | ||
| 55 | + if ASC_IS_AIV { | ||
| 56 | + vcpadd(dst, src, repeat, dst_repeat_stride, src_block_stride, src_repeat_stride); | ||
| 57 | + } | ||
| 58 | +} | ||
| 59 | + | ||
| 60 | +__aicore__ inline void asc_pair_reduce_sum_impl(__ubuf__ float* dst, __ubuf__ float* src, uint32_t count) | ||
| 61 | +{ | ||
| 62 | + asc_set_mask_count_begin(count); | ||
| 63 | + asc_pair_reduce_sum_impl(dst, src, ASC_C_API_DEFAULT_REPEAT.U8, ASC_C_API_DEFAULT_BLOCK_STRIDE.U16, ASC_C_API_DEFAULT_BLOCK_STRIDE.U16, | ||
| 64 | + ASC_C_API_DEFAULT_REPEAT_STRIDE.U16); | ||
| 65 | + asc_set_mask_count_end(); | ||
| 66 | +} | ||
| 67 | + | ||
| 68 | +__aicore__ inline void asc_pair_reduce_sum_sync_impl(__ubuf__ float* dst, __ubuf__ float* src, uint32_t count) | ||
| 69 | +{ | ||
| 70 | + asc_pair_reduce_sum_impl(dst, src, count); | ||
| 71 | + asc_sync_post_process(); | ||
| 72 | +} | ||
| 73 | + | ||
| 74 | + | ||
| 75 | + | ||
| 76 | + | ||
| 77 | + | ||
| 78 | + | ||
| 79 | + | ||
| @@ -41,6 +41,10 @@ __aicore__ inline void asc_sync_mte2(int id); | |||
| 41 | 41 | ||
| 42 | __aicore__ inline void asc_sync(); | 42 | __aicore__ inline void asc_sync(); |
| 43 | 43 | ||
| 44 | +__aicore__ inline void asc_sync_block_arrive(pipe_t pipe, uint8_t mode, int64_t flagID); | ||
| 45 | + | ||
| 46 | +__aicore__ inline void asc_sync_block_wait(int64_t flagID); | ||
| 47 | + | ||
| 44 | 48 | ||
| 45 | 49 | ||
| 46 | 50 | ||
| @@ -55,6 +55,10 @@ __aicore__ inline void asc_get_arch_ver(uint32_t& coreVersion); | |||
| 55 | 55 | ||
| 56 | __simd_callee__ inline int64_t asc_get_ar_spr(); | 56 | __simd_callee__ inline int64_t asc_get_ar_spr(); |
| 57 | 57 | ||
| 58 | +__aicore__ inline int64_t asc_get_ffts_base_addr(); | ||
| 59 | + | ||
| 60 | +__aicore__ inline void asc_set_ffts_base_addr(uint64_t config); | ||
| 61 | + | ||
| 58 | 62 | ||
| 59 | 63 | ||
| 60 | 64 | ||
| @@ -2212,6 +2212,22 @@ __aicore__ inline void asc_le_scalar(__ubuf__ uint8_t* dst, __ubuf__ float* src, | |||
| 2212 | __aicore__ inline void asc_le_scalar_sync(__ubuf__ uint8_t* dst, __ubuf__ float* src, float value, uint8_t repeat, | 2212 | __aicore__ inline void asc_le_scalar_sync(__ubuf__ uint8_t* dst, __ubuf__ float* src, float value, uint8_t repeat, |
| 2213 | uint16_t dst_block_stride, uint16_t src_block_stride, | 2213 | uint16_t dst_block_stride, uint16_t src_block_stride, |
| 2214 | uint16_t dst_repeat_stride, uint16_t src_repeat_stride); | 2214 | uint16_t dst_repeat_stride, uint16_t src_repeat_stride); |
| 2215 | + | ||
| 2216 | +//==========asc_pair_reduce_sum(half/float)============ | ||
| 2217 | +__aicore__ inline void asc_pair_reduce_sum(__ubuf__ half* dst, __ubuf__ half* src, uint8_t repeat, uint16_t dst_repeat_stride, | ||
| 2218 | + uint16_t src_block_stride, uint16_t src_repeat_stride); | ||
| 2219 | + | ||
| 2220 | +__aicore__ inline void asc_pair_reduce_sum(__ubuf__ half* dst, __ubuf__ half* src, uint32_t count); | ||
| 2221 | + | ||
| 2222 | +__aicore__ inline void asc_pair_reduce_sum_sync(__ubuf__ half* dst, __ubuf__ half* src, uint32_t count); | ||
| 2223 | + | ||
| 2224 | +__aicore__ inline void asc_pair_reduce_sum(__ubuf__ float* dst, __ubuf__ float* src, uint8_t repeat, uint16_t dst_repeat_stride, | ||
| 2225 | + uint16_t src_block_stride, uint16_t src_repeat_stride); | ||
| 2226 | + | ||
| 2227 | +__aicore__ inline void asc_pair_reduce_sum(__ubuf__ float* dst, __ubuf__ float* src, uint32_t count); | ||
| 2228 | + | ||
| 2229 | +__aicore__ inline void asc_pair_reduce_sum_sync(__ubuf__ float* dst, __ubuf__ float* src, uint32_t count); | ||
| 2230 | + | ||
| 2215 | 2231 | ||
| 2216 | 2232 | ||
| 2217 | 2233 | ||
| @@ -0,0 +1,42 @@ | |||
| 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 | +class TestSyncBlkArrive : public testing::Test { | ||
| 18 | +protected: | ||
| 19 | + void SetUp() {} | ||
| 20 | + void TearDown() {} | ||
| 21 | +}; | ||
| 22 | + | ||
| 23 | +namespace { | ||
| 24 | +void asc_sync_block_arrive_stub(pipe_t pipe, uint64_t config) | ||
| 25 | +{ | ||
| 26 | + EXPECT_EQ(273, config); | ||
| 27 | +} | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +TEST_F(TestSyncBlkArrive, sync_block_arrive_Succ) | ||
| 31 | +{ | ||
| 32 | + uint8_t mode = 1; | ||
| 33 | + int64_t flagID = 1; | ||
| 34 | + uint64_t config = 273; | ||
| 35 | + pipe_t pipe = PIPE_S; | ||
| 36 | + MOCKER_CPP(ffts_cross_core_sync, void(pipe_t, uint64_t)) | ||
| 37 | + .times(1) | ||
| 38 | + .will(invoke(asc_sync_block_arrive_stub)); | ||
| 39 | + | ||
| 40 | + asc_sync_block_arrive(pipe, mode, flagID); | ||
| 41 | + GlobalMockObject::verify(); | ||
| 42 | +} | ||
| @@ -0,0 +1,39 @@ | |||
| 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 | +class TestSyncBlkWait : public testing::Test { | ||
| 18 | +protected: | ||
| 19 | + void SetUp() {} | ||
| 20 | + void TearDown() {} | ||
| 21 | +}; | ||
| 22 | + | ||
| 23 | +namespace { | ||
| 24 | +void asc_sync_block_wait_stub(int64_t flagID) | ||
| 25 | +{ | ||
| 26 | + EXPECT_EQ(33, flagID); | ||
| 27 | +} | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +TEST_F(TestSyncBlkWait, sync_block_wait_Succ) | ||
| 31 | +{ | ||
| 32 | + int64_t flagID = 33; | ||
| 33 | + MOCKER_CPP(wait_flag_dev, void(int64_t)) | ||
| 34 | + .times(1) | ||
| 35 | + .will(invoke(asc_sync_block_wait_stub)); | ||
| 36 | + | ||
| 37 | + asc_sync_block_wait(flagID); | ||
| 38 | + GlobalMockObject::verify(); | ||
| 39 | +} | ||
| @@ -0,0 +1,40 @@ | |||
| 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 | +class TestGetFftsBaseAddr : public testing::Test { | ||
| 18 | +protected: | ||
| 19 | + void SetUp() {} | ||
| 20 | + void TearDown() {} | ||
| 21 | +}; | ||
| 22 | + | ||
| 23 | +namespace { | ||
| 24 | +int64_t asc_get_ffts_base_addr_stub() | ||
| 25 | +{ | ||
| 26 | + return 2; | ||
| 27 | +} | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +TEST_F(TestGetFftsBaseAddr, asc_get_ffts_base_addr_Succ) | ||
| 31 | +{ | ||
| 32 | + | ||
| 33 | + MOCKER_CPP(get_ffts_base_addr, int64_t(void)) | ||
| 34 | + .times(1) | ||
| 35 | + .will(invoke(asc_get_ffts_base_addr_stub)); | ||
| 36 | + | ||
| 37 | + int64_t val = asc_get_ffts_base_addr(); | ||
| 38 | + EXPECT_EQ(2, val); | ||
| 39 | + GlobalMockObject::verify(); | ||
| 40 | +} | ||
| @@ -0,0 +1,39 @@ | |||
| 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 | +class TestSetFftsBaseAddr : public testing::Test { | ||
| 18 | +protected: | ||
| 19 | + void SetUp() {} | ||
| 20 | + void TearDown() {} | ||
| 21 | +}; | ||
| 22 | + | ||
| 23 | +namespace { | ||
| 24 | +void asc_set_ffts_base_addr_stub(uint64_t config) | ||
| 25 | +{ | ||
| 26 | + EXPECT_EQ(33U, config); | ||
| 27 | +} | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +TEST_F(TestSetFftsBaseAddr, asc_set_ffts_base_addr_Succ) | ||
| 31 | +{ | ||
| 32 | + uint64_t config = 33; | ||
| 33 | + MOCKER_CPP(set_ffts_base_addr, void(uint64_t)) | ||
| 34 | + .times(1) | ||
| 35 | + .will(invoke(asc_set_ffts_base_addr_stub)); | ||
| 36 | + | ||
| 37 | + asc_set_ffts_base_addr(config); | ||
| 38 | + GlobalMockObject::verify(); | ||
| 39 | +} | ||
| @@ -0,0 +1,111 @@ | |||
| 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 | + \ | ||
| 18 | +class TestVectorCompute##class_name##data_type : public testing::Test { \ | ||
| 19 | +protected: \ | ||
| 20 | + void SetUp() {} \ | ||
| 21 | + void TearDown() {} \ | ||
| 22 | +}; \ | ||
| 23 | + \ | ||
| 24 | +namespace { \ | ||
| 25 | + \ | ||
| 26 | +void cce_name##_##data_type##_uint8_t_uint16_t_uint16_t_uint16_t_uint16_t_Stub(__ubuf__ data_type *dst, \ | ||
| 27 | + __ubuf__ data_type *src, uint8_t repeat, \ | ||
| 28 | + uint16_t dst_repeat_stride, uint16_t src_block_stride, \ | ||
| 29 | + uint16_t src_repeat_stride) \ | ||
| 30 | +{ \ | ||
| 31 | + EXPECT_EQ(dst, reinterpret_cast<__ubuf__ data_type *>(11)); \ | ||
| 32 | + EXPECT_EQ(src, reinterpret_cast<__ubuf__ data_type *>(22)); \ | ||
| 33 | + EXPECT_EQ(repeat, static_cast<uint8_t>(1)); \ | ||
| 34 | + EXPECT_EQ(dst_repeat_stride, static_cast<uint16_t>(1)); \ | ||
| 35 | + EXPECT_EQ(src_block_stride, static_cast<uint16_t>(1)); \ | ||
| 36 | + EXPECT_EQ(src_repeat_stride, static_cast<uint16_t>(8)); \ | ||
| 37 | +} \ | ||
| 38 | + \ | ||
| 39 | +void cce_name##_##data_type##_##data_type##_##data_type##_uint64_t_Stub(__ubuf__ data_type *dst, \ | ||
| 40 | + __ubuf__ data_type *src, uint8_t repeat, \ | ||
| 41 | + uint16_t dst_repeat_stride, uint16_t src_block_stride, \ | ||
| 42 | + uint16_t src_repeat_stride) \ | ||
| 43 | +{ \ | ||
| 44 | + EXPECT_EQ(dst, reinterpret_cast<__ubuf__ data_type *>(11)); \ | ||
| 45 | + EXPECT_EQ(src, reinterpret_cast<__ubuf__ data_type *>(22)); \ | ||
| 46 | +} \ | ||
| 47 | + \ | ||
| 48 | +void cce_name##_##data_type##_set_vector_mask_Stub(uint64_t mask1, uint64_t mask0) \ | ||
| 49 | +{ \ | ||
| 50 | + EXPECT_EQ(mask1, static_cast<uint64_t>(0)); \ | ||
| 51 | + EXPECT_EQ(mask0, static_cast<uint64_t>(44)); \ | ||
| 52 | +} \ | ||
| 53 | + \ | ||
| 54 | +} \ | ||
| 55 | + \ | ||
| 56 | +TEST_F(TestVectorCompute##class_name##data_type, c_api_name##_half_half_half_UnaryConfig_Succ) \ | ||
| 57 | +{ \ | ||
| 58 | + __ubuf__ data_type *dst = reinterpret_cast<__ubuf__ data_type *>(11); \ | ||
| 59 | + __ubuf__ data_type *src = reinterpret_cast<__ubuf__ data_type *>(22); \ | ||
| 60 | + \ | ||
| 61 | + uint16_t dst_repeat_stride = 1; \ | ||
| 62 | + uint16_t src_block_stride = 1; \ | ||
| 63 | + uint16_t src_repeat_stride = 8; \ | ||
| 64 | + uint8_t repeat = 1; \ | ||
| 65 | + \ | ||
| 66 | + MOCKER_CPP(cce_name, void(__ubuf__ data_type *,__ubuf__ data_type *, \ | ||
| 67 | + uint8_t, uint16_t, uint16_t, uint16_t)) \ | ||
| 68 | + .times(1) \ | ||
| 69 | + .will(invoke(cce_name##_##data_type##_uint8_t_uint16_t_uint16_t_uint16_t_uint16_t_Stub)); \ | ||
| 70 | + \ | ||
| 71 | + c_api_name(dst, src, repeat, dst_repeat_stride, src_block_stride, src_repeat_stride); \ | ||
| 72 | + GlobalMockObject::verify(); \ | ||
| 73 | +} \ | ||
| 74 | + \ | ||
| 75 | +TEST_F(TestVectorCompute##class_name##data_type, c_api_name##_half_half_half_int32_t_Succ) \ | ||
| 76 | +{ \ | ||
| 77 | + __ubuf__ data_type *dst = reinterpret_cast<__ubuf__ data_type *>(11); \ | ||
| 78 | + __ubuf__ data_type *src = reinterpret_cast<__ubuf__ data_type *>(22); \ | ||
| 79 | + uint32_t count = static_cast<uint32_t>(44); \ | ||
| 80 | + MOCKER_CPP(set_vector_mask, void(uint64_t, uint64_t)) \ | ||
| 81 | + .times(1) \ | ||
| 82 | + .will(invoke(cce_name##_##data_type##_set_vector_mask_Stub)); \ | ||
| 83 | + \ | ||
| 84 | + MOCKER_CPP(cce_name, void(__ubuf__ data_type *,__ubuf__ data_type *, \ | ||
| 85 | + uint8_t, uint16_t, uint16_t, uint16_t)) \ | ||
| 86 | + .times(1) \ | ||
| 87 | + .will(invoke(cce_name##_##data_type##_##data_type##_##data_type##_uint64_t_Stub)); \ | ||
| 88 | + \ | ||
| 89 | + c_api_name(dst, src, count); \ | ||
| 90 | + GlobalMockObject::verify(); \ | ||
| 91 | +} \ | ||
| 92 | + \ | ||
| 93 | +TEST_F(TestVectorCompute##class_name##data_type, c_api_name##_sync_half_half_half_int32_t_Succ) \ | ||
| 94 | +{ \ | ||
| 95 | + __ubuf__ data_type *dst = reinterpret_cast<__ubuf__ data_type *>(11); \ | ||
| 96 | + __ubuf__ data_type *src = reinterpret_cast<__ubuf__ data_type *>(22); \ | ||
| 97 | + uint32_t count = static_cast<uint32_t>(44); \ | ||
| 98 | + MOCKER_CPP(set_vector_mask, void(uint64_t, uint64_t)) \ | ||
| 99 | + .times(1) \ | ||
| 100 | + .will(invoke(cce_name##_##data_type##_set_vector_mask_Stub)); \ | ||
| 101 | + \ | ||
| 102 | + MOCKER_CPP(cce_name, void(__ubuf__ data_type *,__ubuf__ data_type *, \ | ||
| 103 | + uint8_t, uint16_t, uint16_t, uint16_t)) \ | ||
| 104 | + .times(1) \ | ||
| 105 | + .will(invoke(cce_name##_##data_type##_##data_type##_##data_type##_uint64_t_Stub)); \ | ||
| 106 | + c_api_name##_sync(dst, src, count); \ | ||
| 107 | + GlobalMockObject::verify(); \ | ||
| 108 | +} | ||
| 109 | + | ||
| 110 | +TEST_VECTOR_COMPUTE_VCPADD_INSTR(Vcpadd, asc_pair_reduce_sum, vcpadd, half); | ||
| 111 | +TEST_VECTOR_COMPUTE_VCPADD_INSTR(Vcpadd, asc_pair_reduce_sum, vcpadd, float); | ||