| @@ -144,9 +144,10 @@ __simd_callee__ inline void asc_dump(__ubuf__ T* input, uint32_t desc, uint32_t | |||
| 144 | - 在计算数据量时,若dump的总长度未对齐,需要考虑padding数据的影响。当进行非对齐dump时,如果实际dump的元素长度不满足32字节对齐,系统会自动在其末尾补充一定数量的padding数据(这部分数据并不会打印),以满足对齐要求。 | 144 | - 在计算数据量时,若dump的总长度未对齐,需要考虑padding数据的影响。当进行非对齐dump时,如果实际dump的元素长度不满足32字节对齐,系统会自动在其末尾补充一定数量的padding数据(这部分数据并不会打印),以满足对齐要求。 |
| 145 | - SIMD场景下,单次调用本接口打印的数据总量不可超过打印大小限制,默认为30KB。使用时应注意,如果超出这个限制,则数据不会被打印。您可以通过acl.json中的`"simd_printf_fifo_size_per_core"`字段进行配置,配置范围最小为1KB,最大为64MB(可通过[aclInit](https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/latest/API/runtimeapi/aclcppdevg_03_0022.html)接口调整)。当打印数据量较大时,建议增加缓存空间。pytorch调用和算子入图场景暂不支持该配置。 | 145 | - SIMD场景下,单次调用本接口打印的数据总量不可超过打印大小限制,默认为30KB。使用时应注意,如果超出这个限制,则数据不会被打印。您可以通过acl.json中的`"simd_printf_fifo_size_per_core"`字段进行配置,配置范围最小为1KB,最大为64MB(可通过[aclInit](https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/latest/API/runtimeapi/aclcppdevg_03_0022.html)接口调整)。当打印数据量较大时,建议增加缓存空间。pytorch调用和算子入图场景暂不支持该配置。 |
| 146 | 146 | ||
| 147 | -- 在`simd_vf`场景下,每个AIV核在单次`asc_vf_call`执行期间最多能使用2KB的UB空间;同一次`asc_vf_call`中的所有`simd_vf`的`asc_dump`和`printf`调用共享该预留空间。 | 147 | +<!-- npu="950" id16 --> |
| 148 | +- 在`simd_vf`场景下,每个AIV核使用2KB预留UB空间作为FIFO临时缓冲区。同一次`asc_vf_call`中,`printf`、`asc_dump`和`assert`产生的累计调测数据可以超过2KB,但每条完整编码数据必须能放入该缓冲区;否则,该条数据不会打印。 | ||
| 148 | - 每次调用`simd_vf`的`asc_dump`时,除实际dump数据外,还会固定占用72字节的管理信息;实际dump数据需要按32字节向上对齐。 | 149 | - 每次调用`simd_vf`的`asc_dump`时,除实际dump数据外,还会固定占用72字节的管理信息;实际dump数据需要按32字节向上对齐。 |
| 149 | -- `simd_vf`调测接口不会检查上述预留空间是否越界。超过限制可能越界写入预留空间,导致打印结果异常,并可能影响算子执行。 | 150 | +<!-- end id16 --> |
| 150 | 151 | ||
| 151 | ## 调用示例 | 152 | ## 调用示例 |
| 152 | 153 | ||
| @@ -105,9 +105,10 @@ static __attribute__((noinline)) void printf(const char* fmt, Args&&... args); | |||
| 105 | __ubuf__ const char* fmt = "simd vf: int=%d, uint=%u, float=%f, string=%s\n"; | 105 | __ubuf__ const char* fmt = "simd vf: int=%d, uint=%u, float=%f, string=%s\n"; |
| 106 | ``` | 106 | ``` |
| 107 | 107 | ||
| 108 | -- 在`simd_vf`场景下,每个AIV核在单次`asc_vf_call`执行期间最多能使用2KB的Unified Buffer(UB)空间;同一次`asc_vf_call`中的所有`simd_vf`的`printf`和`asc_dump`调用共享该预留空间。 | 108 | +<!-- npu="950" id15 --> |
| 109 | +- 在`simd_vf`场景下,每个AIV核使用2KB预留UB空间作为FIFO临时缓冲区。同一次`asc_vf_call`中,`printf`、`asc_dump`和`assert`产生的累计调测数据可以超过2KB,但每条完整编码数据必须能放入该缓冲区;否则,该条数据不会打印。 | ||
| 109 | - 每次调用`simd_vf`的`printf`时,除格式字符串和参数外,还会固定占用32字节;整条打印数据需要按8字节对齐。 | 110 | - 每次调用`simd_vf`的`printf`时,除格式字符串和参数外,还会固定占用32字节;整条打印数据需要按8字节对齐。 |
| 110 | -- `simd_vf`调测接口不会检查上述预留空间是否越界。超过限制可能越界写入预留空间,导致打印结果异常,并可能影响算子执行。 | 111 | +<!-- end id15 --> |
| 111 | 112 | ||
| 112 | ## SIMD调用示例 | 113 | ## SIMD调用示例 |
| 113 | 114 | ||
| @@ -32,14 +32,15 @@ __aicore__ static inline void asc_vf_call_impl(Args&&... args) | |||
| 32 | funcPtr(args...); | 32 | funcPtr(args...); |
| 33 | 33 | ||
| 34 | if constexpr (AscendC::Internal::SimdVfDebugTraits<DebugTag>::enabled) { | 34 | if constexpr (AscendC::Internal::SimdVfDebugTraits<DebugTag>::enabled) { |
| 35 | - const bool hasOverflow = AscVFDebugTransferUb(); | 35 | + AscVFDebugFinish(); |
| 36 | + const bool transferFailed = AscVFDebugTransferUb(); | ||
| 36 | #ifdef ASCENDC_INTERNAL_SIMD_VF_OVERFLOW_WARNING_ENABLED | 37 | #ifdef ASCENDC_INTERNAL_SIMD_VF_OVERFLOW_WARNING_ENABLED |
| 37 | - if (hasOverflow) { | 38 | + if (transferFailed) { |
| 38 | __asc_aicore::printf_impl( | 39 | __asc_aicore::printf_impl( |
| 39 | - "[WARNING]: SIMD VF debug buffer overflow (max limit is 2KB), output was truncated.\n"); | 40 | + "[WARNING]: SIMD VF debug record exceeds the 2024-byte limit. The record was dropped.\n"); |
告警文本硬编码 2024。 该容量已有可覆盖宏,文本应使用同一常量生成,否则自定义容量时提示错误。 ![]() ![]() | |||
| 40 | } | 41 | } |
| 41 | #else | 42 | #else |
| 42 | - (void)hasOverflow; | 43 | + (void)transferFailed; |
| 43 | #endif | 44 | #endif |
| 44 | } | 45 | } |
| 45 | } | 46 | } |
| @@ -0,0 +1,66 @@ | |||
| 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_assert_simd_impl.h | ||
| 13 | + * \brief | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +#if !defined(__ASCENDC_INCLUDE_INTERNAL_HEADERS__) | ||
| 17 | +#define __ASCENDC_INCLUDE_INTERNAL_HEADERS__ | ||
| 18 | +#define __UNDEF_ASCENDC_INCLUDE_INTERNAL_HEADERS_ASC_ASSERT_SIMD_IMPL__ | ||
| 19 | +#warning \ | ||
| 20 | + "impl/utils/debug/asc_assert_simd_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 \"utils/debug/asc_assert.h\" and use public functions or variables defined in interface header files." | ||
| 21 | +#endif | ||
| 22 | + | ||
| 23 | +#ifndef IMPL_UTILS_DEBUG_ASC_ASSERT_SIMD_IMPL_H | ||
| 24 | +#define IMPL_UTILS_DEBUG_ASC_ASSERT_SIMD_IMPL_H | ||
| 25 | + | ||
| 26 | +#if !defined(ASCENDC_CPU_DEBUG) | ||
| 27 | +#include "impl/utils/debug/asc_simd_printf_impl.h" | ||
| 28 | +#endif | ||
| 29 | + | ||
| 30 | +namespace __asc_simd_vf { | ||
| 31 | +__simd_callee__ inline void __trap() | ||
| 32 | +{ | ||
| 33 | +#if !defined(ASCENDC_CPU_DEBUG) | ||
| 34 | + *((volatile __ubuf__ uint8_t*)-1) = 0; | ||
| 35 | +#endif | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +#if !defined(ASCENDC_CPU_DEBUG) | ||
| 39 | +__ASC_USE_RESERVED_UBUF__(3510, "assert is forbidden when compile option --cce-disable-asc-reserved-ubuf is enabled") | ||
| 40 | +static __attribute__((noinline)) __simd_callee__ void __assert_fail( | ||
| 41 | + __ubuf__ const char* assertion, __ubuf__ const char* file, unsigned int line, | ||
| 42 | + __ubuf__ const char* function) noexcept | ||
| 43 | +{ | ||
| 44 | + printf_impl_assert("[ASSERT] %s:%u: %s: Assertion `%s' failed.\n", file, line, function, assertion); | ||
| 45 | + wait_vf_assert_handshake(); | ||
assert 在 wait_vf_assert_handshake() 中等待消费者写 DRAINED,但空 FIFO 路径根本没有消费者,最终不会执行 trap()。 ![]() ![]() | |||
| 46 | + __trap(); | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | +template <typename... Args> | ||
| 50 | +static __attribute__((noinline)) __simd_callee__ void __assert_fail_msg( | ||
| 51 | + __ubuf__ const char* assertion, __ubuf__ const char* file, unsigned int line, __ubuf__ const char* function, | ||
| 52 | + __ubuf__ const char* fmt, Args&&... args) noexcept | ||
| 53 | +{ | ||
| 54 | + printf_impl_assert_msg(assertion, file, line, function, fmt, args...); | ||
| 55 | + wait_vf_assert_handshake(); | ||
| 56 | + __trap(); | ||
| 57 | +} | ||
| 58 | +#endif | ||
| 59 | +} // namespace __asc_simd_vf | ||
| 60 | + | ||
| 61 | +#endif // IMPL_UTILS_DEBUG_ASC_ASSERT_SIMD_IMPL_H | ||
| 62 | + | ||
| 63 | +#if defined(__UNDEF_ASCENDC_INCLUDE_INTERNAL_HEADERS_ASC_ASSERT_SIMD_IMPL__) | ||
| 64 | +#undef __ASCENDC_INCLUDE_INTERNAL_HEADERS__ | ||
| 65 | +#undef __UNDEF_ASCENDC_INCLUDE_INTERNAL_HEADERS_ASC_ASSERT_SIMD_IMPL__ | ||
| 66 | +#endif | ||
| @@ -16,21 +16,29 @@ | |||
| 16 | #define IMPL_UTILS_DEBUG_ASC_DEBUG_TYPES_H | 16 | #define IMPL_UTILS_DEBUG_ASC_DEBUG_TYPES_H |
| 17 | 17 | ||
| 18 | #ifndef ASCENDC_SIMD_VF_PRINTF_UBUF_MAX_SIZE | 18 | #ifndef ASCENDC_SIMD_VF_PRINTF_UBUF_MAX_SIZE |
| 19 | -// Reserved UB space is 2K in total. 20 bytes for BlockVFBufInfo header, leaving 2028 bytes for buffer. | 19 | +// Reserved UB space is 2K in total. 24 bytes for BlockVFBufInfo header, leaving 2024 bytes for buffer. |
缺少 2KB 预留空间的编译期约束。 ASCENDC_SIMD_VF_PRINTF_UBUF_MAX_SIZE 可由外部覆盖,header 又从 20B 增长到 24B ![]() ![]() | |||
| 20 | -#define ASCENDC_SIMD_VF_PRINTF_UBUF_MAX_SIZE 2028 | 20 | +#define ASCENDC_SIMD_VF_PRINTF_UBUF_MAX_SIZE 2024 |
| 21 | #endif | 21 | #endif |
| 22 | 22 | ||
| 23 | #define ASCENDC_SIMD_VF_MAGIC_NUMBER 0xF0A00B0F | 23 | #define ASCENDC_SIMD_VF_MAGIC_NUMBER 0xF0A00B0F |
| 24 | 24 | ||
| 25 | struct BlockVFBufInfo { | 25 | struct BlockVFBufInfo { |
| 26 | + enum class AssertState : uint8_t { | ||
| 27 | + IDLE = 0U, | ||
| 28 | + RAISED = 1U, | ||
| 29 | + DRAINED = 2U, | ||
| 30 | + }; | ||
| 31 | + | ||
| 26 | uint32_t magic = ASCENDC_SIMD_VF_MAGIC_NUMBER; | 32 | uint32_t magic = ASCENDC_SIMD_VF_MAGIC_NUMBER; |
| 27 | uint32_t length = ASCENDC_SIMD_VF_PRINTF_UBUF_MAX_SIZE; | 33 | uint32_t length = ASCENDC_SIMD_VF_PRINTF_UBUF_MAX_SIZE; |
| 28 | uint32_t writeLen = 0; | 34 | uint32_t writeLen = 0; |
| 29 | - uint16_t pidx = 0; | 35 | + uint16_t resv1 = 0; |
| 30 | uint8_t flag = 0; // 0: normal, nonzero: overflow | 36 | uint8_t flag = 0; // 0: normal, nonzero: overflow |
| 31 | - uint8_t resv1 = 0; | 37 | + uint8_t finish = 0; |
| 32 | uint16_t blockIdx = 0; | 38 | uint16_t blockIdx = 0; |
| 33 | - uint16_t resv2 = 0; | 39 | + AssertState assertFlag = AssertState::IDLE; |
| 40 | + uint8_t resv2 = 0; | ||
| 41 | + uint32_t readLen = 0; | ||
| 34 | uint8_t buffer[ASCENDC_SIMD_VF_PRINTF_UBUF_MAX_SIZE]; | 42 | uint8_t buffer[ASCENDC_SIMD_VF_PRINTF_UBUF_MAX_SIZE]; |
| 35 | }; | 43 | }; |
| 36 | 44 | ||
| @@ -196,6 +196,7 @@ __aicore__ inline void do_overlow_skip( | |||
| 196 | { | 196 | { |
| 197 | if (writeInfo->bufOffset + minTlvLen >= ringBufLen) { | 197 | if (writeInfo->bufOffset + minTlvLen >= ringBufLen) { |
| 198 | ringbuf_skip_directly(writeInfo); | 198 | ringbuf_skip_directly(writeInfo); |
| 199 | + return; | ||
| 199 | } | 200 | } |
| 200 | ringbuf_skip_with_info(writeInfo, ringBufAddr, ringBufLen); | 201 | ringbuf_skip_with_info(writeInfo, ringBufAddr, ringBufLen); |
| 201 | } | 202 | } |
| @@ -294,12 +295,19 @@ __aicore__ static __attribute__((noinline)) void AscVFDebugInitUb() | |||
| 294 | #endif | 295 | #endif |
| 295 | } | 296 | } |
| 296 | 297 | ||
| 298 | +__aicore__ static __attribute__((noinline)) void AscVFDebugFinish() | ||
| 299 | +{ | ||
| 300 | +#if !(defined(ASCENDC_DUMP) && ASCENDC_DUMP == 0) && !defined(ASCENDC_CPU_DEBUG) && defined(__NPU_ARCH__) && \ | ||
| 301 | + __NPU_ARCH__ == 3510 && !defined(__ASC_DISABLE_RESERVED_UBUF__) | ||
| 302 | + __asc_simd_vf::asc_finish_flag(); | ||
| 303 | +#endif | ||
| 304 | +} | ||
| 305 | + | ||
| 297 | __aicore__ static __attribute__((noinline)) bool AscVFDebugTransferUb() | 306 | __aicore__ static __attribute__((noinline)) bool AscVFDebugTransferUb() |
g_sysPrintFifoSpace == nullptr 时累计数据超过 2KB 会死锁。 AI Core 不启动消费者,而 SIMD VF 会等待 readLen == writeLen;后续 finish VF 又排在当前 VF 之后,无法解除等待。 ![]() ![]() | |||
| 298 | { | 307 | { |
| 299 | #if !(defined(ASCENDC_DUMP) && ASCENDC_DUMP == 0) && !defined(ASCENDC_CPU_DEBUG) && defined(__NPU_ARCH__) && \ | 308 | #if !(defined(ASCENDC_DUMP) && ASCENDC_DUMP == 0) && !defined(ASCENDC_CPU_DEBUG) && defined(__NPU_ARCH__) && \ |
| 300 | __NPU_ARCH__ == 3510 && !defined(__ASC_DISABLE_RESERVED_UBUF__) | 309 | __NPU_ARCH__ == 3510 && !defined(__ASC_DISABLE_RESERVED_UBUF__) |
| 301 | if (g_sysPrintFifoSpace != nullptr) { | 310 | if (g_sysPrintFifoSpace != nullptr) { |
| 302 | - pipe_barrier(PIPE_ALL); | ||
| 303 | return asc_vf_debug_ub2gm(); | 311 | return asc_vf_debug_ub2gm(); |
| 304 | } | 312 | } |
| 305 | #endif | 313 | #endif |
| @@ -95,6 +95,14 @@ __simd_callee__ inline uint32_t reserve_dump_tlv(__ubuf__ BlockVFBufInfo* block_ | |||
| 95 | 95 | ||
| 96 | const uint32_t align_dump_len = align_up(dump_size * sizeof(T), data_block_size); | 96 | const uint32_t align_dump_len = align_up(dump_size * sizeof(T), data_block_size); |
| 97 | const uint32_t tlv_len = sizeof(DumpTensorTlv) + align_dump_len; | 97 | const uint32_t tlv_len = sizeof(DumpTensorTlv) + align_dump_len; |
| 98 | + uint32_t write_len = block_info->writeLen; | ||
| 99 | + if (tlv_len > block_info->length || write_len > block_info->length) { | ||
| 100 | + block_info->flag = 1; | ||
| 101 | + return 0; | ||
| 102 | + } | ||
| 103 | + if (write_len + tlv_len > block_info->length) { | ||
| 104 | + wait_vf_debug_buffer_drained_and_reset(block_info); | ||
| 105 | + } | ||
| 98 | return reserve_debug_tlv(block_info, tlv_len) ? tlv_len : 0; | 106 | return reserve_debug_tlv(block_info, tlv_len) ? tlv_len : 0; |
| 99 | } | 107 | } |
| 100 | 108 | ||
| @@ -120,7 +128,6 @@ __simd_callee__ inline void asc_dump_impl(U& src, uint32_t desc, uint32_t dump_s | |||
| 120 | 128 | ||
| 121 | block_info->magic = ASCENDC_SIMD_VF_MAGIC_NUMBER; | 129 | block_info->magic = ASCENDC_SIMD_VF_MAGIC_NUMBER; |
| 122 | block_info->writeLen += tlv_len; | 130 | block_info->writeLen += tlv_len; |
| 123 | - block_info->pidx += 1; | ||
| 124 | #endif | 131 | #endif |
| 125 | } | 132 | } |
| 126 | 133 | ||
| @@ -140,12 +140,14 @@ __simd_callee__ inline uint32_t get_args_len_vf(uint32_t& args_num, Args&&... ar | |||
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | template <typename... Args> | 142 | template <typename... Args> |
| 143 | -__simd_callee__ inline uint32_t get_print_tlv_len_simd(uint32_t& args_num, __ubuf__ const char* fmt, Args&&... args) | 143 | +__simd_callee__ inline uint32_t get_print_tlv_len_simd( |
| 144 | + uint32_t& args_num, __ubuf__ const char* fmt, __ubuf__ const char* dump_head, Args&&... args) | ||
| 144 | { | 145 | { |
| 145 | constexpr uint32_t print_info_len = sizeof(PrintTlv); | 146 | constexpr uint32_t print_info_len = sizeof(PrintTlv); |
| 146 | const uint32_t args_len = get_args_len_vf(args_num, args...); | 147 | const uint32_t args_len = get_args_len_vf(args_num, args...); |
| 147 | const uint32_t fmt_len = get_cstring_len_vf(fmt); | 148 | const uint32_t fmt_len = get_cstring_len_vf(fmt); |
| 148 | - return align_print_tlv_len(print_info_len + args_len + fmt_len); | 149 | + const uint32_t dump_head_len = get_cstring_len_vf(dump_head) - 1; |
| 150 | + return align_print_tlv_len(print_info_len + args_len + fmt_len + dump_head_len); | ||
| 149 | } | 151 | } |
| 150 | 152 | ||
| 151 | __simd_callee__ inline void set_print_tlv_info_vf( | 153 | __simd_callee__ inline void set_print_tlv_info_vf( |
| @@ -169,20 +171,24 @@ __simd_callee__ inline void copy_fmt_to_ubuf(__ubuf__ uint8_t* dst, __ubuf__ con | |||
| 169 | 171 | ||
| 170 | template <typename... Args> | 172 | template <typename... Args> |
| 171 | __simd_callee__ inline void set_print_tlv_data_vf( | 173 | __simd_callee__ inline void set_print_tlv_data_vf( |
| 172 | - __ubuf__ PrintTlv* print_tlv, __ubuf__ const char* fmt, Args&&... args) | 174 | + __ubuf__ PrintTlv* print_tlv, __ubuf__ const char* fmt, __ubuf__ const char* dump_head, Args&&... args) |
| 173 | { | 175 | { |
| 174 | - const uint32_t str_len = get_cstring_len_vf(fmt); | 176 | + const uint32_t dump_head_len = get_cstring_len_vf(dump_head) - 1; |
| 177 | + const uint32_t fmt_len = get_cstring_len_vf(fmt); | ||
| 175 | __ubuf__ uint8_t* param_addr = reinterpret_cast<__ubuf__ uint8_t*>(print_tlv + 1); | 178 | __ubuf__ uint8_t* param_addr = reinterpret_cast<__ubuf__ uint8_t*>(print_tlv + 1); |
| 176 | - __ubuf__ uint8_t* fmt_addr = param_addr + print_tlv->fmtOffset - sizeof(uint64_t); | 179 | + __ubuf__ uint8_t* dump_head_addr = param_addr + print_tlv->fmtOffset - sizeof(uint64_t); |
| 180 | + __ubuf__ uint8_t* fmt_addr = dump_head_addr + dump_head_len; | ||
| 177 | 181 | ||
| 178 | - copy_fmt_to_ubuf(fmt_addr, fmt, str_len); | 182 | + copy_fmt_to_ubuf(dump_head_addr, dump_head, dump_head_len); |
| 183 | + copy_fmt_to_ubuf(fmt_addr, fmt, fmt_len); | ||
| 179 | 184 | ||
| 180 | - uint32_t str_param_offset = print_tlv->fmtOffset + str_len; | 185 | + uint32_t str_param_offset = print_tlv->fmtOffset + dump_head_len + fmt_len; |
| 181 | set_param_vf(param_addr, 0, str_param_offset, args...); | 186 | set_param_vf(param_addr, 0, str_param_offset, args...); |
| 182 | } | 187 | } |
| 183 | 188 | ||
| 184 | template <class... Args> | 189 | template <class... Args> |
| 185 | -__simd_callee__ inline void scalar_printf_impl(DumpType debug_type, __ubuf__ const char* fmt, Args&&... args) | 190 | +__simd_callee__ inline void scalar_printf_impl( |
| 191 | + DumpType debug_type, __ubuf__ const char* fmt, __ubuf__ const char* dump_head, Args&&... args) | ||
| 186 | { | 192 | { |
| 187 | __ubuf__ BlockVFBufInfo* block_info = get_printf_ubuf_addr(0); | 193 | __ubuf__ BlockVFBufInfo* block_info = get_printf_ubuf_addr(0); |
| 188 | if (block_info->flag != 0) { | 194 | if (block_info->flag != 0) { |
| @@ -190,19 +196,30 @@ __simd_callee__ inline void scalar_printf_impl(DumpType debug_type, __ubuf__ con | |||
| 190 | } | 196 | } |
| 191 | 197 | ||
| 192 | uint32_t args_num = 0; | 198 | uint32_t args_num = 0; |
| 193 | - const uint32_t tlv_len = get_print_tlv_len_simd(args_num, fmt, args...); | 199 | + const uint32_t tlv_len = get_print_tlv_len_simd(args_num, fmt, dump_head, args...); |
| 200 | + uint32_t write_len = block_info->writeLen; | ||
| 201 | + | ||
| 202 | + if (tlv_len > block_info->length || write_len > block_info->length) { | ||
| 203 | + block_info->flag = 1; | ||
| 204 | + return; | ||
| 205 | + } | ||
| 206 | + | ||
| 207 | + if (write_len + tlv_len > block_info->length) { | ||
| 208 | + wait_vf_debug_buffer_drained_and_reset(block_info); | ||
| 209 | + write_len = 0; | ||
| 210 | + } | ||
| 211 | + | ||
| 194 | if (!reserve_debug_tlv(block_info, tlv_len)) { | 212 | if (!reserve_debug_tlv(block_info, tlv_len)) { |
| 195 | return; | 213 | return; |
| 196 | } | 214 | } |
| 197 | 215 | ||
| 198 | __ubuf__ PrintTlv* print_tlv = | 216 | __ubuf__ PrintTlv* print_tlv = |
| 199 | - reinterpret_cast<__ubuf__ PrintTlv*>((__ubuf__ uint8_t*)(block_info->buffer) + block_info->writeLen); | 217 | + reinterpret_cast<__ubuf__ PrintTlv*>((__ubuf__ uint8_t*)(block_info->buffer) + write_len); |
| 200 | set_print_tlv_info_vf(debug_type, print_tlv, tlv_len, args_num, block_info->blockIdx); | 218 | set_print_tlv_info_vf(debug_type, print_tlv, tlv_len, args_num, block_info->blockIdx); |
| 201 | - set_print_tlv_data_vf(print_tlv, fmt, args...); | 219 | + set_print_tlv_data_vf(print_tlv, fmt, dump_head, args...); |
| 202 | 220 | ||
| 203 | block_info->magic = ASCENDC_SIMD_VF_MAGIC_NUMBER; | 221 | block_info->magic = ASCENDC_SIMD_VF_MAGIC_NUMBER; |
| 204 | - block_info->writeLen += tlv_len; | 222 | + block_info->writeLen = write_len + tlv_len; |
生产者写完 TLV 后直接更新 writeLen,消费者并发读取,但 writeLen/readLen 既非 volatile,也没有 release/acquire 或硬件同步,消费者可能解析到未写完的 TLV。 ![]() ![]() | |||
| 205 | - block_info->pidx += 1; | ||
| 206 | } | 223 | } |
| 207 | 224 | ||
| 208 | template <class... Args> | 225 | template <class... Args> |
| @@ -210,7 +227,29 @@ __simd_callee__ inline void printf_impl(__ubuf__ const char* fmt, Args&&... args | |||
| 210 | { | 227 | { |
| 211 | #if !(defined(ASCENDC_DUMP) && ASCENDC_DUMP == 0) | 228 | #if !(defined(ASCENDC_DUMP) && ASCENDC_DUMP == 0) |
| 212 | enable_asc_diagnostics(); | 229 | enable_asc_diagnostics(); |
| 213 | - scalar_printf_impl(DumpType::DUMP_SCALAR, fmt, args...); | 230 | + scalar_printf_impl(DumpType::DUMP_SCALAR, fmt, "", args...); |
| 231 | +#endif | ||
| 232 | +} | ||
| 233 | + | ||
| 234 | +template <class... Args> | ||
| 235 | +__simd_callee__ inline void printf_impl_assert(__ubuf__ const char* fmt, Args&&... args) | ||
| 236 | +{ | ||
| 237 | +#if !(defined(ASCENDC_DUMP) && ASCENDC_DUMP == 0) | ||
| 238 | + enable_asc_assert(); | ||
| 239 | + scalar_printf_impl(DumpType::DUMP_ASSERT, fmt, "", args...); | ||
| 240 | +#endif | ||
| 241 | +} | ||
| 242 | + | ||
| 243 | +template <class... Args> | ||
| 244 | +__simd_callee__ inline void printf_impl_assert_msg( | ||
| 245 | + __ubuf__ const char* assertion, __ubuf__ const char* file, unsigned int line, __ubuf__ const char* function, | ||
| 246 | + __ubuf__ const char* fmt, Args&&... args) | ||
| 247 | +{ | ||
| 248 | +#if !(defined(ASCENDC_DUMP) && ASCENDC_DUMP == 0) | ||
| 249 | + enable_asc_assert(); | ||
| 250 | + scalar_printf_impl( | ||
| 251 | + DumpType::DUMP_ASSERT, fmt, "[ASSERT] %s:%u: %s: Assertion `%s' failed. ", file, line, function, assertion, | ||
| 252 | + args...); | ||
| 214 | #endif | 253 | #endif |
| 215 | } | 254 | } |
| 216 | 255 | ||
| @@ -24,11 +24,13 @@ __simd_callee__ inline void init_debug_buffer(__ubuf__ BlockVFBufInfo* blockInfo | |||
| 24 | blockInfo->magic = ASCENDC_SIMD_VF_MAGIC_NUMBER; | 24 | blockInfo->magic = ASCENDC_SIMD_VF_MAGIC_NUMBER; |
| 25 | blockInfo->length = ASCENDC_SIMD_VF_PRINTF_UBUF_MAX_SIZE; | 25 | blockInfo->length = ASCENDC_SIMD_VF_PRINTF_UBUF_MAX_SIZE; |
| 26 | blockInfo->writeLen = 0; | 26 | blockInfo->writeLen = 0; |
| 27 | - blockInfo->pidx = 0; | ||
| 28 | - blockInfo->flag = 0; | ||
| 29 | blockInfo->resv1 = 0; | 27 | blockInfo->resv1 = 0; |
| 28 | + blockInfo->flag = 0; | ||
| 29 | + blockInfo->finish = 0; | ||
| 30 | blockInfo->blockIdx = blockIdx; | 30 | blockInfo->blockIdx = blockIdx; |
| 31 | + blockInfo->assertFlag = BlockVFBufInfo::AssertState::IDLE; | ||
| 31 | blockInfo->resv2 = 0; | 32 | blockInfo->resv2 = 0; |
| 33 | + blockInfo->readLen = 0; | ||
| 32 | } | 34 | } |
| 33 | 35 | ||
| 34 | __simd_callee__ inline bool reserve_debug_tlv(__ubuf__ BlockVFBufInfo* blockInfo, uint32_t tlvLen) | 36 | __simd_callee__ inline bool reserve_debug_tlv(__ubuf__ BlockVFBufInfo* blockInfo, uint32_t tlvLen) |
| @@ -47,6 +47,25 @@ __simd_callee__ constexpr inline uint32_t div_ceil(uint32_t a, uint32_t b) | |||
| 47 | 47 | ||
| 48 | __simd_callee__ constexpr inline uint32_t align_up(uint32_t a, uint32_t b) { return div_ceil(a, b) * b; } | 48 | __simd_callee__ constexpr inline uint32_t align_up(uint32_t a, uint32_t b) { return div_ceil(a, b) * b; } |
| 49 | 49 | ||
| 50 | +__simd_callee__ inline void wait_vf_debug_buffer_drained(__ubuf__ BlockVFBufInfo* block_info) | ||
RTS 停止消费、消费者异常退出或共享字段不可见时,算子只能依赖系统超时被杀,应增加超时并进入丢弃模式。 ![]() ![]() | |||
| 51 | +{ | ||
消费者解析失败后,生产者可能永久等待。 TLV 非法时消费者置 flag 并退出,但 wait_vf_debug_buffer_drained() 只检查读写位置,不检查 flag,正在等待 rollover 的 SIMD VF 无法退出。 ![]() ![]() | |||
| 52 | + while (block_info->readLen != block_info->writeLen) { | ||
| 53 | + __asm__ __volatile__(""); | ||
| 54 | + } | ||
| 55 | +} | ||
| 56 | + | ||
| 57 | +__simd_callee__ inline void reset_vf_debug_buffer(__ubuf__ BlockVFBufInfo* block_info) | ||
| 58 | +{ | ||
| 59 | + block_info->writeLen = 0; | ||
| 60 | + block_info->readLen = 0; | ||
| 61 | +} | ||
| 62 | + | ||
| 63 | +__simd_callee__ inline void wait_vf_debug_buffer_drained_and_reset(__ubuf__ BlockVFBufInfo* block_info) | ||
| 64 | +{ | ||
| 65 | + wait_vf_debug_buffer_drained(block_info); | ||
| 66 | + reset_vf_debug_buffer(block_info); | ||
| 67 | +} | ||
| 68 | + | ||
| 50 | template <typename T> | 69 | template <typename T> |
| 51 | __simd_callee__ constexpr inline DumpTensorDataType get_dump_datatype_impl(); | 70 | __simd_callee__ constexpr inline DumpTensorDataType get_dump_datatype_impl(); |
| 52 | 71 | ||
| @@ -63,6 +82,13 @@ __simd_callee__ inline void enable_asc_diagnostics() | |||
| 63 | #endif | 82 | #endif |
| 64 | } | 83 | } |
| 65 | 84 | ||
| 85 | +__simd_callee__ inline void enable_asc_assert() | ||
| 86 | +{ | ||
| 87 | +#if (!defined(ASCENDC_DUMP) || (ASCENDC_DUMP != 0)) || defined(ASCENDC_TIME_STAMP_ON) | ||
| 88 | + static const struct AscTlv __asc_assert_meta_section__ __attribute__((used, section(".ascend.meta"))) = {4, 4, 5}; | ||
| 89 | +#endif | ||
| 90 | +} | ||
| 91 | + | ||
| 66 | __simd_callee__ constexpr inline uint32_t get_vf_debug_reserved_ub_size() | 92 | __simd_callee__ constexpr inline uint32_t get_vf_debug_reserved_ub_size() |
| 67 | { | 93 | { |
| 68 | constexpr uint32_t ascendcReservedUbSize = 2 * 1024; | 94 | constexpr uint32_t ascendcReservedUbSize = 2 * 1024; |
| @@ -97,11 +123,28 @@ __simd_callee__ __ubuf__ inline BlockVFBufInfo* get_printf_ubuf_addr(uint64_t ad | |||
| 97 | return bufInfo; | 123 | return bufInfo; |
| 98 | } | 124 | } |
| 99 | 125 | ||
| 126 | +__simd_callee__ inline void wait_vf_assert_handshake() | ||
assert 握手同样没有超时和错误兜底。 调试日志异常不应阻止 assert 本身触发;超时后至少应直接 trap()。 ![]() ![]() | |||
| 127 | +{ | ||
| 128 | + __ubuf__ BlockVFBufInfo* block_info = get_printf_ubuf_addr(0); | ||
| 129 | + wait_vf_debug_buffer_drained(block_info); | ||
| 130 | + __ubuf__ volatile BlockVFBufInfo::AssertState* assertFlag = &block_info->assertFlag; | ||
| 131 | + *assertFlag = BlockVFBufInfo::AssertState::RAISED; | ||
| 132 | + while (*assertFlag != BlockVFBufInfo::AssertState::DRAINED) { | ||
| 133 | + __asm__ __volatile__(""); | ||
| 134 | + } | ||
| 135 | +} | ||
| 136 | + | ||
| 100 | __simd_callee__ __ubuf__ inline BlockVFBufInfo* init_printf_ubuf_addr(uint16_t blockIdx = 0) | 137 | __simd_callee__ __ubuf__ inline BlockVFBufInfo* init_printf_ubuf_addr(uint16_t blockIdx = 0) |
| 101 | { | 138 | { |
| 102 | return get_printf_ubuf_addr(get_vf_debug_reserved_ub_addr(), blockIdx); | 139 | return get_printf_ubuf_addr(get_vf_debug_reserved_ub_addr(), blockIdx); |
| 103 | } | 140 | } |
| 104 | 141 | ||
| 142 | +__no_simd_vf_fusion__ __simd_vf__ static inline void asc_finish_flag() | ||
| 143 | +{ | ||
| 144 | + __ubuf__ BlockVFBufInfo* blockInfo = get_printf_ubuf_addr(0); | ||
| 145 | + blockInfo->finish = 1; | ||
| 146 | +} | ||
| 147 | + | ||
| 105 | __simd_callee__ inline void asc_copy_ub2ub(__ubuf__ void* dst, __ubuf__ void* src, uint32_t size) | 148 | __simd_callee__ inline void asc_copy_ub2ub(__ubuf__ void* dst, __ubuf__ void* src, uint32_t size) |
| 106 | { | 149 | { |
| 107 | __cce_scalar::copy_ubuf_to_ubuf(dst, src, 1, size / 32, 0, 0); | 150 | __cce_scalar::copy_ubuf_to_ubuf(dst, src, 1, size / 32, 0, 0); |
| @@ -109,6 +152,8 @@ __simd_callee__ inline void asc_copy_ub2ub(__ubuf__ void* dst, __ubuf__ void* sr | |||
| 109 | } // namespace __asc_simd_vf | 152 | } // namespace __asc_simd_vf |
| 110 | 153 | ||
| 111 | namespace __asc_aicore { | 154 | namespace __asc_aicore { |
| 155 | +__aicore__ inline bool check_ringbuf_space(__gm__ DebugBlockHeadInfo* blockInfo, const uint32_t& tlvLen); | ||
| 156 | + | ||
| 112 | __aicore__ inline void asc_entire_dcci_impl(__gm__ uint64_t* ptr) | 157 | __aicore__ inline void asc_entire_dcci_impl(__gm__ uint64_t* ptr) |
| 113 | { | 158 | { |
| 114 | dcci(ptr, cache_line_t::ENTIRE_DATA_CACHE, dcci_dst_t::CACHELINE_OUT); | 159 | dcci(ptr, cache_line_t::ENTIRE_DATA_CACHE, dcci_dst_t::CACHELINE_OUT); |
| @@ -246,41 +291,98 @@ __aicore__ inline void update_write_info( | |||
| 246 | asc_entire_dcci_impl(reinterpret_cast<__gm__ uint64_t*>(writeInfo)); | 291 | asc_entire_dcci_impl(reinterpret_cast<__gm__ uint64_t*>(writeInfo)); |
| 247 | } | 292 | } |
| 248 | 293 | ||
| 294 | +__aicore__ static bool count_vf_tlv_packages(__ubuf__ uint8_t* tlv, uint32_t tlvLen, uint32_t& packageNum) | ||
| 295 | +{ | ||
| 296 | + constexpr uint32_t tlvHeadLen = 2 * sizeof(uint32_t); | ||
| 297 | + | ||
| 298 | + uint32_t offset = 0; | ||
| 299 | + | ||
| 300 | + while (offset + tlvHeadLen <= tlvLen) { | ||
| 301 | + __ubuf__ uint32_t* head = reinterpret_cast<__ubuf__ uint32_t*>(tlv + offset); | ||
| 302 | + uint32_t payloadLen = head[1]; | ||
| 303 | + | ||
| 304 | + if (payloadLen > tlvLen - offset - tlvHeadLen) { | ||
| 305 | + return false; | ||
| 306 | + } | ||
| 307 | + | ||
| 308 | + offset += tlvHeadLen + payloadLen; | ||
| 309 | + packageNum += 1; | ||
| 310 | + } | ||
| 311 | + | ||
| 312 | + return packageNum != 0 && offset == tlvLen; | ||
| 313 | +} | ||
| 314 | + | ||
| 315 | +__aicore__ inline void asc_vf_debug_publish( | ||
| 316 | + __ubuf__ BlockVFBufInfo* blockInfo, uint32_t curWriteLen, uint32_t curReadLen) | ||
| 317 | +{ | ||
| 318 | + const uint32_t tlvLen = curWriteLen - curReadLen; | ||
消费者把 readLen..writeLen 的多条 TLV 作为一个最长约 2024B 的整体检查空间;即使每条记录都小于 1KB,累计批次超过 1KB 仍会触发永久重试。 ![]() ![]() | |||
| 319 | + __ubuf__ uint8_t* tlv = reinterpret_cast<__ubuf__ uint8_t*>(blockInfo->buffer) + curReadLen; | ||
| 320 | + | ||
| 321 | + uint32_t packageNum = 0; | ||
| 322 | + if (!count_vf_tlv_packages(tlv, tlvLen, packageNum)) { | ||
| 323 | + blockInfo->flag = 1; | ||
| 324 | + return; | ||
| 325 | + } | ||
| 326 | + | ||
| 327 | + __gm__ BlockRingBufInfo* blockRingBufInfo = get_block_ring_buf_info(); | ||
代码直接取得 ringBufAddr/ringBufLen 并强转为另一种结构;应像 get_block_info() 一样验证 magic、长度、地址及读写偏移,避免错误配置导致越界 GM 访问。 ![]() ![]() | |||
| 328 | + auto* debugBlockInfo = reinterpret_cast<__gm__ DebugBlockHeadInfo*>(blockRingBufInfo); | ||
| 329 | + if (!check_ringbuf_space(debugBlockInfo, tlvLen)) { | ||
check_ringbuf_space() 返回 false 时 asc_vf_debug_publish() 直接返回,既不置错误,也不推进 readLen;外层循环会对同一批数据永久重试。 ![]() ![]() | |||
| 330 | + return; | ||
| 331 | + } | ||
| 332 | + __gm__ uint8_t* dstTlv = reinterpret_cast<__gm__ uint8_t*>(call_get_ring_buf_tlv(blockRingBufInfo)); | ||
| 333 | + | ||
| 334 | + constexpr uint32_t sizeU32 = sizeof(uint32_t); | ||
| 335 | + const uint32_t totalWords = tlvLen / sizeU32; | ||
| 336 | + auto* dstWords = reinterpret_cast<__gm__ uint32_t*>(dstTlv); | ||
| 337 | + auto* srcWords = reinterpret_cast<__ubuf__ uint32_t*>(tlv); | ||
| 338 | + for (uint32_t i = 0; i < totalWords; ++i) { | ||
| 339 | + dstWords[i] = srcWords[i]; | ||
| 340 | + } | ||
| 341 | + for (uint32_t i = totalWords * sizeU32; i < tlvLen; ++i) { | ||
| 342 | + dstTlv[i] = tlv[i]; | ||
| 343 | + } | ||
| 344 | + asc_entire_dcci_impl(reinterpret_cast<__gm__ uint64_t*>(dstTlv)); | ||
| 345 | + | ||
| 346 | + __gm__ RingBufWriteInfo* writeInfo = get_ring_buf_write_info(blockRingBufInfo); | ||
| 347 | + update_write_info(writeInfo, tlvLen, packageNum); | ||
| 348 | + blockInfo->readLen = curWriteLen; | ||
| 349 | +} | ||
| 350 | + | ||
| 249 | __aicore__ inline bool asc_vf_debug_ub2gm() | 351 | __aicore__ inline bool asc_vf_debug_ub2gm() |
| 250 | { | 352 | { |
| 251 | __ubuf__ BlockVFBufInfo* blockInfo = get_printf_ubuf_addr_aicore(0); | 353 | __ubuf__ BlockVFBufInfo* blockInfo = get_printf_ubuf_addr_aicore(0); |
| 252 | - __ubuf__ uint8_t* tlv = reinterpret_cast<__ubuf__ uint8_t*>(blockInfo->buffer); | 354 | + for (;;) { |
| 355 | + uint32_t curReadLen = blockInfo->readLen; | ||
损坏的 readLen 大于容量时会被当成 reset 的瞬态状态持续 continue,形成不可恢复的忙循环。 ![]() ![]() | |||
| 356 | + uint32_t curWriteLen = blockInfo->writeLen; | ||
| 253 | 357 | ||
| 254 | - __gm__ BlockRingBufInfo* blockRingBufInfo = get_block_ring_buf_info(); | 358 | + const bool isValidHeader = blockInfo->magic == ASCENDC_SIMD_VF_MAGIC_NUMBER && |
| 255 | - const bool isValidHeader = blockInfo->magic == ASCENDC_SIMD_VF_MAGIC_NUMBER && | 359 | + blockInfo->length <= ASCENDC_SIMD_VF_PRINTF_UBUF_MAX_SIZE && |
| 256 | - blockInfo->length <= ASCENDC_SIMD_VF_PRINTF_UBUF_MAX_SIZE && | 360 | + curWriteLen <= blockInfo->length; |
| 257 | - blockInfo->writeLen <= blockInfo->length; | 361 | + if (!isValidHeader) { |
| 258 | - if (!isValidHeader) { | 362 | + blockInfo->flag = 1; |
| 259 | - blockInfo->flag = 1; | 363 | + break; |
| 260 | - } | ||
| 261 | - const uint32_t tlvLen = isValidHeader ? blockInfo->writeLen : 0; | ||
| 262 | - const uint32_t packageNum = isValidHeader ? blockInfo->pidx : 0; | ||
| 263 | - | ||
| 264 | - sync_all_impl(); | ||
| 265 | - constexpr uint32_t sizeU32 = sizeof(uint32_t); | ||
| 266 | - if (tlvLen > 0) { | ||
| 267 | - __gm__ uint8_t* dstTlv = reinterpret_cast<__gm__ uint8_t*>(call_get_ring_buf_tlv(blockRingBufInfo)); | ||
| 268 | - const uint32_t totalWords = tlvLen / sizeU32; | ||
| 269 | - auto* dstWords = reinterpret_cast<__gm__ uint32_t*>(dstTlv); | ||
| 270 | - auto* srcWords = reinterpret_cast<__ubuf__ uint32_t*>(tlv); | ||
| 271 | - for (uint32_t i = 0; i < totalWords; ++i) { | ||
| 272 | - dstWords[i] = srcWords[i]; | ||
| 273 | } | 364 | } |
| 274 | - for (uint32_t i = totalWords * sizeU32; i < tlvLen; ++i) { | 365 | + // The producer clears writeLen before readLen when resetting a drained UB buffer. |
| 275 | - dstTlv[i] = tlv[i]; | 366 | + if (curReadLen > curWriteLen) { |
| 367 | + continue; | ||
| 276 | } | 368 | } |
| 277 | - sync_all_impl(); | ||
| 278 | 369 | ||
| 279 | - asc_entire_dcci_impl(reinterpret_cast<__gm__ uint64_t*>(dstTlv)); | 370 | + if (curReadLen < curWriteLen) { |
| 280 | - } | 371 | + asc_vf_debug_publish(blockInfo, curWriteLen, curReadLen); |
| 281 | - if (tlvLen > 0) { | 372 | + if (blockInfo->flag != 0) { |
| 282 | - __gm__ RingBufWriteInfo* writeInfo = get_ring_buf_write_info(blockRingBufInfo); | 373 | + break; |
| 283 | - update_write_info(writeInfo, tlvLen, packageNum); | 374 | + } |
| 375 | + continue; | ||
| 376 | + } | ||
| 377 | + | ||
| 378 | + if (blockInfo->assertFlag == BlockVFBufInfo::AssertState::RAISED) { | ||
assert 消费者在写入 DRAINED 后立即退出,AI Core 可能继续执行。 此时 SIMD VF 才开始执行 trap();需要确认硬件保证,或在 AI Core 侧同步/触发异常,避免 assert 后仍产生用户可见副作用。 ![]() ![]() | |||
| 379 | + blockInfo->assertFlag = BlockVFBufInfo::AssertState::DRAINED; | ||
| 380 | + break; | ||
| 381 | + } | ||
| 382 | + | ||
| 383 | + if (blockInfo->finish == 1) { | ||
| 384 | + break; | ||
| 385 | + } | ||
| 284 | } | 386 | } |
| 285 | return blockInfo->flag != 0; | 387 | return blockInfo->flag != 0; |
| 286 | } | 388 | } |
| @@ -66,3 +66,15 @@ __SIMT_DEVICE_FUNCTIONS_DECL__ inline void __trap(); | |||
| 66 | #endif | 66 | #endif |
| 67 | 67 | ||
| 68 | #endif | 68 | #endif |
| 69 | + | ||
| 70 | +#if !defined(__ASCENDC_INCLUDE_INTERNAL_HEADERS__) | ||
| 71 | +#define __ASCENDC_INCLUDE_INTERNAL_HEADERS__ | ||
| 72 | + | ||
| 73 | +#if (__NPU_ARCH__ == 3510) && !defined(__NPU_COMPILER_INTERNAL_PURE_SIMT__) | ||
| 74 | +#include "impl/utils/debug/asc_simd_debug_enable.h" | ||
| 75 | +#include "impl/utils/debug/asc_assert_simd_impl.h" | ||
| 76 | +#endif | ||
| 77 | + | ||
| 78 | +#undef __ASCENDC_INCLUDE_INTERNAL_HEADERS__ | ||
| 79 | + | ||
| 80 | +#endif | ||


非法 header/TLV 也会显示“record exceeds 2024-byte limit”,而 FIFO 为空导致全部日志丢失时反而返回 false、不告警。建议返回明确错误枚举。