已合并
新增capi接口,提供数据归约求和,发送/等待同步点,设置/获取核间同步寄存器基地址能力 #431
zhangyike创建于 2月9日
新增capi接口,提供数据归约求和,发送/等待同步点,设置/获取核间同步寄存器基地址能力 #431
已合并
zhangyike创建于 2月9日
16 个文件变更+569-0
@@ -33,6 +33,8 @@
33#include "sync_impl/asc_wait_flag_impl.h"33#include "sync_impl/asc_wait_flag_impl.h"
34#include "sync_impl/asc_pipe_barrier_impl.h"34#include "sync_impl/asc_pipe_barrier_impl.h"
35#include "sync_impl/asc_sync_data_barrier_impl.h"35#include "sync_impl/asc_sync_data_barrier_impl.h"
36+#include "sync_impl/asc_sync_block_arrive_impl.h"
37+#include "sync_impl/asc_sync_block_wait_impl.h"
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#endif69#endif
58 70 
59#if defined(UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC) 71#if defined(UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC)
@@ -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+#if !defined(ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS)
13+#warning "impl/c_api/instr_impl/npu_arch_2201/sync_impl/asc_sync_block_arrive_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 "#include "c_api/asc_simd.h"" and use public functions or variables defined in interface headers files."
14+#define ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS
15+#define UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC
16+#endif
17+ 
18+#ifndef IMPL_C_API_INSTR_IMPL_NPU_ARCH_2201_SYNC_IMPL_ASC_SYNC_BLOCK_ARRIVE_IMPL_H
19+#define IMPL_C_API_INSTR_IMPL_NPU_ARCH_2201_SYNC_IMPL_ASC_SYNC_BLOCK_ARRIVE_IMPL_H
20+ 
21+#include "instr_impl/npu_arch_2201/utils_impl/utils_impl.h"
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+#endif
30+ 
31+#if defined(UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC)
32+#undef ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS
33+#undef UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC
34+#endif
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+#if !defined(ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS)
13+#warning "impl/c_api/instr_impl/npu_arch_2201/sync_impl/asc_sync_block_wait_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 "#include "c_api/asc_simd.h"" and use public functions or variables defined in interface headers files."
14+#define ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS
15+#define UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC
16+#endif
17+ 
18+#ifndef IMPL_C_API_INSTR_IMPL_NPU_ARCH_2201_SYNC_IMPL_ASC_SYNC_BLOCK_WAIT_IMPL_H
19+#define IMPL_C_API_INSTR_IMPL_NPU_ARCH_2201_SYNC_IMPL_ASC_SYNC_BLOCK_WAIT_IMPL_H
20+ 
21+#include "instr_impl/npu_arch_2201/utils_impl/utils_impl.h"
22+ 
23+__aicore__ inline void asc_sync_block_wait_impl(int64_t flagID)
24+{
25+ wait_flag_dev(flagID);
26+}
27+ 
28+#endif
29+ 
30+#if defined(UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC)
31+#undef ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS
32+#undef UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC
33+#endif
34+ 
@@ -30,6 +30,8 @@
30#include "sys_var_impl/asc_get_block_num_impl.h"30#include "sys_var_impl/asc_get_block_num_impl.h"
31#include "sys_var_impl/asc_get_arch_ver_impl.h"31#include "sys_var_impl/asc_get_arch_ver_impl.h"
32#include "sys_var_impl/get_program_counter_impl.h"32#include "sys_var_impl/get_program_counter_impl.h"
33+#include "sys_var_impl/asc_get_ffts_base_addr_impl.h"
34+#include "sys_var_impl/asc_set_ffts_base_addr_impl.h"
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#endif106#endif
95 107 
96#if defined(UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC) 108#if defined(UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC)
@@ -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+#if !defined(ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS)
13+#warning "impl/c_api/instr_impl/npu_arch_2201/sys_var_impl/asc_get_ffts_base_addr_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 "#include "c_api/asc_simd.h"" and use public functions or variables defined in interface headers files."
14+#define ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS
15+#define UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC
16+#endif
17+ 
18+#ifndef IMPL_C_API_INSTR_IMPL_NPU_ARCH_2201_SYS_VAR_IMPL_ASC_GET_FFTS_BASE_ADDR_IMPL_H
19+#define IMPL_C_API_INSTR_IMPL_NPU_ARCH_2201_SYS_VAR_IMPL_ASC_GET_FFTS_BASE_ADDR_IMPL_H
20+ 
21+#include "instr_impl/npu_arch_2201/utils_impl/utils_impl.h"
22+ 
23+__aicore__ inline int64_t asc_get_ffts_base_addr_impl()
24+{
25+ return get_ffts_base_addr();
26+}
27+ 
28+#endif
29+ 
30+#if defined(UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC)
31+#undef ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS
32+#undef UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC
33+#endif
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+#if !defined(ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS)
13+#warning "impl/c_api/instr_impl/npu_arch_2201/sys_var_impl/asc_set_ffts_base_addr_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 "#include "c_api/asc_simd.h"" and use public functions or variables defined in interface headers files."
14+#define ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS
15+#define UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC
16+#endif
17+ 
18+#ifndef IMPL_C_API_INSTR_IMPL_NPU_ARCH_2201_SYS_VAR_IMPL_ASC_SET_FFTS_BASE_ADDR_IMPL_H
19+#define IMPL_C_API_INSTR_IMPL_NPU_ARCH_2201_SYS_VAR_IMPL_ASC_SET_FFTS_BASE_ADDR_IMPL_H
20+ 
21+#include "instr_impl/npu_arch_2201/utils_impl/utils_impl.h"
22+ 
23+__aicore__ inline void asc_set_ffts_base_addr_impl(uint64_t config)
24+{
25+ set_ffts_base_addr(config);
26+}
27+ 
28+#endif
29+ 
30+#if defined(UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC)
31+#undef ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS
32+#undef UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC
33+#endif
34+ 
@@ -153,6 +153,7 @@
153#include "instr_impl/npu_arch_2201/vector_compute_impl/asc_transto5hd_impl.h"153#include "instr_impl/npu_arch_2201/vector_compute_impl/asc_transto5hd_impl.h"
154#include "instr_impl/npu_arch_2201/vector_compute_impl/asc_get_rsvd_cnt_impl.h"154#include "instr_impl/npu_arch_2201/vector_compute_impl/asc_get_rsvd_cnt_impl.h"
155#include "instr_impl/npu_arch_2201/vector_compute_impl/asc_set_va_reg_impl.h"155#include "instr_impl/npu_arch_2201/vector_compute_impl/asc_set_va_reg_impl.h"
156+#include "instr_impl/npu_arch_2201/vector_compute_impl/asc_pair_reduce_sum_impl.h"
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#endif5104#endif
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+#if !defined(ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS)
17+#warning \
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 "#include "c_api/asc_simd.h"" and use public functions or variables defined in interface headers files."
19+#define ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS
20+#define UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC
21+#endif
22+ 
23+#ifndef IMPL_C_API_INSTR_IMPL_NPU_ARCH_2201_VECTOR_COMPUTE_IMPL_ASC_PAIR_REDUCE_SUM_IMPL_H
24+#define IMPL_C_API_INSTR_IMPL_NPU_ARCH_2201_VECTOR_COMPUTE_IMPL_ASC_PAIR_REDUCE_SUM_IMPL_H
25+ 
26+#include "instr_impl/npu_arch_2201/utils_impl/utils_impl.h"
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+#endif
75+ 
76+#if defined(UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC)
77+#undef ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS
78+#undef UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC
79+#endif
@@ -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#endif48#endif
45 49 
46#if defined(UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC_C_API_H) 50#if defined(UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC_C_API_H)
@@ -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#endif62#endif
59 63 
60#endif64#endif
@@ -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#endif2231#endif
2216 2232 
2217#if defined(UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC_C_API_H) 2233#if defined(UNDEF_ASCENDC_C_API_INCLUDE_COMPILER_INTERNAL_HEADERS_ASCENDC_C_API_H)
@@ -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+#include <gtest/gtest.h>
12+#include <mockcpp/mockcpp.hpp>
13+#include "c_api/stub/cce_stub.h"
14+#include "c_api/asc_simd.h"
15+#include "c_api/utils_intf.h"
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+#include <gtest/gtest.h>
12+#include <mockcpp/mockcpp.hpp>
13+#include "c_api/stub/cce_stub.h"
14+#include "c_api/asc_simd.h"
15+#include "c_api/utils_intf.h"
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+#include <gtest/gtest.h>
12+#include <mockcpp/mockcpp.hpp>
13+#include "c_api/stub/cce_stub.h"
14+#include "c_api/asc_simd.h"
15+#include "c_api/utils_intf.h"
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+#include <gtest/gtest.h>
12+#include <mockcpp/mockcpp.hpp>
13+#include "c_api/stub/cce_stub.h"
14+#include "c_api/asc_simd.h"
15+#include "c_api/utils_intf.h"
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+#include <gtest/gtest.h>
12+#include <mockcpp/mockcpp.hpp>
13+#include "c_api/stub/cce_stub.h"
14+#include "c_api/asc_simd.h"
15+ 
16+#define TEST_VECTOR_COMPUTE_VCPADD_INSTR(class_name, c_api_name, cce_name, data_type) \
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);