Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
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 : #ifndef ADUMP_COMMON_DATA_DUMP_INTERFACE_H
11 : #define ADUMP_COMMON_DATA_DUMP_INTERFACE_H
12 :
13 : #include <cstddef>
14 : #include <cstdint>
15 : #include <string>
16 :
17 : namespace Adx {
18 :
19 : // Data Dump 特性下的平台差异处理,涵盖 KFC stats 参数与 dump_printf 参数。所有平台都注册
20 : // 此接口,未覆盖的方法走基类默认值(默认值对齐原 dump_printf 非 Ascend950 分支取值)。
21 : class DataDumpInterface {
22 : public:
23 39 : virtual ~DataDumpInterface() = default;
24 :
25 : // KFC stats
26 0 : virtual uint64_t GetKfcStackSize() const { return 0; }
27 0 : virtual std::string GetKfcBinName() const { return ""; }
28 3 : virtual bool IsUbFromAiCore() const { return false; } // 原 CHIP_CORE_MAP
29 :
30 : // dump_printf 参数(原 Ascend950 专属逻辑,芯片身份消失)
31 11 : virtual size_t GetCoreTypeIDOffset() const { return 50U; }
32 19 : virtual size_t GetBlockNum() const { return 75U; }
33 17 : virtual int32_t GetStreamSyncTimeout() const { return 60000; }
34 5 : virtual bool IsSimtDumpEnabled(size_t /* dumpWorkSpaceSize */) const { return false; }
35 :
36 : protected:
37 21 : static uint64_t CalcKfcStackSize(uint32_t opStackCount)
38 : {
39 21 : constexpr uint32_t BLOCK_MIN_SIZE = 32;
40 21 : constexpr uint32_t INTEGER_KILOBYTE = 1024;
41 21 : return static_cast<uint64_t>(opStackCount) * BLOCK_MIN_SIZE * INTEGER_KILOBYTE;
42 : }
43 : };
44 :
45 : } // namespace Adx
46 : #endif // ADUMP_COMMON_DATA_DUMP_INTERFACE_H
|