已合并
将asc_vf_call移到公共文件 #4733
pangfd创建于 29 天前
将asc_vf_call移到公共文件 #4733
已合并
从已删除 :master合入到cann/asc-devkitmaster
共 7 个文件变更+104-38
| @@ -36,6 +36,7 @@ | |||
| 36 | 36 | ||
| 37 | 37 | ||
| 38 | 38 | ||
| 39 | + | ||
| 39 | 40 | ||
| 40 | 41 | ||
| 41 | 42 | ||
| @@ -276,28 +277,6 @@ enum class TimeStampId : uint32_t { | |||
| 276 | 277 | ||
| 277 | TIME_STAMP_MAX = 0xffff, | 278 | TIME_STAMP_MAX = 0xffff, |
| 278 | }; | 279 | }; |
| 279 | - | ||
| 280 | -template <auto funcPtr, typename DebugTag = Internal::SimdVfDebugTag, typename... Args> | ||
| 281 | -__aicore__ static inline void AscVFCallImpl(Args&&... args) | ||
| 282 | -{ | ||
| 283 | - if constexpr (Internal::SimdVfDebugTraits<DebugTag>::enabled) { | ||
| 284 | - AscVFDebugInitUb(); | ||
| 285 | - } | ||
| 286 | - | ||
| 287 | - funcPtr(args...); | ||
| 288 | - | ||
| 289 | - if constexpr (Internal::SimdVfDebugTraits<DebugTag>::enabled) { | ||
| 290 | - const bool hasOverflow = AscVFDebugTransferUb(); | ||
| 291 | - | ||
| 292 | - if (hasOverflow) { | ||
| 293 | - __asc_aicore::printf_impl( | ||
| 294 | - "[WARNING]: SIMD VF debug buffer overflow (max limit is 2KB), output was truncated.\n"); | ||
| 295 | - } | ||
| 296 | - | ||
| 297 | - (void)hasOverflow; | ||
| 298 | - | ||
| 299 | - } | ||
| 300 | -} | ||
| 301 | } // namespace AscendC | 280 | } // namespace AscendC |
| 302 | 281 | ||
| 303 | 282 | ||
| @@ -10,7 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | # copy std to highlevel_api impl | 11 | # copy std to highlevel_api impl |
| 12 | install( | 12 | install( |
| 13 | - DIRECTORY std debug | 13 | + DIRECTORY std debug base |
| 14 | DESTINATION ${INSTALL_LIBRARY_DIR}/asc/impl/utils | 14 | DESTINATION ${INSTALL_LIBRARY_DIR}/asc/impl/utils |
| 15 | ${INSTALL_OPTIONAL} COMPONENT asc-devkit FILES_MATCHING | 15 | ${INSTALL_OPTIONAL} COMPONENT asc-devkit FILES_MATCHING |
| 16 | PATTERN "*.h" | 16 | PATTERN "*.h" |
| @@ -0,0 +1,54 @@ | |||
| 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/utils/base/helpers_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 " | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +namespace asc { | ||
| 24 | +namespace details { | ||
| 25 | +template <auto funcPtr, typename DebugTag = AscendC::Internal::SimdVfDebugTag, typename... Args> | ||
| 26 | +__aicore__ static inline void asc_vf_call_impl(Args&&... args) | ||
| 27 | +{ | ||
| 28 | + if constexpr (AscendC::Internal::SimdVfDebugTraits<DebugTag>::enabled) { | ||
| 29 | + AscVFDebugInitUb(); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + funcPtr(args...); | ||
| 33 | + | ||
| 34 | + if constexpr (AscendC::Internal::SimdVfDebugTraits<DebugTag>::enabled) { | ||
| 35 | + const bool hasOverflow = AscVFDebugTransferUb(); | ||
| 36 | + | ||
| 37 | + if (hasOverflow) { | ||
| 38 | + __asc_aicore::printf_impl( | ||
| 39 | + "[WARNING]: SIMD VF debug buffer overflow (max limit is 2KB), output was truncated.\n"); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + (void)hasOverflow; | ||
| 43 | + | ||
| 44 | + } | ||
| 45 | +} | ||
| 46 | +} // namespace details | ||
| 47 | +} // namespace asc | ||
| 48 | + | ||
| 49 | + | ||
| 50 | + | ||
| 51 | + | ||
| 52 | + | ||
| 53 | + | ||
| 54 | + | ||
| @@ -35,6 +35,7 @@ | |||
| 35 | 35 | ||
| 36 | 36 | ||
| 37 | 37 | ||
| 38 | + | ||
| 38 | 39 | ||
| 39 | 40 | ||
| 40 | 41 | ||
| @@ -50,14 +51,6 @@ template <typename T> | |||
| 50 | class GlobalTensor; | 51 | class GlobalTensor; |
| 51 | } // namespace AscendC | 52 | } // namespace AscendC |
| 52 | 53 | ||
| 53 | -template <auto funcPtr, typename... Args> | ||
| 54 | -__aicore__ inline void asc_vf_call(Args&&... args) | ||
| 55 | -{ | ||
| 56 | - if ASCEND_IS_AIV { | ||
| 57 | - AscendC::AscVFCallImpl<funcPtr, AscendC::Internal::SimdVfDebugTag>(args...); | ||
| 58 | - } | ||
| 59 | -} | ||
| 60 | - | ||
| 61 | 54 | ||
| 62 | __BLOCK_LOCAL__ __inline__ uint32_t g_super_kernel_early_start_config; | 55 | __BLOCK_LOCAL__ __inline__ uint32_t g_super_kernel_early_start_config; |
| 63 | 56 | ||
| @@ -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 | + * \file helpers.h | ||
| 13 | + * \brief Provides Ascend C helper functions and service. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + | ||
| 26 | +template <auto func_ptr, typename... Args> | ||
| 27 | +__aicore__ inline void asc_vf_call(Args&&... args) | ||
| 28 | +{ | ||
| 29 | + if ASCEND_IS_AIV { | ||
| 30 | + asc::details::asc_vf_call_impl<func_ptr>(args...); | ||
| 31 | + } | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | + | ||
| 35 | + | ||
| 36 | + | ||
| 37 | + | ||
| 38 | + | ||
| 39 | + | ||
| @@ -39,23 +39,23 @@ TEST_F(TestVFDebug, AscVFDebugTransferUb_Callable) | |||
| 39 | SUCCEED(); | 39 | SUCCEED(); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | -TEST_F(TestVFDebug, AscVFCallImpl_CallsTargetFunction) | 42 | +TEST_F(TestVFDebug, asc_vf_call_impl_CallsTargetFunction) |
| 43 | { | 43 | { |
| 44 | - // Verify AscVFCallImpl (defined in impl/basic_api/kernel_utils.h) invokes the target | 44 | + // Verify asc_vf_call_impl invokes the target |
| 45 | // function after AscVFDebugInitUb and before AscVFDebugTransferUb. | 45 | // function after AscVFDebugInitUb and before AscVFDebugTransferUb. |
| 46 | - AscVFCallImpl<TestTargetFunc>(42); | 46 | + asc::details::asc_vf_call_impl<TestTargetFunc>(42); |
| 47 | EXPECT_EQ(g_testFlag, 42); | 47 | EXPECT_EQ(g_testFlag, 42); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | -TEST_F(TestVFDebug, AscVFCallImpl_InitAndTransferCalled) | 50 | +TEST_F(TestVFDebug, asc_vf_call_impl_InitAndTransferCalled) |
| 51 | { | 51 | { |
| 52 | // Verify both AscVFDebugInitUb and AscVFDebugTransferUb (defined in | 52 | // Verify both AscVFDebugInitUb and AscVFDebugTransferUb (defined in |
| 53 | - // impl/utils/debug/asc_debug_utils.h) are callable within AscVFCallImpl. | 53 | + // impl/utils/debug/asc_debug_utils.h) are callable within asc_vf_call_impl. |
| 54 | g_testFlag = 0; | 54 | g_testFlag = 0; |
| 55 | - AscVFCallImpl<TestTargetFunc>(100); | 55 | + asc::details::asc_vf_call_impl<TestTargetFunc>(100); |
| 56 | EXPECT_EQ(g_testFlag, 100); | 56 | EXPECT_EQ(g_testFlag, 100); |
| 57 | 57 | ||
| 58 | g_testFlag = 0; | 58 | g_testFlag = 0; |
| 59 | - AscVFCallImpl<TestTargetFunc>(-1); | 59 | + asc::details::asc_vf_call_impl<TestTargetFunc>(-1); |
| 60 | EXPECT_EQ(g_testFlag, -1); | 60 | EXPECT_EQ(g_testFlag, -1); |
| 61 | } | 61 | } |